verbose live UI + tool-level SSE events + Groq default + regression tests

This commit is contained in:
2026-06-03 05:04:29 -03:00
parent 131f4d9b86
commit e124a8a7d9
69 changed files with 3030 additions and 137 deletions

31
api/prompts/__init__.py Normal file
View File

@@ -0,0 +1,31 @@
"""Prompt loader + renderer.
Every prompt — system or user — lives as a `.txt` file in this directory.
Two ways to consume them:
- `load(name)` returns the file's text unchanged. Use for system prompts
(and any user prompt that has no placeholders).
- `render(name, **vars)` loads then runs `str.format(**vars)` on it. Use
for user prompts that interpolate question/SQL/rows/findings/etc.
Placeholders are standard Python format syntax: `{name}`. Literal braces
must be doubled: `{{` / `}}`.
"""
from __future__ import annotations
from functools import lru_cache
from pathlib import Path
from typing import Any
PROMPTS_DIR = Path(__file__).resolve().parent
@lru_cache(maxsize=None)
def load(name: str) -> str:
"""Read the named prompt file (no substitution)."""
return (PROMPTS_DIR / f"{name}.txt").read_text(encoding="utf-8").strip()
def render(name: str, /, **vars: Any) -> str:
"""Load a prompt and substitute `{placeholder}` values from kwargs."""
return load(name).format(**vars)