Class OpenAiStreamClient


  • public class OpenAiStreamClient
    extends Object
    描述: open ai 客户端
    Author:
    https:www.unfbx.com 2023-02-28
    • Method Detail

      • streamCompletions

        public void streamCompletions​(Completion completion,
                                      okhttp3.sse.EventSourceListener eventSourceListener)
        问答接口 stream 形式
        Parameters:
        completion - open ai 参数
        eventSourceListener - sse监听器
        See Also:
        ConsoleEventSourceListener
      • streamCompletions

        public void streamCompletions​(String question,
                                      okhttp3.sse.EventSourceListener eventSourceListener)
        问答接口-简易版
        Parameters:
        question - 请求参数
        eventSourceListener - sse监听器
        See Also:
        ConsoleEventSourceListener
      • streamChatCompletion

        public <T extends BaseChatCompletion> void streamChatCompletion​(T chatCompletion,
                                                                        okhttp3.sse.EventSourceListener eventSourceListener)
        流式输出,最新版的GPT-3.5 chat completion 更加贴近官方网站的问答模型
        Parameters:
        chatCompletion - 问答参数
        eventSourceListener - sse监听器
        See Also:
        ConsoleEventSourceListener
      • streamChatCompletion

        public void streamChatCompletion​(List<Message> messages,
                                         okhttp3.sse.EventSourceListener eventSourceListener)
        流式输出,最新版的GPT-3.5 chat completion 更加贴近官方网站的问答模型 警告:(不支持图片输入)
        Parameters:
        messages - 问答列表
        eventSourceListener - sse监听器
        See Also:
        ConsoleEventSourceListener
      • streamChatCompletionWithPlugin

        public <R extends PluginParam,​T> void streamChatCompletionWithPlugin​(ChatCompletion chatCompletion,
                                                                                   okhttp3.sse.EventSourceListener eventSourceListener,
                                                                                   PluginListener pluginEventSourceListener,
                                                                                   PluginAbstract<R,​T> plugin)
        插件问答简易版 默认取messages最后一个元素构建插件对话 默认模型:ChatCompletion.Model.GPT_3_5_TURBO_16K_0613
        Type Parameters:
        R - 插件自定义函数的请求值
        T - 插件自定义函数的返回值
        Parameters:
        chatCompletion - 参数
        eventSourceListener - sse监听器
        pluginEventSourceListener - 插件sse监听器,收集function call返回信息
        plugin - 插件
      • streamChatCompletionWithPlugin

        public <R extends PluginParam,​T> void streamChatCompletionWithPlugin​(ChatCompletion chatCompletion,
                                                                                   okhttp3.sse.EventSourceListener eventSourceListener,
                                                                                   PluginAbstract<R,​T> plugin)
        插件问答简易版 默认取messages最后一个元素构建插件对话 默认模型:ChatCompletion.Model.GPT_3_5_TURBO_16K_0613
        Type Parameters:
        R - 插件自定义函数的请求值
        T - 插件自定义函数的返回值
        Parameters:
        chatCompletion - 参数
        eventSourceListener - sse监听器
        plugin - 插件
      • streamChatCompletionWithPlugin

        public <R extends PluginParam,​T> void streamChatCompletionWithPlugin​(List<Message> messages,
                                                                                   okhttp3.sse.EventSourceListener eventSourceListener,
                                                                                   PluginAbstract<R,​T> plugin)
        插件问答简易版 默认取messages最后一个元素构建插件对话 默认模型:ChatCompletion.Model.GPT_3_5_TURBO_16K_0613
        Type Parameters:
        R - 插件自定义函数的请求值
        T - 插件自定义函数的返回值
        Parameters:
        messages - 问答参数
        eventSourceListener - sse监听器
        plugin - 插件
      • streamChatCompletionWithPlugin

        public <R extends PluginParam,​T> void streamChatCompletionWithPlugin​(List<Message> messages,
                                                                                   String model,
                                                                                   okhttp3.sse.EventSourceListener eventSourceListener,
                                                                                   PluginAbstract<R,​T> plugin)
        插件问答简易版 默认取messages最后一个元素构建插件对话
        Type Parameters:
        R - 插件自定义函数的请求值
        T - 插件自定义函数的返回值
        Parameters:
        messages - 问答参数
        model - 模型
        eventSourceListener - eventSourceListener
        plugin - 插件
      • creditGrants

        @Deprecated
        public CreditGrantsResponse creditGrants()
        Deprecated.
        ## 官方已经禁止使用此api OpenAi账户余额查询
        Returns:
        余额信息
      • subscription

        public Subscription subscription()
        账户信息查询:里面包含总金额等信息
        Returns:
        个人账户信息
      • billingUsage

        public BillingUsage billingUsage​(@NotNull
                                         @NotNull LocalDate starDate,
                                         @NotNull
                                         @NotNull LocalDate endDate)
        账户调用接口消耗金额信息查询 最多查询100天
        Parameters:
        starDate - 开始时间
        endDate - 结束时间
        Returns:
        消耗金额信息