Chris4K commited on
Commit
a7a26f6
·
verified ·
1 Parent(s): 8804244

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -2030,7 +2030,17 @@ def create_gradio_interface():
2030
  ], f, indent=2)
2031
  except Exception as e:
2032
  print(f"[WARN] Could not persist KPI snapshots: {e}")
2033
- return history, thinking
 
 
 
 
 
 
 
 
 
 
2034
 
2035
  msg.submit(respond, [msg, chatbot], [chatbot, thinking_box])
2036
  send_btn.click(respond, [msg, chatbot], [chatbot, thinking_box])
 
2030
  ], f, indent=2)
2031
  except Exception as e:
2032
  print(f"[WARN] Could not persist KPI snapshots: {e}")
2033
+ # Convert history to Gradio Chatbot format: list of [user, assistant] pairs
2034
+ formatted_history = []
2035
+ temp = []
2036
+ for h in history:
2037
+ if h["role"] == "user":
2038
+ temp = [h["content"]]
2039
+ elif h["role"] == "assistant" and temp:
2040
+ temp.append(h["content"])
2041
+ formatted_history.append(temp)
2042
+ temp = []
2043
+ return formatted_history, thinking
2044
 
2045
  msg.submit(respond, [msg, chatbot], [chatbot, thinking_box])
2046
  send_btn.click(respond, [msg, chatbot], [chatbot, thinking_box])