Skip to main content

classify

Function classify 

Source
pub async fn classify(
    text: &str,
    config: &Arc<BotConfig>,
    cache: &PageCache,
    http: &Client,
) -> (Intent, bool)
Expand description

Classify a free-form message into an intent.

Order of operations:

  1. URL in message (fanfiction host) → Metadata/Download/Bookmark immediately (no LLM needed, deterministic).
  2. Cache hit → return cached intent.
  3. LLM enabled → POST /api/generate (Ollama, format json) with timeout; validate against whitelist.
  4. LLM disabled or failure → keyword heuristics, then natural-language /ask fallback handled by the caller.

Returns (Intent, cached: bool).