Architecture
The app is split into a UI layer and a processing layer, with the LLM served separately by Ollama.
┌─────────────────┐
│ tres_uno.py │ Streamlit UI
│ (upload, prompt│ - file upload (pdf/docx/txt)
│ slider, buttons│ - prompt box + length slider
│ audio output) │ - explain / lookup / listen
└────────┬────────┘
│ calls
▼
┌─────────────────┐
│ tres.py │ Processing + LLM logic
│ │ - file_preprocessing(): load & chunk
│ │ - llm_pipeline(): summarize per chunk
│ │ - explain_text(): Mistral explanation
│ │ - explain_with_wordnet(): definitions
│ │ - generate_tts(): text-to-speech
└───┬─────────┬───┘
│ │
LangChain│ │ ollama.generate
loaders & │ ▼
splitters │ ┌───────────┐
│ │ Ollama │ local Mistral model
│ └───────────┘
▼
PDF / DOCX / TXT files
Flow: a file is loaded and split into chunks (LangChain RecursiveCharacterTextSplitter), each chunk is sent to Mistral via Ollama with the user's prompt, and the per-chunk responses are joined into the final summary. The summary is then optionally converted to speech. The chunk size, overlap, and token budget all scale off the length slider.
Tech Stack
| Layer | Tools |
|---|---|
| UI | Streamlit |
| LLM | Mistral via Ollama (local) |
| Document loading / chunking | LangChain (PyPDFLoader, RecursiveCharacterTextSplitter), python-docx, pypandoc |
| Dictionary lookup | NLTK WordNet |
| Text-to-speech | pyttsx3 / gTTS |
| Evaluation | rouge-score |
| Language | Python |