Skip to main content

qwen3_vl/
lib.rs

1//! Qwen3-VL structured-output engine for findit-studio.
2//!
3//! Imported as `qwen3_vl` (the package name is `qwen3-vl` on
4//! crates.io; Cargo derives the lib name by replacing hyphens
5//! with underscores).
6//!
7//! Standalone crate with no `findit-proto` dependency: the
8//! image-analysis preset produces a typed
9//! [`image_analysis::ImageAnalysis`] (re-exported from the
10//! `llmtask` sibling crate, which hosts the canonical shared
11//! type), whose shape mirrors `findit-proto::database::SceneVlmResult`
12//! so a downstream consumer can map field-by-field without
13//! re-running inference.
14//!
15//! The crate has two layers:
16//!
17//! - [`Engine`] + [`Task`] — a generic Qwen3-VL constrained-JSON inference
18//!   engine. Wraps `mistralrs 0.8`; backend selection (metal / cuda /
19//!   …) is up to the consumer (see the README). Async-only; callers
20//!   wrap returned `Future`s with `tokio::time::timeout(..)` or
21//!   `tokio::select!` for shutdown observation.
22//! - [`image_analysis`] — the only preset that ships today. Owns the
23//!   prompt, the constrained-JSON schema, the resilient parser, and
24//!   the [`image_analysis::ImageAnalysis`] output type. Detection-array
25//!   fields (`subjects`, `objects`, etc.) are flat `Vec<SmolStr>`; see
26//!   the `image_analysis` module doc and `CHANGELOG.md` for
27//!   the rationale on dropping the previous
28//!   `Detection { label, confidence }` wrapper.
29//!
30//! Cancellation contract: dropping the future returned by [`Engine::run`]
31//! is a fast wakeup, **not** GPU cancellation. mistralrs's engine loop
32//! runs the in-flight scheduler step to completion in the background; the
33//! response is silently discarded on send. Use `tokio::time::timeout(..)`
34//! for a deadline.
35
36#![deny(missing_docs)]
37
38pub mod engine;
39pub mod error;
40pub mod image_analysis;
41
42pub use crate::{
43  engine::{Engine, EngineOptions, RequestOptions},
44  error::{Error, LoadError},
45  image_analysis::ImageAnalysisTask,
46};
47pub use llmtask::{ImageAnalysis, JsonParseError, Task};
48
49/// Re-exported from the [`image`] crate for caller convenience —
50/// [`Engine::run`] consumes `Vec<DynamicImage>`.
51pub use image::DynamicImage;