kavansaun commited on
Commit
3c5842b
·
verified ·
1 Parent(s): ff5890d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -35,9 +35,11 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
35
  repo.create_file(filename, "Saving" + filename, "")
36
 
37
  return gr.TextArea(new_id,visible=False) # Returning the "TextArea" object with what we want. Set visible to True if you want the id to appear when its made.
38
-
39
- def predict_prompt(inputs, user_id): # This function creates a response for the chatbot to respond with.
40
  user_dictionary[user_id].append({"role": "user", "content": inputs}) # This adds the input from the user and saves it to the history before we do anything else.
 
 
41
 
42
  time.sleep(5) # This pauses the function for the alloted amount of time (ex: time.sleep(5) -> pause for 5 seconds) *this doesnt account for the time it takes for the bot to create a response, so the bots overall response time will be noticably higher than the amount of time you put in*
43
 
@@ -81,6 +83,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
81
  Chatbot = gr.Chatbot(label="Anonymous User",layout=['bubble']) # Creating a gradio-chatbot User Interface with the label "Anonymous User".
82
 
83
  txt = gr.Textbox(show_label=False, placeholder = initial_message,container=False)
 
84
  txt.submit(predict_prompt, [txt, user_id], Chatbot) # Adding the messages into the row with gradio.
85
 
86
  chatblock.launch() # launch!
 
35
  repo.create_file(filename, "Saving" + filename, "")
36
 
37
  return gr.TextArea(new_id,visible=False) # Returning the "TextArea" object with what we want. Set visible to True if you want the id to appear when its made.
38
+
39
+ def user_prompt(inputs):
40
  user_dictionary[user_id].append({"role": "user", "content": inputs}) # This adds the input from the user and saves it to the history before we do anything else.
41
+
42
+ def predict_prompt(inputs, user_id): # This function creates a response for the chatbot to respond with.
43
 
44
  time.sleep(5) # This pauses the function for the alloted amount of time (ex: time.sleep(5) -> pause for 5 seconds) *this doesnt account for the time it takes for the bot to create a response, so the bots overall response time will be noticably higher than the amount of time you put in*
45
 
 
83
  Chatbot = gr.Chatbot(label="Anonymous User",layout=['bubble']) # Creating a gradio-chatbot User Interface with the label "Anonymous User".
84
 
85
  txt = gr.Textbox(show_label=False, placeholder = initial_message,container=False)
86
+ txt.submit(user_prompt,txt)
87
  txt.submit(predict_prompt, [txt, user_id], Chatbot) # Adding the messages into the row with gradio.
88
 
89
  chatblock.launch() # launch!