Spaces:
Sleeping
Sleeping
IDAgents Developer
commited on
Commit
·
cc66b1b
1
Parent(s):
a9ea169
Fix all reset functions format conversion for Gradio 4.20.0
Browse files
app.py
CHANGED
|
@@ -167,9 +167,10 @@ def reset_chat(agent_json):
|
|
| 167 |
name = agent_data.get("agent_name", "Agent")
|
| 168 |
welcome = f"👋 Hello! I'm {name}. How can I assist you today?"
|
| 169 |
chat_history = [{"role":"assistant","content":welcome}]
|
|
|
|
| 170 |
invocation_log = ""
|
| 171 |
active_children= []
|
| 172 |
-
return
|
| 173 |
|
| 174 |
def load_agent_to_builder(agent_name):
|
| 175 |
if agent_name in agents_config:
|
|
@@ -252,7 +253,9 @@ def load_history(agent_name, histories):
|
|
| 252 |
histories[agent_name] = [
|
| 253 |
{"role":"assistant","content":f"👋 Hello! I'm {agent_name}. How can I help?"}
|
| 254 |
]
|
| 255 |
-
|
|
|
|
|
|
|
| 256 |
|
| 257 |
def chatpanel_handle(agent_name, user_text, histories):
|
| 258 |
"""
|
|
@@ -2325,8 +2328,10 @@ def build_ui():
|
|
| 2325 |
del histories[agent_name]
|
| 2326 |
chat_history = [{"role": "assistant", "content": f"👋 Hello! I'm {agent_name}. How can I help?"}]
|
| 2327 |
histories[agent_name] = chat_history
|
|
|
|
|
|
|
| 2328 |
return (
|
| 2329 |
-
|
| 2330 |
"", "", "", "", "", "", "", "", # stewardship fields cleared (8 fields)
|
| 2331 |
"", "", "", "", "", "", "", "", "", "", # empiric fields cleared (10 fields)
|
| 2332 |
"", "", "", "", "", "", "", "", "", # ipc fields cleared (9 fields)
|
|
@@ -2449,7 +2454,9 @@ def build_ui():
|
|
| 2449 |
chat_history = [{"role":"assistant","content":welcome}]
|
| 2450 |
if name in histories:
|
| 2451 |
del histories[name]
|
| 2452 |
-
|
|
|
|
|
|
|
| 2453 |
|
| 2454 |
reset_button.click(
|
| 2455 |
reset_and_clear_builder_history,
|
|
|
|
| 167 |
name = agent_data.get("agent_name", "Agent")
|
| 168 |
welcome = f"👋 Hello! I'm {name}. How can I assist you today?"
|
| 169 |
chat_history = [{"role":"assistant","content":welcome}]
|
| 170 |
+
gradio_history = convert_messages_for_gradio(chat_history)
|
| 171 |
invocation_log = ""
|
| 172 |
active_children= []
|
| 173 |
+
return gradio_history, "", invocation_log, active_children
|
| 174 |
|
| 175 |
def load_agent_to_builder(agent_name):
|
| 176 |
if agent_name in agents_config:
|
|
|
|
| 253 |
histories[agent_name] = [
|
| 254 |
{"role":"assistant","content":f"👋 Hello! I'm {agent_name}. How can I help?"}
|
| 255 |
]
|
| 256 |
+
# Convert to Gradio format before returning
|
| 257 |
+
gradio_history = convert_messages_for_gradio(histories[agent_name])
|
| 258 |
+
return gradio_history
|
| 259 |
|
| 260 |
def chatpanel_handle(agent_name, user_text, histories):
|
| 261 |
"""
|
|
|
|
| 2328 |
del histories[agent_name]
|
| 2329 |
chat_history = [{"role": "assistant", "content": f"👋 Hello! I'm {agent_name}. How can I help?"}]
|
| 2330 |
histories[agent_name] = chat_history
|
| 2331 |
+
# Convert to Gradio format
|
| 2332 |
+
gradio_history = convert_messages_for_gradio(chat_history)
|
| 2333 |
return (
|
| 2334 |
+
gradio_history, histories, "",
|
| 2335 |
"", "", "", "", "", "", "", "", # stewardship fields cleared (8 fields)
|
| 2336 |
"", "", "", "", "", "", "", "", "", "", # empiric fields cleared (10 fields)
|
| 2337 |
"", "", "", "", "", "", "", "", "", # ipc fields cleared (9 fields)
|
|
|
|
| 2454 |
chat_history = [{"role":"assistant","content":welcome}]
|
| 2455 |
if name in histories:
|
| 2456 |
del histories[name]
|
| 2457 |
+
# Convert to Gradio format
|
| 2458 |
+
gradio_history = convert_messages_for_gradio(chat_history)
|
| 2459 |
+
return gradio_history, gr.update(value="", interactive=True, placeholder="Type your question here…"), [], histories
|
| 2460 |
|
| 2461 |
reset_button.click(
|
| 2462 |
reset_and_clear_builder_history,
|