OuroborosM commited on
Commit
4938fd8
·
1 Parent(s): b309c40

update algo with then

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -765,6 +765,24 @@ def retry(history3):
765
  print("chathmi3 error:", e)
766
  # yield chathmi3(last_request, chatbot_history)
767
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
768
  with gr.Blocks() as demo:
769
  # gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
770
  # main = gr.ChatInterface(
@@ -825,8 +843,10 @@ with gr.Blocks() as demo:
825
  # upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
826
  clear_button.click(clearall, None, chatbot)
827
  retry_button.click(retry, chatbot, chatbot)
828
- inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot])
829
- stop_button.click(read_logs, None, logs, cancels=[inf1])
 
 
830
  upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
831
  agentchoice.change(SetAgent, agentchoice, None)
832
  frash_logs.click(read_logs, None, logs)
 
765
  print("chathmi3 error:", e)
766
  # yield chathmi3(last_request, chatbot_history)
767
 
768
+ def display_input(message, history2):
769
+ global last_request
770
+ print("Input Message:", message)
771
+ last_request = message
772
+ history2 = history2 + [(message, None)]
773
+ return history2
774
+
775
+ def Inference_Agent(history_inf):
776
+ global last_request
777
+ message = last_request
778
+ try:
779
+ response = agent.run(message)
780
+ time.sleep(0.1)
781
+ history_inf = history_inf + [(None, response)]
782
+ return history_inf
783
+ except Exception as e:
784
+ print("error:", e)
785
+
786
  with gr.Blocks() as demo:
787
  # gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
788
  # main = gr.ChatInterface(
 
843
  # upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
844
  clear_button.click(clearall, None, chatbot)
845
  retry_button.click(retry, chatbot, chatbot)
846
+ # inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot])
847
+ inf2 = inputtext.submit(display_input, [inputtext, chatbot], chatbot).\
848
+ then(Inference_Agent, chatbot, chatbot)
849
+ stop_button.click(read_logs, None, logs, cancels=[inf2])
850
  upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
851
  agentchoice.change(SetAgent, agentchoice, None)
852
  frash_logs.click(read_logs, None, logs)