| Package | Description |
|---|---|
| com.plexpt.chatgpt | |
| com.plexpt.chatgpt.entity.chat | |
| com.plexpt.chatgpt.util |
| Modifier and Type | Method and Description |
|---|---|
ChatCompletionResponse |
ChatGPT.chatCompletion(List<Message> messages)
支持多个问答参数来与服务端进行对话
|
void |
ChatGPTStream.streamChatCompletion(List<Message> messages,
okhttp3.sse.EventSourceListener eventSourceListener)
流式输出
|
| Modifier and Type | Field and Description |
|---|---|
private Message |
ChatChoice.delta
请求参数stream为true返回是delta
|
private Message |
ChatChoice.message
请求参数stream为false返回是message
|
| Modifier and Type | Method and Description |
|---|---|
static Message |
Message.of(String content) |
static Message |
Message.ofAssistant(String content) |
static Message |
Message.ofFunction(String function) |
static Message |
Message.ofSystem(String content) |
| Modifier and Type | Field and Description |
|---|---|
private static Map<String,List<Message>> |
ChatContextHolder.context |
| Modifier and Type | Method and Description |
|---|---|
static List<Message> |
ChatContextHolder.get(String id)
获取对话历史
|
| Modifier and Type | Method and Description |
|---|---|
static void |
ChatContextHolder.add(String id,
Message message)
添加对话
|
| Modifier and Type | Method and Description |
|---|---|
static int |
TokensUtil.tokens(List<Message> messages,
String model)
通过模型名称计算messages获取编码数组
参考官方的处理逻辑:
https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
|
static int |
TokensUtil.tokens(String modelName,
List<Message> messages)
计算tokens
|
Copyright © 2024. All rights reserved.