类 GLMFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OpenAIMessage,OpenAIResponse,OpenAIRequest>
io.agentscope.core.formatter.openai.OpenAIBaseFormatter
io.agentscope.core.formatter.openai.OpenAIChatFormatter
io.agentscope.core.formatter.openai.GLMFormatter
- 所有已实现的接口:
Formatter<OpenAIMessage,OpenAIResponse, OpenAIRequest>
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();
-
字段概要
从类继承的字段 io.agentscope.core.formatter.openai.OpenAIBaseFormatter
messageConverter, responseParser -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidapplyToolChoice(OpenAIRequest request, ToolChoice toolChoice) Apply tool choice configuration 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.OpenAIChatFormatter
applyAdditionalBodyParams, applyMaxTokens, applyOptions, applyTools从类继承的方法 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
-
构造器详细资料
-
GLMFormatter
public GLMFormatter()
-
-
方法详细资料
-
doFormat
- 覆盖:
doFormat在类中OpenAIChatFormatter
-
supportsStrict
protected boolean supportsStrict()从类复制的说明: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).
- 覆盖:
supportsStrict在类中OpenAIChatFormatter- 返回:
- 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在类中OpenAIChatFormatter- 参数:
request- OpenAI request DTOtoolChoice- Tool choice configuration (null means auto)
-