Add error string when error
Browse files- actions.py +15 -3
- app.py +0 -1
actions.py
CHANGED
@@ -68,6 +68,7 @@ def execute_task(task_id: int, active_index: int, error_value, *args):
|
|
68 |
# If there is an undefined variable referenced, HighlightedText will signal the error.
|
69 |
undefined_vars = prompt_vars - vars_in_scope.keys()
|
70 |
if len(undefined_vars) > 0:
|
|
|
71 |
return outputs + [
|
72 |
gr.HighlightedText.update(
|
73 |
value=[
|
@@ -81,6 +82,17 @@ def execute_task(task_id: int, active_index: int, error_value, *args):
|
|
81 |
]
|
82 |
|
83 |
formatted_input = task_input.format(**vars_in_scope)
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
# If there is an undefined variable referenced, HighlightedText will signal the error.
|
69 |
undefined_vars = prompt_vars - vars_in_scope.keys()
|
70 |
if len(undefined_vars) > 0:
|
71 |
+
outputs[active_index] = "ERROR"
|
72 |
return outputs + [
|
73 |
gr.HighlightedText.update(
|
74 |
value=[
|
|
|
82 |
]
|
83 |
|
84 |
formatted_input = task_input.format(**vars_in_scope)
|
85 |
+
try:
|
86 |
+
# Task logic gets inserted into the right index
|
87 |
+
outputs[active_index] = all_tasks[task_id].execute(
|
88 |
+
active_index, formatted_input
|
89 |
+
)
|
90 |
+
return outputs + [error_update]
|
91 |
+
except Exception as e:
|
92 |
+
outputs[active_index] = "ERROR"
|
93 |
+
return outputs + [
|
94 |
+
gr.HighlightedText.update(
|
95 |
+
value=[(str(e), "ERROR")],
|
96 |
+
visible=True,
|
97 |
+
)
|
98 |
+
]
|
app.py
CHANGED
@@ -46,7 +46,6 @@ with gr.Blocks() as demo:
|
|
46 |
inputs=[],
|
47 |
outputs=[error_message],
|
48 |
)
|
49 |
-
|
50 |
prev_tasks = []
|
51 |
for i, task in all_tasks.items():
|
52 |
execution_event = execution_event.then(
|
|
|
46 |
inputs=[],
|
47 |
outputs=[error_message],
|
48 |
)
|
|
|
49 |
prev_tasks = []
|
50 |
for i, task in all_tasks.items():
|
51 |
execution_event = execution_event.then(
|