类 GenerateOptions.Builder
- 封闭类:
GenerateOptions
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明additionalBodyParam(String key, Object value) Adds an additional parameter to include in the request body.additionalBodyParams(Map<String, Object> params) Sets all additional parameters to include in the request body.additionalHeader(String key, String value) Adds an additional HTTP header to include in API requests.additionalHeaders(Map<String, String> headers) Sets all additional HTTP headers to include in API requests.additionalQueryParam(String key, String value) Adds an additional query parameter to include in API requests.additionalQueryParams(Map<String, String> params) Sets all additional query parameters to include in API requests.Sets the API key for authentication.Sets the base URL for the API endpoint.build()Builds a new GenerateOptions instance with the set values.cacheControl(Boolean cacheControl) Sets whether cache control is enabled for prompt caching.endpointPath(String endpointPath) Sets the endpoint path for the API request.executionConfig(ExecutionConfig executionConfig) Sets the execution configuration for timeout and retry behavior.frequencyPenalty(Double frequencyPenalty) Sets the frequency penalty.maxCompletionTokens(Integer maxCompletionTokens) Sets the maximum number of completion tokens to generate.Sets the maximum number of tokens to generate.Sets the model name to use for generation.presencePenalty(Double presencePenalty) Sets the presence penalty.reasoningEffort(String reasoningEffort) Sets the reasoning effort level for o1 models.Sets the random seed for deterministic generation.Sets whether streaming mode is enabled.temperature(Double temperature) Sets the temperature for text generation.thinkingBudget(Integer thinkingBudget) Sets the thinking budget (maximum tokens for reasoning/thinking content).toolChoice(ToolChoice toolChoice) Sets the tool choice configuration for controlling how the model uses tools.Sets the top-k sampling parameter.Sets the top-p (nucleus sampling) parameter.
-
构造器详细资料
-
Builder
public Builder()
-
-
方法详细资料
-
apiKey
Sets the API key for authentication.- 参数:
apiKey- the API key- 返回:
- this builder instance
-
baseUrl
Sets the base URL for the API endpoint.- 参数:
baseUrl- the base URL- 返回:
- this builder instance
-
endpointPath
Sets the endpoint path for the API request.This allows customization for OpenAI-compatible APIs that use different endpoint paths than the standard OpenAI API (e.g., "/v4/chat/completions", "/api/v1/llm/chat", etc.). When null, the default endpoint path will be used.
- 参数:
endpointPath- the endpoint path (e.g., "/v1/chat/completions")- 返回:
- this builder instance
-
modelName
Sets the model name to use for generation.- 参数:
modelName- the model name (e.g., "gpt-4", "gpt-3.5-turbo")- 返回:
- this builder instance
-
stream
Sets whether streaming mode is enabled.- 参数:
stream- true for streaming, false for non-streaming- 返回:
- this builder instance
-
temperature
Sets the temperature for text generation.Higher values (e.g., 0.8) make output more random, while lower values (e.g., 0.2) make it more focused and deterministic.
- 参数:
temperature- the temperature value between 0 and 2- 返回:
- this builder instance
-
topP
Sets the top-p (nucleus sampling) parameter.Controls diversity via nucleus sampling: considers the smallest set of tokens whose cumulative probability exceeds the top_p value.
- 参数:
topP- the top-p value between 0 and 1- 返回:
- this builder instance
-
maxTokens
Sets the maximum number of tokens to generate.- 参数:
maxTokens- the maximum tokens limit- 返回:
- this builder instance
-
maxCompletionTokens
Sets the maximum number of completion tokens to generate.This is an alternative to
maxTokens(Integer)for OpenAI-compatible APIs that supportmax_completion_tokens. This builder does not enforce exclusivity withmaxTokens; both may be set and will be forwarded as-is by formatters that support both fields.- 参数:
maxCompletionTokens- the maximum completion tokens limit- 返回:
- this builder instance
-
frequencyPenalty
Sets the frequency penalty.Reduces repetition by penalizing tokens based on their frequency in the text so far. Higher values decrease repetition more strongly.
- 参数:
frequencyPenalty- the frequency penalty between -2 and 2- 返回:
- this builder instance
-
presencePenalty
Sets the presence penalty.Reduces repetition by penalizing tokens that have already appeared in the text. Higher values decrease repetition more strongly.
- 参数:
presencePenalty- the presence penalty between -2 and 2- 返回:
- this builder instance
-
thinkingBudget
Sets the thinking budget (maximum tokens for reasoning/thinking content).This parameter is specific to models that support thinking mode. When set, the model will show its reasoning process before generating the final answer. Setting this parameter may automatically enable thinking mode in some models.
- 参数:
thinkingBudget- the maximum tokens for thinking content- 返回:
- this builder
-
reasoningEffort
Sets the reasoning effort level for o1 models.This parameter controls how much effort the model spends on reasoning. Valid values are "low", "medium", and "high".
- 参数:
reasoningEffort- the reasoning effort level- 返回:
- this builder
-
executionConfig
Sets the execution configuration for timeout and retry behavior.When configured, model API calls will apply timeout and retry logic according to the execution config (timeout duration, max attempts, backoff, error filtering).
- 参数:
executionConfig- the execution configuration, or null to disable- 返回:
- this builder instance
-
toolChoice
Sets the tool choice configuration for controlling how the model uses tools.This setting controls whether the model can call tools, must call tools, or must call a specific tool:
ToolChoice.Auto- Let model decide (default when null)ToolChoice.None- Prevent tool callingToolChoice.Required- Force at least one tool callToolChoice.Specific- Force specific tool call
- 参数:
toolChoice- the tool choice configuration, or null for default (auto)- 返回:
- this builder instance
- 另请参阅:
-
topK
Sets the top-k sampling parameter.Limits the model to only consider the top K most probable tokens at each step. Lower values make output more focused, higher values allow more diversity.
- 参数:
topK- the top-k value- 返回:
- this builder instance
-
seed
Sets the random seed for deterministic generation.When set, the model will attempt to generate the same output for the same input and seed value, enabling reproducible results.
- 参数:
seed- the seed value- 返回:
- this builder instance
-
cacheControl
Sets whether cache control is enabled for prompt caching.When true, the formatter will automatically add
cache_control: {"type": "ephemeral"}to system messages and the last message in the request.- 参数:
cacheControl- true to enable cache control, false to disable- 返回:
- this builder instance
-
additionalHeader
Adds an additional HTTP header to include in API requests.- 参数:
key- the header namevalue- the header value- 返回:
- this builder instance
-
additionalHeaders
Sets all additional HTTP headers to include in API requests.- 参数:
headers- the headers map- 返回:
- this builder instance
-
additionalBodyParam
Adds an additional parameter to include in the request body.- 参数:
key- the parameter namevalue- the parameter value- 返回:
- this builder instance
-
additionalBodyParams
Sets all additional parameters to include in the request body.- 参数:
params- the parameters map- 返回:
- this builder instance
-
additionalQueryParam
Adds an additional query parameter to include in API requests.- 参数:
key- the parameter namevalue- the parameter value- 返回:
- this builder instance
-
additionalQueryParams
Sets all additional query parameters to include in API requests.- 参数:
params- the parameters map- 返回:
- this builder instance
-
build
Builds a new GenerateOptions instance with the set values.- 返回:
- a new GenerateOptions instance
-