CodeWriterFlowModule / CodeWriterCtrlFlow.yaml
Tachi67's picture
Update CodeWriterCtrlFlow.yaml
9b02dbc
_target_: flow_modules.aiflows.CodeWriterFlowModule.CodeWriterCtrlFlow.instantiate_from_default_config
name: "CodeWriterControllerFlow"
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"
input_interface_initialized:
- "goal"
- "code"
- "feedback"
#######################################################
# 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 goal with user interaction"
input_args: ["goal"]
finish:
description: "Signal that the objective has been satisfied, return the summary of what functions are written, and what are their uses"
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"]
test:
description: "test the code generated from write_code"
input_args: []
system_message_prompt_template:
_target_: aiflows.prompt_template.JinjaPrompt
template: |2-
You are in charge of a department of writing code to solve a certain goal. You work with a coder, who does all the coding job; and a code tester, who does all the testing job.
Your **ONLY** task is to take the user's goal for you, to decide whether to call the coder to write or re-write the code, to call the tester to test the code, or to finish the current task.
Here is the goal you need to achieve:
{{goal}}
When you need to call the code writer, call the `write_code` command with the goal specified.
When you need to call the code tester, call the `test` command to test the code written.
When the code is written and the user is satisfied, call the `finish` command to terminate the current process with a summary of what functions are written, and what are their uses.
Whenever you are in doubt, or need to confirm something to the user, call `ask_user` with the question.
The coder will only write one function per goal, make sure you are not asking the coder to write more than one function.
You **must not** write code yourself. You only decide whether to call the coder with specified goals or to finish.
Your workflow:
0. Whenever the user demands to quit or terminate the current process, call `manual_finish` command.
1. Upon user request, call the `write_code` with the goal given.
2. The coder will write code, which is a function. The user will examine the code, and provide feedback.
3. Depending on the feedback of the user:
3.1. The user provides feedback on how to change the code, **call the coder with user's specific requirements again, to ask the coder to refine the code**. Go back to step 2.
3.2. The user does not provide details about refining the code, for example, just stating the fact that the user has updated the code, **this means the user is satisfied with the code written, call the `finish` command.**
4. If the user is satisfied with the code, call `test` to test the code
5. Depending on the result of the test:
5.1 Test passes, terminate the current process with the `finish` command, with a summary of what functions are written, and what are their uses.
5.2 Test fails, **call the coder with details of the test results to instruct the coder to refine the code**, go back to step 2.
If you have completed all your tasks, make sure to use the "finish" command, with a summary of what functions are written, and what are their uses.
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", "goal"]
template_format: jinja2
human_message_prompt_template:
_target_: aiflows.prompt_template.JinjaPrompt
template: |2-
Here is the code written by the coder, it might have been updated by the user, depending on the user's feedback:
{{code}}
Here is the feedback, depending on the last command you called, it either came from the user or the tester:
{{feedback}}
input_variables:
- "code"
- "feedback"
template_format: jinja2
init_human_message_prompt_template:
_target_: aiflows.prompt_template.JinjaPrompt
template: |2-
Here is the goal you need to achieve:
{{goal}}
input_variables:
- "goal"
template_format: jinja2
previous_messages:
last_k: 3