mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 14:44:21 +01:00
feat: add temperature env var (#2083)
This commit is contained in:
@@ -83,6 +83,7 @@ serial_test = "3.2.0"
|
||||
mockall = "0.13.1"
|
||||
wiremock = "0.6.0"
|
||||
tokio = { version = "1.43", features = ["full"] }
|
||||
temp-env = "0.3.6"
|
||||
|
||||
[[example]]
|
||||
name = "agent"
|
||||
|
||||
@@ -44,11 +44,15 @@ impl ModelConfig {
|
||||
|
||||
let toolshim_model = std::env::var("GOOSE_TOOLSHIM_OLLAMA_MODEL").ok();
|
||||
|
||||
let temperature = std::env::var("GOOSE_TEMPERATURE")
|
||||
.ok()
|
||||
.and_then(|val| val.parse::<f32>().ok());
|
||||
|
||||
Self {
|
||||
model_name,
|
||||
tokenizer_name: tokenizer_name.to_string(),
|
||||
context_limit,
|
||||
temperature: None,
|
||||
temperature,
|
||||
max_tokens: None,
|
||||
toolshim,
|
||||
toolshim_model,
|
||||
@@ -182,4 +186,27 @@ mod tests {
|
||||
.with_toolshim_model(Some("mistral-nemo".to_string()));
|
||||
assert_eq!(config.toolshim_model, Some("mistral-nemo".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_model_config_temp_env_var() {
|
||||
use temp_env::with_var;
|
||||
|
||||
with_var("GOOSE_TEMPERATURE", Some("0.128"), || {
|
||||
let config = ModelConfig::new("test-model".to_string());
|
||||
assert_eq!(config.temperature, Some(0.128));
|
||||
});
|
||||
|
||||
with_var("GOOSE_TEMPERATURE", Some("notanum"), || {
|
||||
let config = ModelConfig::new("test-model".to_string());
|
||||
assert_eq!(config.temperature, None);
|
||||
});
|
||||
|
||||
with_var("GOOSE_TEMPERATURE", Some(""), || {
|
||||
let config = ModelConfig::new("test-model".to_string());
|
||||
assert_eq!(config.temperature, None);
|
||||
});
|
||||
|
||||
let config = ModelConfig::new("test-model".to_string());
|
||||
assert_eq!(config.temperature, None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user