Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def respond(message, chat_history):
|
4 |
+
bot_message = " ".join([m for m,_ in chat_history]+[message])
|
5 |
+
chat_history.append((message, bot_message))
|
6 |
+
return "", chat_history
|
7 |
|
8 |
+
def history(chatbot):
|
9 |
+
text = "\n\n".join([f"**Usuario**: {m}\n **Chatbot**: {r}" for m,r in chatbot])
|
10 |
+
return text
|
11 |
+
|
12 |
+
botImg='https://lagunaai-my.sharepoint.com/personal/juanariasv_lagunaai_onmicrosoft_com/Documents/output-onlinepngtools.png'
|
13 |
+
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
chatbot = gr.Chatbot(height=150,avatar_images=(None,botImg)) #just to fit the notebook
|
16 |
+
with gr.Row():
|
17 |
+
with gr.Column():
|
18 |
+
msg = gr.Textbox(show_label=False)
|
19 |
+
with gr.Column():
|
20 |
+
with gr.Row():
|
21 |
+
btn = gr.Button("➤")
|
22 |
+
btn.size="sm"
|
23 |
+
clear = gr.ClearButton(components=[msg, chatbot], value="🔄")
|
24 |
+
clear.size="sm"
|
25 |
+
with gr.Row():
|
26 |
+
upload=gr.UploadButton("Cargar comprobante 📁", file_types=["image"])
|
27 |
+
upload.size="sm"
|
28 |
+
pedido=gr.Button("Validar pedido")
|
29 |
+
pedido.size="sm"
|
30 |
+
|
31 |
+
#history_button = gr.Button("Show history")
|
32 |
+
btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
33 |
+
msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) #Press enter to submit
|
34 |
+
#history_box = gr.Textbox()
|
35 |
+
#history_button.click(history, inputs=chatbot, outputs=history_box)
|
36 |
+
gr.close_all()
|
37 |
+
demo.launch()
|