Add fallback models when not configured
When no models are specified in agent config, use sensible defaults: - Chat/Default tasks: ollama/llama3 - Code/Planning/ToolUse: openai/gpt-4o This allows minimal configs without explicit model routing. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -76,9 +76,23 @@ impl Agent {
|
|||||||
|
|
||||||
/// Get the model for a specific task type
|
/// Get the model for a specific task type
|
||||||
fn get_model(&self, task_type: TaskType) -> Result<String> {
|
fn get_model(&self, task_type: TaskType) -> Result<String> {
|
||||||
self.config
|
// First try to get model from agent config
|
||||||
.get_model_for_task(task_type)
|
if let Some(model) = self.config.get_model_for_task(task_type) {
|
||||||
.ok_or_else(|| AgentError::ConfigError(format!("No model configured for {:?}", task_type)))
|
return Ok(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: use a reasonable default based on available providers
|
||||||
|
// Prefer ollama for local-first, then openai
|
||||||
|
match task_type {
|
||||||
|
TaskType::Code | TaskType::Planning | TaskType::ToolUse => {
|
||||||
|
// For complex tasks, try openai first
|
||||||
|
Ok("openai/gpt-4o".to_string())
|
||||||
|
}
|
||||||
|
TaskType::Chat | TaskType::Default => {
|
||||||
|
// For chat and default, use ollama
|
||||||
|
Ok("ollama/llama3".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get available tools as provider Tool definitions
|
/// Get available tools as provider Tool definitions
|
||||||
|
|||||||
Reference in New Issue
Block a user