Phoenix21 commited on
Commit
01e8804
·
verified ·
1 Parent(s): 3e00622

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -7,6 +7,11 @@ def chat_interface_fn(message, history, session_id):
7
  'session_id' is used to store conversation across turns.
8
  Deduplicates consecutive repeated Q&A pairs to avoid repetition.
9
  """
 
 
 
 
 
10
  # 1) Get answer from the session-based memory pipeline
11
  answer = run_with_session_memory(message, session_id)
12
 
@@ -18,7 +23,8 @@ def chat_interface_fn(message, history, session_id):
18
  # 3) Convert history to message dictionaries for display
19
  message_dicts = []
20
  for msg in history:
21
- message_dicts.append(msg) # Directly append the dictionary
 
22
 
23
  # Return the message dicts and updated history
24
  return message_dicts, history
 
7
  'session_id' is used to store conversation across turns.
8
  Deduplicates consecutive repeated Q&A pairs to avoid repetition.
9
  """
10
+ # Ensure history is a list of dictionaries
11
+ if history and isinstance(history[0], tuple):
12
+ print("DEBUG: Converting history from tuple format to dictionary format.")
13
+ history = [{"role": "user", "content": h[0]}, {"role": "assistant", "content": h[1]} for h in history]
14
+
15
  # 1) Get answer from the session-based memory pipeline
16
  answer = run_with_session_memory(message, session_id)
17
 
 
23
  # 3) Convert history to message dictionaries for display
24
  message_dicts = []
25
  for msg in history:
26
+ # Ensure the message format is correct: it should always be a dictionary
27
+ message_dicts.append(msg)
28
 
29
  # Return the message dicts and updated history
30
  return message_dicts, history