Find answers from the community

Updated last year

Hi all Firstly thanks for the amazing

At a glance
Hi all,Firstly thanks for the amazing and quick responses.
My issue is with initialzing an index. I am using Qdrant for my chat engine backend, and I have multiple collections inside. Now I am taking inoput from user to use different collections. Below is the code I am using, but the error I'm facing is the index does not change when the collection changes even when I initialze the chat again

Plain Text
def initializeChat():
    client = qdrant_client.QdrantClient(
        url=f"{url}")
    vector_store = QdrantVectorStore(client=client, collection_name=f"{collection}")
    index = VectorStoreIndex.from_vector_store(
        vector_store=vector_store, service_context=service_context)
    print(collection)
return index

It initialized for collection1, but when user passes collection2 , I run the above lines of code again,(print statement prints as collection2), the index does not change and is still using previous collection. How to solve for this
FYI more details of my code: Chat is a websocket, it triggers above initializeChat
W
L
A
4 comments
Can you check the vector_store content in each case
where does the collection name come from? You aren't passing it into the function. Maybe avoid using a global variable for that
Its getting passed correctly, I missed it while sharing the snippet of code here, but I am passing the information from my main
Plain Text
def initializeChat(url,collection):
    client = qdrant_client.QdrantClient(
        url=f"{url}")
    vector_store = QdrantVectorStore(client=client, collection_name=f"{collection}")
    index = VectorStoreIndex.from_vector_store(
        vector_store=vector_store, service_context=service_context)
    print(collection)
return index

this is my function, have some other code along with it, so was not sharing it here properly
I am not using a global variable, it getting passed from my frontend
From what I'm seeing, it should be working. Not totally sure what the issue is
Add a reply
Sign up and join the conversation on Discord