This demo needs a PostgreSQL database with pgvector
installed.
Many package managers like Homebrew and apt
have pre-packaged version of pgvector
.
Don't forget to activate the extension for the database used in the demo:
CREATE EXTENSION vector;
# create venv
python3 -m venv venv
# activate venv
. venv/bin/activate
# install deps
pip install langchain openai pgvector tiktoken unstructured psycopg2 tabulate
The code in the demo uses the following env vars:
OPENAI_API_KEY
, eg:sk-F9Ci...2J
PG_CONN_STR_LOCAL
, eg:postgresql://myuser:***@localhost:5432/mydb
PG_CONN_STR_DDN
, eg:postgresql://4ce270ae3cdd4440aed5d105869949c5:***@data.splitgraph.com:5432/ddn
# first, index the repositories in namespace 'cityofchicago'
python3 index_repos.py cityofchicago
# query the repositories in the cityofchicago namespace
python query.py cityofchicago 'How many restaurants are there in Chicago?'