Spaces:
Running
Running
Update interface.py
Browse files- interface.py +16 -12
interface.py
CHANGED
|
@@ -47,27 +47,31 @@ def criar_interface():
|
|
| 47 |
)
|
| 48 |
enviar_btn = gr.Button("Enviar", variant="primary")
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
yield
|
|
|
|
|
|
|
| 57 |
resposta_final = responder_como_aldo(user_msg, modelo)
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
|
| 61 |
enviar_btn.click(
|
| 62 |
fn=responder,
|
| 63 |
-
inputs=[
|
| 64 |
outputs=[chatbot, user_input],
|
| 65 |
show_progress=True
|
| 66 |
)
|
| 67 |
|
| 68 |
user_input.submit(
|
| 69 |
fn=responder,
|
| 70 |
-
inputs=[
|
| 71 |
outputs=[chatbot, user_input],
|
| 72 |
show_progress=True
|
| 73 |
)
|
|
@@ -115,4 +119,4 @@ def criar_interface():
|
|
| 115 |
return interface
|
| 116 |
|
| 117 |
def configurar_interface():
|
| 118 |
-
return criar_interface()
|
|
|
|
| 47 |
)
|
| 48 |
enviar_btn = gr.Button("Enviar", variant="primary")
|
| 49 |
|
| 50 |
+
def responder(chat_history, user_msg, modelo):
|
| 51 |
+
if not user_msg.strip():
|
| 52 |
+
return chat_history, ""
|
| 53 |
+
|
| 54 |
+
# Adiciona a mensagem do usuário e uma resposta temporária
|
| 55 |
+
chat_history = chat_history + [[user_msg, "Dr. Aldo Henrique está digitando..."]]
|
| 56 |
+
yield chat_history, ""
|
| 57 |
+
|
| 58 |
+
# Gera a resposta real
|
| 59 |
resposta_final = responder_como_aldo(user_msg, modelo)
|
| 60 |
+
|
| 61 |
+
# Atualiza com a resposta final
|
| 62 |
+
chat_history[-1][1] = resposta_final
|
| 63 |
+
yield chat_history, ""
|
| 64 |
|
| 65 |
enviar_btn.click(
|
| 66 |
fn=responder,
|
| 67 |
+
inputs=[chatbot, user_input, modelo_select],
|
| 68 |
outputs=[chatbot, user_input],
|
| 69 |
show_progress=True
|
| 70 |
)
|
| 71 |
|
| 72 |
user_input.submit(
|
| 73 |
fn=responder,
|
| 74 |
+
inputs=[chatbot, user_input, modelo_select],
|
| 75 |
outputs=[chatbot, user_input],
|
| 76 |
show_progress=True
|
| 77 |
)
|
|
|
|
| 119 |
return interface
|
| 120 |
|
| 121 |
def configurar_interface():
|
| 122 |
+
return criar_interface()
|