Upload 11 files
Browse files- CoderFlow.py +4 -0
- CoderFlow.yaml +134 -0
- Controller_CoderFlow.py +68 -0
- Controller_CoderFlow.yaml +157 -0
- CtrlExMem_CoderFlow.py +46 -0
- CtrlExMem_CoderFlow.yaml +168 -0
- Planner_CoderFlow.py +63 -0
- Planner_CoderFlow.yaml +135 -0
- UpdatePlanAtomicFlow.py +30 -0
- UpdatePlanAtomicFlow.yaml +9 -0
- __init__.py +19 -0
CoderFlow.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flow_modules.Tachi67.AbstractBossFlowModule import AbstractBossFlow
|
2 |
+
|
3 |
+
class CoderFlow(AbstractBossFlow):
|
4 |
+
pass
|
CoderFlow.yaml
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: CoderFlow
|
2 |
+
description: "A flow used to tackle goals with coding in a step-by-step fashion"
|
3 |
+
|
4 |
+
_target_: Tachi67.CoderFlowModule.CoderFlow.instantiate_from_default_config
|
5 |
+
|
6 |
+
memory_files: ???
|
7 |
+
|
8 |
+
subflows_config:
|
9 |
+
MemoryReading:
|
10 |
+
_target_: Tachi67.MemoryReadingFlowModule.MemoryReadingAtomicFlow.instantiate_from_default_config
|
11 |
+
output_interface:
|
12 |
+
- "plan"
|
13 |
+
- "logs"
|
14 |
+
- "code_library"
|
15 |
+
|
16 |
+
Planner:
|
17 |
+
_target_: Tachi67.CoderFlowModule.Planner_CoderFlow.instantiate_from_default_config
|
18 |
+
subflows_config:
|
19 |
+
Controller:
|
20 |
+
backend:
|
21 |
+
api_infos: ???
|
22 |
+
model_name:
|
23 |
+
openai: gpt-4
|
24 |
+
azure: azure/gpt-4
|
25 |
+
Executor:
|
26 |
+
subflows_config:
|
27 |
+
write_plan:
|
28 |
+
subflows_config:
|
29 |
+
PlanGenerator:
|
30 |
+
backend:
|
31 |
+
api_infos: ???
|
32 |
+
model_name:
|
33 |
+
openai: gpt-4
|
34 |
+
azure: azure/gpt-4
|
35 |
+
|
36 |
+
CtrlExMem:
|
37 |
+
_target_: Tachi67.CoderFlowModule.CtrlExMem_CoderFlow.instantiate_from_default_config
|
38 |
+
subflows_config:
|
39 |
+
Controller:
|
40 |
+
backend:
|
41 |
+
api_infos: ???
|
42 |
+
model_name:
|
43 |
+
openai: gpt-4
|
44 |
+
azure: azure/gpt-4
|
45 |
+
Executor:
|
46 |
+
subflows_config:
|
47 |
+
extend_library:
|
48 |
+
memory_files: ???
|
49 |
+
subflows_config:
|
50 |
+
Planner:
|
51 |
+
subflows_config:
|
52 |
+
Controller:
|
53 |
+
backend:
|
54 |
+
api_infos: ???
|
55 |
+
model_name:
|
56 |
+
openai: gpt-4
|
57 |
+
azure: azure/gpt-4
|
58 |
+
Executor:
|
59 |
+
subflows_config:
|
60 |
+
write_plan:
|
61 |
+
subflows_config:
|
62 |
+
PlanGenerator:
|
63 |
+
backend:
|
64 |
+
api_infos: ???
|
65 |
+
model_name:
|
66 |
+
openai: gpt-4
|
67 |
+
azure: azure/gpt-4
|
68 |
+
CtrlExMem:
|
69 |
+
subflows_config:
|
70 |
+
Controller:
|
71 |
+
backend:
|
72 |
+
api_infos: ???
|
73 |
+
model_name:
|
74 |
+
openai: gpt-4
|
75 |
+
azure: azure/gpt-4
|
76 |
+
Executor:
|
77 |
+
subflows_config:
|
78 |
+
write_code:
|
79 |
+
subflows_config:
|
80 |
+
Controller:
|
81 |
+
backend:
|
82 |
+
api_infos: ???
|
83 |
+
model_name:
|
84 |
+
openai: gpt-4
|
85 |
+
azure: azure/gpt-4
|
86 |
+
Executor:
|
87 |
+
subflows_config:
|
88 |
+
write_code:
|
89 |
+
memory_files: ???
|
90 |
+
subflows_config:
|
91 |
+
CodeGenerator:
|
92 |
+
backend:
|
93 |
+
api_infos: ???
|
94 |
+
model_name:
|
95 |
+
openai: gpt-4
|
96 |
+
azure: azure/gpt-4
|
97 |
+
test:
|
98 |
+
memory_files: ???
|
99 |
+
re_plan:
|
100 |
+
subflows_config:
|
101 |
+
Controller:
|
102 |
+
backend:
|
103 |
+
api_infos: ???
|
104 |
+
model_name:
|
105 |
+
openai: gpt-4
|
106 |
+
azure: azure/gpt-4
|
107 |
+
Executor:
|
108 |
+
subflows_config:
|
109 |
+
write_plan:
|
110 |
+
subflows_config:
|
111 |
+
PlanGenerator:
|
112 |
+
backend:
|
113 |
+
api_infos: ???
|
114 |
+
model_name:
|
115 |
+
openai: gpt-4
|
116 |
+
azure: azure/gpt-4
|
117 |
+
re_plan:
|
118 |
+
subflows_config:
|
119 |
+
Controller:
|
120 |
+
backend:
|
121 |
+
api_infos: ???
|
122 |
+
model_name:
|
123 |
+
openai: gpt-4
|
124 |
+
azure: azure/gpt-4
|
125 |
+
Executor:
|
126 |
+
subflows_config:
|
127 |
+
write_plan:
|
128 |
+
subflows_config:
|
129 |
+
PlanGenerator:
|
130 |
+
backend:
|
131 |
+
api_infos: ???
|
132 |
+
model_name:
|
133 |
+
openai: gpt-4
|
134 |
+
azure: azure/gpt-4
|
Controller_CoderFlow.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any, Dict, List
|
2 |
+
from flow_modules.Tachi67.ExtendLibraryFlowModule import ControllerFlow_ExtLib
|
3 |
+
|
4 |
+
|
5 |
+
from dataclasses import dataclass
|
6 |
+
|
7 |
+
|
8 |
+
@dataclass
|
9 |
+
class Command:
|
10 |
+
name: str
|
11 |
+
description: str
|
12 |
+
input_args: List[str]
|
13 |
+
|
14 |
+
class Controller_CoderFlow(ControllerFlow_ExtLib):
|
15 |
+
def __init__(
|
16 |
+
self,
|
17 |
+
commands: List[Command],
|
18 |
+
**kwargs):
|
19 |
+
super().__init__(**kwargs)
|
20 |
+
self.system_message_prompt_template = self.system_message_prompt_template.partial(
|
21 |
+
commands=self.build_commands_manual(commands),
|
22 |
+
plan="no plans yet",
|
23 |
+
plan_file_location="no location yet",
|
24 |
+
code_library="no code library yet",
|
25 |
+
code_library_location="no location yet",
|
26 |
+
logs="no logs yet",
|
27 |
+
)
|
28 |
+
self.hint_for_model = """
|
29 |
+
Make sure your response is in the following format:
|
30 |
+
Response Format:
|
31 |
+
{
|
32 |
+
"command": "call one of the subordinates",
|
33 |
+
"command_args": {
|
34 |
+
"arg name": "value"
|
35 |
+
}
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
def _get_code_library_location(self, input_data):
|
40 |
+
assert "memory_files" in input_data, "memory_files not passed to Coder/Controller"
|
41 |
+
assert "code_library" in input_data["memory_files"], "code_library not in memory files"
|
42 |
+
return input_data["memory_files"]["code_library"]
|
43 |
+
|
44 |
+
def _get_code_library_content(self, input_data):
|
45 |
+
assert "code_library" in input_data, "code_library not passed to Coder/Controller"
|
46 |
+
code_library_content = input_data["code_library"]
|
47 |
+
if len(code_library_content) == 0:
|
48 |
+
code_library_content = 'No plan yet'
|
49 |
+
return code_library_content
|
50 |
+
|
51 |
+
def _update_prompts_and_input(self, input_data: Dict[str, Any]):
|
52 |
+
if 'goal' in input_data:
|
53 |
+
input_data['goal'] += self.hint_for_model
|
54 |
+
if 'result' in input_data:
|
55 |
+
input_data['result'] += self.hint_for_model
|
56 |
+
plan_file_location = self._get_plan_file_location(input_data)
|
57 |
+
plan_content = self._get_plan_content(input_data)
|
58 |
+
code_library_location = self._get_code_library_location(input_data)
|
59 |
+
code_library_content = self._get_code_library_content(input_data)
|
60 |
+
logs_content = self._get_logs_content(input_data)
|
61 |
+
self.system_message_prompt_template = self.system_message_prompt_template.partial(
|
62 |
+
plan_file_location=plan_file_location,
|
63 |
+
plan=plan_content,
|
64 |
+
code_library_location=code_library_location,
|
65 |
+
code_library=code_library_content,
|
66 |
+
logs=logs_content
|
67 |
+
)
|
68 |
+
|
Controller_CoderFlow.yaml
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_target_: Tachi67.CoderFlowModule.ControllerCoderFlow.instantiate_from_default_config
|
2 |
+
name: "ControllerFlow_Coder"
|
3 |
+
description: "Proposes the next action to take towards achieving the goal, and prepares the input for the branching flow"
|
4 |
+
enable_cache: True
|
5 |
+
|
6 |
+
#######################################################
|
7 |
+
# Input keys
|
8 |
+
#######################################################
|
9 |
+
|
10 |
+
input_interface_non_initialized: # initial input keys
|
11 |
+
- "goal"
|
12 |
+
- "memory_files"
|
13 |
+
- "plan"
|
14 |
+
- "logs"
|
15 |
+
- "code_library
|
16 |
+
|
17 |
+
input_interface_initialized:
|
18 |
+
- "result"
|
19 |
+
- "memory_files"
|
20 |
+
- "plan"
|
21 |
+
- "logs"
|
22 |
+
- "code_library"
|
23 |
+
|
24 |
+
#######################################################
|
25 |
+
# Output keys
|
26 |
+
#######################################################
|
27 |
+
|
28 |
+
output_interface:
|
29 |
+
- 'command'
|
30 |
+
- 'command_args'
|
31 |
+
|
32 |
+
backend:
|
33 |
+
api_infos: ???
|
34 |
+
model_name:
|
35 |
+
openai: gpt-4
|
36 |
+
azure: azure/gpt-4
|
37 |
+
|
38 |
+
commands:
|
39 |
+
extend_library:
|
40 |
+
description: "Given goal, write functions to achieve the goal, and then extend the library with the functions"
|
41 |
+
input_args: [ "goal" ]
|
42 |
+
re_plan:
|
43 |
+
description: "When something is wrong with current plan, draft another plan based on the old plan and information about why it's bad or how to refine it."
|
44 |
+
input_args: [ "goal" ]
|
45 |
+
finish:
|
46 |
+
description: "Signal that the objective has been satisfied, return the summary of what was done"
|
47 |
+
input_args: [ "summary" ]
|
48 |
+
manual_finish:
|
49 |
+
description: "The user demands to quit and terminate the current process"
|
50 |
+
input_args: [ ]
|
51 |
+
ask_user:
|
52 |
+
description: "Ask user a question for confirmation or assistance"
|
53 |
+
input_args: [ "question" ]
|
54 |
+
update_plan:
|
55 |
+
description: "Pass the updated plan to edit plan file and override current plan"
|
56 |
+
input_args: [ "updated_plan" ]
|
57 |
+
run_code:
|
58 |
+
description: "Run a code script written by yourself, e.g. downloading a package to the current environment, importing and calling a function from the code library"
|
59 |
+
input_args: [ "code", "language" ]
|
60 |
+
|
61 |
+
|
62 |
+
system_message_prompt_template:
|
63 |
+
_target_: langchain.PromptTemplate
|
64 |
+
template: |2-
|
65 |
+
Your department is in charge of achieving goals with writing and executing code. You are the leader of this department.
|
66 |
+
|
67 |
+
You have a code library located at {{code_library_location}}, which contains functions that are already written and saved by your subordinates.
|
68 |
+
Here are the functions in the library:
|
69 |
+
{{code_library}}
|
70 |
+
|
71 |
+
You work with several subordinates, they will be in charge of the specific tasks, including extending the code library, running a code script (you need to write the code script yourself, e.g. importing and calling a function from the code library), re-planning, etc.
|
72 |
+
|
73 |
+
To call one of the subordinates, you need to call the corresponding command with necessary arguments, here are the commands and their descriptions:
|
74 |
+
{{commands}}
|
75 |
+
|
76 |
+
You are given a step-by-step plan to finish the goal, **make sure you follow the plan**, **notice that, if you are informed that the plan is overriden, this plan is the new plan you should stick to.**, the plan is located in a plan file {{plan_file_location}}:
|
77 |
+
{{plan}}
|
78 |
+
|
79 |
+
You should execute the plan step-by-step, for each step, you should do the following workflows:
|
80 |
+
0.1 Whenever the user demands to quit or terminate the current process, call `manual_finish` command.
|
81 |
+
0.2 Whenever in doubt, or you have something to ask, or confirm to the user, call `ask_user` with your question.
|
82 |
+
0.3 During the execution of the plan, if something goes wrong, call the `re_plan` with detailed information about what was wrong.
|
83 |
+
1. If the current step of plan asks to extend the library, call `extend_library` with the goal of the current step of plan.
|
84 |
+
2. In one of the following situations, call `run_code` with the code script you write:
|
85 |
+
2.1. The current step of plan does not require to extend the library, but requires to run a code script.
|
86 |
+
2.2. The current step of plan requires to import and run some functions from the library. In this case you **MUST** make sure you import the library, something like `from LIBRARY_NAME import FUNCTION_NAME` should suffice.
|
87 |
+
2.3. You need to download a package to the current environment, e.g. `pip install PACKAGE_NAME`, in this case the language of code should be `shell`.
|
88 |
+
After the code is run, the user will provide feedback about the execution, react to the feedback accordingly.
|
89 |
+
3. Whenever you have done one step of the plan, do the following:
|
90 |
+
3.1 Reflect on what plan you are having right now.
|
91 |
+
3.2 Reflect on which step of the plan you just finished.
|
92 |
+
3.3 Generate a plan, **it is exactly the same as the plan you have now, but with the current step of plan marked as done**
|
93 |
+
3.4 Call `update_plan` with the plan you just generated.
|
94 |
+
4. Proceed to the next step of the plan, go back to workflow 1 or 2.
|
95 |
+
5. When every step of the plan is done, call the `finish` command, with a summary of what was done.
|
96 |
+
|
97 |
+
Here is an example of execution:
|
98 |
+
### Beginning of an example execution: ###
|
99 |
+
Plan: 1. Extend the library with a function that reads the stock prices from yahoo finance for the last `k` months for a company given its `company_code` 2. Call this function for `company_code`=TSLA and `k`=6.
|
100 |
+
You start from step 1 of the plan, execute workflow 1, the extend_library command is called with the goal of step 1 of the plan.
|
101 |
+
You are informed of what functions are written and saved to the library.
|
102 |
+
You realize that step 1 is done, you go to workflow 3 to update the plan:
|
103 |
+
3.1 You recall the plan you have.
|
104 |
+
3.2 You realize step 1 of the plan is done.
|
105 |
+
3.3 You generate the updated plan: 1. Extend the library with a function that reads the stock prices for the last k months for a company given its `company_code` (DONE) 2. Call this function for `company_code`=TSLA and k=6.
|
106 |
+
3.4 You call `update_plan` with the generated plan.
|
107 |
+
The updated plan will override the existing plan, you are informed of the behaviour of override.
|
108 |
+
You enter step 2 of the plan.
|
109 |
+
You go to workflow 2 to run a code script, you write a code script that imports the function you just wrote and call it with the arguments specified in the plan.
|
110 |
+
You are informed that package yahoo finance is not installed, the user instructs to install the yahoo finance package, you go to workflow 2 to run a code script, you write a code script that installs the package.
|
111 |
+
You are informed that the package is installed, you go to workflow 2 to run a code script, you write a code script that imports the function you just wrote and call it with the arguments specified in the plan.
|
112 |
+
You are informed that the code has been successfully ran, the user is satisfied with the result.
|
113 |
+
You realize that step 2 is done, you go to workflow 3 to update the plan:
|
114 |
+
3.1 You recall the plan you have.
|
115 |
+
3.2 You realize step 2 of the plan is done.
|
116 |
+
3.3 You generate the updated plan: 1. Extend the library with a function that reads the stock prices for the last k months for a company given its `company_code` (DONE) 2. Call this function for `company_code`=TSLA and k=6. (DONE)
|
117 |
+
3.4 You call `update_plan` with the generated plan.
|
118 |
+
The updated plan will override the existing plan, you are informed of the behaviour of override.
|
119 |
+
All steps are done, you call `finish`, with a summary of what functions are written and saved to the library.
|
120 |
+
### End of an example of execution ###
|
121 |
+
|
122 |
+
Here is a list of history actions you have taken, for your reference:
|
123 |
+
{{logs}}
|
124 |
+
|
125 |
+
Constraints:
|
126 |
+
1. Exclusively use the commands listed in double quotes e.g. "command name"
|
127 |
+
|
128 |
+
Your response **MUST** be in the following format:
|
129 |
+
Response Format:
|
130 |
+
{
|
131 |
+
"command": "call one of the subordinates",
|
132 |
+
"command_args": {
|
133 |
+
"arg name": "value"
|
134 |
+
}
|
135 |
+
}
|
136 |
+
Ensure your responses can be parsed by Python json.loads
|
137 |
+
|
138 |
+
input_variables: ["commands", "plan_file_location", "plan", "logs", "code_library_location", "code_library"]
|
139 |
+
template_format: jinja2
|
140 |
+
|
141 |
+
human_message_prompt_template:
|
142 |
+
_target_: flows.prompt_template.JinjaPrompt
|
143 |
+
template: |2-
|
144 |
+
Here is the result of your previous action:
|
145 |
+
{{result}}
|
146 |
+
input_variables:
|
147 |
+
- "result"
|
148 |
+
template_format: jinja2
|
149 |
+
|
150 |
+
init_human_message_prompt_template:
|
151 |
+
_target_: flows.prompt_template.JinjaPrompt
|
152 |
+
template: |2-
|
153 |
+
Here is the goal you need to achieve, follow your plan to finish the goal:
|
154 |
+
{{goal}}
|
155 |
+
input_variables:
|
156 |
+
- "goal"
|
157 |
+
template_format: jinja2
|
CtrlExMem_CoderFlow.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, Any
|
2 |
+
|
3 |
+
from flow_modules.Tachi67.AbstractBossFlowModule import CtrlExMemFlow
|
4 |
+
from flows.base_flows import CircularFlow
|
5 |
+
|
6 |
+
class CtrlExMem_CoderFlow(CtrlExMemFlow):
|
7 |
+
def _on_reach_max_round(self):
|
8 |
+
self._state_update_dict({
|
9 |
+
"answer": "the maximum amount of rounds was reached before the coder flow has done the job",
|
10 |
+
"summary": "CoderFlow: the maximum amount of rounds was reached before the flow has done the job",
|
11 |
+
"status": "unfinished"
|
12 |
+
})
|
13 |
+
|
14 |
+
@CircularFlow.output_msg_payload_processor
|
15 |
+
def detect_finish_or_continue(self, output_payload: Dict[str, Any], src_flow) -> Dict[str, Any]:
|
16 |
+
command = output_payload["command"]
|
17 |
+
if command == "finish":
|
18 |
+
return {
|
19 |
+
"EARLY_EXIT": True,
|
20 |
+
"answer": output_payload["command_args"]["summary"],
|
21 |
+
"summary": "Coder: " + output_payload["command_args"]["summary"],
|
22 |
+
"status": "finished"
|
23 |
+
}
|
24 |
+
elif command == "manual_finish":
|
25 |
+
# ~~~ return the manual quit status ~~~
|
26 |
+
return {
|
27 |
+
"EARLY_EXIT": True,
|
28 |
+
"answer": "CoderFlow was terminated explicitly by the user, process is unfinished",
|
29 |
+
"summary": "Coder: process terminated by the user explicitly, nothing generated",
|
30 |
+
"status": "unfinished"
|
31 |
+
}
|
32 |
+
elif command == "update_plan":
|
33 |
+
keys_to_fetch_from_state = ["memory_files"]
|
34 |
+
fetched_state = self._fetch_state_attributes_by_keys(keys=keys_to_fetch_from_state)
|
35 |
+
output_payload["command_args"]["memory_files"] = fetched_state["memory_files"]
|
36 |
+
return output_payload
|
37 |
+
|
38 |
+
elif command == "re_plan":
|
39 |
+
keys_to_fetch_from_state = ["plan", "memory_files"]
|
40 |
+
fetched_state = self._fetch_state_attributes_by_keys(keys=keys_to_fetch_from_state)
|
41 |
+
output_payload["command_args"]["plan_file_location"] = fetched_state["memory_files"]["plan"]
|
42 |
+
output_payload["command_args"]["plan"] = fetched_state["plan"]
|
43 |
+
return output_payload
|
44 |
+
|
45 |
+
else:
|
46 |
+
return output_payload
|
CtrlExMem_CoderFlow.yaml
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_target_: Tachi67.CoderFlowModule.CtrlExMem_CoderFlow.instantiate_from_default_config
|
2 |
+
name: "CtrlExMem_CoderFlow"
|
3 |
+
description: "MemorizedControllerExecutor flow for Coder flow"
|
4 |
+
|
5 |
+
input_interface:
|
6 |
+
- "plan"
|
7 |
+
- "logs"
|
8 |
+
- "code_library"
|
9 |
+
- "memory_files"
|
10 |
+
- "goal"
|
11 |
+
|
12 |
+
subflows_config:
|
13 |
+
Controller:
|
14 |
+
_target_: Tachi67.CoderFlowModule.Controller_CoderFlow.instantiate_from_default_config
|
15 |
+
backend:
|
16 |
+
api_infos: ???
|
17 |
+
model_name:
|
18 |
+
openai: gpt-4
|
19 |
+
azure: azure/gpt-4
|
20 |
+
Executor:
|
21 |
+
_target_: flows.base_flows.BranchingFlow.instantiate_from_default_config
|
22 |
+
subflows_config:
|
23 |
+
extend_library:
|
24 |
+
_target_: Tachi67.ExtendLibraryFlowModule.ExtendLibraryFlow.instantiate_from_default_config
|
25 |
+
memory_files: ???
|
26 |
+
subflows_config:
|
27 |
+
Planner:
|
28 |
+
_target_: Tachi67.PlanWriterFlowModule.PlanWriterFlow.instantiate_from_default_config
|
29 |
+
subflows_config:
|
30 |
+
Controller:
|
31 |
+
backend:
|
32 |
+
api_infos: ???
|
33 |
+
model_name:
|
34 |
+
openai: gpt-4
|
35 |
+
azure: azure/gpt-4
|
36 |
+
Executor:
|
37 |
+
subflows_config:
|
38 |
+
write_plan:
|
39 |
+
subflows_config:
|
40 |
+
PlanGenerator:
|
41 |
+
backend:
|
42 |
+
api_infos: ???
|
43 |
+
model_name:
|
44 |
+
openai: gpt-4
|
45 |
+
azure: azure/gpt-4
|
46 |
+
CtrlExMem:
|
47 |
+
_target_: Tachi67.ExtendLibraryFlowModule.CtrlExMem_ExtLib.instantiate_from_default_config
|
48 |
+
subflows_config:
|
49 |
+
Controller:
|
50 |
+
backend:
|
51 |
+
api_infos: ???
|
52 |
+
model_name:
|
53 |
+
openai: gpt-4
|
54 |
+
azure: azure/gpt-4
|
55 |
+
Executor:
|
56 |
+
subflows_config:
|
57 |
+
write_code:
|
58 |
+
subflows_config:
|
59 |
+
Controller:
|
60 |
+
backend:
|
61 |
+
api_infos: ???
|
62 |
+
model_name:
|
63 |
+
openai: gpt-4
|
64 |
+
azure: azure/gpt-4
|
65 |
+
Executor:
|
66 |
+
subflows_config:
|
67 |
+
write_code:
|
68 |
+
memory_files: ???
|
69 |
+
subflows_config:
|
70 |
+
CodeGenerator:
|
71 |
+
backend:
|
72 |
+
api_infos: ???
|
73 |
+
model_name:
|
74 |
+
openai: gpt-4
|
75 |
+
azure: azure/gpt-4
|
76 |
+
test:
|
77 |
+
memory_files: ???
|
78 |
+
re_plan:
|
79 |
+
subflows_config:
|
80 |
+
Controller:
|
81 |
+
backend:
|
82 |
+
api_infos: ???
|
83 |
+
model_name:
|
84 |
+
openai: gpt-4
|
85 |
+
azure: azure/gpt-4
|
86 |
+
Executor:
|
87 |
+
subflows_config:
|
88 |
+
write_plan:
|
89 |
+
subflows_config:
|
90 |
+
PlanGenerator:
|
91 |
+
backend:
|
92 |
+
api_infos: ???
|
93 |
+
model_name:
|
94 |
+
openai: gpt-4
|
95 |
+
azure: azure/gpt-4
|
96 |
+
ask_user:
|
97 |
+
_target_: Tachi67.ExtendLibraryFlowModule.ExtLibAskUserFlow.instantiate_from_default_config
|
98 |
+
re_plan:
|
99 |
+
_target_: Tachi67.ReplanningFlowModule.ReplanningFlow.instantiate_from_default_config
|
100 |
+
subflows_config:
|
101 |
+
Controller:
|
102 |
+
backend:
|
103 |
+
api_infos: ???
|
104 |
+
model_name:
|
105 |
+
openai: gpt-4
|
106 |
+
azure: azure/gpt-4
|
107 |
+
Executor:
|
108 |
+
subflows_config:
|
109 |
+
write_plan:
|
110 |
+
subflows_config:
|
111 |
+
PlanGenerator:
|
112 |
+
backend:
|
113 |
+
api_infos: ???
|
114 |
+
model_name:
|
115 |
+
openai: gpt-4
|
116 |
+
azure: azure/gpt-4
|
117 |
+
run_code:
|
118 |
+
_target_: Tachi67.RunCodeFlowModule.RunCodeFlow.instantiate_from_default_config
|
119 |
+
update_plan:
|
120 |
+
_target_: Tachi67.CoderFlowModule.UpdatePlanAtomicFlow.yaml.instantiate_from_default_config
|
121 |
+
MemoryReading:
|
122 |
+
_target_: Tachi67.MemoryReadingFlowModule.MemoryReadingAtomicFlow.instantiate_from_default_config
|
123 |
+
output_interface:
|
124 |
+
- "plan"
|
125 |
+
- "logs"
|
126 |
+
- "code_library"
|
127 |
+
|
128 |
+
topology:
|
129 |
+
- goal: "Select the next action and prepare the input for the executor."
|
130 |
+
input_interface:
|
131 |
+
_target_: flows.interfaces.KeyInterface
|
132 |
+
additional_transformations:
|
133 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
134 |
+
flow: Controller
|
135 |
+
output_interface:
|
136 |
+
_target_: CtrlExMem_CoderFlow.detect_finish_or_continue
|
137 |
+
reset: false
|
138 |
+
|
139 |
+
- goal: "Execute the action specified by the Controller."
|
140 |
+
input_interface:
|
141 |
+
_target_: flows.interfaces.KeyInterface
|
142 |
+
keys_to_rename:
|
143 |
+
command: branch
|
144 |
+
command_args: branch_input_data
|
145 |
+
keys_to_select: ["branch", "branch_input_data"]
|
146 |
+
flow: Executor
|
147 |
+
output_interface:
|
148 |
+
_target_: flows.interfaces.KeyInterface
|
149 |
+
keys_to_rename:
|
150 |
+
branch_output_data: observation
|
151 |
+
keys_to_unpack: ["observation"]
|
152 |
+
reset: false
|
153 |
+
|
154 |
+
- goal: "Write memory to memory files"
|
155 |
+
input_interface:
|
156 |
+
_target_: flows.interfaces.KeyInterface
|
157 |
+
additional_transformations:
|
158 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
159 |
+
flow: MemoryWriting
|
160 |
+
reset: false
|
161 |
+
|
162 |
+
- goal: "Read memory from memory files (flow_state)"
|
163 |
+
input_interface:
|
164 |
+
_target_: flows.interfaces.KeyInterface
|
165 |
+
additional_transformations:
|
166 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
167 |
+
flow: MemoryReading
|
168 |
+
reset: false
|
Planner_CoderFlow.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, Any
|
2 |
+
import os
|
3 |
+
from flow_modules.Tachi67.PlanWriterFlowModule import PlanWriterFlow
|
4 |
+
from flows.base_flows import CircularFlow
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
class Planner_CoderFlow(PlanWriterFlow):
|
9 |
+
def _on_reach_max_round(self):
|
10 |
+
self._state_update_dict({
|
11 |
+
"plan": "The maximum amount of rounds was reached before the model generated the plan.",
|
12 |
+
"status": "unfinished"
|
13 |
+
})
|
14 |
+
|
15 |
+
@CircularFlow.output_msg_payload_processor
|
16 |
+
def detect_finish_or_continue(self, output_payload: Dict[str, Any], src_flow) -> Dict[str, Any]:
|
17 |
+
command = output_payload["command"]
|
18 |
+
if command == "finish":
|
19 |
+
# ~~~ fetch temp file location, plan content, memory file (of upper level flow e.g. ExtLib) from flow state
|
20 |
+
keys_to_fetch_from_state = ["temp_plan_file_location", "plan", "memory_files"]
|
21 |
+
fetched_state = self._fetch_state_attributes_by_keys(keys=keys_to_fetch_from_state)
|
22 |
+
temp_plan_file_location = fetched_state["temp_plan_file_location"]
|
23 |
+
plan_content = fetched_state["plan"]
|
24 |
+
plan_file_location = fetched_state["memory_files"]["plan"]
|
25 |
+
|
26 |
+
# ~~~ delete the temp plan file ~~~
|
27 |
+
if os.path.exists(temp_plan_file_location):
|
28 |
+
os.remove(temp_plan_file_location)
|
29 |
+
|
30 |
+
# ~~~ write plan content to plan file ~~~
|
31 |
+
with open(plan_file_location, 'w') as file:
|
32 |
+
file.write(plan_content)
|
33 |
+
|
34 |
+
# ~~~ return the plan content ~~~
|
35 |
+
return {
|
36 |
+
"EARLY_EXIT": True,
|
37 |
+
"plan": plan_content,
|
38 |
+
"summary": "Coder/PlanWriter: " + output_payload["command_args"]["summary"],
|
39 |
+
"status": "finished"
|
40 |
+
}
|
41 |
+
elif command == "manual_finish":
|
42 |
+
# ~~~ delete the temp plan file ~~~
|
43 |
+
keys_to_fetch_from_state = ["temp_plan_file_location"]
|
44 |
+
fetched_state = self._fetch_state_attributes_by_keys(keys=keys_to_fetch_from_state)
|
45 |
+
temp_plan_file_location = fetched_state["temp_plan_file_location"]
|
46 |
+
if os.path.exists(temp_plan_file_location):
|
47 |
+
os.remove(temp_plan_file_location)
|
48 |
+
# ~~~ return the manual quit status ~~~
|
49 |
+
return {
|
50 |
+
"EARLY_EXIT": True,
|
51 |
+
"plan": "no plan was generated",
|
52 |
+
"summary": "Coder/PlanWriter: PlanWriter was terminated explicitly by the user, process is unfinished",
|
53 |
+
"status": "unfinished"
|
54 |
+
}
|
55 |
+
elif command == "write_plan":
|
56 |
+
keys_to_fetch_from_state = ["memory_files", "code_library"]
|
57 |
+
fetched_state = self._fetch_state_attributes_by_keys(keys=keys_to_fetch_from_state)
|
58 |
+
output_payload["command_args"]["plan_file_location"] = fetched_state["memory_files"]["plan"]
|
59 |
+
output_payload["command_args"]["code_library_location"] = fetched_state["memory_files"]["code_library"]
|
60 |
+
output_payload["command_args"]["code_library"] = fetched_state["code_library"]
|
61 |
+
return output_payload
|
62 |
+
else:
|
63 |
+
return output_payload
|
Planner_CoderFlow.yaml
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "Planner/Coder"
|
2 |
+
description: "Generates plan with interactions with the user, used for the coder class"
|
3 |
+
|
4 |
+
_target_: Tachi67.CoderFlowModule.Planner_CoderFlow.instantiate_from_default_config
|
5 |
+
|
6 |
+
input_interface:
|
7 |
+
- "goal"
|
8 |
+
- "code_library"
|
9 |
+
- "memory_files"
|
10 |
+
|
11 |
+
output_interface:
|
12 |
+
- "plan"
|
13 |
+
- "status"
|
14 |
+
- "summary"
|
15 |
+
|
16 |
+
### Subflows specification
|
17 |
+
subflows_config:
|
18 |
+
Controller:
|
19 |
+
_target_: Tachi67.PlanWriterFlowModule.PlanWriterCtrlFlow.instantiate_from_default_config
|
20 |
+
backend:
|
21 |
+
api_infos: ???
|
22 |
+
model_name:
|
23 |
+
openai: gpt-4
|
24 |
+
azure: azure/gpt-4
|
25 |
+
|
26 |
+
Executor:
|
27 |
+
_target_: flows.base_flows.BranchingFlow.instantiate_from_default_config
|
28 |
+
subflows_config:
|
29 |
+
write_plan:
|
30 |
+
_target_: Tachi67.InteractivePlanGenFlowModule.InteractivePlanGenFlow.instantiate_from_default_config
|
31 |
+
input_interface:
|
32 |
+
- "goal"
|
33 |
+
- "plan_file_location"
|
34 |
+
- "code_library_location"
|
35 |
+
- "code_library"
|
36 |
+
subflows_config:
|
37 |
+
PlanGenerator:
|
38 |
+
_target_: Tachi67.PlanGeneratorFlowModule.PlanGeneratorAtomicFlow.instantiate_from_default_config
|
39 |
+
backend:
|
40 |
+
api_infos: ???
|
41 |
+
model_name:
|
42 |
+
openai: gpt-4
|
43 |
+
azure: azure/gpt-4
|
44 |
+
input_interface_non_initialized:
|
45 |
+
- "goal"
|
46 |
+
- "code_library"
|
47 |
+
- "code_library_location"
|
48 |
+
input_interface_initialized:
|
49 |
+
- "goal"
|
50 |
+
- "code_library"
|
51 |
+
- "code_library_location"
|
52 |
+
system_message_prompt_template:
|
53 |
+
_target_: flows.prompt_template.JinjaPrompt
|
54 |
+
template: |2-
|
55 |
+
You are a planner for a coding department, you write step-by-step plans for the coders to follow and execute.
|
56 |
+
|
57 |
+
You and the coders work with a code library located at {{code_library_location}}, **it is important that when you make plans, make the best use of the functions in the library.** Here are the contents in the library:
|
58 |
+
{{code_library}}
|
59 |
+
|
60 |
+
The coders are able to read and write the code library, namely, they can import and use the functions in the library, and they are also able to extend the library.
|
61 |
+
|
62 |
+
Apart from reading and writing code, the coders are also able to execute a code script written by themselves.
|
63 |
+
|
64 |
+
**You task is: given a goal to achieve, write step-by-step plans for the coders, each step of your plan should involve one of the three actions:
|
65 |
+
1. Extend the code library with a function, describe the purpose, input and output of this function so that the coders understand what you mean and write appropriate functions.
|
66 |
+
2. Run a code script, for example, downloading a package after you realize the current environment lacks it; import and call one function from the code library with specific inputs.
|
67 |
+
3. Give a final answer**
|
68 |
+
|
69 |
+
Here are some criteria you should consider in order to write a good plan:
|
70 |
+
1. The plan should be nicely separated into steps, each step should involve extending the library, or running code, or giving a final answer.
|
71 |
+
2. Always try to use the functions already existent in the code library. To use them, instruct the coders to import and run the function from the code library.
|
72 |
+
3. If the current milestone cannot be solved by the functions in the library, generalize the problem and instruct the coders to extend the library with a function to deal with this problem.
|
73 |
+
For example, suppose the goal you need to achieve is "Download Google's stock prices from the last 6 months from Yahoo finance", there is no function available to solve this in the library.
|
74 |
+
In this case, your step of plan is: "Extend the library with a function that reads the stock prices for the last k months for a company given its `company_code`"
|
75 |
+
4. On top of criterion 3, when you instruct the coders to extend the library, make sure that:
|
76 |
+
4.1. Each time you instruct to extend the library, ask for only one function.
|
77 |
+
4.2. If the problem you generalize involves several separated steps and should not be done in one function, decompose the problem into several sub-problems and instruct the coders to extend the library with a function for each sub-problem, this should be done in several steps of plan.
|
78 |
+
|
79 |
+
Performance Evaluation:
|
80 |
+
1. Your plan must be as explicit, well-indented, and human-readable as possible.
|
81 |
+
2. Your plan must be step-by-step with number indexes, each step involves extending the library, or running code, or answering.
|
82 |
+
3. You should make plans with as few steps as possible.
|
83 |
+
|
84 |
+
**It's important that you should only respond in JSON format as described below:**
|
85 |
+
Response Format:
|
86 |
+
{
|
87 |
+
"plan": "A step-by-step plan to finish the given goal",
|
88 |
+
}
|
89 |
+
Ensure your responses can be parsed by Python json.loads
|
90 |
+
input_variables:
|
91 |
+
- "code_library_location"
|
92 |
+
- "code_library"
|
93 |
+
|
94 |
+
PlanFileEditor:
|
95 |
+
_target_: Tachi67.PlanFileEditFlowModule.PlanFileEditAtomicFlow.instantiate_from_default_config
|
96 |
+
|
97 |
+
ParseFeedback:
|
98 |
+
_target_: Tachi67.ParseFeedbackFlowModule.ParseFeedbackAtomicFlow.instantiate_from_default_config
|
99 |
+
input_interface:
|
100 |
+
- "temp_plan_file_location"
|
101 |
+
output_interface:
|
102 |
+
- "plan"
|
103 |
+
- "feedback"
|
104 |
+
|
105 |
+
ask_user:
|
106 |
+
_target_: Tachi67.PlanWriterFlowModule.PlanWriterAskUserFlow.instantiate_from_default_config
|
107 |
+
|
108 |
+
|
109 |
+
early_exit_key: "EARLY_EXIT"
|
110 |
+
|
111 |
+
topology:
|
112 |
+
- goal: "Select the next action and prepare the input for the executor."
|
113 |
+
input_interface:
|
114 |
+
_target_: flows.interfaces.KeyInterface
|
115 |
+
additional_transformations:
|
116 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
117 |
+
flow: Controller
|
118 |
+
output_interface:
|
119 |
+
_target_: Planner_CoderFlow.detect_finish_or_continue
|
120 |
+
reset: false
|
121 |
+
|
122 |
+
- goal: "Execute the action specified by the Controller."
|
123 |
+
input_interface:
|
124 |
+
_target_: flows.interfaces.KeyInterface
|
125 |
+
keys_to_rename:
|
126 |
+
command: branch
|
127 |
+
command_args: branch_input_data
|
128 |
+
keys_to_select: ["branch", "branch_input_data"]
|
129 |
+
flow: Executor
|
130 |
+
output_interface:
|
131 |
+
_target_: flows.interfaces.KeyInterface
|
132 |
+
keys_to_rename:
|
133 |
+
branch_output_data: observation
|
134 |
+
keys_to_unpack: ["observation"]
|
135 |
+
reset: false
|
UpdatePlanAtomicFlow.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#TODO: generalize updateplanatomicflow with the one in extendlibrary
|
2 |
+
from typing import Dict, Any
|
3 |
+
from flows.base_flows.atomic import AtomicFlow
|
4 |
+
class UpdatePlanAtomicFlow(AtomicFlow):
|
5 |
+
def _check_input(self, input_data: Dict[str, Any]):
|
6 |
+
assert "memory_files" in input_data, "memory_files not passed to UpdatePlanAtomicFlow.yaml"
|
7 |
+
assert "plan" in input_data["memory_files"], "plan not in memory_files"
|
8 |
+
|
9 |
+
def _call(self, input_data: Dict[str, Any]):
|
10 |
+
try:
|
11 |
+
plan_file_location = input_data["memory_files"]["plan"]
|
12 |
+
plan_to_write = input_data["updated_plan"]
|
13 |
+
with open(plan_file_location, 'w') as file:
|
14 |
+
file.write(plan_to_write + "\n")
|
15 |
+
return {
|
16 |
+
"result": "updated plan saved to the plan file and has overriden the previous plan",
|
17 |
+
"summary": f"Coder/UpdatePlanFlow: updated plan saved to {plan_file_location}"
|
18 |
+
}
|
19 |
+
except Exception as e:
|
20 |
+
return {
|
21 |
+
"result": f"Error occurred: {str(e)}",
|
22 |
+
"summary": f"Coder/UpdatePlanFlow: error occurred while writing updated plan: {str(e)}"
|
23 |
+
}
|
24 |
+
|
25 |
+
def run(
|
26 |
+
self,
|
27 |
+
input_data: Dict[str, Any]
|
28 |
+
):
|
29 |
+
self._check_input(input_data)
|
30 |
+
return self._call(input_data)
|
UpdatePlanAtomicFlow.yaml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_target_: Tachi67.CoderFlowModule.UpdatePlanAtomicFlow.instantiate_from_default_config
|
2 |
+
name: "UpdatePlanAtomicFlow"
|
3 |
+
description: "Writes new plan to plan file"
|
4 |
+
|
5 |
+
input_interface:
|
6 |
+
- "updated_plan"
|
7 |
+
|
8 |
+
output_interface:
|
9 |
+
- "result"
|
__init__.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dependencies = [
|
2 |
+
{"url": "Tachi67/AbstractBossFlowModule", "revision": "main"},
|
3 |
+
{"url": "Tachi67/MemoryReadingFlowModule", "revision": "main"},
|
4 |
+
{"url": "Tachi67/PlanWriterFlowModule", "revision": "main"},
|
5 |
+
{"url": "Tachi67/ExtendLibraryFlowModule", "revision": "main"},
|
6 |
+
{"url": "Tachi67/RunCodeFlowModule", "revision": "main"},
|
7 |
+
{"url": "Tachi67/ReplanningFlowModule", "revision": "main"},
|
8 |
+
{"url": "aiflows/HumanStandardInputFlowModule", "revision": "5683a922372c5fa90be9f6447d6662d8d80341fc"},
|
9 |
+
{"url": "aiflows/ChatFlowModule", "revision": "a749ad10ed39776ba6721c37d0dc22af49ca0f17"},
|
10 |
+
]
|
11 |
+
|
12 |
+
from flows import flow_verse
|
13 |
+
flow_verse.sync_dependencies(dependencies)
|
14 |
+
|
15 |
+
from .UpdatePlanAtomicFlow import UpdatePlanAtomicFlow
|
16 |
+
from .CoderFlow import CoderFlow
|
17 |
+
from .Controller_CoderFlow import Controller_CoderFlow
|
18 |
+
from .CtrlExMem_CoderFlow import CtrlExMem_CoderFlow
|
19 |
+
from .Planner_CoderFlow import Planner_CoderFlow
|