Interface ChatCompletionsClient
- All Known Implementing Classes:
ChatCompletionsHttpClient
public interface ChatCompletionsClient
这是一个用于与 OpenAI 兼容的聊天完成(chat completion)服务端点进行交互的客户端。
支持非流式响应(即一次性返回所有数据的响应方式)。 LlmResponse (包括排放数据)以及流式传输(streaming)
服务器发送的事件(Server-Sent Events, SSE)响应(包含多个增量数据) LlmResponse (排放物)。请参阅……
OpenAI Chat Completions API
参考文档 用于 Wire 协议。
-
方法概述
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Flowable<LlmResponse> complete(LlmRequest llmRequest, boolean stream) 根据提供的消息,从聊天完成(chat completions)端点生成对话式响应。
-
方法详细信息(Method Details)
-
complete
根据提供的消息,从聊天完成(chat completions)端点生成对话式响应。这一过程包括构建数据包(payload)、向该端点发送请求,以及启动对完整对话内容的处理。在非 2xx 类型的 HTTP 响应中,返回的内容是:
Flowable“emits a” 的意思是“发出某种信号、声音或辐射”。例如: - “The light bulb emits a bright white light”(灯泡发出明亮的白光。) - “The machine emits a low noise during operation”(机器在运行时发出轻微的噪音。)ChatCompletionsHttpException;调用者可以查看(相关内容)。ChatCompletionsHttpException.statusCode()无需解析消息内容。在连接层发生故障时,系统会使用一种简单的(即未经处理的)方式来处理错误或异常情况。IOException相反,会发出另一种信号(或信息)。- Parameters:
llmRequest- The request containing the model, configuration, and sequence of messages.stream- Whether to request a streaming response.- Returns:
- A
Flowableemitting the discrete (or combined)LlmResponseobjects.
-