This service is a collection of APIs that are specific to the Annotation UI application which is used to create datasets for RAG benchmarking. It uses FastAPI and PostgreSQL to achieve the task at hand.
To use the code, you need to follow these steps:
-
Clone the repository from GitHub:
git clone git@github.com:OpenNyAI/Annotation-Backend.git
-
The code requires Python 3.10 or higher and the project follows poetry package system. To install poetry, run the following command in the terminal:
curl -sSL https://install.python-poetry.org | python3 -
-
Once poetry is installed, run the following commands to create a virtual environment and install the dependencies:
python3 -m venv .venv source .venv/bin/activate poetry install
-
If you don't already have a postgres instance running, please run the below command in the terminal to start a local postgres instance:
docker compose up postgres
-
Rename the .env.template file to .env and populate the respective postgres db values, jwt token secrets, gmail credentials and openai key values into the variables present inside.
-
The last step is the database migration to create and update the tables in the given postgres instance. Run the following command in the terminal:
./db_scripts/upgrade-db.sh
Once the above installation steps are completed, run the following command in the terminal:
./tools/run-server.sh
- The auth APIs and their specifications can be found in http://localhost:8080/auth/docs.
- The admin APIs and their specifications can be found in http://localhost:8080/admin/docs.
- The user APIs and their specifications can be found in http://localhost:8080/user/docs.
-
Install the pgvector extension in postgres if it is absent
# For Debian/Ubuntu sudo apt-get install pgvector # For MacOS brew install pgvector # For Windows pip install pgxnclient pgxn install vector
-
Then in the psql terminal or PostgreSQL client, create the pgvector extension using the below SQL command:
CREATE EXTENSION IF NOT EXISTS vector;