juanmartip95 commited on
Commit
658adc0
1 Parent(s): 9721bd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -19
app.py CHANGED
@@ -28,24 +28,12 @@ def res(prompt, historial):
28
  return respuesta, historial
29
 
30
  def respond(message, chat_history, history):
31
- response = res(message, history)
32
- bot_message = response[0]
33
- chat_history.append((message, bot_message))
34
- upload_list_sharepoint(conversation_id, "Anonymous", message, bot_message)
35
-
36
- # Check if the conversation is over
37
- if "Hasta la vista" in message: # replace with your actual condition
38
- # Get the assistant's last message
39
- last_message = response[1][-1]['content'] # assuming the last message is from the assistant
40
- # Pass the JSON output to the extract_info function
41
- info = extract_info(last_message)
42
- # Use the extracted info
43
- WA(info)
44
-
45
- return "", chat_history, response[1]
46
-
47
-
48
-
49
 
50
  def WA(history):
51
  sendWA("491771675218",history)
@@ -104,7 +92,7 @@ with gr.Blocks(theme=gr.themes.Default(text_size="sm"),css=css) as demo:
104
  history_button = gr.Button("Show history")
105
  btn.click(respond, inputs=[msg, chatbot,history], outputs=[msg, chatbot,history])
106
  msg.submit(respond, inputs=[msg, chatbot,history], outputs=[msg, chatbot,history]) #Press enter to submit
107
- pedido.click(extract_info, inputs=last_message,outputs=pedido)
108
 
109
  clear.click(lambda: None, None, chatbot, queue=False)
110
  history_box = gr.Textbox()
 
28
  return respuesta, historial
29
 
30
  def respond(message, chat_history, history):
31
+ #print(history,type(history))
32
+ response= res(message,history)
33
+ bot_message = response[0]
34
+ chat_history.append((message, bot_message))
35
+ upload_list_sharepoint(conversation_id,"Anonymous",message,bot_message)
36
+ return "", chat_history,response[1]
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  def WA(history):
39
  sendWA("491771675218",history)
 
92
  history_button = gr.Button("Show history")
93
  btn.click(respond, inputs=[msg, chatbot,history], outputs=[msg, chatbot,history])
94
  msg.submit(respond, inputs=[msg, chatbot,history], outputs=[msg, chatbot,history]) #Press enter to submit
95
+ pedido.click(WA, inputs=history,outputs=pedido)
96
 
97
  clear.click(lambda: None, None, chatbot, queue=False)
98
  history_box = gr.Textbox()