ChatResponse
public class ChatResponse
io/agentscope/core/model/ChatResponse.java:29–207聊天响应,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.model 包。核心成员包括 getId、getContent、getUsage、getMetadata、getFinishReason、withId。
Represents a chat completion response from a language model.
This immutable data class contains the response content, usage information, and optional metadata returned by the model after processing a chat request.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 Builder for creating ChatResponse instances. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public ChatResponse(String id, List<ContentBlock> content, ChatUsage usage, Map<String, Object> metadata, String finishReason) | 创建新的ChatResponse 实例。 Creates a new ChatResponse instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getId() | 获取标识。 Gets the unique identifier for this response. |
public List<ContentBlock> getContent() | 获取内容。 Gets the content blocks containing the response content. |
public ChatUsage getUsage() | 获取用量。 Gets the token usage information for this response. |
public Map<String, Object> getMetadata() | 获取元数据来自模型提供者。 Gets the metadata from the model provider. |
public String getFinishReason() | 获取 `getFinishReason`。 Gets the reason the model stopped generating tokens. |
public ChatResponse withId(String newId) | 执行使用标识相关操作。 Creates a new instance of ChatResponse with the specified ID,
copying all other fields from this instance. |
public static Builder builder()static | 创建新的构建器用于 ChatResponse。 Creates a new builder for ChatResponse. |
构造器详情Constructor Detail
ChatResponse
public ChatResponse(String id, List<ContentBlock> content, ChatUsage usage, Map<String, Object> metadata, String finishReason)
创建新的ChatResponse 实例。
Creates a new ChatResponse instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。the unique identifier for this response |
content | List<ContentBlock> | 内容(类型 `List`)。the list of content blocks containing the response content |
usage | ChatUsage | 用量(类型 `ChatUsage`)。the token usage information for this response |
metadata | Map<String, Object> | 元数据(类型 `Map`)。additional metadata from the model provider |
finishReason | String | 推理用于。the reason for |
io/agentscope/core/model/ChatResponse.java:46–57方法详情Method Detail
getId
public String getId()
获取标识。
Gets the unique identifier for this response.
Stringio/agentscope/core/model/ChatResponse.java:64–66getContent
public List<ContentBlock> getContent()
获取内容。
Gets the content blocks containing the response content.
List<ContentBlock>io/agentscope/core/model/ChatResponse.java:73–75getUsage
public ChatUsage getUsage()
获取用量。
Gets the token usage information for this response.
ChatUsageio/agentscope/core/model/ChatResponse.java:82–84getMetadata
public Map<String, Object> getMetadata()
获取元数据来自模型提供者。
Gets the metadata from the model provider.
Map<String, Object>io/agentscope/core/model/ChatResponse.java:91–93getFinishReason
public String getFinishReason()
获取 getFinishReason。
Gets the reason the model stopped generating tokens.
Stringio/agentscope/core/model/ChatResponse.java:100–102withId
public ChatResponse withId(String newId)
执行使用标识相关操作。
Creates a new instance of ChatResponse with the specified ID, copying all other fields from this instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
newId | String | 新建标识(类型 `String`)。the new identifier |
ChatResponseio/agentscope/core/model/ChatResponse.java:111–113builder
public static Builder builder()
创建新的构建器用于 ChatResponse。
Creates a new builder for ChatResponse.
Builderio/agentscope/core/model/ChatResponse.java:120–122嵌套类详情Nested Class Detail
Builder
public static class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.core.model 包。核心成员包括 id、content、usage、metadata、finishReason、build。
Builder for creating ChatResponse instances.