类 OpenAIChatFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OpenAIMessage,OpenAIResponse,OpenAIRequest>
io.agentscope.core.formatter.openai.OpenAIBaseFormatter
io.agentscope.core.formatter.openai.OpenAIChatFormatter
- 所有已实现的接口:
Formatter<OpenAIMessage,OpenAIResponse, OpenAIRequest>
Formatter for OpenAI Chat Completion HTTP API.
Converts between AgentScope Msg objects and OpenAI DTO types.
This formatter is used with the HTTP-based OpenAI client for standard OpenAI GPT models. It provides full support for:
- All sampling parameters (temperature, top_p, penalties)
- Tool calling with strict mode support
- Full tool_choice options (auto, none, required, specific)
-
字段概要
从类继承的字段 io.agentscope.core.formatter.openai.OpenAIBaseFormatter
messageConverter, responseParser -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidapplyAdditionalBodyParams(OpenAIRequest request, GenerateOptions opts) Apply additional body parameters from GenerateOptions to OpenAI request.protected voidapplyMaxTokens(OpenAIRequest request, GenerateOptions options, GenerateOptions defaultOptions) voidapplyOptions(OpenAIRequest request, GenerateOptions options, GenerateOptions defaultOptions) Apply generation options to the request.voidapplyToolChoice(OpenAIRequest request, ToolChoice toolChoice) Apply tool choice configuration to the request.voidapplyTools(OpenAIRequest request, List<ToolSchema> tools) Apply tool schemas to the request.protected List<OpenAIMessage> protected booleanReturns whether this formatter's target API supports the strict parameter in tool definitions.从类继承的方法 io.agentscope.core.formatter.openai.OpenAIBaseFormatter
applyCacheControl, applyToolChoice, applyTools, buildRequest, buildRequest, parseResponse从类继承的方法 io.agentscope.core.formatter.AbstractBaseFormatter
convertToolResultToString, extractTextContent, extractTextContent, format, formatRoleLabel, getOptionOrDefault, hasMediaContent, saveBase64DataToTempFile, shouldBypassHistory
-
构造器详细资料
-
OpenAIChatFormatter
public OpenAIChatFormatter()
-
-
方法详细资料
-
doFormat
-
applyOptions
public void applyOptions(OpenAIRequest request, GenerateOptions options, GenerateOptions defaultOptions) 从类复制的说明:OpenAIBaseFormatterApply generation options to the request. Subclasses implement provider-specific option handling.- 指定者:
applyOptions在接口中Formatter<OpenAIMessage,OpenAIResponse, OpenAIRequest> - 指定者:
applyOptions在类中OpenAIBaseFormatter- 参数:
request- OpenAI request DTOoptions- Generation options to applydefaultOptions- Default options to use if options parameter is null
-
applyMaxTokens
protected void applyMaxTokens(OpenAIRequest request, GenerateOptions options, GenerateOptions defaultOptions) -
applyTools
从类复制的说明:OpenAIBaseFormatterApply tool schemas to the request. Subclasses implement provider-specific tool handling.- 指定者:
applyTools在接口中Formatter<OpenAIMessage,OpenAIResponse, OpenAIRequest> - 指定者:
applyTools在类中OpenAIBaseFormatter- 参数:
request- OpenAI request DTOtools- List of tool schemas to apply (may be null or empty)
-
supportsStrict
protected boolean supportsStrict()Returns whether this formatter's target API supports the strict parameter in tool definitions.Subclasses can override this method to disable strict parameter for providers that don't support it (e.g., DeepSeek).
- 返回:
- true if strict parameter is supported, false otherwise
-
applyToolChoice
从类复制的说明:OpenAIBaseFormatterApply tool choice configuration to the request. Subclasses implement provider-specific tool choice handling.- 指定者:
applyToolChoice在接口中Formatter<OpenAIMessage,OpenAIResponse, OpenAIRequest> - 指定者:
applyToolChoice在类中OpenAIBaseFormatter- 参数:
request- OpenAI request DTOtoolChoice- Tool choice configuration (null means auto)
-
applyAdditionalBodyParams
Apply additional body parameters from GenerateOptions to OpenAI request. This handles parameters like reasoning_effort that are set via additionalBodyParam().
-