Dilan Croos
Explore the docs »
·
Report Bug
·
Request Feature
Table of Contents
A local Django chat app that answers questions from files you place in a local knowledge-base folder. Source files are converted to Markdown with Microsoft's MarkItDown first, then the app indexes only the generated Markdown files. The app uses Ollama for local chat and embedding models, so it does not need a paid LLM API after installation.
To get a local copy up and running follow these simple steps.
- Python 3.11 or newer
- Ollama running locally
Install Ollama from https://ollama.com/download, then pull the default models:
ollama pull llama3.2
ollama pull nomic-embed-textClone the repo
git clone git@github.com:dilancroos/django_chat.git
cd django_chatCreate and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txtCreate an environment file:
cp envtemp .envRun the database migrations and create a user:
python manage.py migrate
python manage.py makemigrationsagain
python manage.py migratepython manage.py createsuperuserPut source files in knowledge_base/. The app converts them into Markdown in
knowledge_markdown/, then indexes only those generated .md files.
Supported first-version source file types are:
- Word
- PowerPoint
- XLS and XLSX
- CSV
- Markdown
- TXT
- HTML
- JSON and XML
- ZIP
The app checks this folder when you send a chat message. If files changed, it
converts the files into Markdown, then rebuilds the local index in
rag_storage/ before answering.
You can rebuild the index manually:
python manage.py rebuild_rag_indexTo skip rebuilding when the stored manifest is current:
python manage.py rebuild_rag_index --skip-unchangedStart Ollama, then start Django:
python manage.py runserverOpen http://127.0.0.1:8000, sign in, and ask questions about the files in
knowledge_base/. Do not edit knowledge_markdown/ manually; it is generated
from the source folder.
The app automatically creates the ai-chat chat group and botty bot user the
first time a chat message is sent.
These settings can be changed in .env:
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_CHAT_MODEL=llama3.2
OLLAMA_EMBED_MODEL=nomic-embed-text
RAG_SOURCE_DIR=knowledge_base
RAG_MARKDOWN_DIR=knowledge_markdown
RAG_STORAGE_DIR=rag_storagepython manage.py testDilan Croos - mail@dilancroos.com
Project Link: https://github.com/dilancroos/django_chat
- Django chat template by Andreas Jud