source scripts/venv-init.shRun the following docker compose command to start the services
docker compose upThen run the following script to load test data into the postgres db
python scripts/load_sample_data.pyRun the following script to pull the gemma2 model in the Ollama docker container
docker exec -it ollama ollama pull gemma2To stop, press crtl+c in the terminal and run the following commmand to stop the docker containers
docker compose downRun the following command to start the application;
bash start.sh- Activate the virtual environment
- Run the PostgreSQL Docker container
- Run Alembic migrations
- Load sample data into the database
- Run the Ollama Docker container
- Pull the gemma2 model
- Start the FastAPI app
To stop, press crtl+c in the terminal and run the following commmand to stop the docker containers
docker stop ollama some-postgresEnter the following in your terminal:
Request:
curl -X 'POST' \
'http://127.0.0.1:8000/ask' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"question": "What employees work on the AI Research project?"
}'Response:
{
"question": "What employees work on the AI Research project?",
"sql_query": "SELECT \"employee\".\"name\"\nFROM employee_projects\nJOIN employee ON employee_projects.\"employee_id\" = employee.id\nWHERE employee_projects.\"project_id\" = 1;",
"query_result": "\"[('John Doe',), ('Alice Brown',)]\"",
"final_answer": "John Doe and Alice Brown work on the AI Research project. \n"
}Visit the following FastAPI Swagger page to test the API endpoint: http://127.0.0.1:8000/docs
Enter in the following payload for the /ask POST endpoint
{
"question": "What employees work on the AI Research project?"
}- LLM to SQL: https://python.langchain.com/v0.1/docs/use_cases/sql/quickstart/
- Ollama Docker: https://hub.docker.com/r/ollama/ollama
Quickly query postgress database:
docker exec -it some-postgres psql -U postgresPython formatting:
pip install -r requirements-dev.txt
black .