Builder
public static class Builder
io/agentscope/core/model/GenerateOptions.java:518–902构建器,用于构建并配置目标实例。位于 io.agentscope.core.model 包。核心成员包括 apiKey、baseUrl、endpointPath、modelName、stream、temperature。
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 Detail
apiKey
public Builder apiKey(String apiKey)
设置API 键。
Sets the API key for authentication.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiKey | String | API 密钥。the API key |
Builderio/agentscope/core/model/GenerateOptions.java:552–555baseUrl
public Builder baseUrl(String baseUrl)
设置基类 URL 用于 API 端点。
Sets the base URL for the API endpoint.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL。the base URL |
Builderio/agentscope/core/model/GenerateOptions.java:563–566endpointPath
public Builder endpointPath(String endpointPath)
设置端点路径用于 API 请求。
Sets the endpoint path for the API request.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
endpointPath | String | 端点路径(类型 `String`)。the endpoint path (e.g., "/v1/chat/completions") |
Builderio/agentscope/core/model/GenerateOptions.java:578–581modelName
public Builder modelName(String modelName)
设置模型名称。
Sets the model name to use for generation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelName | String | 模型名称(类型 `String`)。the model name (e.g., "gpt-4", "gpt-3.5-turbo") |
Builderio/agentscope/core/model/GenerateOptions.java:589–592stream
public Builder stream(Boolean stream)
设置流。
Sets whether streaming mode is enabled.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stream | Boolean | 流(类型 `Boolean`)。true for streaming, false for non-streaming |
Builderio/agentscope/core/model/GenerateOptions.java:600–603temperature
public Builder temperature(Double temperature)
设置该配置项。
Sets the temperature for text generation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
temperature | Double | temperature(类型 `Double`)。the temperature value between 0 and 2 |
Builderio/agentscope/core/model/GenerateOptions.java:614–617topP
public Builder topP(Double topP)
设置该配置项。
Sets the top-p (nucleus sampling) parameter.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
topP | Double | top P(类型 `Double`)。the top-p value between 0 and 1 |
Builderio/agentscope/core/model/GenerateOptions.java:628–631maxTokens
public Builder maxTokens(Integer maxTokens)
设置最大令牌数。
Sets the maximum number of tokens to generate.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
maxTokens | Integer | 最大令牌数(类型 `Integer`)。the maximum tokens limit |
Builderio/agentscope/core/model/GenerateOptions.java:639–642maxCompletionTokens
public Builder maxCompletionTokens(Integer maxCompletionTokens)
设置最大补全令牌数。
Sets the maximum number of completion tokens to generate.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
maxCompletionTokens | Integer | 最大补全令牌数(类型 `Integer`)。the maximum completion tokens limit |
Builderio/agentscope/core/model/GenerateOptions.java:655–658frequencyPenalty
public Builder frequencyPenalty(Double frequencyPenalty)
设置该配置项。
Sets the frequency penalty.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
frequencyPenalty | Double | frequency Penalty(类型 `Double`)。the frequency penalty between -2 and 2 |
Builderio/agentscope/core/model/GenerateOptions.java:669–672presencePenalty
public Builder presencePenalty(Double presencePenalty)
设置该配置项。
Sets the presence penalty.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
presencePenalty | Double | 在线状态 Penalty(类型 `Double`)。the presence penalty between -2 and 2 |
Builderio/agentscope/core/model/GenerateOptions.java:683–686thinkingBudget
public Builder thinkingBudget(Integer thinkingBudget)
设置该配置项。
Sets the thinking budget (maximum tokens for reasoning/thinking content).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
thinkingBudget | Integer | thinking 预算(类型 `Integer`)。the maximum tokens for thinking content |
Builderio/agentscope/core/model/GenerateOptions.java:698–701reasoningEffort
public Builder reasoningEffort(String reasoningEffort)
设置该配置项。
Sets the reasoning effort level for o1 models.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
reasoningEffort | String | 推理 Effort(类型 `String`)。the reasoning effort level |
Builderio/agentscope/core/model/GenerateOptions.java:712–715executionConfig
public Builder executionConfig(ExecutionConfig executionConfig)
设置执行配置用于超时和重试行为。
Sets the execution configuration for timeout and retry behavior.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
executionConfig | ExecutionConfig | 执行配置(类型 `ExecutionConfig`)。the execution configuration, or null to disable |
Builderio/agentscope/core/model/GenerateOptions.java:726–729toolChoice
public Builder toolChoice(ToolChoice toolChoice)
设置工具选项。
Sets the tool choice configuration for controlling how the model uses tools.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolChoice | ToolChoice | 工具选项(类型 `ToolChoice`)。the tool choice configuration, or null for default (auto) |
Builderio/agentscope/core/model/GenerateOptions.java:747–750topK
public Builder topK(Integer topK)
设置该配置项。
Sets the top-k sampling parameter.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
topK | Integer | top K(类型 `Integer`)。the top-k value |
Builderio/agentscope/core/model/GenerateOptions.java:761–764seed
public Builder seed(Long seed)
设置预置。
Sets the random seed for deterministic generation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
seed | Long | 预置值。the seed value |
Builderio/agentscope/core/model/GenerateOptions.java:775–778cacheControl
public Builder cacheControl(Boolean cacheControl)
设置该配置项。
Sets whether cache control is enabled for prompt caching.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
cacheControl | Boolean | 缓存 Control(类型 `Boolean`)。true to enable cache control, false to disable |
Builderio/agentscope/core/model/GenerateOptions.java:789–792parallelToolCalls
public Builder parallelToolCalls(Boolean parallelToolCalls)
设置该配置项。
Sets whether to enable parallel function calling during tool use.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
parallelToolCalls | Boolean | parallel 工具调用(类型 `Boolean`)。true to enable parallel tool calls, false to disable |
Builderio/agentscope/core/model/GenerateOptions.java:800–803responseFormat
public Builder responseFormat(ResponseFormat responseFormat)
设置响应格式用于结构化输出。
Sets the response format for structured output.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
responseFormat | ResponseFormat | 响应格式配置。the response format configuration |
Builderio/agentscope/core/model/GenerateOptions.java:811–814additionalHeader
public Builder additionalHeader(String key, String value)
执行 additionalHeader 方法。
Adds an additional HTTP header to include in API requests.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 请求头名称。the header name |
value | String | 请求头值。the header value |
Builderio/agentscope/core/model/GenerateOptions.java:823–829additionalHeaders
public Builder additionalHeaders(Map<String, String> headers)
设置该参数。
Sets all additional HTTP headers to include in API requests.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
headers | Map<String, String> | 请求头映射。the headers map |
Builderio/agentscope/core/model/GenerateOptions.java:837–840additionalBodyParam
public Builder additionalBodyParam(String key, Object value)
执行 additionalBodyParam 方法。
Adds an additional parameter to include in the request body.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 参数名称。the parameter name |
value | Object | 参数值。the parameter value |
Builderio/agentscope/core/model/GenerateOptions.java:849–855additionalBodyParams
public Builder additionalBodyParams(Map<String, Object> params)
设置该参数。
Sets all additional parameters to include in the request body.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
params | Map<String, Object> | 参数映射。the parameters map |
Builderio/agentscope/core/model/GenerateOptions.java:863–866additionalQueryParam
public Builder additionalQueryParam(String key, String value)
执行 additionalQueryParam 方法。
Adds an additional query parameter to include in API requests.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 参数名称。the parameter name |
value | String | 参数值。the parameter value |
Builderio/agentscope/core/model/GenerateOptions.java:875–881additionalQueryParams
public Builder additionalQueryParams(Map<String, String> params)
设置该参数。
Sets all additional query parameters to include in API requests.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
params | Map<String, String> | 参数映射。the parameters map |
Builderio/agentscope/core/model/GenerateOptions.java:889–892build
public GenerateOptions build()
构建新的GenerateOptions 实例使用设置值。
Builds a new GenerateOptions instance with the set values.
GenerateOptionsio/agentscope/core/model/GenerateOptions.java:899–901