Inputs and Priorities
The crate splits inputs into eager text records and lazy file records. Priority influences which chunks survive when the token budget tightens.
Content inputs#
use forgetless::{FileWithPriority, Forgetless, Priority, WithPriority};
let png = std::fs::read("diagram.png")?;
let result = Forgetless::new()
.add("plain medium-priority text")
.add(WithPriority::high("recent discussion"))
.add_pinned("system instructions")
.add_file("notes.md")
.add_file(FileWithPriority::critical("architecture.pdf"))
.add_bytes(&png, "image/png")
.add_bytes_p(&png, "image/png", Priority::High)
.run()
.await?;Priority helpers#
| Helper | Priority | Where it lives |
|---|---|---|
| WithPriority::critical | Critical | Text content wrapper for .add(). |
| WithPriority::high | High | Text content wrapper for .add(). |
| WithPriority::medium | Medium | Explicit default if you want to be verbose. |
| WithPriority::low | Low | Background context with weaker retention. |
| FileWithPriority::critical | Critical | Lazy file wrapper for .add_file(). |
| FileWithPriority::high | High | Lazy file wrapper for .add_file(). |
| FileWithPriority::medium | Medium | Explicit medium file priority. |
| FileWithPriority::low | Low | Lazy file wrapper for lower-value file context. |
Lazy files#
Forgetless stores file paths first and delays real reads until run(). That matters because the builder can preview and filter paths before paying the cost of parsing every PDF, image, or source tree.
| Behavior | Implementation detail |
|---|---|
| Default priority | Plain path inputs become LazyFile with Priority::Medium. |
| Accepted path forms | &str, String, PathBuf, &Path, and FileWithPriority<P>. |
| Preview phase | When a query exists and more than five lazy files were registered, previews are used to shortlist files. |
| Read phase | Only shortlisted files are converted into ContentInput and chunked. |
Related#
Pipeline
See how the Forgetless context optimization pipeline runs: preview filtering, parallel file reads, chunking, relevance scoring, and budget-based selection.
Chunking
Configure content-aware chunking for LLMs: pick presets by content type and tune deduplication, overlap, and target token size for accurate ranking.
Introduction
Learn how Forgetless, a Rust LLM context optimizer, ranks and compresses oversized prompts and files into budget-aware context for production workflows.