Java对接豆包等AI大模型的设计方案(六)-- 对接OpenAI的java库
一、背景
本文主要是围绕着 openai开源项目 展开,具体讲一讲使用它来对接ai大模型的对接示例。
OpenAI-Java 该项目已停更,但是作为java语言对接ai大模型的框架,还是有可以借鉴之处。
它包括以下三部分:
- api : request/response POJOs for the GPT APIs.
- client : a basic retrofit client for the GPT endpoints, includes the api module
- service : A basic service class that creates and calls the client. This is the easiest way to get started.
二、框架介绍
1、api
请求和响应的POJO类,包括com.theokanning.openai.completion.chat.ChatMessage(请求上下文消息),com.theokanning.openai.completion.CompletionResult(正常响应体),com.theokanning.open