The chat endpoint is the primary interface to the Mesa de Ayuda IA multi-agent system. It accepts a natural language question from a salesperson, optionally a base64-encoded image for multimodal product analysis, and an optional boolean confirmation flag used to finalize pending CRM registration workflows. The request is validated by a 4-layer security pipeline and then routed through the LangGraphDocumentation 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.
StateGraph orchestrator, which classifies the intent, dispatches one or more specialized agents (catalog, policies, sales process, multimodal, or action), consolidates their outputs, and returns a structured JSON response containing the answer, the agents involved, source document excerpts, and any non-fatal warnings.
Method and Path
Request Body
The user’s natural language question. Must be 2 000 characters or fewer. Questions longer than this limit are rejected with HTTP 400. This field is the primary input to the intent classifier and the individual agents.
The ID of an existing conversation session returned by a previous
/chat/ response (meta.conversation_id). When provided, the backend loads the stored message history from PostgreSQL and supplies it as context to the agents, enabling multi-turn dialogue. Omit or set to null to start a new conversation.A base64-encoded data URI of an image (e.g.,
data:image/jpeg;base64,/9j/4AAQ...). When present, the orchestrator automatically routes the request to the multimodal agent (agente_multimodal), which uses Gemini Vision to analyze the image and cross-reference the result against the product catalog collection (col_catalogo).Set to
true to confirm a pending CRM registration action proposed by the action agent (agente_accion) in a previous turn. When the action agent has collected all required fields (client, contact, product, quantity, price, payment terms) and presented a summary, it awaits this confirmation flag before writing to data/registro_oportunidades.txt and inserting into the oportunidades PostgreSQL table.Response Body
The final, consolidated natural language response generated by the orchestrator. For multi-agent (mixed-intent) queries, this is the output of the consolidator node that integrates the individual agents’ partial answers into a single coherent reply.
Metadata about the orchestration run.
Array of source document excerpts retrieved from ChromaDB that grounded the response. Each entry contains:
A list of non-fatal warning messages. The response is still returned even when warnings are present. Common warnings include ChromaDB being unavailable, a consolidation error for mixed-intent queries, or insufficient information found in the knowledge base.
Examples
Security
The chat endpoint is protected by four security layers before any agent is invoked:
- Layer 1 — Input validation (FastAPI Dependency): The
validar_inputdependency rejects questions longer than 2 000 characters with HTTP 400 ("Input rechazado: Pregunta demasiado larga"). It also scans for injection patterns using regex (e.g.,ignora.*instrucciones,eres.*ahora,bypass) and returns HTTP 400 ("Input rechazado: Patrón sospechoso detectado") if a match is found. - Layer 2 — Prompt hardening: Each agent’s system prompt contains immutable instructions that prevent role reassignment or context leaking, regardless of user input.
- Layer 3 — Server-side sandboxing (
security.py): A second pass of pattern detection runs insideChatServicebefore the orchestrator is invoked. - Layer 4 — Output validation: The consolidator verifies that the final answer does not contain hallucinations before returning it.