Skip to content

AI Sheet Cache 🟑 BETA

The Sheet editor evaluates BOT_AI_PROMPT cells through the LLM path and stores the resulting answer in a bounded in-process cache.

Developer guide map

Architecture

botsheet-core registers BOT_AI_PROMPT in its formula dispatcher. The handler in botsheet/src/handlers/ai.rs exposes /api/sheet/ai/evaluate-prompt and /api/sheet/ai/batch-evaluate, uses call_llm, and hashes the prompt plus worksheet context to build the cache key.

Route Request Response
/api/sheet/ai/evaluate-prompt prompt, optional sheet_id, cell_ref, worksheet_index result, cached
/api/sheet/ai/batch-evaluate prompts, optional sheet_id results, cached_count, fresh_count

BOT_AI_PROMPT Formula

The formula is dispatched by name in botsheet-core/src/formulas/mod.rs. Its result is the model's answer as a cell value; a failing or unconfigured provider returns an explicit error, not a keyword-derived guess.

Cache Layer

Constant Value Meaning
MAX_BATCH_SIZE 100 Upper bound for one batch request.
MAX_CONCURRENT_LLM 10 Concurrent model calls in a batch.

The cache is guarded by a mutex and semaphore; entries are keyed by a SHA-256 digest of prompt and context.

UI Integration

The Sheet app (see Sheet - Spreadsheets) renders a loading state (...) while AI formulas are being evaluated, then swaps the cell content via HTMX when the result is ready.

Limits

  • An unconfigured or failing provider returns 503 ai_unavailable; there is no offline fallback answer.
  • The cache is in-process, so it does not survive a server restart and is not shared between instances.
  • Batches are capped at 100 prompts and 10 concurrent LLM calls.

See Also