Interface ModelConfig
- All Known Implementing Classes:
DashScopeModelConfig
public interface ModelConfig
Configuration interface for model settings in scheduled tasks.
This interface defines a contract for model configuration objects that encapsulate model-related settings. It provides a unified way to handle model configurations across different model providers.
Key Benefits:
- Serializable Configuration - Easier to persist and transmit model settings
- Decoupling - Configuration is separate from model implementation
- Type Safety - Strongly typed configuration objects
- Flexibility - Support for different model providers
Usage Example:
// Create model configuration
ModelConfig modelConfig = DashScopeModelConfig.builder()
.apiKey(apiKey)
.modelName("qwen-max")
.stream(true)
.build();
// Use in AgentConfig
AgentConfig agentConfig = AgentConfig.builder()
.name("MyAgent")
.modelConfig(modelConfig)
.build();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionio.agentscope.core.model.ModelCreate a Model instance from this configuration.Get the model name or identifier.
-
Method Details
-
getModelName
String getModelName()Get the model name or identifier.This is used for logging, identification, and routing purposes.
- Returns:
- The model name/identifier
-
createModel
io.agentscope.core.model.Model createModel()Create a Model instance from this configuration.This method converts the configuration into an actual Model object that can be used for agent execution. Each call may return a new instance or a cached instance depending on the implementation.
Usage Example:
ModelConfig modelConfig = DashScopeModelConfig.builder() .apiKey(apiKey) .modelName("qwen-max") .build(); // Create the actual model instance Model model = modelConfig.createModel();- Returns:
- A Model instance configured according to this configuration
- Throws:
IllegalStateException- if the model cannot be created
-