Skip to main content

llama_crab/
lib.rs

1//! `llama-crab` — safe, ergonomic Rust bindings to `llama.cpp`.
2//!
3//! ## Quickstart
4//!
5//! ```no_run
6//! use llama_crab::{Llama, LlamaParams};
7//!
8//! let mut llama = Llama::load(LlamaParams::new("model.gguf").with_n_ctx(2048))?;
9//! let resp = llama.create_completion("Hello, world!", 64)?;
10//! println!("{}", resp.text);
11//! # Ok::<(), Box<dyn std::error::Error>>(())
12//! ```
13
14#![doc(
15    html_logo_url = "https://raw.githubusercontent.com/DominguesM/llama-crab/main/docs/src/assets/logo.png"
16)]
17#![cfg_attr(docsrs, feature(doc_cfg))]
18#![allow(clippy::needless_doctest_main)]
19// A binding crate has a large public API surface; pedantic lints add
20// little value. The CI enforces *correctness* (compilation, tests,
21// docs) via `-D warnings` and the workspace's curated lint set, but we
22// don't promote every individual pedantic warning to an error.
23#![allow(
24    dead_code,
25    unused_imports,
26    clippy::all,
27    clippy::pedantic,
28    clippy::nursery,
29    clippy::cargo
30)]
31
32pub mod backend;
33pub mod batch;
34pub mod cache;
35pub mod chat;
36pub mod context;
37pub mod error;
38pub mod high_level;
39pub mod json_schema;
40pub mod log;
41pub mod logit_bias;
42pub mod model;
43pub mod sampling;
44pub mod speculative;
45pub mod token;
46pub mod token_data;
47pub mod util;
48
49#[cfg(feature = "mtmd")]
50#[cfg_attr(docsrs, doc(cfg(feature = "mtmd")))]
51pub mod multimodal;
52
53pub use crate::backend::{LlamaBackend, NumaStrategy};
54pub use crate::batch::{BatchAddError, LlamaBatch};
55pub use crate::chat::Role;
56pub use crate::context::{LlamaContext, LlamaContextParams};
57pub use crate::error::{LlamaError, Result};
58pub use crate::high_level::chat_completion::ChatMessage;
59pub use crate::high_level::completion::{Completion, StopReason};
60pub use crate::high_level::tokenizer::{FimTokens, LlamaTokenizer, Tokenizer};
61pub use crate::high_level::{Llama, LlamaParams};
62pub use crate::log::{send_logs_to_tracing, LogOptions};
63pub use crate::logit_bias::LlamaLogitBias;
64pub use crate::model::{params::LlamaModelParams, LlamaModel};
65pub use crate::sampling::{LlamaSampler, SamplerChain};
66pub use crate::token::LlamaToken;
67pub use crate::token_data::{LlamaTokenData, LlamaTokenDataArray};