recon-driven sql composer; pick → compose → execute; llm out of structural sql

This commit is contained in:
2026-06-03 11:01:02 -03:00
parent 61494362a3
commit 29c620b2c2
27 changed files with 1516 additions and 249 deletions

View File

@@ -9,7 +9,8 @@ Provider selection is via `settings.llm_provider`. Supported:
Every call opens a Langfuse `generation` span automatically, tagged with the
model name and populated with token usage from the provider's response.
Spans nest under whatever observation the caller has open, so the trace
hierarchy shows `text_to_sql > llm.chat` with usage on the inner node.
hierarchy shows the wrapping step (e.g. `pick_for_question`) with the
`llm.chat` generation as a child carrying the usage.
"""
from __future__ import annotations
@@ -119,7 +120,7 @@ def _active_model() -> str:
def chat(*, system: str, user: str, max_tokens: int = 1024, span_name: str = "llm.chat") -> str:
"""Run a single chat completion. Opens a Langfuse generation span around
the call with the model name + token usage. `span_name` is the label
shown in Langfuse — pass something descriptive (e.g. "text_to_sql.gen")
shown in Langfuse — pass something descriptive (e.g. "direct_answer.pick")
so traces are scannable."""
provider = get_settings().llm_provider.lower()
impl = _PROVIDERS.get(provider)