mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-20 15:44:25 +01:00
feat: add temperature env var (#2083)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2361,6 +2361,7 @@ dependencies = [
|
|||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"serial_test",
|
"serial_test",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"temp-env",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"tokenizers",
|
"tokenizers",
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ serial_test = "3.2.0"
|
|||||||
mockall = "0.13.1"
|
mockall = "0.13.1"
|
||||||
wiremock = "0.6.0"
|
wiremock = "0.6.0"
|
||||||
tokio = { version = "1.43", features = ["full"] }
|
tokio = { version = "1.43", features = ["full"] }
|
||||||
|
temp-env = "0.3.6"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "agent"
|
name = "agent"
|
||||||
|
|||||||
@@ -44,11 +44,15 @@ impl ModelConfig {
|
|||||||
|
|
||||||
let toolshim_model = std::env::var("GOOSE_TOOLSHIM_OLLAMA_MODEL").ok();
|
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 {
|
Self {
|
||||||
model_name,
|
model_name,
|
||||||
tokenizer_name: tokenizer_name.to_string(),
|
tokenizer_name: tokenizer_name.to_string(),
|
||||||
context_limit,
|
context_limit,
|
||||||
temperature: None,
|
temperature,
|
||||||
max_tokens: None,
|
max_tokens: None,
|
||||||
toolshim,
|
toolshim,
|
||||||
toolshim_model,
|
toolshim_model,
|
||||||
@@ -182,4 +186,27 @@ mod tests {
|
|||||||
.with_toolshim_model(Some("mistral-nemo".to_string()));
|
.with_toolshim_model(Some("mistral-nemo".to_string()));
|
||||||
assert_eq!(config.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