From 4cedea9fdb2e02173bc7a21738c1c721ce540885 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 22 Apr 2025 16:46:28 -0700 Subject: [PATCH] dave: more flexible env config With this I was able to get openrouter working: DAVE_API_KEY=$OPENROUTER_API_KEY DAVE_ENDPOINT=https://openrouter.ai/api/v1 DAVE_MODEL="google/gemini-2.0-flash-001" RUST_LOG=async_openai=debug,notedeck_dave=debug ./target/release/notedeck --- crates/notedeck_dave/src/config.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/notedeck_dave/src/config.rs b/crates/notedeck_dave/src/config.rs index abc9423d..d466c89e 100644 --- a/crates/notedeck_dave/src/config.rs +++ b/crates/notedeck_dave/src/config.rs @@ -10,9 +10,13 @@ pub struct ModelConfig { impl Default for ModelConfig { fn default() -> Self { ModelConfig { - endpoint: None, - model: "gpt-4o".to_string(), - api_key: std::env::var("OPENAI_API_KEY").ok(), + endpoint: std::env::var("DAVE_ENDPOINT").ok(), + model: std::env::var("DAVE_MODEL") + .ok() + .unwrap_or("gpt-4o".to_string()), + api_key: std::env::var("DAVE_API_KEY") + .ok() + .or(std::env::var("OPENAI_API_KEY").ok()), } } }