Classifies user intent using LLM when keyword confidence is low. This helper is available to callers that want explicit one-shot intent classification outside the main pre-analysis path. Uses a lightweight classification prompt that returns a single word.
(llm: &dyn LlmClient, message: &str)
| 360 | /// |
| 361 | /// Uses a lightweight classification prompt that returns a single word. |
| 362 | pub async fn detect_with_llm(llm: &dyn LlmClient, message: &str) -> anyhow::Result<Self> { |
| 363 | use crate::llm::Message; |
| 364 | |
| 365 | let system = INTENT_CLASSIFY_SYSTEM; |
| 366 | let messages = vec![Message::user(message)]; |
| 367 | |
| 368 | let response = llm |
| 369 | .complete(&messages, Some(system), &[]) |
| 370 | .await |
| 371 | .context("LLM intent classification failed")?; |
| 372 | |
| 373 | let text = response.text().trim().to_lowercase(); |
| 374 | |
| 375 | let style = match text.as_str() { |
| 376 | "plan" => AgentStyle::Plan, |
| 377 | "explore" => AgentStyle::Explore, |
| 378 | "verification" => AgentStyle::Verification, |
| 379 | "codereview" | "code review" => AgentStyle::CodeReview, |
| 380 | _ => AgentStyle::GeneralPurpose, |
| 381 | }; |
| 382 | |
| 383 | Ok(style) |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | // ============================================================================ |