Environment variables are loaded at startup via python-dotenv insideDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/gcapella0/agente-inteligente-expedientes/llms.txt
Use this file to discover all available pages before exploring further.
src/config.py. The file .env.example ships with the repository and serves as the canonical template — copy it before first run:
.env with your real values. Variables without a default listed below are required and the service will raise an EnvironmentError if they are missing when the relevant agent starts.
Config priority: The LLM factory (
src/services/llm/llm_factory.py) checks MongoDB collection sistema_config (document _id: "llm_config") first. If that document exists, it overrides the values in .env — enabling hot-reload of LLM config via PUT /config/llm without restarting the service. All other variables are read directly from the environment on startup.Security
Secret key used to sign and verify JWT tokens (HS256 algorithm). Must be long, random, and unpredictable in production. The default value below is only a placeholder — replace it before deploying.Default:
cambiar-en-produccion-clave-larga-y-complejaGenerate a secure value with:Email / IMAP
These variables configure WatcherAgent — the polling agent that monitors an IMAP mailbox and downloads attachments from matching emails.IMAP server hostname.Default:
imap.gmail.comEmail address used to authenticate with the IMAP server.
App password for IMAP authentication. For Gmail, generate this in Google Account → Security → App passwords. Do not use your regular account password.
Whether to connect to the IMAP server using SSL/TLS.Default:
trueThe IMAP folder (mailbox) to monitor for incoming attachments.Default:
INBOXInterval in seconds between IMAP polling cycles. Reduce for more responsive processing; increase to lower API load.Default:
60Comma-separated list of keywords to match against the email subject. An email matches if its subject contains any of these terms (case-insensitive, accent-insensitive). Only matching emails are processed.Default:
Certificado, Diploma, Hoja de vida, Curriculum, CV, Titulo, Documentacion, Voucher de pago, Constancia, Certificado de notasComma-separated list of keywords to match against the email body. Works the same way as
SUBJECT_KEYWORD as a secondary filter.Default: Certificado, Diploma, Hoja de vida, Curriculum, CV, Titulo, Documentacion, Voucher de pago, Constancia, Certificado de notasMongoDB
MongoDB connection URI. When running with Docker Compose, this is automatically overridden in
docker-compose.yml to mongodb://host.docker.internal:27017 — you do not need to change it for single-server deployments.Default: mongodb://localhost:27017Name of the MongoDB database. All collections (docentes, documentos, sistema_config, etc.) are created here.Default:
expedientes_unegLLM — General
Selects the active LLM backend. Set to
openrouter for production (cloud, API key required) or ollama for local development (free, no API key needed).Values: openrouter | ollamaDefault: openrouterLLM — OpenRouter
These variables apply whenLLM_PROVIDER=openrouter.
API key obtained from openrouter.ai. Required when
LLM_PROVIDER=openrouter. The validate_ocr() function in config.py will raise an error if this is missing at OCR-agent startup.The primary model identifier to call first. Must be a valid OpenRouter model slug.Example:
minimax/minimax-m2.5:freeComma-separated list of fallback model slugs. When the primary model returns a
RateLimitError, OpenRouterProvider automatically rotates to the next model in this list (up to 3 retries per model before moving on).Example: google/gemma-3-27b-it:free,meta-llama/llama-4-scout:free,qwen/qwen3-8b:freeBase URL for the OpenRouter API. Follows the OpenAI-compatible endpoint format.Default:
https://openrouter.ai/api/v1LLM — Ollama
These variables apply whenLLM_PROVIDER=ollama.
URL of the locally running Ollama server. When using Docker Compose, set this to
http://host.docker.internal:11434 so the container can reach the host process.Default: http://localhost:11434Model name to use for inference. Must already be pulled with
ollama pull <model>.Examples: gemma4:e4b, phi3:mini, qwen2.5:0.5bDefault: mistralHTTP request timeout in seconds for calls to Ollama’s
/api/chat endpoint. CPU inference for larger models can take 30–120 seconds — do not set this too low.Default: 120Maximum number of tokens the model may generate in a single response.Default:
1000Number of CPU threads to allocate for Ollama inference. When unset, Ollama uses all available CPU cores. Useful for capping resource usage on shared servers.Default: all available cores
Optional paths & logging
Filesystem path where WatcherAgent deposits downloaded email attachments, organized as
{INPUT_DIR}/{docente_name}/.Default: data/inputFilesystem path where StorageAgent moves and stores compressed final documents, organized by teacher’s ID number (
cedula).Default: data/storageDirectory for all log files generated by Loguru:
watcher.log, audit.jsonl, operational.log, ocr.log, etc.Default: logsRetention period for the
audit.jsonl log file before older entries are pruned by Loguru’s rotation policy.Default: 90 daysFile size threshold at which
audit.jsonl is rotated (a new file is started and the old one is archived).Default: 50 MBMinimum log level emitted by Loguru across all log sinks (
watcher.log, operational.log, ocr.log, etc.). Valid values are standard Python log level names.Values: DEBUG | INFO | WARNING | ERROR | CRITICALDefault: INFO