diff options
Diffstat (limited to '')
| -rw-r--r-- | src/commands/ai.rs | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/commands/ai.rs b/src/commands/ai.rs index a75f164..5ab077e 100644 --- a/src/commands/ai.rs +++ b/src/commands/ai.rs | |||
| @@ -4,7 +4,7 @@ use crate::lang; | |||
| 4 | 4 | ||
| 5 | type Context<'a> = poise::Context<'a, Data, Error>; | 5 | type Context<'a> = poise::Context<'a, Data, Error>; |
| 6 | 6 | ||
| 7 | /// Query the AI senator via OpenRouter | 7 | /// Query the AI senator via OpenRouter or local LLM |
| 8 | #[poise::command(slash_command)] | 8 | #[poise::command(slash_command)] |
| 9 | pub async fn senator( | 9 | pub async fn senator( |
| 10 | ctx: Context<'_>, | 10 | ctx: Context<'_>, |
| @@ -13,20 +13,8 @@ pub async fn senator( | |||
| 13 | ) -> crate::error::Result<()> { | 13 | ) -> crate::error::Result<()> { |
| 14 | ctx.defer().await?; | 14 | ctx.defer().await?; |
| 15 | 15 | ||
| 16 | let api_key = ctx | 16 | let (api_url, api_key, model) = ctx.data().config.resolve_llm(); |
| 17 | .data() | 17 | let client = crate::openrouter::OpenRouterClient::new(api_url, api_key, model); |
| 18 | .config | ||
| 19 | .openrouter_api_key | ||
| 20 | .as_ref() | ||
| 21 | .ok_or_else(|| Error::Custom(lang::L_OPENROUTER_NO_KEY.into()))?; | ||
| 22 | let model = ctx | ||
| 23 | .data() | ||
| 24 | .config | ||
| 25 | .openrouter_model | ||
| 26 | .as_deref() | ||
| 27 | .unwrap_or("cognitivecomputations/dolphin-mistral-24b-venice-edition:free"); | ||
| 28 | |||
| 29 | let client = crate::openrouter::OpenRouterClient::new(api_key.clone(), model.to_string()); | ||
| 30 | let response = client.chat(lang::SENATOR_SYSTEM_PROMPT, &text).await?; | 18 | let response = client.chat(lang::SENATOR_SYSTEM_PROMPT, &text).await?; |
| 31 | 19 | ||
| 32 | if tts_vc.unwrap_or(false) { | 20 | if tts_vc.unwrap_or(false) { |
