In this example, we will build index for text embedding from local markdown files, and provide a simple query endpoint via fastapi. We provide a simple docker container using docker compose to build pgvector17 along with a simple python fastapi script
We appreciate a star ⭐ at CocoIndex Github if this is helpful.
In the .env file, use local Postgres URL
# For local testing
COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex
-
Install dependencies:
pip install -e . -
Setup:
cocoindex setup main
-
Update index:
cocoindex update main
-
Run:
uvicorn main:fastapi_app --reload --host 0.0.0.0 --port 8000
```bash
curl "http://localhost:8000/search?q=model&limit=3"
```
In the .env file, use Docker Postgres URL
COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@coco_db:5436/cocoindex
Build the docker container via:
docker compose up --buildTest the endpoint:
curl "http://0.0.0.0:8080/search?q=model&limit=3"