Find answers from the community

Updated 2 years ago

Supabase

At a glance

A community member encountered an error while following a guide to set up a Supabase vector index. They provided the code they were using, which included setting the OpenAI API key and creating a Supabase vector store. The comments indicate that the community member was able to resolve the issue with the OpenAI API key by setting it directly in the openai module, in addition to the os.environ approach. However, the community member then faced a new issue of not being able to find the 'base_demo' collection in Supabase. Another community member suggested that the community member was able to find the collection, indicating that the issue was resolved.

Useful resources
Hello Everybody
I found the error while following the guide: https://gpt-index.readthedocs.io/en/latest/examples/vector_stores/SupabaseVectorIndexDemo.html

Plain Text
import logging
import sys
import openai

from llama_index import SimpleDirectoryReader, Document, StorageContext
from llama_index.indices.vector_store import VectorStoreIndex
from llama_index.vector_stores import SupabaseVectorStore
import textwrap

import os
os.environ['OPENAI_API_KEY'] = "sk-XXXXXXXXXXXXXXXXXXXXX"

documents = SimpleDirectoryReader('documents/').load_data()
print('Document ID:', documents[0].doc_id, 'Document Hash:', documents[0].doc_hash)

vector_store = SupabaseVectorStore(
    postgres_connection_string="postgresql://user:password@host:port/database", 
    collection_name='base_demo'
)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(documents, storage_context=storage_context)


That is the code

Help me
Attachment
image.png
L
w
15 comments
What is the full error you get?
Looks like another key issues.

Try also setting it directly on openai, in addition to the os.environ part

Plain Text
import openai

openai.api_key ="sk-..."


Weird stuff with keys lately πŸ˜…
Thanks it is working now
but I can't find the data in the supabase
But I can't find 'base_demo' collection in the supabase
Thank you for your help
Nice! πŸ‘
Add a reply
Sign up and join the conversation on Discord