JSAV commited on
Commit
05778fb
1 Parent(s): db2cb65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -23,17 +23,17 @@ def res(prompt, historial):
23
 
24
  return respuesta, historial
25
 
26
- def respond(message, chat_history):
27
- bot_message = " ".join([m for m,_ in chat_history]+[message])
 
 
 
 
28
  chat_history.append((message, bot_message))
29
- return "", chat_history
30
 
31
- def history(chatbot):
32
- text = "\n\n".join([f"**Usuario**: {m}\n **Chatbot**: {r}" for m,r in chatbot])
33
- return text
34
 
35
  botImg='https://lagunaai-my.sharepoint.com/personal/juanariasv_lagunaai_onmicrosoft_com/Documents/output-onlinepngtools.png'
36
-
37
  with gr.Blocks() as demo:
38
  chatbot = gr.Chatbot(height=150,avatar_images=(None,botImg)) #just to fit the notebook
39
  with gr.Row():
@@ -50,10 +50,10 @@ with gr.Blocks() as demo:
50
  upload.size="sm"
51
  pedido=gr.Button("Validar pedido")
52
  pedido.size="sm"
53
-
54
  #history_button = gr.Button("Show history")
55
- btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
56
- msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) #Press enter to submit
57
  #history_box = gr.Textbox()
58
  #history_button.click(history, inputs=chatbot, outputs=history_box)
59
  gr.close_all()
 
23
 
24
  return respuesta, historial
25
 
26
+ import gradio as gr
27
+
28
+ def respond(message, chat_history, history):
29
+ print(history,type(history))
30
+ response= res(message,history)
31
+ bot_message = response[0]
32
  chat_history.append((message, bot_message))
33
+ return "", chat_history,response[1]
34
 
 
 
 
35
 
36
  botImg='https://lagunaai-my.sharepoint.com/personal/juanariasv_lagunaai_onmicrosoft_com/Documents/output-onlinepngtools.png'
 
37
  with gr.Blocks() as demo:
38
  chatbot = gr.Chatbot(height=150,avatar_images=(None,botImg)) #just to fit the notebook
39
  with gr.Row():
 
50
  upload.size="sm"
51
  pedido=gr.Button("Validar pedido")
52
  pedido.size="sm"
53
+ history=gr.JSON(value="[]",visible=False)
54
  #history_button = gr.Button("Show history")
55
+ btn.click(respond, inputs=[msg, chatbot,history], outputs=[msg, chatbot,history])
56
+ msg.submit(respond, inputs=[msg, chatbot,history], outputs=[msg, chatbot,history]) #Press enter to submit
57
  #history_box = gr.Textbox()
58
  #history_button.click(history, inputs=chatbot, outputs=history_box)
59
  gr.close_all()