Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -72,7 +72,7 @@ import os
|
|
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() == "":
|
@@ -81,7 +81,11 @@ def format_prompt(state, bot_index, character_name, character_description, user_
|
|
81 |
user_name = "You"
|
82 |
|
83 |
prompt = f"{character_description}\n"
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
if message['role'] == 'user':
|
86 |
prompt += f"{user_name}: {message['content']}\n"
|
87 |
else:
|
|
|
72 |
|
73 |
|
74 |
# Function to get bot response
|
75 |
+
def format_prompt(state, bot_index, character_name, character_description, user_name, num_messages=5):
|
76 |
if character_name is None or character_name.strip() == "":
|
77 |
character_name = "Ryan"
|
78 |
if character_description is None or character_description.strip() == "":
|
|
|
81 |
user_name = "You"
|
82 |
|
83 |
prompt = f"{character_description}\n"
|
84 |
+
|
85 |
+
# Get the last num_messages messages from the conversation history
|
86 |
+
recent_messages = state["history"][bot_index][-num_messages:]
|
87 |
+
|
88 |
+
for message in recent_messages:
|
89 |
if message['role'] == 'user':
|
90 |
prompt += f"{user_name}: {message['content']}\n"
|
91 |
else:
|