ModelProvider
public interface ModelProvider
源码Source
io/agentscope/core/model/spi/ModelProvider.java:22–45定义模型提供者契约的接口。位于 io.agentscope.core.model.spi 包。核心成员包括 providerId、supports、create。
Service Provider Interface for model adapters discovered from extension modules.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String providerId() | 返回提供者标识。 Provider identifier, for example `openai`. |
public boolean supports(String modelId) | 设置支持。 Returns whether this provider can create a model for the full model id,
for example `openai:gpt-4o`. |
default public boolean supports(String modelId, ModelCreationContext context)default | 执行支持相关操作。 Returns whether this provider can create a model for the full model id and context. |
public Model create(String modelId) | 创建并返回实例。 Creates a model for the full model id. |
default public Model create(String modelId, ModelCreationContext context)default | 创建并返回实例。 Creates a model for the full model id using a provider-neutral context. |
方法详情Method Detail
providerId
public String providerId()
返回提供者标识。
Provider identifier, for example openai.
String返回字符串结果。Returns a string.
源码Source
io/agentscope/core/model/spi/ModelProvider.java:25supports
public boolean supports(String modelId)
设置支持。
Returns whether this provider can create a model for the full model id, for example openai:gpt-4o.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/core/model/spi/ModelProvider.java:31supports
default public boolean supports(String modelId, ModelCreationContext context)
default
执行支持相关操作。
Returns whether this provider can create a model for the full model id and context.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
context | ModelCreationContext | 上下文(类型 `ModelCreationContext`)。The context. |
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/core/model/spi/ModelProvider.java:34–36create
public Model create(String modelId)
创建并返回实例。
Creates a model for the full model id.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
Model返回模型。Returns model.
源码Source
io/agentscope/core/model/spi/ModelProvider.java:39create
default public Model create(String modelId, ModelCreationContext context)
default
创建并返回实例。
Creates a model for the full model id using a provider-neutral context.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
context | ModelCreationContext | 上下文(类型 `ModelCreationContext`)。The context. |
Model返回模型。Returns model.
源码Source
io/agentscope/core/model/spi/ModelProvider.java:42–44