Table of Contents
- Structure of CodeWriterFlow
- run_codewriter
- CodeWriterCtrlFlow
- CodeWriterAskUserFlow
- CodeWriterFlow
- __init__
Structure of CodeWriterFlow
goal
|
v
+---------------+
| Controller | --------<<<<-----------+
+---------------+ |
| |
| (command, command args) |
| |
v |
+------------------+ |
| Executor | Each branch is an |
| (Tree Structure) | executor |
+------------------+ |
| ^
| (summary) |
| |
v |
| |
+-> goes back to the Controller>-+
Structure of the Executors:
+-------------------+
| Branching |
| Executor |
+-------------------+
/ | \
/ | \
/ | \
/ | \
write_code ask_user test
About the branches:
- ask_user: Ask user for info / confirmation, etc.
- write_code: Generates code (user edit is allowed) and fetches user feedback.
- test: Test the code, user can provide test suites, if nothing is provided, syntax of the code is checked.
How it works: Controller calls write_code until user is satisfied in the feedback, then controller calls test to test the code, if test passes, finish.
run_codewriter
CodeWriterCtrlFlow
CodeWriterCtrlFlow Objects
class CodeWriterCtrlFlow(ChatAtomicFlow)
refer to https://huggingface.co/aiflows/JarvisFlowModule/blob/main/Controller_JarvisFlow.py
This class controls the execution of the CodeWriterFlow.
Input Interface Non Initialized:
goal
Input Interface Initialized:
goal
code
feedback
Output Interface:
command
command_args
Configuration Parameters:
backend
: the backend used to call the LLM.commands
: a list of commands that the controller can use.system_message_prompt_template
: the template of the system message prompt.init_human_message_prompt_template
: the template of the init human (user) message prompt.human_message_prompt_template
: the template of the human (user) message prompt.previous_messages
: the sliding window of previous messages.
CodeWriterAskUserFlow
CodeWriterAskUserFlow Objects
class CodeWriterAskUserFlow(HumanStandardInputFlow)
This class is used to ask for user feedback whenever the controller is unsure of something, or need confirmation, etc.
Input Interface:
question
: The question asked by the controller
Expected Behaviour:
- The question is displayed, and the user gives feedback by inputing string.
Output Interface:
feedback
: The input of the user.code
: No code was written.
Configuration Parameters:
query_message_prompt_template
: The template of the message that is displayed to the user.request_multi_line_input
: Whether the user should be able to input multiple lines. Default: False.end_of_input_string
: The string that the user can input to indicate that he/she is done with the input. Default: EOI
run
def run(input_data: Dict[str, Any]) -> Dict[str, Any]
Run the flow.
Arguments:
input_data
: The input data.
Returns:
The output data.
CodeWriterFlow
CodeWriterFlow Objects
class CodeWriterFlow(ContentWriterFlow)
This flow inherits from ContentWriterFlow, it is used to write code in an interactive way. In the subflow of the executor, we specify an InteractiveCodeGenFlow (https://huggingface.co/aiflows/InteractiveCodeGenFlowModule)
Input Interface:
goal
Output Interface:
code
result
summary
status
Configuration Parameters:
name
: Name of the flowdescription
: Description of the flow_target_
: The instantiation target of the flowinput_interface
: The input to the flow. Inherited from ContentWriterFlow, in this case, it isgoal
.output_interface
: The output of the flow.subflows_config
: Configurations of subflowsearly_exit_keys
: The keys that will trigger an early exit of the flowtopology
: Configures the topology of the subflows, please have a special look at the I/O interfaces of the subflows.
detect_finish_or_continue
@CircularFlow.output_msg_payload_processor
def detect_finish_or_continue(output_payload: Dict[str, Any],
src_flow) -> Dict[str, Any]
This function is used to detect whether the code generation process is finished or not.
It is configured in the topology of the subflows, see CodeWriterFlow.yaml for more details.
Arguments:
output_payload
: The output payload of the subflowsrc_flow
: The subflow that generated the output payload
Returns:
The output payload of the subflow
run
def run(input_data: Dict[str, Any]) -> Dict[str, Any]
The run function of the flow.
Arguments:
input_data
: The input data of the flow
Returns:
The output data of the flow