Class GLMFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OpenAIMessage,OpenAIResponse,OpenAIRequest>
io.agentscope.extensions.model.openai.formatter.OpenAIBaseFormatter
io.agentscope.extensions.model.openai.formatter.OpenAIChatFormatter
io.agentscope.extensions.model.openai.formatter.GLMFormatter
- All Implemented Interfaces:
io.agentscope.core.formatter.Formatter<OpenAIMessage,OpenAIResponse, OpenAIRequest>
Deprecated.
Formatter for Zhipu GLM models (glm-4, glm-3-turbo, etc.).
Zhipu GLM API has the following specific requirements:
- At least one user message is required (error 1214 otherwise)
- Only supports "auto" for tool_choice
- Does NOT support strict parameter in tool definitions
- Supports temperature, top_p, max_tokens, seed (but not frequency/presence penalty)
Usage:
OpenAIChatModel.builder()
.formatter(new GLMFormatter())
.modelName("glm-4")
.baseUrl("https://open.bigmodel.cn/api/paas/v4/")
.apiKey(apiKey)
.build();
-
Field Summary
Fields inherited from class io.agentscope.extensions.model.openai.formatter.OpenAIBaseFormatter
messageConverter, responseParser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyToolChoice(OpenAIRequest request, io.agentscope.core.model.ToolChoice toolChoice) Deprecated.Apply tool choice configuration to the request.protected List<OpenAIMessage>Deprecated.protected booleanDeprecated.Returns whether this formatter's target API supports the strict parameter in tool definitions.Methods inherited from class io.agentscope.extensions.model.openai.formatter.OpenAIChatFormatter
applyAdditionalBodyParams, applyMaxTokens, applyOptions, applyTools, convertMessage, doFormatMethods inherited from class io.agentscope.extensions.model.openai.formatter.OpenAIBaseFormatter
applyToolChoice, applyTools, buildRequest, buildRequest, parseResponseMethods inherited from class io.agentscope.core.formatter.AbstractBaseFormatter
convertToolResultToString, extractTextContent, extractTextContent, format, format, formatRoleLabel, getOptionOrDefault, hasMediaContent, saveBase64DataToTempFile, shouldBypassHistory
-
Constructor Details
-
GLMFormatter
public GLMFormatter()Deprecated.
-
-
Method Details
-
doFormat
Deprecated.- Overrides:
doFormatin classOpenAIChatFormatter
-
supportsStrict
protected boolean supportsStrict()Deprecated.Description copied from class:OpenAIChatFormatterReturns 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).
- Overrides:
supportsStrictin classOpenAIChatFormatter- Returns:
- true if strict parameter is supported, false otherwise
-
applyToolChoice
Deprecated.Description copied from class:OpenAIBaseFormatterApply tool choice configuration to the request. Subclasses implement provider-specific tool choice handling.- Specified by:
applyToolChoicein interfaceio.agentscope.core.formatter.Formatter<OpenAIMessage,OpenAIResponse, OpenAIRequest> - Overrides:
applyToolChoicein classOpenAIChatFormatter- Parameters:
request- OpenAI request DTOtoolChoice- Tool choice configuration (null means auto)
-
GLMFormatter.