Expand description
Auto-detect available solver backends and configure the chain.
Production captchaforge ergonomics: a developer should be able to
cargo add captchaforge && captchaforge::auto_solve(page).await and
have it Just Work — no manual VLM endpoint configuration, no STT
server URLs, no tesseract path hunting. This module does the
probing and surfaces the result as Capabilities.
§What gets probed
- Ollama — HTTP probe
localhost:11434/api/tags. If reachable, the response lists locally-pulled models. We pick the first model whose name matches a known vision-model pattern (llama3.2-vision,llava,bakllava,qwen2-vl,qwen3-vl,gemma3-vl,pixtral,minicpm-v). - Whisper CLI —
which whisperon PATH. The OpenAI Whisper reference CLI;whisper <audio.mp3> --model tinyreturns a transcript on stdout. - Tesseract —
which tesseracton PATH. Used for canvas / SVG / static-text CAPTCHAs. - OpenAI —
OPENAI_API_KEYenv var. If set, OpenAI Whisper API is available as STT fallback.
§Auto-install
Capabilities::ensure_vlm_model will ollama pull a default
vision model if Ollama is present but no vision model is. Disabled
by default; opt in with [Config::auto_install_backends].
§Example
let caps = captchaforge::backends::probe().await;
if caps.vlm.is_some() {
println!("VLM ready: {}", caps.vlm.as_ref().unwrap().model);
}Structs§
- Capabilities
- Detected backend capabilities. Populated by
probe; consumed bycrate::config::Config::build_chainto wire solvers conditionally. - OcrBackend
- SttBackend
- VlmBackend
Enums§
Constants§
- DEFAULT_
VLM_ AUTO_ PULL - Default vision model to auto-pull when Ollama is present but no vision model is. Picked for size/quality tradeoff: ~7GB, runs on most consumer GPUs and decent CPUs.
- DEFAULT_
WHISPER_ MODEL - Default Whisper model size to use when invoking the local CLI.
- VISION_
MODEL_ PATTERNS - Set of vendor model-name fragments that identify a vision-capable Ollama model. Order matters: earlier entries are preferred when multiple match.
Functions§
- pick_
best_ vision_ model - Pure helper: pick the best vision model from a list of Ollama
model names by matching against
VISION_MODEL_PATTERNSin priority order. - probe
- Probe the local environment for available backends. Cheap (~50ms total) — three parallel HTTP/PATH checks.
- which
- Locate a binary on PATH. Returns the absolute path on hit,
Noneon miss. Pure helper used by bothprobe_sttandprobe_ocr.