Simple command-line chat program that:
- Takes a question as a command-line argument.
- Retrieves relevant chunks from two Qdrant collections.
- Sends those chunks to an LLM via Ollama.
- Prints the answer.
- Python 3.9+
- Ollama running locally (chat + embeddings endpoint)
- At least one model pulled (example:
llama3.2) - Qdrant running with two collections that store payload text
- Start Ollama:
ollama serve- Create
.envin the project directory:
OLLAMA_MODEL=llama3.2
OLLAMA_EMBED_MODEL=nomic-embed-text
OLLAMA_CHAT_URL=http://localhost:11434/api/chat
OLLAMA_EMBED_URL=http://localhost:11434/api/embed
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=
QDRANT_COLLECTION_1=collection_one
QDRANT_COLLECTION_2=collection_two
QDRANT_LIMIT=3
QDRANT_TEXT_FIELDS=text,content,chunk,document,page_content- Pull required models on the Ollama server:
ollama pull llama3.2
ollama pull nomic-embed-text- Run:
python rag_chat.py "What are the main differences between source A and source B?"python rag_chat.py "your question" \
[--env .env] \
[--collection1 <qdrant-collection>] \
[--collection2 <qdrant-collection>] \
[--model llama3.2] \
[--embed-model nomic-embed-text] \
[--top-k 3] \
[--ollama-url http://localhost:11434/api/chat] \
[--ollama-embed-url http://localhost:11434/api/embed] \
[--qdrant-url http://localhost:6333] \
[--qdrant-api-key <key>] \
[--text-fields text,content,chunk,document,page_content] \
[--show-context]- The script generates the question embedding via Ollama, then uses vector search in each Qdrant collection.
- The script checks whether chat/embedding models exist on the configured Ollama server and fails with a clear install command if missing.
- For proxied Ollama endpoints that do not expose management APIs (
/api/showor/api/tags), model preflight becomes best-effort and the script continues to normal query execution. QDRANT_TEXT_FIELDScontrols which payload fields are checked for text context (first matching string is used).- CLI flags override
.envvalues when both are present. - Use
--show-contextto inspect selected chunks from each collection.
Build locally:
docker build -t rag-chat:local .Run:
docker run --rm \
--env-file .env \
rag-chat:local \
"your question here"You can also pass flags after the question, for example:
docker run --rm --env-file .env rag-chat:local \
"your question here" --top-k 5 --show-contextWorkflow file: .github/workflows/docker-publish.yml
- Publishes to
ghcr.io/<owner>/<repo>. - Triggers only on pushes to version tags matching
v*(example:v1.2.3). - Uses the pushed Git tag as the Docker tag and also publishes
latest. - Runs only once per release push (no duplicate
main+tagbuild), because branch pushes are not configured as triggers.