prashantmatlani commited on
Commit
dbe5ee2
·
1 Parent(s): 5e849b8

updated chat history display

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -76,10 +76,17 @@ with gr.Blocks() as demo:
76
 
77
  def bot_response(message, history, chat_id):
78
  user_content = message["text"]
 
 
 
 
 
 
79
  history.append({"role": "user", "content": user_content})
80
  history.append({"role": "assistant", "content": ""})
81
 
82
- for partial_resp in chat_function(message, history[:-1]):
 
83
  history[-1]["content"] = partial_resp
84
  yield history
85
 
 
76
 
77
  def bot_response(message, history, chat_id):
78
  user_content = message["text"]
79
+
80
+ # 1. Pass a CLEAN copy of the historical conversation *before* appending new turns
81
+ # This ensures core_logic gets a proper history trail without duplication.
82
+ clean_history_snapshot = list(history)
83
+
84
+ # 2. Now prepare the live local UI array for streaming feedback
85
  history.append({"role": "user", "content": user_content})
86
  history.append({"role": "assistant", "content": ""})
87
 
88
+ # 3. Run the generator using your clean background state snapshot
89
+ for partial_resp in chat_function(message, clean_history_snapshot):
90
  history[-1]["content"] = partial_resp
91
  yield history
92