Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -72,20 +72,21 @@ import os
|
|
72 |
|
73 |
|
74 |
# Function to get bot response
|
75 |
-
def format_prompt(state, bot_index, character_name, character_description):
|
76 |
if character_name is None or character_name.strip() == "":
|
77 |
character_name = "Ryan"
|
78 |
if character_description is None or character_description.strip() == "":
|
79 |
character_description = "Ryan is a college student who is always willing to help. He knows a lot about math and coding."
|
|
|
|
|
80 |
|
81 |
-
prompt = f"{character_description}
|
82 |
for message in state["history"][bot_index]:
|
83 |
if message['role'] == 'user':
|
84 |
-
prompt += f"
|
85 |
else:
|
86 |
-
prompt += f"{character_name}: {message['content']}
|
87 |
-
prompt += f"{character_name}:
|
88 |
-
print(prompt)
|
89 |
return prompt
|
90 |
import aiohttp
|
91 |
import asyncio
|
|
|
72 |
|
73 |
|
74 |
# Function to get bot response
|
75 |
+
def format_prompt(state, bot_index, character_name, character_description, user_name):
|
76 |
if character_name is None or character_name.strip() == "":
|
77 |
character_name = "Ryan"
|
78 |
if character_description is None or character_description.strip() == "":
|
79 |
character_description = "Ryan is a college student who is always willing to help. He knows a lot about math and coding."
|
80 |
+
if user_name is None or user_name.strip() == "":
|
81 |
+
user_name = "You"
|
82 |
|
83 |
+
prompt = f"<|im_start|>system {character_description}<|im_end|>\n"
|
84 |
for message in state["history"][bot_index]:
|
85 |
if message['role'] == 'user':
|
86 |
+
prompt += f"<|im_start|>user {user_name}: {message['content']}<|im_end|>\n"
|
87 |
else:
|
88 |
+
prompt += f"<|im_start|>assistant {character_name}: {message['content']}<|im_end|>\n"
|
89 |
+
prompt += f"<|im_start|>assistant {character_name}:"
|
|
|
90 |
return prompt
|
91 |
import aiohttp
|
92 |
import asyncio
|