langchainrust 0.7.0

A LangChain-inspired framework for building LLM applications in Rust. Supports OpenAI, Agents, Tools, Memory, Chains, RAG, BM25, Hybrid Retrieval, LangGraph, HyDE, Reranking, MultiQuery, and native Function Calling.
// src/memory/context_window/mod.rs
//! Context Window for long context management.
//!
//! Manages conversation context by fitting messages within a token limit,
//! using either truncation or LLM-based summarization strategies.
//!
//! # Core Concepts
//!
//! - **ContextWindow**: Fits messages within a max token budget.
//! - **Strategy::Truncate**: Drops oldest messages, preserving system messages.
//! - **Strategy::Summarize**: Uses an LLM to compress old messages into a summary.
//!
//! # Example
//!
//! ```ignore
//! use langchainrust::{ContextWindow, Strategy, TiktokenCounter};
//!
//! // Truncation strategy
//! let cw = ContextWindow::new(4096);
//! let fitted = cw.fit(messages).await?;
//!
//! // Summarization strategy
//! let cw = ContextWindow::with_strategy(4096, Strategy::Summarize::new(llm));
//! let fitted = cw.fit(messages).await?;
//! ```

pub mod manager;
pub mod trimmer;

pub use manager::ContextWindow;
pub use trimmer::Strategy;

#[cfg(test)]
mod tests;