Find answers from the community

Updated 2 months ago

Chatbot returns empty response after updating python packages

Hello guys, I'm facing an issue on mu chatbot. It's being a long time i didn't run my chatbot because i was training my GPT AI, I updated my python package and run my query fonctions and after my query returns "empty response". It did never return this message. Can you help me ? here is the code of my query:
Plain Text
        # Récupération info model

        model = GetModel(requestDTO.Model)

        # Initialisation OpenAI

        llm = AzureOpenAI(
            model=model.ChatModel.Model,
            deployment_name=model.ChatModel.Name,
            temperature=requestDTO.Temperature,
            api_key=model.Key1,
            azure_endpoint=model.Server,
            api_version=model.ChatModel.ApiVersion,
        )

        embed_model = AzureOpenAIEmbedding(
            model=model.LearningModel.Model,
            deployment_name=model.LearningModel.Name,
            api_key=model.Key1,
            azure_endpoint=model.Server,
            api_version=model.LearningModel.ApiVersion,
        )

        Settings.llm = llm
        Settings.embed_model = embed_model
        Settings.context_window = _contextWindow
        Settings.num_output = _numOutput

         # Génération de l'historique

        messages = []

        if (requestDTO.History != None):
            for item in requestDTO.History:
                messages.append(ChatMessage(role=item.Type.lower(), content=item.Prompt))
      
        # Initialisation des paramĂštres pour les requĂštes sur MongoDB Atlas

        mongodb_client = pymongo.MongoClient(_mongoURI)
        store = MongoDBAtlasVectorSearch(mongodb_client, db_name=requestDTO.Index)

        # Initialisation de l'index via les index sur MongoDB Atlas
        # Et inversement, commenter/décommenter si on veut juste query l'index existant
        # build index
        
        vector_index = VectorStoreIndex.from_vector_store(store)

        # configure retriever
        
        retriever = VectorIndexRetriever(index=vector_index, similarity_top_k=requestDTO.LinkNumber)
        
        # configure response synthesizer, ici on peut chosir le mode réponse pour la query(ici on peut influer sur la maniere dont le contexte et le prompt sont itéré sur la query)
        
        response_synthesizer = get_response_synthesizer(response_mode=GetResponseMode(requestDTO.Mode), text_qa_template=qa_template)
        
        # assemble query engine, o recupere l'index grace au retriver et aussi le mode de reponse du "ResponseMode.TREE_SUMMARIZE" via response_synthesizer 
        
        query_retreiver = RetrieverQueryEngine(retriever=retriever, response_synthesizer=response_synthesizer)

        # Partie permettant de créer la réponse

        #query_engine = vector_index.as_query_engine(text_qa_template=qa_template)
        #gpt_result = query_engine.query(requestDTO.Prompt)

        gpt_result = query_retreiver.query(requestDTO.Prompt)

        resultDTO = ServiceQueryResponse.ServiceQueryResponseResultDTO(gpt_result.response, [])
        
        for item in gpt_result.source_nodes:
            node = ServiceQueryResponse.ServiceQueryResponseNodeDTO(item.node.extra_info.get("file_name"), item.node.extra_info.get("page_label"), item.node.text, item.score)
            resultDTO.Nodes.append(node)

        # Construction de la réponse

        responseDTO = ServiceQueryResponse.ServiceQueryResponseDTO(False, None, resultDTO)

        # Terminée, on envoi la réponse définitive

        return GenerateQueryResponse(requestDTO, responseDTO), 200
    
    except Exception as error:

        return str(error), 400
W
K
17 comments
Hi, Did you touch your vector store in between? or maybe changed code here or there?
Since you are starting after so many days, if the data is not much I would suggest re-indexing once
so the index could be like corrupted?
and yes i did not change the code
there are many documents in the indexes should i re-index them anyway?
If there are many, Then lets try creating a retriever first
see if the retriever is able to fetch soemthing based on your query
if not then we can be sure that there is something wrong in the vector store
I put the retriever like this :
Plain Text
        retriever = VectorIndexRetriever(
            index=index                      
        )


and print it to see what it contains :
No I mean try to retrieve something like
Plain Text
response = retriever.retrieve("Query here")

print(response)
it return erro 400
i put it like this and it return me this :
Attachments
image.png
image.png
So maybe there is some issues in your vector store
did the vector change in the last version or not? because i was checking that and i don't see something different in how to use/call it
You can try updating the deps and then try again
maybe it starts working and you dont have to index again
okay thanks for the help ^^
Add a reply
Sign up and join the conversation on Discord