Builder
public static final class Builder
源码Source
io/agentscope/core/model/ModelCreationContext.java:198–289构建器,用于构建并配置目标实例。位于 io.agentscope.core.model 包。核心成员包括 apiKey、baseUrl、endpointPath、stream、enableThinking、cachePolicy。
A class in io.agentscope.core.model that talks to model services and returns generated or embedded output. Declared in io.agentscope.core.model.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Builder apiKey(String apiKey) | 设置API 键。 Performs the api key operation. |
public Builder baseUrl(String baseUrl) | 设置基类 URL。 Performs the base url operation. |
public Builder endpointPath(String endpointPath) | 设置端点路径。 Performs the endpoint path operation. |
public Builder stream(Boolean stream) | 设置流。 Performs the stream operation. |
public Builder enableThinking(Boolean enableThinking) | 启用该配置。 Enables the thinking. |
public Builder cachePolicy(CachePolicy cachePolicy) | 设置缓存策略。 Performs the cache policy operation. |
public Builder cacheId(String cacheId) | 设置缓存标识。 Performs the cache id operation. |
public Builder option(String key, Object value) | 设置选项。 Performs the option operation. |
public T Builder component(Class<T> type, T value) | 设置该配置项。 Performs the component operation. |
public ModelCreationContext build() | 构建并返回最终实例。 Creates and returns an instance. |
方法详情Method Detail
apiKey
public Builder apiKey(String apiKey)
设置API 键。
Performs the api key operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiKey | String | API 键(类型 `String`)。The api key. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:223–226baseUrl
public Builder baseUrl(String baseUrl)
设置基类 URL。
Performs the base url operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:228–231endpointPath
public Builder endpointPath(String endpointPath)
设置端点路径。
Performs the endpoint path operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
endpointPath | String | 端点路径(类型 `String`)。The endpoint path. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:233–236stream
public Builder stream(Boolean stream)
设置流。
Performs the stream operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stream | Boolean | 流(类型 `Boolean`)。The stream. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:238–241enableThinking
public Builder enableThinking(Boolean enableThinking)
启用该配置。
Enables the thinking.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
enableThinking | Boolean | 启用 Thinking(类型 `Boolean`)。The enable thinking. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:243–246cachePolicy
public Builder cachePolicy(CachePolicy cachePolicy)
设置缓存策略。
Performs the cache policy operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
cachePolicy | CachePolicy | 缓存策略(类型 `CachePolicy`)。The cache policy. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:248–251cacheId
public Builder cacheId(String cacheId)
设置缓存标识。
Performs the cache id operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
cacheId | String | 缓存标识(类型 `String`)。The cache id. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:253–256option
public Builder option(String key, Object value)
设置选项。
Performs the option operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
value | Object | 值(类型 `Object`)。The value. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:258–266component
public T Builder component(Class<T> type, T value)
设置该配置项。
Performs the component operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
type | Class<T> | 类型(类型 `Class`)。The type. |
value | T | 值(类型 `T`)。The value. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/core/model/ModelCreationContext.java:268–276build
public ModelCreationContext build()
构建并返回最终实例。
Creates and returns an instance.
ModelCreationContext返回ModelCreationContext。Returns model creation context.
源码Source
io/agentscope/core/model/ModelCreationContext.java:278–280