Skip to main content

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.

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 LangGraph 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

POST /api/v1/chat/

Request Body

question
string
required
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.
conversation_id
string
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.
image
string
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).
confirmation
boolean
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

answer
string
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.
meta
object
Metadata about the orchestration run.
sources
SourceInfo[]
Array of source document excerpts retrieved from ChromaDB that grounded the response. Each entry contains:
warnings
string[]
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

// Request
{
  "question": "¿Cuál es el precio de lista y la disponibilidad del producto Patito Pro 2026?",
  "conversation_id": null,
  "image": null,
  "confirmation": null
}

// Response
{
  "answer": "El Patito Pro 2026 tiene un precio de lista de USD 1,299, está EN STOCK y cuenta con procesador de alto rendimiento, 16 GB RAM, 512 GB SSD. Incluye garantía estándar de 12 meses.",
  "meta": {
    "agents_used": ["agente_catalogo"],
    "latency_ms": 1423.5,
    "conversation_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  },
  "sources": [
    {
      "document_name": "01_Catalogo_Productos_Precios.txt",
      "content_snippet": "Patito Pro 2026 — Precio: USD 1,299 — Estado: EN STOCK",
      "relevance_score": 0.91
    }
  ],
  "warnings": []
}

Security

The chat endpoint is protected by four security layers before any agent is invoked:
  1. Layer 1 — Input validation (FastAPI Dependency): The validar_input dependency 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.
  2. Layer 2 — Prompt hardening: Each agent’s system prompt contains immutable instructions that prevent role reassignment or context leaking, regardless of user input.
  3. Layer 3 — Server-side sandboxing (security.py): A second pass of pattern detection runs inside ChatService before the orchestrator is invoked.
  4. Layer 4 — Output validation: The consolidator verifies that the final answer does not contain hallucinations before returning it.

Build docs developers (and LLMs) love