AS AgentScopeAPI 手册 / API Reference

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
apiKeyStringAPI 键(类型 `String`)。The api key.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:223–226

baseUrl

public Builder baseUrl(String baseUrl)

设置基类 URL。

Performs the base url operation.

参数Parameters
名称Name类型Type说明Description
baseUrlString基类 URL(类型 `String`)。The base url.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:228–231

endpointPath

public Builder endpointPath(String endpointPath)

设置端点路径。

Performs the endpoint path operation.

参数Parameters
名称Name类型Type说明Description
endpointPathString端点路径(类型 `String`)。The endpoint path.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:233–236

stream

public Builder stream(Boolean stream)

设置流。

Performs the stream operation.

参数Parameters
名称Name类型Type说明Description
streamBoolean流(类型 `Boolean`)。The stream.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:238–241

enableThinking

public Builder enableThinking(Boolean enableThinking)

启用该配置。

Enables the thinking.

参数Parameters
名称Name类型Type说明Description
enableThinkingBoolean启用 Thinking(类型 `Boolean`)。The enable thinking.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:243–246

cachePolicy

public Builder cachePolicy(CachePolicy cachePolicy)

设置缓存策略。

Performs the cache policy operation.

参数Parameters
名称Name类型Type说明Description
cachePolicyCachePolicy缓存策略(类型 `CachePolicy`)。The cache policy.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:248–251

cacheId

public Builder cacheId(String cacheId)

设置缓存标识。

Performs the cache id operation.

参数Parameters
名称Name类型Type说明Description
cacheIdString缓存标识(类型 `String`)。The cache id.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:253–256

option

public Builder option(String key, Object value)

设置选项。

Performs the option operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
valueObject值(类型 `Object`)。The value.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:258–266

component

public T Builder component(Class<T> type, T value)

设置该配置项。

Performs the component operation.

参数Parameters
名称Name类型Type说明Description
typeClass<T>类型(类型 `Class`)。The type.
valueT值(类型 `T`)。The value.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/model/ModelCreationContext.java:268–276

build

public ModelCreationContext build()

构建并返回最终实例。

Creates and returns an instance.

返回Returns ModelCreationContext
返回ModelCreationContext。Returns model creation context.
源码Source io/agentscope/core/model/ModelCreationContext.java:278–280
基于官方固定版本源码静态生成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.