This project is an implementation of question answering sql rag in InfluxDB and langgraph.
- Docker installed.
- An account in Langsmith.
- Ollama
Currently, the project supports the following memory savers and switching them in .env
file:
- MemorySaver
- PostgresSaver
- Clone the repository.
- Copy the
.env.example
to.env
and update the values as per your environment. Some value would be available after up and running the docker containers. - Up the docker containers
docker compose up -d --build
InfluxDB
- Run
docker compose exec -it influxdb3 bash
- Create the token:
influxdb3 create token --admin
- Set
INFLUXDB3_AUTH_TOKEN
:export INFLUXDB3_AUTH_TOKEN=admin_token
- Create the database:
influxdb3 create database sensors
- Write into the database:
influxdb3 write --database sensors --file /home/data/air-sensor-data.lp
influxdb3 write --database sensors --file /home/data/sensor-meta-data.lp
- Verify:
influxdb3 query --database=sensors "SHOW TABLES"
- Delete if needed:
influxdb3 delete table --database sensors air_sensors
influxdb3 delete table --database sensors sensor_meta
Update the .env
file with the token and database name.
Ollama
- Run
docker compose exec -it ollama bash
- Install models:
ollama pull llama3.2
ollama pull llama3-groq-tool-use
ollama pull nomic-embed-text
- Start the server:
ollama serve
Langgraph Studio
- Run
docker compose exec -it langgraph langgraph dev --host 0.0.0.0 --port 2024
- Studio UI. On failure, browse to
Langgraph Platform > Langgraph Studio
. - Langsmith UI.
CLI RAG
- Run
docker compose exec -it langgraph python rag.py
- To end the chat type
exit
orquit
.
Frontend UI
- Adjust
frontend/.env
- Go to:
http://localhost:8501/
or replacelocalhost
with the IP address of the machine.
It is recommended to perform unit test before commiting the code. To run unit test, ensure ENV=dev
in .env
.
To access the server:
docker compose exec -it langgraph bash
and run the following command:
pytest
This repo uses pre-commit
hooks to check type and linting before committing the code.
Virtual environment:
python -m venv .venv
Activate:
source .venv/bin/activate
In Windows, use:
.venv\Scripts\activate
Install:
pip install pre-commit
Enable:
pre-commit install
- Clone the repo.
- Copy the
.env.example
to.env
and update the values as per your environment. - Set
ENV=prod
in.env
- Up the docker containers:
docker compose -f compose.yml up -d
The production-ready Docker image is automatically built and published to Docker Hub on every new GitHub Release.
Pulling the Image:
docker pull likh/influxdb-sql-rag:latest
Recommended to pull a specific tag (e.g. v1.0.0).
Currently, there is no automatically build the streamlit
as anyone can use any other frontend technology.
This project is licensed under the MIT License - see the LICENSE file for details.