Commit
•
268b72d
1
Parent(s):
57293c3
Update app.py
Browse files
app.py
CHANGED
@@ -600,20 +600,25 @@ with gr.Blocks(theme='sudeepshouche/minimalist', css=css) as demo:
|
|
600 |
global final_response
|
601 |
global query
|
602 |
global selected_choices
|
603 |
-
|
|
|
604 |
# Inicializar el historial de chat si está vacío con el mensaje del usuario actual
|
605 |
if not chat_history:
|
606 |
chat_history = [[message, ""]]
|
607 |
else:
|
608 |
# Agregar el mensaje actual al historial de chat
|
609 |
chat_history.append([message, ""])
|
610 |
-
|
611 |
# Resumir los mensajes previos en chat_history_engine
|
612 |
chat_history_engine = summarize_assistant_messages(chat_history_engine)
|
613 |
-
|
|
|
|
|
|
|
614 |
# Engine:
|
615 |
retriever_tools = [tool for choice, tool in choices_with_tools if choice in selected_choices]
|
616 |
-
print("
|
|
|
617 |
# Configuración dinámica de RouterRetriever y engine
|
618 |
retriever = RouterRetriever(
|
619 |
selector=PydanticMultiSelector.from_defaults(
|
@@ -642,21 +647,20 @@ with gr.Blocks(theme='sudeepshouche/minimalist', css=css) as demo:
|
|
642 |
|
643 |
# Generar la respuesta usando el motor de chat
|
644 |
response = chat_engine.stream_chat(message, chat_history=chat_history_engine)
|
645 |
-
|
646 |
# Extraer la información de los metadatos y textos de la respuesta
|
647 |
metadata_info = extraer_informacion_metadata(response, max_results=10)
|
648 |
texts_info = extraer_textos_metadata(response, max_results=10)
|
649 |
-
|
650 |
if metadata_info:
|
651 |
result_metadata = "\n".join(metadata_info)
|
652 |
if texts_info:
|
653 |
result_texts = texts_info
|
654 |
-
|
655 |
# Procesar la respuesta generada y agregarla al historial del chat
|
656 |
for text in response.response_gen:
|
657 |
chat_history[-1][1] += text
|
658 |
-
yield "", chat_history
|
659 |
-
|
660 |
# Guardar la conversación en el dataset
|
661 |
save_to_dataset(message, chat_history[-1][1], "no-ingresado")
|
662 |
|
|
|
600 |
global final_response
|
601 |
global query
|
602 |
global selected_choices
|
603 |
+
global bm_status # Asegúrate de declarar bm_status como global
|
604 |
+
|
605 |
# Inicializar el historial de chat si está vacío con el mensaje del usuario actual
|
606 |
if not chat_history:
|
607 |
chat_history = [[message, ""]]
|
608 |
else:
|
609 |
# Agregar el mensaje actual al historial de chat
|
610 |
chat_history.append([message, ""])
|
611 |
+
|
612 |
# Resumir los mensajes previos en chat_history_engine
|
613 |
chat_history_engine = summarize_assistant_messages(chat_history_engine)
|
614 |
+
|
615 |
+
# Determina si 'retriever_all_tool' está en los retrievers seleccionados y ajusta 'bm_status'
|
616 |
+
bm_status = any(tool is retriever_all_tool for label, tool in choices_with_tools if label in selected_choices)
|
617 |
+
|
618 |
# Engine:
|
619 |
retriever_tools = [tool for choice, tool in choices_with_tools if choice in selected_choices]
|
620 |
+
print("Choice: " + str(retriever_tools))
|
621 |
+
|
622 |
# Configuración dinámica de RouterRetriever y engine
|
623 |
retriever = RouterRetriever(
|
624 |
selector=PydanticMultiSelector.from_defaults(
|
|
|
647 |
|
648 |
# Generar la respuesta usando el motor de chat
|
649 |
response = chat_engine.stream_chat(message, chat_history=chat_history_engine)
|
650 |
+
|
651 |
# Extraer la información de los metadatos y textos de la respuesta
|
652 |
metadata_info = extraer_informacion_metadata(response, max_results=10)
|
653 |
texts_info = extraer_textos_metadata(response, max_results=10)
|
654 |
+
|
655 |
if metadata_info:
|
656 |
result_metadata = "\n".join(metadata_info)
|
657 |
if texts_info:
|
658 |
result_texts = texts_info
|
659 |
+
|
660 |
# Procesar la respuesta generada y agregarla al historial del chat
|
661 |
for text in response.response_gen:
|
662 |
chat_history[-1][1] += text
|
663 |
+
yield "", chat_history
|
|
|
664 |
# Guardar la conversación en el dataset
|
665 |
save_to_dataset(message, chat_history[-1][1], "no-ingresado")
|
666 |
|