refactor: unified LLM config - CHAT_URL/VISION_URL/SUMMARY_URL with env var overrides
This commit is contained in:
+43
-2
@@ -216,13 +216,47 @@ pub mod cache {
|
||||
pub mod llm {
|
||||
use super::*;
|
||||
|
||||
/// Chat / function-calling LLM endpoint (agents/search, translation, etc.)
|
||||
/// Default: http://127.0.0.1:8082/v1/chat/completions
|
||||
pub static CHAT_URL: Lazy<String> = Lazy::new(|| {
|
||||
env::var("MOMENTRY_LLM_CHAT_URL")
|
||||
.or_else(|_| env::var("MOMENTRY_LLM_SUMMARY_URL"))
|
||||
.or_else(|_| env::var("MOMENTRY_LLM_URL"))
|
||||
.unwrap_or_else(|_| "http://127.0.0.1:8082/v1/chat/completions".to_string())
|
||||
});
|
||||
|
||||
pub static CHAT_MODEL: Lazy<String> = Lazy::new(|| {
|
||||
env::var("MOMENTRY_LLM_CHAT_MODEL")
|
||||
.or_else(|_| env::var("MOMENTRY_LLM_SUMMARY_MODEL"))
|
||||
.or_else(|_| env::var("MOMENTRY_LLM_MODEL"))
|
||||
.unwrap_or_else(|_| "google_gemma-4-26B-A4B-it-Q5_K_M.gguf".to_string())
|
||||
});
|
||||
|
||||
/// Vision LLM endpoint (frame analysis, OCR). Can be same as CHAT_URL or different.
|
||||
/// Default: falls back to CHAT_URL
|
||||
pub static VISION_URL: Lazy<String> = Lazy::new(|| {
|
||||
env::var("MOMENTRY_LLM_VISION_URL")
|
||||
.unwrap_or_else(|_| CHAT_URL.clone())
|
||||
});
|
||||
|
||||
pub static VISION_MODEL: Lazy<String> = Lazy::new(|| {
|
||||
env::var("MOMENTRY_LLM_VISION_MODEL")
|
||||
.unwrap_or_else(|_| CHAT_MODEL.clone())
|
||||
});
|
||||
|
||||
/// Text summary LLM endpoint (5W1H, story). Can be same as CHAT_URL or different.
|
||||
pub static SUMMARY_URL: Lazy<String> = Lazy::new(|| {
|
||||
env::var("MOMENTRY_LLM_SUMMARY_URL")
|
||||
.unwrap_or_else(|_| "http://127.0.0.1:8081/v1/chat/completions".to_string())
|
||||
.ok()
|
||||
.or_else(|| Some(CHAT_URL.clone()))
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
pub static SUMMARY_MODEL: Lazy<String> = Lazy::new(|| {
|
||||
env::var("MOMENTRY_LLM_SUMMARY_MODEL").unwrap_or_else(|_| "gemma4".to_string())
|
||||
env::var("MOMENTRY_LLM_SUMMARY_MODEL")
|
||||
.ok()
|
||||
.or_else(|| Some(CHAT_MODEL.clone()))
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
pub static SUMMARY_TIMEOUT_SECS: Lazy<u64> = Lazy::new(|| {
|
||||
@@ -237,6 +271,13 @@ pub mod llm {
|
||||
.map(|v| v == "true" || v == "1")
|
||||
.unwrap_or(true)
|
||||
});
|
||||
|
||||
pub static CHAT_TIMEOUT_SECS: Lazy<u64> = Lazy::new(|| {
|
||||
env::var("MOMENTRY_LLM_CHAT_TIMEOUT")
|
||||
.unwrap_or_else(|_| "120".to_string())
|
||||
.parse()
|
||||
.unwrap_or(120)
|
||||
});
|
||||
}
|
||||
|
||||
pub static SFTPGO_BASE_URL: Lazy<String> = Lazy::new(|| {
|
||||
|
||||
Reference in New Issue
Block a user