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
//! `cliai` is a small Rust library for invoking AI tools through local CLI backends.
//!
//! It exposes a minimal trait-based interface so applications can work with
//! different AI backends without coupling to a provider SDK or HTTP client.
//!
//! # Included backends
//!
//! - [`Ollama`] for local models via the `ollama` CLI
//! - [`Copilot`] for GitHub Copilot CLI via the `copilot` binary
//!
//! # Design
//!
//! This crate shells out to installed executables. That keeps the dependency
//! surface small, but it also means:
//!
//! - the backend binary must be installed and available on `PATH`, unless
//! overridden with `with_bin()`
//! - prompts are passed to external processes
//! - runtime behavior depends on the installed CLI tool
//!
//! # Example
//!
//! ```no_run
//! use cliai::{AiBackend, GenerateRequest, Ollama};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let ai = Ollama::new("llama3.2");
//! let response = ai.generate(
//! &GenerateRequest::new("Write a haiku about Rust.")
//! .with_instructions("Be concise."),
//! )?;
//!
//! println!("{}", response.text);
//! Ok(())
//! }
//! ```
pub use ;
pub use AiError;
pub use GenerateRequest;
pub use GenerateResponse;
/// Common interface implemented by supported AI backends.
///
/// Backends are expected to invoke an external CLI tool and return the generated
/// text as a [`GenerateResponse`].