Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -74,12 +74,15 @@ import os
|
|
74 |
def format_prompt(state, bot_index, character_name, character_description, user_name, num_messages=20):
|
75 |
if character_name is None or character_name.strip() == "":
|
76 |
character_name = "Ryan"
|
|
|
77 |
if character_description is None or character_description.strip() == "":
|
78 |
-
character_description = "Ryan is a college student who is always willing to help. He
|
|
|
79 |
if user_name is None or user_name.strip() == "":
|
80 |
user_name = "You"
|
81 |
-
|
82 |
-
prompt = f"{
|
|
|
83 |
|
84 |
# Get the last num_messages messages from the conversation history
|
85 |
recent_messages = state["history"][bot_index][-num_messages:]
|
@@ -89,7 +92,9 @@ def format_prompt(state, bot_index, character_name, character_description, user_
|
|
89 |
prompt += f"{user_name}: {message['content']}\n"
|
90 |
else:
|
91 |
prompt += f"{character_name}: {message['content']}\n"
|
|
|
92 |
prompt += f"{character_name}:"
|
|
|
93 |
print(prompt)
|
94 |
return prompt
|
95 |
import aiohttp
|
|
|
74 |
def format_prompt(state, bot_index, character_name, character_description, user_name, num_messages=20):
|
75 |
if character_name is None or character_name.strip() == "":
|
76 |
character_name = "Ryan"
|
77 |
+
|
78 |
if character_description is None or character_description.strip() == "":
|
79 |
+
character_description = "Ryan is a friendly and knowledgeable college student who is always willing to help. He has a strong background in math and coding, and enjoys engaging in intellectual discussions on a wide range of topics."
|
80 |
+
|
81 |
if user_name is None or user_name.strip() == "":
|
82 |
user_name = "You"
|
83 |
+
|
84 |
+
prompt = f"The following is a conversation between {user_name} and {character_name}.\n\n"
|
85 |
+
prompt += f"{character_name}'s background:\n{character_description}\n\n"
|
86 |
|
87 |
# Get the last num_messages messages from the conversation history
|
88 |
recent_messages = state["history"][bot_index][-num_messages:]
|
|
|
92 |
prompt += f"{user_name}: {message['content']}\n"
|
93 |
else:
|
94 |
prompt += f"{character_name}: {message['content']}\n"
|
95 |
+
|
96 |
prompt += f"{character_name}:"
|
97 |
+
|
98 |
print(prompt)
|
99 |
return prompt
|
100 |
import aiohttp
|