AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/model/ChatResponse.java:127–206

构建器,用于构建并配置目标实例。位于 io.agentscope.core.model 包。核心成员包括 id、content、usage、metadata、finishReason、build。

Builder for creating ChatResponse instances.

方法摘要Method Summary

方法Method说明Description
public Builder id(String id)
设置标识。
Sets the response identifier.
public Builder content(List<ContentBlock> content)
设置内容。
Sets the content blocks for the response.
public Builder usage(ChatUsage usage)
设置用量。
Sets the usage information for the response.
public Builder metadata(Map<String, Object> metadata)
设置元数据用于响应。
Sets the metadata for the response.
public Builder finishReason(String finishReason)
设置该配置项。
Sets the finish reason for the response.
public ChatResponse build()
构建新的ChatResponse 实例使用设置值。
Builds a new ChatResponse instance with the set values.

方法详情Method Detail

id

public Builder id(String id)

设置标识。

Sets the response identifier.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。the unique identifier for this response
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatResponse.java:140–143

content

public Builder content(List<ContentBlock> content)

设置内容。

Sets the content blocks for the response.

参数Parameters
名称Name类型Type说明Description
contentList<ContentBlock>内容(类型 `List`)。the list of content blocks containing the response content
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatResponse.java:151–154

usage

public Builder usage(ChatUsage usage)

设置用量。

Sets the usage information for the response.

参数Parameters
名称Name类型Type说明Description
usageChatUsage用量(类型 `ChatUsage`)。the token usage information
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatResponse.java:162–165

metadata

public Builder metadata(Map<String, Object> metadata)

设置元数据用于响应。

Sets the metadata for the response.

参数Parameters
名称Name类型Type说明Description
metadataMap<String, Object>元数据(类型 `Map`)。additional metadata from the model provider
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatResponse.java:173–176

finishReason

public Builder finishReason(String finishReason)

设置该配置项。

Sets the finish reason for the response.

参数Parameters
名称Name类型Type说明Description
finishReasonStringfinish 推理(类型 `String`)。the finish reason sent by the model provider
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatResponse.java:184–187

build

public ChatResponse build()

构建新的ChatResponse 实例使用设置值。

Builds a new ChatResponse instance with the set values.

返回Returns ChatResponse
一种新的ChatResponse 实例。a new ChatResponse instance
源码Source io/agentscope/core/model/ChatResponse.java:198–205
基于官方固定版本源码静态生成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.