public class ChatResponseDefault extends Object implements ChatResponse
| Modifier and Type | Field and Description |
|---|---|
protected StringBuilder |
aggregationMessageContent |
protected List<ChatChoice> |
choices |
protected ChatException |
error |
protected boolean |
finished |
protected String |
model |
boolean |
reasoning
思考中
|
protected AiUsage |
usage |
| Constructor and Description |
|---|
ChatResponseDefault(boolean stream) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChoice(ChatChoice choice)
添加输出选择
|
AssistantMessage |
getAggregationMessage()
获取聚合消息
|
List<ChatChoice> |
getChoices()
获取所有选择
|
ChatException |
getError()
获取错误
|
AssistantMessage |
getMessage()
获取消息
|
String |
getModel()
获取模型
|
AiUsage |
getUsage()
获取使用情况(完成时,才会有使用情况)
|
boolean |
hasChoices()
是否有消息
|
boolean |
isFinished()
是否完成
|
boolean |
isStream()
是否为流响应
|
ChatChoice |
lastChoice()
最后一个选择
|
void |
reset()
重置响应数据
|
void |
setError(ChatException error)
设置错误
|
void |
setFinished(boolean finished)
设置完成状态
|
void |
setModel(String model)
设置模型
|
void |
setUsage(AiUsage usage)
设置使用情况
|
protected final List<ChatChoice> choices
protected ChatException error
protected AiUsage usage
protected String model
protected boolean finished
protected StringBuilder aggregationMessageContent
public boolean reasoning
public String getModel()
getModel in interface ChatResponsepublic ChatException getError()
getError in interface ChatResponsepublic List<ChatChoice> getChoices()
getChoices in interface ChatResponsepublic boolean hasChoices()
hasChoices in interface ChatResponsepublic ChatChoice lastChoice()
lastChoice in interface ChatResponsepublic AssistantMessage getMessage()
getMessage in interface ChatResponsepublic AssistantMessage getAggregationMessage()
getAggregationMessage in interface ChatResponse@Nullable public AiUsage getUsage()
getUsage in interface ChatResponsepublic boolean isFinished()
isFinished in interface ChatResponsepublic boolean isStream()
isStream in interface ChatResponsepublic void reset()
public void addChoice(ChatChoice choice)
choice - 选择public void setError(ChatException error)
error - 错误public void setUsage(AiUsage usage)
usage - 使用情况public void setModel(String model)
model - 响应模型public void setFinished(boolean finished)
finished - 完成状态Copyright © 2025. All rights reserved.