A document Q&A agent: load a local file (PDF or text), then ask questions about it. The agent answers using only retrieved content from the loaded document, not its own general knowledge.
POST /load → file path → chunking → embedding → stored in a local Chroma vector database
POST /ai → question → agent retrieves relevant chunks via a tool → answers based on them
No multi-agent pipeline and no external MCP servers here — retrieval is plain LangChain/Chroma code, called by the agent as a single tool. The agent's job is limited to deciding when to search and how to phrase the answer.
| File | Purpose |
|---|---|
rag.py |
Loads a file, splits it into chunks, builds/updates the local Chroma vector store |
aiagent.py |
Agent definition, the ragtool retrieval tool, and the call() function used by both entry points |
api.py |
FastAPI app exposing /load and /ai endpoints |
main.py |
Terminal entry point for manual testing, handles /load as a special command |
test.py |
Sends HTTP requests to the running API for testing |
config.yaml |
Model name, system prompt, temperature, and max tokens for the agent |
pip install -r requirements.txtCopy example.env to .env and adjust if needed. Defaults assume a local Ollama server:
url=http://localhost:11434/v1
api=ollama
Embeddings run fully locally via sentence-transformers (all-MiniLM-L6-v2) — no API key or external call needed for embedding.
Terminal version:
python main.pyType /load when prompted to load a document by file path, then ask questions about it.
API version:
uvicorn api:app --reloadTest at localhost:8000/docs, or run:
python test.pyLoad a document:
curl -X POST http://localhost:8000/load -H "Content-Type: application/json" -d '{"path": "C:/path/to/file.pdf"}'Ask a question:
curl -X POST http://localhost:8000/ai -H "Content-Type: application/json" -d '{"text": "What is this document about?"}'Reliable tool-calling matters a lot here — the agent must actually call ragtool rather than guessing an answer from general knowledge. Smaller/general-purpose local models (e.g. mistral:7b) sometimes fail to trigger the tool call correctly and hallucinate instead. Models trained specifically for native tool-calling (e.g. qwen3:8b on Ollama) are noticeably more reliable for this project.
- Only one document is loaded at a time — loading a new file replaces the previous vector store.
- No document deletion or listing endpoint yet.
- No MCP servers — all retrieval is local, synchronous LangChain/Chroma code.