Fix execute task
Browse files- actions.py +10 -11
- ai/llm.py +1 -0
- components.py +1 -2
actions.py
CHANGED
@@ -29,7 +29,6 @@ def remove_input(*visibility):
|
|
29 |
|
30 |
|
31 |
def _is_task_row_fully_invisible(row: List[int]) -> bool:
|
32 |
-
print(row)
|
33 |
for visible in row:
|
34 |
if bool(visible):
|
35 |
return False
|
@@ -60,14 +59,12 @@ def add_task(index, *visibility):
|
|
60 |
def remove_task(*visibility):
|
61 |
visibility = list(visibility)
|
62 |
n_avail_tasks = len(Task.AVAILABLE_TASKS)
|
63 |
-
print(visibility, n_avail_tasks)
|
64 |
|
65 |
for i in range(MAX_TASKS):
|
66 |
start_row = i * n_avail_tasks
|
67 |
is_row_invisible = _is_task_row_fully_invisible(
|
68 |
visibility[start_row : start_row + n_avail_tasks]
|
69 |
)
|
70 |
-
print(start_row, start_row + n_avail_tasks, is_row_invisible)
|
71 |
if is_row_invisible:
|
72 |
unchanged_up_to = start_row - n_avail_tasks
|
73 |
return (
|
@@ -82,25 +79,27 @@ def _clear_error():
|
|
82 |
return gr.HighlightedText.update(value=None, visible=False)
|
83 |
|
84 |
|
85 |
-
def execute_task(id_: int, prev_error_value,
|
86 |
"""
|
87 |
Params:
|
88 |
- id_: This will tell us which task to execute.
|
89 |
- prev_error_value: I carry around whether there is an error in the execution, to be displayed at the end.
|
90 |
-
-
|
91 |
-
-
|
92 |
"""
|
93 |
-
|
94 |
-
task_inputs = vars_in_scope[:
|
95 |
-
input_vars = vars_in_scope[
|
96 |
-
task_outputs = vars_in_scope[MAX_INPUTS:]
|
97 |
non_empty_task_inputs = [ti for ti in task_inputs if ti]
|
98 |
|
99 |
# Put all defined variables into a dict, with names (except task inputs)
|
100 |
vars = {
|
101 |
f"{Input.VNAME}{i}": input_ for i, input_ in enumerate(input_vars) if input_
|
102 |
}
|
103 |
-
vars.update(
|
|
|
|
|
104 |
# Get all variables referenced within the task inputs
|
105 |
prompt_vars = {v for ti in non_empty_task_inputs for v in re.findall("{(.*?)}", ti)}
|
106 |
|
|
|
29 |
|
30 |
|
31 |
def _is_task_row_fully_invisible(row: List[int]) -> bool:
|
|
|
32 |
for visible in row:
|
33 |
if bool(visible):
|
34 |
return False
|
|
|
59 |
def remove_task(*visibility):
|
60 |
visibility = list(visibility)
|
61 |
n_avail_tasks = len(Task.AVAILABLE_TASKS)
|
|
|
62 |
|
63 |
for i in range(MAX_TASKS):
|
64 |
start_row = i * n_avail_tasks
|
65 |
is_row_invisible = _is_task_row_fully_invisible(
|
66 |
visibility[start_row : start_row + n_avail_tasks]
|
67 |
)
|
|
|
68 |
if is_row_invisible:
|
69 |
unchanged_up_to = start_row - n_avail_tasks
|
70 |
return (
|
|
|
79 |
return gr.HighlightedText.update(value=None, visible=False)
|
80 |
|
81 |
|
82 |
+
def execute_task(id_: int, prev_error_value, n_task_inputs, *vars_in_scope):
|
83 |
"""
|
84 |
Params:
|
85 |
- id_: This will tell us which task to execute.
|
86 |
- prev_error_value: I carry around whether there is an error in the execution, to be displayed at the end.
|
87 |
+
- n_task_inputs: How many inputs does this task have?
|
88 |
+
- vars_in_scope: All variables in scope. This can be a) input varaibles, b) task inputs or c) previous task outputs.
|
89 |
"""
|
90 |
+
n_task_inputs = int(n_task_inputs)
|
91 |
+
task_inputs = vars_in_scope[:n_task_inputs]
|
92 |
+
input_vars = vars_in_scope[n_task_inputs:MAX_INPUTS]
|
93 |
+
task_outputs = vars_in_scope[n_task_inputs + MAX_INPUTS :]
|
94 |
non_empty_task_inputs = [ti for ti in task_inputs if ti]
|
95 |
|
96 |
# Put all defined variables into a dict, with names (except task inputs)
|
97 |
vars = {
|
98 |
f"{Input.VNAME}{i}": input_ for i, input_ in enumerate(input_vars) if input_
|
99 |
}
|
100 |
+
vars.update(
|
101 |
+
{f"{Task.VNAME}{i}": task_output for i, task_output in enumerate(task_outputs)}
|
102 |
+
)
|
103 |
# Get all variables referenced within the task inputs
|
104 |
prompt_vars = {v for ti in non_empty_task_inputs for v in re.findall("{(.*?)}", ti)}
|
105 |
|
ai/llm.py
CHANGED
@@ -23,6 +23,7 @@ def call(
|
|
23 |
if not temperature:
|
24 |
temperature = TEMPERATURE
|
25 |
|
|
|
26 |
return openai.ChatCompletion.create( # type: ignore
|
27 |
model=model,
|
28 |
messages=messages,
|
|
|
23 |
if not temperature:
|
24 |
temperature = TEMPERATURE
|
25 |
|
26 |
+
print(f"Running OpenAI with :: {locals()}")
|
27 |
return openai.ChatCompletion.create( # type: ignore
|
28 |
model=model,
|
29 |
messages=messages,
|
components.py
CHANGED
@@ -36,7 +36,6 @@ class Component(ABC):
|
|
36 |
self.gr_component = self._render(self._id, self._initial_visibility)
|
37 |
|
38 |
def execute(self, *args):
|
39 |
-
print(f"Executing {self._source} :: {self._id}")
|
40 |
return self._execute(*args)
|
41 |
|
42 |
|
@@ -178,7 +177,7 @@ class Task:
|
|
178 |
|
179 |
def execute(self, *args):
|
180 |
inner_task = self.inner_tasks[self.active_task]
|
181 |
-
print(f"Executing {inner_task._source}
|
182 |
return inner_task.execute(*args)
|
183 |
|
184 |
|
|
|
36 |
self.gr_component = self._render(self._id, self._initial_visibility)
|
37 |
|
38 |
def execute(self, *args):
|
|
|
39 |
return self._execute(*args)
|
40 |
|
41 |
|
|
|
177 |
|
178 |
def execute(self, *args):
|
179 |
inner_task = self.inner_tasks[self.active_task]
|
180 |
+
print(f"Executing {inner_task._source}: {inner_task._id}")
|
181 |
return inner_task.execute(*args)
|
182 |
|
183 |
|