Zack Saadioui
8/26/2024
1
2
bash
%pip install llama-index llama-index-vector-stores-postgres
1
2
3
4
5
6
7
8
bash
!sudo apt update
!echo | sudo apt install -y postgresql-common
!echo | sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
!echo | sudo apt install postgresql-15-pgvector
!sudo service postgresql start
!sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'password';"
!sudo -u postgres psql -c "CREATE DATABASE vector_db;"
1
2
3
python
import os
os.environ["OPENAI_API_KEY"] = "<your key>"
1
<your key>
1
2
3
bash
!mkdir -p 'data/paul_graham/'
!wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt' -O 'data/paul_graham/paul_graham_essay.txt'
1
SimpleDirectoryReader
1
2
``
Modify
1
2
3
4
python
query_engine = index.as_query_engine()
response = query_engine.query("What is the significance of IBM 1401 in computing history?")
print(response)
Copyright © Arsturn 2024