DEV Community

parmarjatin4911@gmail.com
parmarjatin4911@gmail.com

Posted on

1

Llama Index and Supabase

Llama Index and Supabase

!pip install -qU llama_index

import os
from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.vector_stores import SupabaseVectorStore

os.environ['OPENAI_API_KEY'] = "[your_openai_api_key]"

documents = SimpleDirectoryReader('data').load_data()
index = VectorStoreIndex.from_documents(documents)
index.storage_context.persist()

DB_PASSWORD = os.environ['DB_PASSWORD']
DB_CONNECTION = f"postgresql://postgres:{DB_PASSWORD}@localhost:5431/db"

vector_store = SupabaseVectorStore(
postgres_connection_string=DB_CONNECTION,
collection_name='base_demo'
)

query_engine = index.as_query_engine()
response = query_engine.query("What did the author do growing up?")
print(response)

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay