Update app.py
Browse files
app.py
CHANGED
|
@@ -87,14 +87,22 @@ if __name__ == "__main__":
|
|
| 87 |
return agent.update_parameters(seed=seed)
|
| 88 |
|
| 89 |
# ✅ FIXED: retry must return, not yield
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
# ===== Build Gradio Interface =====
|
| 100 |
with gr.Blocks(css=css) as demo:
|
|
|
|
| 87 |
return agent.update_parameters(seed=seed)
|
| 88 |
|
| 89 |
# ✅ FIXED: retry must return, not yield
|
| 90 |
+
def handle_retry(history, retry_data, temperature, max_new_tokens, max_tokens, multi_agent, conversation, max_round):
|
| 91 |
+
update_seed()
|
| 92 |
+
new_history = history[:retry_data.index]
|
| 93 |
+
previous_prompt = history[retry_data.index]["content"]
|
| 94 |
+
|
| 95 |
+
# ✅ This MUST return, not yield
|
| 96 |
+
result = agent.run_gradio_chat(
|
| 97 |
+
new_history + [{"role": "user", "content": previous_prompt}],
|
| 98 |
+
temperature, max_new_tokens, max_tokens, multi_agent, conversation, max_round
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
# If your agent returns a generator, consume it into a list or string
|
| 102 |
+
if hasattr(result, "__iter__") and not isinstance(result, (str, dict, list)):
|
| 103 |
+
result = list(result)
|
| 104 |
+
|
| 105 |
+
return result
|
| 106 |
|
| 107 |
# ===== Build Gradio Interface =====
|
| 108 |
with gr.Blocks(css=css) as demo:
|