geronimo-pericoli
commited on
Commit
•
b9df223
1
Parent(s):
d3b4e27
Update app.py
Browse files
app.py
CHANGED
@@ -481,8 +481,33 @@ table {
|
|
481 |
font-size: x-small !important;
|
482 |
}
|
483 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
with gr.Blocks(theme='sudeepshouche/minimalist', css=css) as demo:
|
485 |
|
|
|
|
|
|
|
|
|
|
|
486 |
def get_ref():
|
487 |
return {mkdn: gr.Markdown(result_metadata), texts: gr.HTML(str(result_texts))}
|
488 |
|
@@ -559,6 +584,7 @@ with gr.Blocks(theme='sudeepshouche/minimalist', css=css) as demo:
|
|
559 |
global result_texts
|
560 |
global final_response
|
561 |
global query
|
|
|
562 |
|
563 |
# Inicializar el historial de chat si está vacío con el mensaje del usuario actual
|
564 |
if not chat_history:
|
@@ -570,6 +596,9 @@ with gr.Blocks(theme='sudeepshouche/minimalist', css=css) as demo:
|
|
570 |
# Resumir los mensajes previos en chat_history_engine
|
571 |
chat_history_engine = summarize_assistant_messages(chat_history_engine)
|
572 |
|
|
|
|
|
|
|
573 |
# Generar la respuesta usando el motor de chat
|
574 |
response = chat_engine.stream_chat(message, chat_history=chat_history_engine)
|
575 |
|
@@ -615,18 +644,9 @@ with gr.Blocks(theme='sudeepshouche/minimalist', css=css) as demo:
|
|
615 |
|
616 |
with gr.Column():
|
617 |
with gr.Accordion(elem_classes="accordion", label="Bases de datos del conocimiento", open=False):
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
###### [3] MANUAL DE NORMAS TÉCNICAS DE CALIDAD
|
622 |
-
###### [4] Resolución 1160 - GMP - 2016
|
623 |
-
###### [5] Resolución 2266 - DECRETO FITOTERAPÉUTICOS - 2004
|
624 |
-
###### [6] Resolución 3619 - GLP - 2013
|
625 |
-
###### [7] Resolución 005107 - FITOTERAPEUTICOS - 2005
|
626 |
-
###### [8] Resolución 3690 - 2016
|
627 |
-
###### [9] Resolución 3157 - 2018
|
628 |
-
###### [10] Preguntas y respuestas Res. 3157 - 2018
|
629 |
-
""")
|
630 |
|
631 |
with gr.Accordion(elem_classes="accordion", label="Referencias", open=True):
|
632 |
mkdn = gr.Markdown()
|
|
|
481 |
font-size: x-small !important;
|
482 |
}
|
483 |
"""
|
484 |
+
|
485 |
+
choices_with_tools = [
|
486 |
+
("[1] Guía BPL", retriever_1_tool),
|
487 |
+
("[2] Guía BPM Medicamentos", retriever_2_tool),
|
488 |
+
("[3] MANUAL DE NORMAS TÉCNICAS DE CALIDAD", retriever_3_tool),
|
489 |
+
("[4] Resolución 1160 - GMP - 2016", retriever_4_tool),
|
490 |
+
# ("[5] Resolución 2266 - DECRETO FITOTERAPÉUTICOS - 2004", retriever_5_tool),
|
491 |
+
("[6] Resolución 3619 - GLP - 2013", retriever_6_tool),
|
492 |
+
("[7] Resolución 005107 - FITOTERAPEUTICOS - 2005", retriever_7_tool),
|
493 |
+
("[8] Resolución 3690 - 2016", retriever_8_tool),
|
494 |
+
("[9] Resolución 3157 - 2018", retriever_9_tool),
|
495 |
+
("[10] Preguntas y respuestas Res. 3157 - 2018", retriever_10_tool),
|
496 |
+
("General", retriever_all),
|
497 |
+
|
498 |
+
]
|
499 |
+
|
500 |
+
# Solo extraer los nombres para mostrarlos en la interfaz
|
501 |
+
selected_choices = [label for label, _ in choices_with_tools]
|
502 |
+
choice_labels = [label for label, _ in choices_with_tools]
|
503 |
+
|
504 |
with gr.Blocks(theme='sudeepshouche/minimalist', css=css) as demo:
|
505 |
|
506 |
+
# Actualizar las choices seleccionadas
|
507 |
+
def update_selected_choices(choices):
|
508 |
+
global selected_choices
|
509 |
+
selected_choices = choices
|
510 |
+
|
511 |
def get_ref():
|
512 |
return {mkdn: gr.Markdown(result_metadata), texts: gr.HTML(str(result_texts))}
|
513 |
|
|
|
584 |
global result_texts
|
585 |
global final_response
|
586 |
global query
|
587 |
+
global selected_choices
|
588 |
|
589 |
# Inicializar el historial de chat si está vacío con el mensaje del usuario actual
|
590 |
if not chat_history:
|
|
|
596 |
# Resumir los mensajes previos en chat_history_engine
|
597 |
chat_history_engine = summarize_assistant_messages(chat_history_engine)
|
598 |
|
599 |
+
# Engine:
|
600 |
+
exec(os.environ.get('engine'))
|
601 |
+
|
602 |
# Generar la respuesta usando el motor de chat
|
603 |
response = chat_engine.stream_chat(message, chat_history=chat_history_engine)
|
604 |
|
|
|
644 |
|
645 |
with gr.Column():
|
646 |
with gr.Accordion(elem_classes="accordion", label="Bases de datos del conocimiento", open=False):
|
647 |
+
# CheckboxGroup para seleccionar bases de datos
|
648 |
+
chx = gr.CheckboxGroup(choices=choice_labels, value=choice_labels, label="Bases de datos del conocimiento")
|
649 |
+
chx.select(fn=update_selected_choices, inputs=chx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
|
651 |
with gr.Accordion(elem_classes="accordion", label="Referencias", open=True):
|
652 |
mkdn = gr.Markdown()
|