AS AgentScopeAPI 手册 / API Reference

ChatChoice

@JsonInclude(JsonInclude.Include.NON_NULL) public class ChatChoice
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:48–105

聊天选项,保存相关配置项。位于 io.agentscope.core.chat.completions.model 包。核心成员包括 getIndex、setIndex、getMessage、setMessage、getDelta、setDelta。

Single choice in a Chat Completions style response.

This class follows OpenAI's Chat Completions API format.

Example:

`{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you?"
},
"finish_reason": "stop"
}
`

Possible finish_reason values:

  • "stop" - Natural end of message

  • "length" - Max tokens reached

  • "tool_calls" - Model wants to call tools

  • "content_filter" - Content was filtered

方法摘要Method Summary

方法Method说明Description
public int getIndex()
获取索引。
Returns the index.
public void setIndex(int index)
设置索引。
Sets the index.
public ChatMessage getMessage()
获取消息。
Returns the message.
public void setMessage(ChatMessage message)
设置消息。
Sets the message.
public ChatMessage getDelta()
获取增量。
Returns the delta.
public void setDelta(ChatMessage delta)
设置增量。
Sets the delta.
public String getFinishReason()
获取 `getFinishReason`。
Returns the finish reason.
public void setFinishReason(String finishReason)
设置 `setFinishReason`。
Sets the finish reason.
public Object getLogprobs()
获取 `getLogprobs`。
Returns the logprobs.
public void setLogprobs(Object logprobs)
设置 `setLogprobs`。
Sets the logprobs.

方法详情Method Detail

getIndex

public int getIndex()

获取索引。

Returns the index.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:66–68

setIndex

public void setIndex(int index)

设置索引。

Sets the index.

参数Parameters
名称Name类型Type说明Description
indexint索引(类型 `int`)。The index.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:70–72

getMessage

public ChatMessage getMessage()

获取消息。

Returns the message.

返回Returns ChatMessage
返回ChatMessage。Returns chat message.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:74–76

setMessage

public void setMessage(ChatMessage message)

设置消息。

Sets the message.

参数Parameters
名称Name类型Type说明Description
messageChatMessage消息(类型 `ChatMessage`)。The message.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:78–80

getDelta

public ChatMessage getDelta()

获取增量。

Returns the delta.

返回Returns ChatMessage
返回ChatMessage。Returns chat message.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:82–84

setDelta

public void setDelta(ChatMessage delta)

设置增量。

Sets the delta.

参数Parameters
名称Name类型Type说明Description
deltaChatMessage增量(类型 `ChatMessage`)。The delta.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:86–88

getFinishReason

public String getFinishReason()

获取 getFinishReason。

Returns the finish reason.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:90–92

setFinishReason

public void setFinishReason(String finishReason)

设置 setFinishReason。

Sets the finish reason.

参数Parameters
名称Name类型Type说明Description
finishReasonStringfinish 推理(类型 `String`)。The finish reason.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:94–96

getLogprobs

public Object getLogprobs()

获取 getLogprobs。

Returns the logprobs.

返回Returns Object
返回对象。Returns object.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:98–100

setLogprobs

public void setLogprobs(Object logprobs)

设置 setLogprobs。

Sets the logprobs.

参数Parameters
名称Name类型Type说明Description
logprobsObjectlogprobs(类型 `Object`)。The logprobs.
源码Source io/agentscope/core/chat/completions/model/ChatChoice.java:102–104
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.