Builder
public static class Builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:313–459AnthropicChatModel的构建器。位于 io.agentscope.extensions.model.anthropic 包。核心成员包括 baseUrl、apiKey、authToken、modelName、stream、defaultOptions。
Builder for AnthropicChatModel.
方法摘要Method Summary
方法详情Method Detail
baseUrl
public Builder baseUrl(String baseUrl)
设置基类 URL。
Sets the base URL for the Anthropic API.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL。the base URL |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:331–334apiKey
public Builder apiKey(String apiKey)
设置API 键。
Sets the API key for authentication.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiKey | String | API 密钥。the API key |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:342–345authToken
public Builder authToken(String authToken)
设置认证令牌。
Sets the bearer token for authentication with an Anthropic-compatible gateway.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
authToken | String | 认证令牌(类型 `String`)。the token without the `Bearer ` prefix (null to omit) |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:356–359modelName
public Builder modelName(String modelName)
设置模型名称。
Sets the model name.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelName | String | 模型名称。the model name |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:367–370stream
public Builder stream(boolean streamEnabled)
设置流。
Enables or disables streaming.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
streamEnabled | boolean | 流已启用(类型 `boolean`)。true to enable streaming |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:378–381defaultOptions
public Builder defaultOptions(GenerateOptions defaultOptions)
设置默认选项。
Sets default generation options.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
defaultOptions | GenerateOptions | 默认选项。the default options |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:389–392formatter
public Builder formatter(AnthropicBaseFormatter formatter)
设置自定义格式化器。
Sets a custom formatter.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
formatter | AnthropicBaseFormatter | 格式化器。the formatter |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:400–403proxy
public Builder proxy(ProxyConfig proxyConfig)
设置代理。
Sets the proxy configuration for HTTP traffic.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
proxyConfig | ProxyConfig | 代理配置(类型 `ProxyConfig`)。the proxy configuration (see `ProxyConfig`) |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:415–418cacheTtl
public Builder cacheTtl(String cacheTtl)
设置缓存存活时间。
Sets the TTL for prompt-caching markers (e.g.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
cacheTtl | String | 缓存存活时间(类型 `String`)。the cache TTL string (null for default 5m ephemeral) |
Builder返回当前实例,以支持链式调用。this builder
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:426–429contextWindowSize
public Builder contextWindowSize(int contextWindowSize)
设置该配置项。
Performs the context window size operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
contextWindowSize | int | 上下文 Window 大小(类型 `int`)。The context window size. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:431–434build
public AnthropicChatModel build()
构建AnthropicChatModel 实例。
Builds the AnthropicChatModel instance.
AnthropicChatModel一种新的AnthropicChatModel。a new AnthropicChatModel
源码Source
io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:441–458