This repo contains the code for the backend of Lanvas.
Tech Stack:
- Python - Language
- FastAPI - API Framework
- Supabase - Database, Auth, Storage, Vectorstore
- LangChain - LLM Framework
- OpenAI - LLM
- Instructor - Structured Output Generation
- RabbitMQ - Message Broker
- Celery - Task Queue
- PyTest - Testing Framework
The architecture for the chat API is based on the Official LangChain guide for RAG with Chat History with a few modifications.
Since Supabase is the database and vectorstore for Lanvas, there is a Custom Retriever
and ChatHistory
to make the chain work.
Celery is used to handle analytics tasks that aggregate the following:
- Topics discussed by a student
- Misconceptions of a student
The analysis is powered by Instructor and OpenAI's GPT LLM.
-
Install poetry
-
Install dependencies using poetry
poetry install
-
Install and setup RabbitMQ
-
Install Supabase CLI
-
Create a new Supabase project using the dashboard
-
Link with the newly created Supabase project
supabase link --project-ref ""
-
Setup Tables and Functions with migrations in the
supabase/migrations/
directorysupabase db push
-
Setup
.env
filecp .env.sample .env
-
Activate virtual environment
poetry shell
-
Setup Celery worker
celery -A celery_tasks worker -l INFO
-
Start the FastAPI server
uvicorn main:app --reload
-
Visit the docs at
http://localhost:8000/docs
There are a few unit tests setup which you can verify by running the following command:
poetry run pytest -s