Evaluation is the E pillar of the E-O-C-S framework. Mesa de Ayuda IA ships an offline batch evaluator (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/geremyjampiersalasgarcia-eng/Caso_Practico_Semillero_IA/llms.txt
Use this file to discover all available pages before exploring further.
scripts/evaluate.py) that uses a second Gemini call as an impartial “judge” to score the system’s own responses against a structured Pydantic rubric. Results are persisted to the evaluations table in PostgreSQL, providing an audit trail of response quality over time and a mechanism to detect regressions after document updates or model changes.
Running the Evaluator
The evaluator is a standalone Python script. It reads conversation history from PostgreSQL, calls the Gemini LLM judge for each question/answer pair, parses the structured output, and writes one row per evaluation dimension to theevaluations table.
Ensure the backend database is reachable
The script uses the same
DATABASE_URL from your .env. PostgreSQL must be running:Each call to
scripts/evaluate.py consumes additional Gemini API tokens: one LLM call per conversation evaluated. On the free tier (15 RPM), evaluating 10 conversations may take 1–2 minutes to avoid rate-limit errors. Consider running the script during off-peak hours or adding a time.sleep() between iterations in high-volume environments.Evaluation Rubric
The rubric is defined as a pair of Pydantic v2 models inapp/evaluation/rubrica.py. Every scoring dimension is represented by a MetricaEvaluacion instance that captures both a numeric score and a human-readable justification:
| Dimension | What Is Scored |
|---|---|
precision_precio | Does the quoted price match the official catalog? |
cita_fuentes | Did the response name the source document it used? |
autorizacion_descuento | If a discount above 10% was involved, did the agent warn that manager approval is required? |
completitud_crm | Did the action agent collect all mandatory CRM fields (name, company, size) before confirming a registration? |
tono | Is the response professional, friendly, and corporate in tone? |
longitud | Is the response concise and to the point without unnecessary padding? |
EvaluacionRica.model_json_schema() and injected directly into the judge’s system prompt, ensuring the LLM returns a JSON object that exactly matches the model structure.
Golden Dataset
The filetests/golden_dataset.json is a lightweight regression corpus that pairs representative user questions with their expected intent classifications. It is used by the automated regression test to verify that the LangGraph orchestrator correctly routes each question:
| Field | Description |
|---|---|
question | A natural-language question representative of a real sales query |
expected_intent | The intent category the classifier should assign (catalogo_precios, politicas_comerciales, proceso_ventas, accion_registro, or mixta) |
Evaluation Results
The evaluator writes one row per scored dimension to theevaluations table, defined in app/models/evaluation.py:
evaluations — one for each dimension in EvaluacionRica. To calculate an overall quality score for a conversation, average the score values across all six dimensions for that conversation_id.
Example SQL to retrieve the average quality score per conversation:
Golden Regression Test
The filetests/test_golden_regression.py is a pytest suite that runs all five golden-dataset questions through the full LangGraph orchestrator and asserts that each call completes without an exception and returns a non-null final_answer:
classify → router → agent → consolidate pipeline executes cleanly for every representative intent. It intentionally avoids asserting exact LLM outputs (which are non-deterministic) and focuses on structural correctness: the graph must not crash and must always produce a final answer.