GLMModelProvider
public final class GLMModelProvider implements ModelProvider
io/agentscope/extensions/model/openai/compat/glm/GLMModelProvider.java:58–132GLM 模型提供者,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.openai.compat.glm 包,实现 ModelProvider。核心成员包括 providerId、supports、create。
Zhipu AI (Z.ai) GLM provider registered through java.util.ServiceLoader.
GLM exposes an OpenAI-compatible Chat Completions endpoint, so this provider creates
OpenAIChatModel instances preconfigured for GLM:
-
Base URL defaults to
https://open.bigmodel.cn/api/paas/v4 -
Formatter defaults to
GLMFormatter(a customFormattercomponent in theModelCreationContexttakes precedence, e.g.GLMMultiAgentFormatter) -
Native structured output defaults to disabled, because the GLM
response_formatonly supportsjson_object(notjson_schema); the agent falls back to thegenerate_responsetool instead
The API key is taken from ModelCreationContext#getApiKey(), then from the
GLM_API_KEY environment variable, then from ZHIPUAI_API_KEY.
Usage:
`ReActAgent agent = ReActAgent.builder()
.name("assistant")
.model("glm:glm-5.2") // resolved by ModelRegistry through this provider
.build();
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String providerId() | 返回提供者标识。 Returns the provider id. |
public boolean supports(String modelId) | 设置支持。 Performs the supports operation. |
public Model create(String modelId) | 创建并返回实例。 Creates and returns an instance. |
public Model create(String modelId, ModelCreationContext context) | 创建并返回实例。 Creates and returns an instance. |
方法详情Method Detail
providerId
public String providerId()
返回提供者标识。
Returns the provider id.
Stringio/agentscope/extensions/model/openai/compat/glm/GLMModelProvider.java:64–67supports
public boolean supports(String modelId)
设置支持。
Performs the supports operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
booleanio/agentscope/extensions/model/openai/compat/glm/GLMModelProvider.java:69–72create
public Model create(String modelId)
创建并返回实例。
Creates and returns an instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
Modelio/agentscope/extensions/model/openai/compat/glm/GLMModelProvider.java:74–77create
public Model create(String modelId, ModelCreationContext context)
创建并返回实例。
Creates and returns an instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
context | ModelCreationContext | 上下文(类型 `ModelCreationContext`)。The context. |
Modelio/agentscope/extensions/model/openai/compat/glm/GLMModelProvider.java:79–111