GLMFormatter
@Deprecated public class GLMFormatter extends OpenAIChatFormatter
源码Source
io/agentscope/extensions/model/openai/formatter/GLMFormatter.java:50–123GLM 格式化器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.openai.formatter 包,继承自 OpenAIChatFormatter。核心成员包括 doFormat、supportsStrict、applyToolChoice、GLMFormatter。
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();
`
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public GLMFormatter() | 初始化 `GLMFormatter` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
protected List<OpenAIMessage> doFormat(List<Msg> msgs) | 执行格式操作。 Performs the do format operation. |
protected boolean supportsStrict() | 返回 `supportsStrict` 结果。 Returns the supports strict. |
public void applyToolChoice(OpenAIRequest request, ToolChoice toolChoice) | 应用工具选项。 Performs the apply tool choice operation. |
构造器详情Constructor Detail
GLMFormatter
public GLMFormatter()
初始化 GLMFormatter 实例。
Creates a new instance.
源码Source
io/agentscope/extensions/model/openai/formatter/GLMFormatter.java:55–57方法详情Method Detail
doFormat
protected List<OpenAIMessage> doFormat(List<Msg> msgs)
执行格式操作。
Performs the do format operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。The msgs. |
List<OpenAIMessage>返回列出。Returns list.
源码Source
io/agentscope/extensions/model/openai/formatter/GLMFormatter.java:59–63supportsStrict
protected boolean supportsStrict()
返回 supportsStrict 结果。
Returns the supports strict.
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/extensions/model/openai/formatter/GLMFormatter.java:65–68applyToolChoice
public void applyToolChoice(OpenAIRequest request, ToolChoice toolChoice)
应用工具选项。
Performs the apply tool choice operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | OpenAIRequest | 请求(类型 `OpenAIRequest`)。The request. |
toolChoice | ToolChoice | 工具选项(类型 `ToolChoice`)。The tool choice. |
源码Source
io/agentscope/extensions/model/openai/formatter/GLMFormatter.java:70–73