Skip to main content

forgetless/
lib.rs

1//! # Forgetless
2//!
3//! Context optimization for LLMs.
4//! Takes massive context, outputs optimized version that fits your token budget.
5//!
6//! ## Quick Start
7//!
8//! ```rust,ignore
9//! use forgetless::Forgetless;
10//!
11//! let result = Forgetless::new(128_000)
12//!     .add("system prompt + conversation + everything...")
13//!     .add_file("document.pdf")
14//!     .add_files(&["code.rs", "data.json"])
15//!     .run()
16//!     .await?;
17//!
18//! // Send to your LLM
19//! let response = your_llm.chat(&result.content).await?;
20//! ```
21
22#![warn(missing_docs)]
23#![warn(clippy::all)]
24
25// Internal modules (organized by feature)
26pub mod ai;
27pub mod builder;
28pub mod core;
29pub mod input;
30pub mod processing;
31
32// Re-exports for backward compatibility and convenience
33
34// Core types
35pub use core::config::{Config, ForgetlessConfig, ScoringConfig};
36pub use core::error::{Error, Result};
37pub use core::types::{
38    OptimizationStats, OptimizedContext, PolishedContext, ScoreBreakdown, ScoredChunk,
39};
40
41// Builder
42pub use builder::Forgetless;
43
44// Input
45pub use input::content::{
46    ContentInput, FileWithPriority, IntoContent, IntoFileContent, WithPriority,
47};
48pub use input::file::read_file_content;
49
50// Processing
51pub use processing::chunking::{Chunk, ChunkConfig, Chunker, ContentType};
52pub use processing::scoring::Priority;
53pub use processing::token::{TokenCounter, TokenizerModel};
54
55// AI
56pub use ai::embeddings::{cosine_similarity, embed_batch, embed_text, EmbeddingCache};
57pub use ai::llm::{LLMConfig, Quantization, LLM};
58pub use ai::vision::{describe_image, describe_image_with_prompt, init_vision, is_vision_ready};
59
60/// Library version
61pub const VERSION: &str = env!("CARGO_PKG_VERSION");