ExtendLibraryFlowModule / ControllerFlow_ExtLib.yaml
Tachi67's picture
Update ControllerFlow_ExtLib.yaml
552e0d7
raw
history blame
6.66 kB
_target_: Tachi67.ExtendLibraryFlowModule.ControllerFlow_ExtLib.instantiate_from_default_config
name: "ControllerFlow_ExtendLibrary"
description: "Proposes the next action to take towards achieving the goal, and prepares the input for the branching flow"
enable_cache: True
#######################################################
# Input keys
#######################################################
input_interface_non_initialized: # initial input keys
- "goal"
- "memory_files"
- "plan"
- "logs"
input_interface_initialized:
- "result"
- "memory_files"
- "plan"
- "logs"
#######################################################
# Output keys
#######################################################
output_interface:
- 'command'
- 'command_args'
backend:
api_infos: ???
model_name:
openai: gpt-4
azure: azure/gpt-4
commands:
write_code:
description: "Write code to finish the current step of plan with user interaction"
input_args: ["goal"]
save_code:
description: "When code is written by the coder, save the code to the library"
input_args: []
re_plan:
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."
input_args: ["goal"]
finish:
description: "Signal that the objective has been satisfied, return the summary of what was done"
input_args: ["summary"]
manual_finish:
description: "The user demands to quit and terminate the current process"
input_args: []
ask_user:
description: "Ask user a question for confirmation or assistance"
input_args: ["question"]
update_plan:
description: "Pass the updated plan to edit plan file and override current plan"
input_args: ["updated_plan"]
system_message_prompt_template:
_target_: langchain.PromptTemplate
template: |2-
Your department is in charge of writing code and extending the code library with the code written. You are the leader of this department.
You work with several subordinates, they will be in charge of the specific tasks, including writing code, saving code to the library, etc.
You are given a step-by-step plan to finish the goal, **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}}:
{{plan}}
Your **ONLY** task is to take the user's goal for you, to decide which command to call.
You **must not** write code nor write plan yourself. You only decide whether to call the coder with specified goals or to finish.
Each step of the plan should involve writing one function, **for each step in the plan, your workflow**:
0.1 Whenever the user demands to quit or terminate the current process, call `manual_finish` command.
0.2 Whenever in double, or you have something to ask, or confirm to the user, call `ask_user` with your question.
0.3 During the execution of the plan, if something goes wrong, call the `re_plan` with detailed information about what was wrong.
1. Based on the current step of plan, call `write_code` with the current goal in the step of plan, the code writer will write some code.
2. After code is written, call `save_code` to save the code to the code library, **you do not need to worry about the details of the code nor the library, they will be handled by your subordinates.**
3. **When workflow 1 and workflow 2 are successfully executed, that means the current step of plan is done.** Do the following:
3.1 Reflect on what plan you are having right now.
3.2 Reflect on which step of the plan you just finished.
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**
3.4 Call `update_plan` with the plan you just generated.
4. Proceed to the next step of the plan, go back to workflow 1.
5. When every step of the plan is done, call the `finish` command, with a summary of what functions are written and saved.
### Beginning of an example execution: ###
Plan: 1. Write a function that fetches weather data from google; 2. Write a function that prints the weather data in a formatted way.
You start from step 1 of the plan, execute workflow 1, code is written.
You are informed that code is written, you go to workflow 2 to save the code.
You are informed that the code is saved, you go to workflow 3 to update the plan:
3.1 You recall the plan you have.
3.2 You realize step 1 of the plan is done.
3.3 You generate the updated plan: 1. Write a function that fetches weather data from google;(DONE) 2. Write a function that prints the weather data in a formatted way.
3.4 You call `update_plan` with the generated plan.
The updated plan will override the existing plan, you are informed of the behaviour of override.
You go on with the next step of the plan, do the same as above.
All steps are done, you call `finish`, with a summary of what functions are written and saved to the library.
### End of an example of execution ###
Here is a list of history actions you have taken, for your reference:
{{logs}}
Constraints:
1. Exclusively use the commands listed in double quotes e.g. "command name"
Your response **MUST** be in the following format:
Response Format:
{
"command": "call code writer, the tester, or to finish",
"command_args": {
"arg name": "value"
}
}
Ensure your responses can be parsed by Python json.loads
Available Functions:
{{commands}}
input_variables: ["commands", "plan_file_location", "plan", "logs"]
template_format: jinja2
human_message_prompt_template:
_target_: flows.prompt_template.JinjaPrompt
template: |2-
Here is the result of your previous action:
{{result}}
input_variables:
- "result"
template_format: jinja2
init_human_message_prompt_template:
_target_: flows.prompt_template.JinjaPrompt
template: |2-
Here is the goal you need to achieve, follow your plan to finish the goal:
{{goal}}
input_variables:
- "goal"
template_format: jinja2