feat: load provider/model specified inside the recipe config (#6884)
Signed-off-by: Abhijay007 <Abhijay007j@gmail.com> Co-authored-by: Zane Staggs <zane@squareup.com>
This commit is contained in:
@@ -254,18 +254,27 @@ async fn start_agent(
|
||||
}
|
||||
|
||||
if let Some(recipe) = original_recipe {
|
||||
manager
|
||||
.update(&session.id)
|
||||
.recipe(Some(recipe))
|
||||
.apply()
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Failed to update session with recipe: {}", err);
|
||||
ErrorResponse {
|
||||
message: format!("Failed to update session with recipe: {}", err),
|
||||
status: StatusCode::INTERNAL_SERVER_ERROR,
|
||||
let mut update = manager.update(&session.id).recipe(Some(recipe.clone()));
|
||||
|
||||
if let Some(ref settings) = recipe.settings {
|
||||
if let Some(ref provider) = settings.goose_provider {
|
||||
update = update.provider_name(provider);
|
||||
|
||||
if let Some(ref model) = settings.goose_model {
|
||||
if let Ok(model_config) = ModelConfig::new(model) {
|
||||
update = update.model_config(model_config);
|
||||
}
|
||||
}
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
||||
update.apply().await.map_err(|err| {
|
||||
error!("Failed to update session with recipe: {}", err);
|
||||
ErrorResponse {
|
||||
message: format!("Failed to update session with recipe: {}", err),
|
||||
status: StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
})?;
|
||||
}
|
||||
|
||||
// Refetch session to get all updates
|
||||
|
||||
@@ -1577,7 +1577,8 @@ impl Agent {
|
||||
None => {
|
||||
let model_name = config
|
||||
.get_goose_model()
|
||||
.map_err(|_| anyhow!("Could not configure agent: missing model"))?;
|
||||
.ok()
|
||||
.ok_or_else(|| anyhow!("Could not configure agent: missing model"))?;
|
||||
crate::model::ModelConfig::new(&model_name)
|
||||
.map_err(|e| anyhow!("Could not configure agent: invalid model {}", e))?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user