Commit
·
b78f40d
1
Parent(s):
bb8f6fb
v2
Browse files
app.py
CHANGED
|
@@ -156,9 +156,9 @@ def run_crewai_process(user_query, model, temperature):
|
|
| 156 |
yield agent_thoughts, final_answer_chat, generated_code, execution_output, generated_plot_path
|
| 157 |
return # Exit the generator
|
| 158 |
|
| 159 |
-
# Format for Gradio Chatbot (list of dictionaries
|
| 160 |
final_answer_chat = [
|
| 161 |
-
{"role": "user", "content": user_query},
|
| 162 |
{"role": "assistant", "content": "Code generation complete. See the 'Generated Code' box. Attempting to execute code..."}
|
| 163 |
]
|
| 164 |
yield agent_thoughts, final_answer_chat, generated_code, execution_output, generated_plot_path
|
|
@@ -213,11 +213,13 @@ def run_crewai_process(user_query, model, temperature):
|
|
| 213 |
|
| 214 |
# Update final answer chat to reflect execution attempt
|
| 215 |
final_answer_chat = [
|
| 216 |
-
{"role": "user", "content": user_query},
|
| 217 |
{"role": "assistant", "content": "Code execution finished. See 'Execution Output'."}
|
| 218 |
]
|
| 219 |
if generated_plot_path:
|
| 220 |
final_answer_chat.append({"role": "assistant", "content": "Plot generated successfully. See 'Generated Plot'."})
|
|
|
|
|
|
|
| 221 |
|
| 222 |
yield agent_thoughts, final_answer_chat, generated_code, execution_output, generated_plot_path
|
| 223 |
|
|
@@ -225,8 +227,12 @@ def run_crewai_process(user_query, model, temperature):
|
|
| 225 |
# If an error occurs during CrewAI process, return the error message
|
| 226 |
traceback_str = traceback.format_exc()
|
| 227 |
agent_thoughts += f"\nAn error occurred during CrewAI process: {e}\n{traceback_str}"
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
finally:
|
| 232 |
# Restore original stdout
|
|
|
|
| 156 |
yield agent_thoughts, final_answer_chat, generated_code, execution_output, generated_plot_path
|
| 157 |
return # Exit the generator
|
| 158 |
|
| 159 |
+
# Format for Gradio Chatbot (list of dictionaries with 'role' and 'content' keys only)
|
| 160 |
final_answer_chat = [
|
| 161 |
+
{"role": "user", "content": str(user_query)},
|
| 162 |
{"role": "assistant", "content": "Code generation complete. See the 'Generated Code' box. Attempting to execute code..."}
|
| 163 |
]
|
| 164 |
yield agent_thoughts, final_answer_chat, generated_code, execution_output, generated_plot_path
|
|
|
|
| 213 |
|
| 214 |
# Update final answer chat to reflect execution attempt
|
| 215 |
final_answer_chat = [
|
| 216 |
+
{"role": "user", "content": str(user_query)},
|
| 217 |
{"role": "assistant", "content": "Code execution finished. See 'Execution Output'."}
|
| 218 |
]
|
| 219 |
if generated_plot_path:
|
| 220 |
final_answer_chat.append({"role": "assistant", "content": "Plot generated successfully. See 'Generated Plot'."})
|
| 221 |
+
else:
|
| 222 |
+
final_answer_chat.append({"role": "assistant", "content": "No plot was generated. Check the execution output for details."})
|
| 223 |
|
| 224 |
yield agent_thoughts, final_answer_chat, generated_code, execution_output, generated_plot_path
|
| 225 |
|
|
|
|
| 227 |
# If an error occurs during CrewAI process, return the error message
|
| 228 |
traceback_str = traceback.format_exc()
|
| 229 |
agent_thoughts += f"\nAn error occurred during CrewAI process: {e}\n{traceback_str}"
|
| 230 |
+
error_message = f"An error occurred during CrewAI process: {e}"
|
| 231 |
+
final_answer_chat = [
|
| 232 |
+
{"role": "user", "content": str(user_query)},
|
| 233 |
+
{"role": "assistant", "content": error_message}
|
| 234 |
+
]
|
| 235 |
+
yield agent_thoughts, final_answer_chat, generated_code, execution_output, generated_plot_path
|
| 236 |
|
| 237 |
finally:
|
| 238 |
# Restore original stdout
|