# erennss78/kori-agente architecture

> Architecture diagram of the GitHub repository erennss78/kori-agente, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erennss78/kori-agente
- Repository: https://github.com/erennss78/kori-agente

## Overview

Kori is a Spanish-language sensor-data analyst: a user asks a question, the agent plans and validates it, checks whether column meanings are confirmed, computes results deterministically, and returns text and optionally a table. Data adapters load configured datasets; semantic cards support clarification and persist confirmed meanings. A separate OpenAI-compatible HTTP server exposes the agent to LibreChat, while local Ollama supplies the model. The README also documents generated-reference evaluation and model comparisons. Some agent stages are described in the README but their implementation details were not sampled.

Main entry points: [`kori_agente/agente.py`](https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py) (Agent workflow), [`kori_agente/datos.py`](https://github.com/erennss78/kori-agente/blob/master/kori_agente/datos.py) (Source adapter), [`kori_agente/servidor_kori.py`](https://github.com/erennss78/kori-agente/blob/master/kori_agente/servidor_kori.py) (Chat API), [`kori_agente/evaluar.py`](https://github.com/erennss78/kori-agente/blob/master/kori_agente/evaluar.py) (Agent evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_librechat["LibreChat"]
  node_api["Chat API<br/>[servidor_kori.py]"]
end

subgraph group_analysis["Question analysis"]
  node_agent["Agent workflow<br/>[agente.py]"]
  node_plan["Plan and validate<br/>[agente.py]"]
  node_clarification["Clarification loop<br/>[agente.py]"]
  node_response["Answer and table<br/>[agente.py]"]
  node_calculations["Queries and quality<br/>[herramientas.py]"]
end

subgraph group_data["Data and semantics"]
  node_loader["Source adapter<br/>[datos.py]"]
  node_source_config["Source configuration<br/>[fuentes.json]"]
  node_cards["Semantic cards<br/>[tarjetas.py]"]
  node_card_store[("Confirmed meanings<br/>[tarjetas.py]")]
end

subgraph group_evaluation["Model evaluation"]
  node_gold["Reference generator<br/>[generar_gold.py]"]
  node_evaluation["Agent evaluation<br/>[evaluar.py]"]
  node_comparison["Model comparison"]
  node_results_table["Results summary<br/>[tabla_modelos.py]"]
end

node_user(("Chat user"))
node_ollama["Ollama model"]
node_sensor_data["Sensor datasets"]

node_user -->|"asks through"| node_librechat
node_librechat -->|"sends chat"| node_api
node_api -->|"calls responder"| node_agent
node_api -->|"loads datasets"| node_loader
node_api -->|"confirms meanings"| node_cards
node_agent -->|"plans and validates"| node_plan
node_plan -->|"requests plan"| node_ollama
node_agent -->|"loads data"| node_loader
node_agent -->|"checks semantics"| node_cards
node_agent -->|"runs analysis"| node_calculations
node_agent -->|"asks if ambiguous"| node_clarification
node_clarification -->|"uses evidence"| node_cards
node_agent -->|"drafts answer"| node_response
node_response -->|"requests wording"| node_ollama
node_source_config -->|"configures sources"| node_loader
node_sensor_data -->|"reads files"| node_loader
node_cards -->|"persists confirmations"| node_card_store
node_gold -->|"loads datasets"| node_loader
node_gold -->|"calculates references"| node_calculations
node_evaluation -->|"evaluates answers"| node_agent
node_evaluation -->|"loads datasets"| node_loader
node_evaluation -->|"checks results"| node_calculations
node_comparison -->|"runs benchmarks"| node_evaluation
node_results_table -->|"reads comparison setup"| node_comparison

click node_librechat "https://github.com/erennss78/kori-agente/tree/master/kori_interfaz"
click node_api "https://github.com/erennss78/kori-agente/blob/master/kori_agente/servidor_kori.py"
click node_agent "https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py"
click node_plan "https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py"
click node_clarification "https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py"
click node_response "https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py"
click node_loader "https://github.com/erennss78/kori-agente/blob/master/kori_agente/datos.py"
click node_source_config "https://github.com/erennss78/kori-agente/blob/master/kori_agente/fuentes.json"
click node_cards "https://github.com/erennss78/kori-agente/blob/master/kori_agente/tarjetas.py"
click node_card_store "https://github.com/erennss78/kori-agente/blob/master/kori_agente/tarjetas.py"
click node_calculations "https://github.com/erennss78/kori-agente/blob/master/kori_agente/herramientas.py"
click node_gold "https://github.com/erennss78/kori-agente/blob/master/kori_agente/generar_gold.py"
click node_evaluation "https://github.com/erennss78/kori-agente/blob/master/kori_agente/evaluar.py"
click node_comparison "https://github.com/erennss78/kori-agente/blob/master/kori_agente/comparar_modelos.py"
click node_results_table "https://github.com/erennss78/kori-agente/blob/master/kori_agente/tabla_modelos.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_librechat,node_api,node_user toneBlue
class node_agent,node_plan,node_clarification,node_response,node_calculations toneAmber
class node_loader,node_source_config,node_cards,node_card_store toneMint
class node_gold,node_evaluation,node_comparison,node_results_table toneRose
class node_ollama,node_sensor_data toneIndigo
```

## Components

### Chat interface

- [LibreChat](https://github.com/erennss78/kori-agente/tree/master/kori_interfaz): `kori_interfaz`
- [Chat API](https://github.com/erennss78/kori-agente/blob/master/kori_agente/servidor_kori.py): `kori_agente/servidor_kori.py`

### Question analysis

- [Agent workflow](https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py): `kori_agente/agente.py`
- [Plan and validate](https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py): `kori_agente/agente.py`
- [Clarification loop](https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py): `kori_agente/agente.py`
- [Answer and table](https://github.com/erennss78/kori-agente/blob/master/kori_agente/agente.py): `kori_agente/agente.py`
- [Queries and quality](https://github.com/erennss78/kori-agente/blob/master/kori_agente/herramientas.py): `kori_agente/herramientas.py`

### Data and semantics

- [Source adapter](https://github.com/erennss78/kori-agente/blob/master/kori_agente/datos.py): `kori_agente/datos.py`
- [Source configuration](https://github.com/erennss78/kori-agente/blob/master/kori_agente/fuentes.json): `kori_agente/fuentes.json`
- [Semantic cards](https://github.com/erennss78/kori-agente/blob/master/kori_agente/tarjetas.py): `kori_agente/tarjetas.py`
- [Confirmed meanings](https://github.com/erennss78/kori-agente/blob/master/kori_agente/tarjetas.py): `kori_agente/tarjetas.py`

### Model evaluation

- [Reference generator](https://github.com/erennss78/kori-agente/blob/master/kori_agente/generar_gold.py): `kori_agente/generar_gold.py`
- [Agent evaluation](https://github.com/erennss78/kori-agente/blob/master/kori_agente/evaluar.py): `kori_agente/evaluar.py`
- [Model comparison](https://github.com/erennss78/kori-agente/blob/master/kori_agente/comparar_modelos.py): `kori_agente/comparar_modelos.py`
- [Results summary](https://github.com/erennss78/kori-agente/blob/master/kori_agente/tabla_modelos.py): `kori_agente/tabla_modelos.py`

### Other components

- **Chat user**
- **Ollama model**
- **Sensor datasets**

## Connections

- Chat user → LibreChat: asks through (evidence: `README.md`)
- LibreChat → Chat API: sends chat (evidence: `README.md`)
- Chat API → Agent workflow: calls responder (evidence: `kori_agente/servidor_kori.py`)
- Chat API → Source adapter: loads datasets (evidence: `kori_agente/servidor_kori.py`)
- Chat API → Semantic cards: confirms meanings (evidence: `kori_agente/servidor_kori.py`)
- Agent workflow → Plan and validate: plans and validates (evidence: `kori_agente/agente.py`)
- Plan and validate → Ollama model: requests plan (evidence: `README.md`)
- Agent workflow → Source adapter: loads data (evidence: `kori_agente/agente.py`)
- Agent workflow → Semantic cards: checks semantics (evidence: `kori_agente/agente.py`)
- Agent workflow → Queries and quality: runs analysis (evidence: `kori_agente/agente.py`)
- Agent workflow → Clarification loop: asks if ambiguous (evidence: `kori_agente/agente.py`)
- Clarification loop → Semantic cards: uses evidence (evidence: `kori_agente/agente.py`)
- Agent workflow → Answer and table: drafts answer (evidence: `README.md`)
- Answer and table → Ollama model: requests wording (evidence: `README.md`)
- Source configuration → Source adapter: configures sources (evidence: `kori_agente/datos.py`)
- Sensor datasets → Source adapter: reads files (evidence: `kori_agente/datos.py`)
- Semantic cards → Confirmed meanings: persists confirmations (evidence: `kori_agente/tarjetas.py`)
- Reference generator → Source adapter: loads datasets (evidence: `kori_agente/generar_gold.py`)
- Reference generator → Queries and quality: calculates references (evidence: `kori_agente/generar_gold.py`)
- Agent evaluation → Agent workflow: evaluates answers (evidence: `kori_agente/evaluar.py`)
- Agent evaluation → Source adapter: loads datasets (evidence: `kori_agente/evaluar.py`)
- Agent evaluation → Queries and quality: checks results (evidence: `kori_agente/evaluar.py`)
- Model comparison → Agent evaluation: runs benchmarks (evidence: `kori_agente/comparar_modelos.py`)
- Results summary → Model comparison: reads comparison setup (evidence: `kori_agente/tabla_modelos.py`)
