1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! # ollama-vision
//!
//! Robust Ollama vision model toolkit for image tagging and captioning.
//!
//! ## Features
//!
//! - **Image tagging** with a 7-strategy response parser that handles every
//! common LLM output format (JSON arrays, code blocks, `<think>` tags,
//! JSON objects, numbered lists, comma-separated text)
//! - **Image captioning** with automatic `<think>` block stripping
//! - **Works with any Ollama vision model** (llava, minicpm-v, llama3.2-vision, etc.)
//! - **Base64 API** for in-memory images (no file I/O required)
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use ollama_vision::{OllamaVisionConfig, TagOptions, CaptionOptions};
//! use std::path::Path;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = OllamaVisionConfig::with_model("llava");
//! let client = reqwest::Client::new();
//!
//! // Tag an image
//! let tags = ollama_vision::tag_image(
//! &client, &config,
//! Path::new("photo.jpg"),
//! &TagOptions::default(),
//! ).await?;
//! println!("Tags: {:?}", tags);
//!
//! // Caption an image
//! let caption = ollama_vision::caption_image(
//! &client, &config,
//! Path::new("photo.jpg"),
//! &CaptionOptions::default(),
//! ).await?;
//! println!("Caption: {}", caption);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Parsing Robustness
//!
//! The tag parser handles all common LLM response formats:
//!
//! ```rust
//! use ollama_vision::parse_tags;
//!
//! // Pure JSON array
//! assert!(parse_tags(r#"["portrait", "fantasy"]"#).is_ok());
//!
//! // With <think> blocks from reasoning models
//! assert!(parse_tags(r#"<think>analyzing...</think>["portrait"]"#).is_ok());
//!
//! // Markdown code blocks
//! assert!(parse_tags("```json\n[\"portrait\"]\n```").is_ok());
//!
//! // JSON objects with "tags" key
//! assert!(parse_tags(r#"{"tags": ["portrait"]}"#).is_ok());
//!
//! // Comma-separated fallback
//! assert!(parse_tags("portrait, fantasy, dark").is_ok());
//! ```
// Re-export main types at crate root
pub use ;
pub use ;
pub use ;
pub use ;