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.
Written byBerke (pzzaworks)
Content inputs
1use forgetless::{FileWithPriority, Forgetless, Priority, WithPriority};23let png = std::fs::read("diagram.png")?;45let result = Forgetless::new()6 .add("plain medium-priority text")7 .add(WithPriority::high("recent discussion"))8 .add_pinned("system instructions")9 .add_file("notes.md")10 .add_file(FileWithPriority::critical("architecture.pdf"))11 .add_bytes(&png, "image/png")12 .add_bytes_p(&png, "image/png", Priority::High)13 .run()14 .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. |