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:
# 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