GLMMultiAgentFormatter
public class GLMMultiAgentFormatter extends OpenAIMultiAgentFormatter
io/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:54–95GLM Multi 智能体格式化器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.openai.compat.glm 包,继承自 OpenAIMultiAgentFormatter。核心成员包括 doFormat、convertMessage、supportsStrict、applyOptions、applyToolChoice、GLMMultiAgentFormatter。
Multi-agent formatter for Zhipu AI (Z.ai) GLM models.
This formatter extends OpenAIMultiAgentFormatter with the same GLM-specific
handling as GLMFormatter:
-
At least one user message is required (error 1214 otherwise)
-
Does NOT support the
nameparameter in messages -
tool_choiceonly supports"auto"; forced choices are degraded, whilenoneremoves tools to preserve the no-tool-call contract -
Does NOT support the
strictparameter in tool definitions -
Unsupported sampling parameters are stripped,
max_completion_tokensis mapped tomax_tokens, andtemperature/top_pare clamped to the GLM ranges (seeGLMFormatterfor details)
Usage:
`OpenAIChatModel.builder()
.formatter(new GLMMultiAgentFormatter())
.modelName("glm-5.2")
.baseUrl("https://open.bigmodel.cn/api/paas/v4")
.apiKey(apiKey)
.build();
`
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public GLMMultiAgentFormatter() | 初始化 `GLMMultiAgentFormatter` 实例。 Creates a new instance. |
public GLMMultiAgentFormatter(String conversationHistoryPrompt) | 初始化 `GLMMultiAgentFormatter` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
protected List<OpenAIMessage> doFormat(List<Msg> msgs) | 执行格式操作。 Performs the do format operation. |
protected OpenAIMessage convertMessage(Msg msg, boolean hasMedia) | 转换消息。 Converts the message. |
protected boolean supportsStrict() | 返回 `supportsStrict` 结果。 Returns the supports strict. |
public void applyOptions(OpenAIRequest request, GenerateOptions options, GenerateOptions defaultOptions) | 应用选项。 Performs the apply options operation. |
public void applyToolChoice(OpenAIRequest request, ToolChoice toolChoice) | 应用工具选项。 Performs the apply tool choice operation. |
构造器详情Constructor Detail
GLMMultiAgentFormatter
public GLMMultiAgentFormatter()
初始化 GLMMultiAgentFormatter 实例。
Creates a new instance.
io/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:56–58GLMMultiAgentFormatter
public GLMMultiAgentFormatter(String conversationHistoryPrompt)
初始化 GLMMultiAgentFormatter 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
conversationHistoryPrompt | String | 会话历史提示词(类型 `String`)。The conversation history prompt. |
io/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:60–62方法详情Method Detail
doFormat
protected List<OpenAIMessage> doFormat(List<Msg> msgs)
执行格式操作。
Performs the do format operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。The msgs. |
List<OpenAIMessage>io/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:64–68convertMessage
protected OpenAIMessage convertMessage(Msg msg, boolean hasMedia)
转换消息。
Converts the message.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msg | Msg | 消息(类型 `Msg`)。The msg. |
hasMedia | boolean | 有 Media(类型 `boolean`)。The has media. |
OpenAIMessageio/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:70–77supportsStrict
protected boolean supportsStrict()
返回 supportsStrict 结果。
Returns the supports strict.
booleanio/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:79–82applyOptions
public void applyOptions(OpenAIRequest request, GenerateOptions options, GenerateOptions defaultOptions)
应用选项。
Performs the apply options operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | OpenAIRequest | 请求(类型 `OpenAIRequest`)。The request. |
options | GenerateOptions | 选项(类型 `GenerateOptions`)。The options. |
defaultOptions | GenerateOptions | 默认选项(类型 `GenerateOptions`)。The default options. |
io/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:84–89applyToolChoice
public void applyToolChoice(OpenAIRequest request, ToolChoice toolChoice)
应用工具选项。
Performs the apply tool choice operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | OpenAIRequest | 请求(类型 `OpenAIRequest`)。The request. |
toolChoice | ToolChoice | 工具选项(类型 `ToolChoice`)。The tool choice. |
io/agentscope/extensions/model/openai/compat/glm/GLMMultiAgentFormatter.java:91–94