AS AgentScopeAPI 手册 / API Reference

ChatResponse

public class ChatResponse
源码Source 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.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。the unique identifier for this response
contentList<ContentBlock>内容(类型 `List`)。the list of content blocks containing the response content
usageChatUsage用量(类型 `ChatUsage`)。the token usage information for this response
metadataMap<String, Object>元数据(类型 `Map`)。additional metadata from the model provider
finishReasonString推理用于。the reason for
源码Source io/agentscope/core/model/ChatResponse.java:46–57

方法详情Method Detail

getId

public String getId()

获取标识。

Gets the unique identifier for this response.

返回Returns String
返回字符串结果。the response identifier
源码Source io/agentscope/core/model/ChatResponse.java:64–66

getContent

public List<ContentBlock> getContent()

获取内容。

Gets the content blocks containing the response content.

返回Returns List<ContentBlock>
返回列出。the list of content blocks
源码Source io/agentscope/core/model/ChatResponse.java:73–75

getUsage

public ChatUsage getUsage()

获取用量。

Gets the token usage information for this response.

返回Returns ChatUsage
返回ChatUsage。the usage information
源码Source io/agentscope/core/model/ChatResponse.java:82–84

getMetadata

public Map<String, Object> getMetadata()

获取元数据来自模型提供者。

Gets the metadata from the model provider.

返回Returns Map<String, Object>
元数据映射。the metadata map
源码Source io/agentscope/core/model/ChatResponse.java:91–93

getFinishReason

public String getFinishReason()

获取 getFinishReason。

Gets the reason the model stopped generating tokens.

返回Returns String
返回字符串结果。the finish reason
源码Source io/agentscope/core/model/ChatResponse.java:100–102

withId

public ChatResponse withId(String newId)

执行使用标识相关操作。

Creates a new instance of ChatResponse with the specified ID, copying all other fields from this instance.

参数Parameters
名称Name类型Type说明Description
newIdString新建标识(类型 `String`)。the new identifier
返回Returns ChatResponse
一种新的ChatResponse 实例。a new ChatResponse instance
源码Source io/agentscope/core/model/ChatResponse.java:111–113

builder

public static Builder builder()
static

创建新的构建器用于 ChatResponse。

Creates a new builder for ChatResponse.

返回Returns Builder
一种新的构建器实例。a new Builder instance
源码Source io/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.

基于官方固定版本源码静态生成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.