Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,8 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
|
|
| 27 |
user_dictionary.update({new_id:message_history}) # Add the new id and empty history into the dictionary.
|
| 28 |
instructions = 'First Rule: Act like a human. Second Rule: Choose to be accommodative or unaccommodative' # Change the message under the apostrophes to change the instructions you want the bot to inhibit.
|
| 29 |
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.
|
| 30 |
-
|
|
|
|
| 31 |
# Creating a new file with the new id to save the user responses and the chat bot responses to the repository
|
| 32 |
repo = g.get_user().get_repo("CATDATA")
|
| 33 |
file_type = '.txt'
|
|
@@ -54,7 +55,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
|
|
| 54 |
|
| 55 |
user_dictionary[user_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.
|
| 56 |
|
| 57 |
-
response = [(user_dictionary[user_id][i]["content"], user_dictionary[user_id][i+1]["content"]) for i in range(
|
| 58 |
|
| 59 |
# Repository details
|
| 60 |
repo = g.get_user().get_repo("CATDATA")
|
|
@@ -89,7 +90,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
|
|
| 89 |
)
|
| 90 |
|
| 91 |
# Adding the messages into the row with gradio.
|
| 92 |
-
txt.submit(predict_prompt, [txt, user_id], Chatbot)
|
| 93 |
txt.submit(None, None, txt, js="() => {''}")
|
| 94 |
|
| 95 |
chatblock.launch() # launch!
|
|
|
|
| 27 |
user_dictionary.update({new_id:message_history}) # Add the new id and empty history into the dictionary.
|
| 28 |
instructions = 'First Rule: Act like a human. Second Rule: Choose to be accommodative or unaccommodative' # Change the message under the apostrophes to change the instructions you want the bot to inhibit.
|
| 29 |
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.
|
| 30 |
+
user_dictionary[new_id].append({})
|
| 31 |
+
|
| 32 |
# Creating a new file with the new id to save the user responses and the chat bot responses to the repository
|
| 33 |
repo = g.get_user().get_repo("CATDATA")
|
| 34 |
file_type = '.txt'
|
|
|
|
| 55 |
|
| 56 |
user_dictionary[user_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.
|
| 57 |
|
| 58 |
+
response = [(user_dictionary[user_id][i]["content"], user_dictionary[user_id][i+1]["content"]) for i in range(2, len(user_dictionary[user_id])-2, 2)] # Variable for the response
|
| 59 |
|
| 60 |
# Repository details
|
| 61 |
repo = g.get_user().get_repo("CATDATA")
|
|
|
|
| 90 |
)
|
| 91 |
|
| 92 |
# Adding the messages into the row with gradio.
|
| 93 |
+
txt.submit(predict_prompt, [txt, user_id], Chatbot, show_progress=False)
|
| 94 |
txt.submit(None, None, txt, js="() => {''}")
|
| 95 |
|
| 96 |
chatblock.launch() # launch!
|