IDAgents Developer commited on
Commit
865930f
·
1 Parent(s): cc66b1b

Fix deployed chat panel format conversion for Gradio 4.20.0

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -2024,7 +2024,9 @@ def build_ui():
2024
  # Prevent tool invocation on empty/whitespace input (e.g., initial greeting or agent selection)
2025
  if user_text is None or not str(user_text).strip():
2026
  # Just return the current history, do not invoke any tool
2027
- return histories.get(agent_name, []), histories, user_text or ""
 
 
2028
 
2029
  # --- IPC dynamic requirements integration ---
2030
  ipc_tool_triggered = False
@@ -2266,12 +2268,14 @@ def build_ui():
2266
  else:
2267
  final_history, updated_histories, cleared_input, invocation_log = chatpanel_handle(agent_name, user_text, histories)
2268
  challenger_info = None
2269
- return final_history, updated_histories, cleared_input, invocation_log
 
2270
  except Exception:
2271
  # fallback to old behavior if error
2272
  final_history, updated_histories, cleared_input, invocation_log = chatpanel_handle(agent_name, user_text, histories)
2273
  challenger_info = None
2274
- return final_history, updated_histories, cleared_input, invocation_log
 
2275
  # Update histories
2276
  updated_histories = histories.copy()
2277
  updated_histories[agent_name] = final_history
@@ -2295,7 +2299,10 @@ def build_ui():
2295
  # If challenger is not enabled, do not show the markdown at all
2296
  elif not challenger_enabled:
2297
  challenger_md = ""
2298
- return final_history, updated_histories, "", invocation_log, challenger_md
 
 
 
2299
 
2300
  chat_send.click(
2301
  fn=chatpanel_handle_with_dynamic_vars,
 
2024
  # Prevent tool invocation on empty/whitespace input (e.g., initial greeting or agent selection)
2025
  if user_text is None or not str(user_text).strip():
2026
  # Just return the current history, do not invoke any tool
2027
+ current_history = histories.get(agent_name, [])
2028
+ gradio_history = convert_messages_for_gradio(current_history)
2029
+ return gradio_history, histories, user_text or ""
2030
 
2031
  # --- IPC dynamic requirements integration ---
2032
  ipc_tool_triggered = False
 
2268
  else:
2269
  final_history, updated_histories, cleared_input, invocation_log = chatpanel_handle(agent_name, user_text, histories)
2270
  challenger_info = None
2271
+ gradio_history = convert_messages_for_gradio(final_history)
2272
+ return gradio_history, updated_histories, cleared_input, invocation_log
2273
  except Exception:
2274
  # fallback to old behavior if error
2275
  final_history, updated_histories, cleared_input, invocation_log = chatpanel_handle(agent_name, user_text, histories)
2276
  challenger_info = None
2277
+ gradio_history = convert_messages_for_gradio(final_history)
2278
+ return gradio_history, updated_histories, cleared_input, invocation_log
2279
  # Update histories
2280
  updated_histories = histories.copy()
2281
  updated_histories[agent_name] = final_history
 
2299
  # If challenger is not enabled, do not show the markdown at all
2300
  elif not challenger_enabled:
2301
  challenger_md = ""
2302
+
2303
+ # Convert to Gradio format before returning
2304
+ gradio_history = convert_messages_for_gradio(final_history)
2305
+ return gradio_history, updated_histories, "", invocation_log, challenger_md
2306
 
2307
  chat_send.click(
2308
  fn=chatpanel_handle_with_dynamic_vars,