Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,16 +37,20 @@ class FalconChatBot:
|
|
| 37 |
self.system_prompt = system_prompt
|
| 38 |
|
| 39 |
def process_history(self, history):
|
|
|
|
|
|
|
|
|
|
| 40 |
# Filter out special commands from the history
|
| 41 |
filtered_history = []
|
| 42 |
for message in history:
|
| 43 |
user_message = message["user"]
|
| 44 |
assistant_message = message["assistant"]
|
| 45 |
-
|
| 46 |
if not user_message.startswith("Falcon:"):
|
| 47 |
filtered_history.append({"user": user_message, "assistant": assistant_message})
|
| 48 |
return filtered_history
|
| 49 |
|
|
|
|
| 50 |
def predict(self, system_prompt, user_message, assistant_message, history, max_length=500):
|
| 51 |
# Process the history to remove special commands
|
| 52 |
processed_history = self.process_history(history)
|
|
|
|
| 37 |
self.system_prompt = system_prompt
|
| 38 |
|
| 39 |
def process_history(self, history):
|
| 40 |
+
if history is None:
|
| 41 |
+
return []
|
| 42 |
+
|
| 43 |
# Filter out special commands from the history
|
| 44 |
filtered_history = []
|
| 45 |
for message in history:
|
| 46 |
user_message = message["user"]
|
| 47 |
assistant_message = message["assistant"]
|
| 48 |
+
# Check if the user_message is not a special command
|
| 49 |
if not user_message.startswith("Falcon:"):
|
| 50 |
filtered_history.append({"user": user_message, "assistant": assistant_message})
|
| 51 |
return filtered_history
|
| 52 |
|
| 53 |
+
|
| 54 |
def predict(self, system_prompt, user_message, assistant_message, history, max_length=500):
|
| 55 |
# Process the history to remove special commands
|
| 56 |
processed_history = self.process_history(history)
|