kavansaun commited on
Commit
db35bf9
·
verified ·
1 Parent(s): 0105f63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -25,7 +25,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
25
  message_history = [] # Empty list for message history.
26
  user_dictionary.update({new_id:message_history})
27
  instructions = 'Be accommodative or unaccommodative' # Change the message under the apostrophes to change the instructions you want the bot to inhibit.
28
- user_dictionary[new_id].update({"role": "developer", "content": instructions}) # This line adds the instructions to the message history (as a developer) so it will always inhibit the instructions no matter what the user says.
29
 
30
  # Creating a new file with the user id to save the user responses and chat bot responses to the repository
31
  repo = g.get_user().get_repo("CATDATA")
@@ -39,7 +39,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
39
  Chatbot = gr.Chatbot(label="Anonymous User") # Creating a gradio-chatbot User Interface with the label "Anonymous User".
40
 
41
  def predict_prompt(input): # This function creates a response for the chatbot to respond with.
42
- user_dictionary[new_id].update({"role": "user", "content": input}) # This adds the input from the user and saves it to the history before we do anything else.
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
 
@@ -50,7 +50,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
50
 
51
  reply_prompt = create_prompt.choices[0].message.content # Variable for the reply prompt.
52
 
53
- user_dictionary[new_id].update({"role": "assistant", "content": reply_prompt}) # Adds the chatbots response to the history as an "assistant". This is the role commonly used for chatbots.
54
 
55
  response = [(user_dictionary[new_id][i]["content"], user_dictionary[new_id][i+1]["content"]) for i in range(1, len(user_dictionary[new_id])-1, 2)] # Variable for the response
56
 
 
25
  message_history = [] # Empty list for message history.
26
  user_dictionary.update({new_id:message_history})
27
  instructions = 'Be accommodative or unaccommodative' # Change the message under the apostrophes to change the instructions you want the bot to inhibit.
28
+ user_dictionary[new_id].append({"role": "developer", "content": instructions}) # This line adds the instructions to the message history (as a developer) so it will always inhibit the instructions no matter what the user says.
29
 
30
  # Creating a new file with the user id to save the user responses and chat bot responses to the repository
31
  repo = g.get_user().get_repo("CATDATA")
 
39
  Chatbot = gr.Chatbot(label="Anonymous User") # Creating a gradio-chatbot User Interface with the label "Anonymous User".
40
 
41
  def predict_prompt(input): # This function creates a response for the chatbot to respond with.
42
+ user_dictionary[new_id].append({"role": "user", "content": input}) # This adds the input from the user and saves it to the history before we do anything else.
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
 
 
50
 
51
  reply_prompt = create_prompt.choices[0].message.content # Variable for the reply prompt.
52
 
53
+ user_dictionary[new_id].append({"role": "assistant", "content": reply_prompt}) # Adds the chatbots response to the history as an "assistant". This is the role commonly used for chatbots.
54
 
55
  response = [(user_dictionary[new_id][i]["content"], user_dictionary[new_id][i+1]["content"]) for i in range(1, len(user_dictionary[new_id])-1, 2)] # Variable for the response
56