prashantmatlani commited on
Commit
8200f63
·
1 Parent(s): e417ea9

fixed conversation initialization in api_server.py

Browse files
Files changed (1) hide show
  1. api_server.py +7 -5
api_server.py CHANGED
@@ -188,11 +188,13 @@ def chat(req: ChatRequest, background_tasks: BackgroundTasks):
188
  # ✅ Store initial query
189
  if not state.initial_query and not message.startswith("__agent__:"):
190
  #state.initial_query = message
191
- state.initial_query = next(
192
- (m["content"] for m in data.get("history", []) if m["role"] == "client"),
193
- ""
194
- ) # improve initial query restore
195
-
 
 
196
 
197
  print("\n📥 USER MESSAGE:", message)
198
 
 
188
  # ✅ Store initial query
189
  if not state.initial_query and not message.startswith("__agent__:"):
190
  #state.initial_query = message
191
+ if state.history:
192
+ state.initial_query = next(
193
+ (m["content"] for m in data.get("history", []) if m["role"] == "client"),
194
+ ""
195
+ ) # improve initial query restore
196
+ else:
197
+ state.initial_query = message
198
 
199
  print("\n📥 USER MESSAGE:", message)
200