Tonic commited on
Commit
f71aa87
1 Parent(s): c0ab3b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
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
- # Check if the user_message is not a special command
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)