MCPcopy Create free account
hub / github.com/AI45Lab/Code / detect_with_llm

Method detect_with_llm

core/src/prompts.rs:362–384  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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// ============================================================================

Callers

nothing calls this directly

Calls 4

contextMethod · 0.80
completeMethod · 0.45
textMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected