Skip to main content

Module attachment_api

Module attachment_api 

Source
Expand description

Pre-extraction endpoint for file attachments.

POST /attachments/preprocess fires background extraction tasks the moment a user attaches a file — so by the time they hit Send the content is already cached and injection is zero-overhead.

Hardware-adaptive concurrency:

  • Plain-text formats (code, JSON, CSV, Markdown, …) bypass the semaphore — they are just an fs::read + UTF-8 decode, essentially free.
  • Binary formats (PDF, DOCX, XLSX, PPTX, …) acquire a semaphore permit first. The semaphore is sized to num_cpus / 2 (min 1, max 8) so the LLM server is never starved of CPU/RAM on low-spec hardware.

Structs§

PreprocessRequest
PreprocessResponse

Constants§

CACHE_TTL_SECS
TTL for cached pre-extracted entries (30 minutes). The background eviction task checks every 5 minutes.

Functions§

attachment_cache_key
Build a stable, unique cache key for an attachment.
preprocess_attachments
POST /attachments/preprocess