0

I plan to build a AI faq base on their website,

        pinecone.init(api_key = PINECONE_API_KEY, environment = PINECONE_ENV)
        index_name = "project-name"
        if index_name not in pinecone.list_indexes():
            pinecone.create_index(index_name, dimension=1536, metric='cosine')

        # connect to index
        pinecone_index = pinecone.Index(index_name)
        vector_store = PineconeVectorStore(pinecone_index = pinecone_index)

        loader = SitemapReader()
        documents = loader.load_data(sitemap_url='https://example.com/wp-sitemap-posts-faq-1.xml')

        embed_model = OpenAIEmbedding(model='text-embedding-ada-002', embed_batch_size=100)
        service_context = ServiceContext.from_defaults(embed_model = embed_model)
        storage_context = StorageContext.from_defaults(vector_store = vector_store)

        index = GPTVectorStoreIndex.from_documents(documents, storage_context = storage_context, service_context = service_context)

It seems there are two ways to handle this.

  1. Create an index for each user, but that would make it have a lot of indexes.
  2. Create metadata for each document, but I am not sure how to append user_id data in this example.

What is the normal way to handle this situation in production, any thought is appreciated.

Ilake Chang
  • 1,542
  • 1
  • 14
  • 19

0 Answers0