AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:448–611

构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.model.openai.dto 包。核心成员包括 model、messages、stream、streamOptions、temperature、topP。

A class in io.agentscope.extensions.model.openai.dto that talks to model services and returns generated or embedded output. Declared in io.agentscope.extensions.model.openai.dto.

方法摘要Method Summary

方法Method说明Description
public Builder model(String model)
设置模型。
Performs the model operation.
public Builder messages(List<OpenAIMessage> messages)
设置消息。
Performs the messages operation.
public Builder stream(Boolean stream)
设置流。
Performs the stream operation.
public Builder streamOptions(OpenAIStreamOptions streamOptions)
设置流选项。
Streams the options.
public Builder temperature(Double temperature)
设置该配置项。
Performs the temperature operation.
public Builder topP(Double topP)
设置该配置项。
Performs the top p operation.
public Builder maxTokens(Integer maxTokens)
设置最大令牌数。
Performs the max tokens operation.
public Builder maxCompletionTokens(Integer maxCompletionTokens)
设置最大补全令牌数。
Performs the max completion tokens operation.
public Builder frequencyPenalty(Double frequencyPenalty)
设置该配置项。
Performs the frequency penalty operation.
public Builder presencePenalty(Double presencePenalty)
设置该配置项。
Performs the presence penalty operation.
public Builder stop(Object stop)
设置停止。
Performs the stop operation.
public Builder seed(Integer seed)
设置预置。
Performs the seed operation.
public Builder n(Integer n)
设置n。
Performs the n operation.
public Builder tools(List<OpenAITool> tools)
设置工具。
Performs the tools operation.
public Builder toolChoice(Object toolChoice)
设置工具选项。
Performs the tool choice operation.
public Builder user(String user)
设置用户。
Performs the user operation.
public Builder responseFormat(Map<String, Object> responseFormat)
设置响应格式。
Performs the response format operation.
public Builder includeReasoning(Boolean includeReasoning)
设置该配置项。
Performs the include reasoning operation.
public Builder extraParam(String key, Object value)
设置该配置项。
Performs the extra param operation.
public Builder extraParams(Map<String, Object> extraParams)
设置该配置项。
Performs the extra params operation.
public OpenAIRequest build()
构建并返回最终实例。
Creates and returns an instance.
public Builder logprobs(Boolean logprobs)
设置该配置项。
Performs the logprobs operation.
public Builder topLogprobs(Integer topLogprobs)
设置该配置项。
Performs the top logprobs operation.
public Builder reasoningEffort(String reasoningEffort)
设置该配置项。
Performs the reasoning effort operation.
public Builder thinkingBudget(Integer thinkingBudget)
设置该配置项。
Performs the thinking budget operation.
public Builder parallelToolCalls(Boolean parallelToolCalls)
设置该配置项。
Performs the parallel tool calls operation.
public Builder serviceTier(String serviceTier)
设置该配置项。
Performs the service tier operation.
public Builder store(Boolean store)
设置存储。
Performs the store operation.
public Builder metadata(Map<String, Object> metadata)
设置元数据。
Performs the metadata operation.
public Builder prediction(Map<String, Object> prediction)
设置该配置项。
Performs the prediction operation.
public Builder modalities(List<String> modalities)
设置该配置项。
Performs the modalities operation.
public Builder audio(Map<String, Object> audio)
设置音频。
Performs the audio operation.

方法详情Method Detail

model

public Builder model(String model)

设置模型。

Performs the model operation.

参数Parameters
名称Name类型Type说明Description
modelString模型实例(类型 `String`)。The model.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:451–454

messages

public Builder messages(List<OpenAIMessage> messages)

设置消息。

Performs the messages operation.

参数Parameters
名称Name类型Type说明Description
messagesList<OpenAIMessage>消息列表(类型 `List`)。The messages.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:456–459

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/extensions/model/openai/dto/OpenAIRequest.java:461–464

streamOptions

public Builder streamOptions(OpenAIStreamOptions streamOptions)

设置流选项。

Streams the options.

参数Parameters
名称Name类型Type说明Description
streamOptionsOpenAIStreamOptions流选项(类型 `OpenAIStreamOptions`)。The stream options.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:466–469

temperature

public Builder temperature(Double temperature)

设置该配置项。

Performs the temperature operation.

参数Parameters
名称Name类型Type说明Description
temperatureDoubletemperature(类型 `Double`)。The temperature.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:471–474

topP

public Builder topP(Double topP)

设置该配置项。

Performs the top p operation.

参数Parameters
名称Name类型Type说明Description
topPDoubletop P(类型 `Double`)。The top p.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:476–479

maxTokens

public Builder maxTokens(Integer maxTokens)

设置最大令牌数。

Performs the max tokens operation.

参数Parameters
名称Name类型Type说明Description
maxTokensInteger最大令牌数(类型 `Integer`)。The max tokens.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:481–484

maxCompletionTokens

public Builder maxCompletionTokens(Integer maxCompletionTokens)

设置最大补全令牌数。

Performs the max completion tokens operation.

参数Parameters
名称Name类型Type说明Description
maxCompletionTokensInteger最大补全令牌数(类型 `Integer`)。The max completion tokens.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:486–489

frequencyPenalty

public Builder frequencyPenalty(Double frequencyPenalty)

设置该配置项。

Performs the frequency penalty operation.

参数Parameters
名称Name类型Type说明Description
frequencyPenaltyDoublefrequency Penalty(类型 `Double`)。The frequency penalty.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:491–494

presencePenalty

public Builder presencePenalty(Double presencePenalty)

设置该配置项。

Performs the presence penalty operation.

参数Parameters
名称Name类型Type说明Description
presencePenaltyDouble在线状态 Penalty(类型 `Double`)。The presence penalty.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:496–499

stop

public Builder stop(Object stop)

设置停止。

Performs the stop operation.

参数Parameters
名称Name类型Type说明Description
stopObject停止(类型 `Object`)。The stop.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:501–504

seed

public Builder seed(Integer seed)

设置预置。

Performs the seed operation.

参数Parameters
名称Name类型Type说明Description
seedInteger预置(类型 `Integer`)。The seed.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:506–509

n

public Builder n(Integer n)

设置n。

Performs the n operation.

参数Parameters
名称Name类型Type说明Description
nIntegern(类型 `Integer`)。The n.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:511–514

tools

public Builder tools(List<OpenAITool> tools)

设置工具。

Performs the tools operation.

参数Parameters
名称Name类型Type说明Description
toolsList<OpenAITool>工具列表(类型 `List`)。The tools.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:516–519

toolChoice

public Builder toolChoice(Object toolChoice)

设置工具选项。

Performs the tool choice operation.

参数Parameters
名称Name类型Type说明Description
toolChoiceObject工具选项(类型 `Object`)。The tool choice.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:521–524

user

public Builder user(String user)

设置用户。

Performs the user operation.

参数Parameters
名称Name类型Type说明Description
userString用户(类型 `String`)。The user.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:526–529

responseFormat

public Builder responseFormat(Map<String, Object> responseFormat)

设置响应格式。

Performs the response format operation.

参数Parameters
名称Name类型Type说明Description
responseFormatMap<String, Object>响应格式(类型 `Map`)。The response format.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:531–534

includeReasoning

public Builder includeReasoning(Boolean includeReasoning)

设置该配置项。

Performs the include reasoning operation.

参数Parameters
名称Name类型Type说明Description
includeReasoningBooleaninclude 推理(类型 `Boolean`)。The include reasoning.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:536–539

extraParam

public Builder extraParam(String key, Object value)

设置该配置项。

Performs the extra param operation.

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

extraParams

public Builder extraParams(Map<String, Object> extraParams)

设置该配置项。

Performs the extra params operation.

参数Parameters
名称Name类型Type说明Description
extraParamsMap<String, Object>extra 参数(类型 `Map`)。The extra params.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:546–549

build

public OpenAIRequest build()

构建并返回最终实例。

Creates and returns an instance.

返回Returns OpenAIRequest
返回OpenAIRequest。Returns OpenAI request.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:551–555

logprobs

public Builder logprobs(Boolean logprobs)

设置该配置项。

Performs the logprobs operation.

参数Parameters
名称Name类型Type说明Description
logprobsBooleanlogprobs(类型 `Boolean`)。The logprobs.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:557–560

topLogprobs

public Builder topLogprobs(Integer topLogprobs)

设置该配置项。

Performs the top logprobs operation.

参数Parameters
名称Name类型Type说明Description
topLogprobsIntegertop Logprobs(类型 `Integer`)。The top logprobs.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:562–565

reasoningEffort

public Builder reasoningEffort(String reasoningEffort)

设置该配置项。

Performs the reasoning effort operation.

参数Parameters
名称Name类型Type说明Description
reasoningEffortString推理 Effort(类型 `String`)。The reasoning effort.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:567–570

thinkingBudget

public Builder thinkingBudget(Integer thinkingBudget)

设置该配置项。

Performs the thinking budget operation.

参数Parameters
名称Name类型Type说明Description
thinkingBudgetIntegerthinking 预算(类型 `Integer`)。The thinking budget.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:572–575

parallelToolCalls

public Builder parallelToolCalls(Boolean parallelToolCalls)

设置该配置项。

Performs the parallel tool calls operation.

参数Parameters
名称Name类型Type说明Description
parallelToolCallsBooleanparallel 工具调用(类型 `Boolean`)。The parallel tool calls.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:577–580

serviceTier

public Builder serviceTier(String serviceTier)

设置该配置项。

Performs the service tier operation.

参数Parameters
名称Name类型Type说明Description
serviceTierString服务 Tier(类型 `String`)。The service tier.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:582–585

store

public Builder store(Boolean store)

设置存储。

Performs the store operation.

参数Parameters
名称Name类型Type说明Description
storeBoolean存储实例(类型 `Boolean`)。The store.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:587–590

metadata

public Builder metadata(Map<String, Object> metadata)

设置元数据。

Performs the metadata operation.

参数Parameters
名称Name类型Type说明Description
metadataMap<String, Object>元数据(类型 `Map`)。The metadata.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:592–595

prediction

public Builder prediction(Map<String, Object> prediction)

设置该配置项。

Performs the prediction operation.

参数Parameters
名称Name类型Type说明Description
predictionMap<String, Object>prediction(类型 `Map`)。The prediction.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:597–600

modalities

public Builder modalities(List<String> modalities)

设置该配置项。

Performs the modalities operation.

参数Parameters
名称Name类型Type说明Description
modalitiesList<String>modalities(类型 `List`)。The modalities.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:602–605

audio

public Builder audio(Map<String, Object> audio)

设置音频。

Performs the audio operation.

参数Parameters
名称Name类型Type说明Description
audioMap<String, Object>音频(类型 `Map`)。The audio.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIRequest.java:607–610
基于官方固定版本源码静态生成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.