mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 22:54:24 +01:00
Goose recipes have settings now (#2397)
Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Lifei Zhou <lifei@squareup.com>
This commit is contained in:
@@ -34,6 +34,8 @@ pub struct SessionBuilderConfig {
|
||||
pub extensions_override: Option<Vec<ExtensionConfig>>,
|
||||
/// Any additional system prompt to append to the default
|
||||
pub additional_system_prompt: Option<String>,
|
||||
/// Settings to override the global Goose settings
|
||||
pub settings: Option<SessionSettings>,
|
||||
/// Enable debug printing
|
||||
pub debug: bool,
|
||||
/// Maximum number of consecutive identical tool calls allowed
|
||||
@@ -136,18 +138,35 @@ async fn offer_extension_debugging_help(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct SessionSettings {
|
||||
pub goose_model: Option<String>,
|
||||
pub goose_provider: Option<String>,
|
||||
pub temperature: Option<f32>,
|
||||
}
|
||||
|
||||
pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
|
||||
// Load config and get provider/model
|
||||
let config = Config::global();
|
||||
|
||||
let provider_name: String = config
|
||||
.get_param("GOOSE_PROVIDER")
|
||||
let provider_name = session_config
|
||||
.settings
|
||||
.as_ref()
|
||||
.and_then(|s| s.goose_provider.clone())
|
||||
.or_else(|| config.get_param("GOOSE_PROVIDER").ok())
|
||||
.expect("No provider configured. Run 'goose configure' first");
|
||||
|
||||
let model: String = config
|
||||
.get_param("GOOSE_MODEL")
|
||||
let model_name = session_config
|
||||
.settings
|
||||
.as_ref()
|
||||
.and_then(|s| s.goose_model.clone())
|
||||
.or_else(|| config.get_param("GOOSE_MODEL").ok())
|
||||
.expect("No model configured. Run 'goose configure' first");
|
||||
let model_config = goose::model::ModelConfig::new(model.clone());
|
||||
|
||||
let temperature = session_config.settings.as_ref().and_then(|s| s.temperature);
|
||||
|
||||
let model_config =
|
||||
goose::model::ModelConfig::new(model_name.clone()).with_temperature(temperature);
|
||||
|
||||
// Create the agent
|
||||
let agent: Agent = Agent::new();
|
||||
@@ -165,7 +184,7 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
|
||||
worker_model
|
||||
);
|
||||
} else {
|
||||
tracing::info!("🤖 Using model: {}", model);
|
||||
tracing::info!("🤖 Using model: {}", model_name);
|
||||
}
|
||||
|
||||
agent
|
||||
@@ -430,7 +449,7 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
|
||||
output::display_session_info(
|
||||
session_config.resume,
|
||||
&provider_name,
|
||||
&model,
|
||||
&model_name,
|
||||
&session_file,
|
||||
Some(&provider_for_display),
|
||||
);
|
||||
@@ -452,6 +471,7 @@ mod tests {
|
||||
builtins: vec!["developer".to_string()],
|
||||
extensions_override: None,
|
||||
additional_system_prompt: Some("Test prompt".to_string()),
|
||||
settings: None,
|
||||
debug: true,
|
||||
max_tool_repetitions: Some(5),
|
||||
interactive: true,
|
||||
|
||||
Reference in New Issue
Block a user