Table of Contents
- Structure of ExtendLibraryFlow
- SaveCodeAtomicFlow
- ExtLibAskUserFlow
- ExtendLibraryFlow
- UpdatePlanAtomicFlow
- run_ExtendLibrary
- CtrlExMem_ExtLib
- ControllerFlow_ExtLib
- __init__
Structure of ExtendLibraryFlow
goal, memory_files (dict)
|
v
+-------------------+
| MemoryReading | Reads in the content of the memory files
| Flow |
+-------------------+
|
| (memory_content)
|
v
+-------------------+
| PlanWriter | Writes a step-by-step plan to achieve the goal
+-------------------+
|
| (plan)
|
v
+-------------------+
| CtrlExMemFlow | Illustrated below. Carries out the plan in an controller-executor fashion,
| | with memory management mechanisms.
+-------------------+
|
(summary, result)
Here is the structure of the CtrlExMemFlow
:
plan, memory_files, memory_content, goal
|
v
+---------------+
| Controller | --------<<<<-----------+
+---------------+ |
| |
| (command, command args) |
| |
v |
+------------------+ |
| Executor | Each branch is an |
| (Tree Structure) | executor |
+------------------+ |
| ^
| (execution results) ^
| ^
v ^
+---------------+ ^
| MemWriteFlow | Updates memory files ^
+---------------+ ^
| ^
| (summary) |
| |
v |
+---------------+ |
| MemReadFlow | Reads updated memory |
+---------------+ |
| |
| (updated memory content) |
| |
+-> goes back to the Controller>-+
Structure of the Executors:
+-------------------+
| Branching |
| Executor |
+-------------------+
/ | | | \
/ | | | \
/ | | | \
/ | | | \
write_code ask_user re_plan update_plan save_code
Memory files of ExtendLibraryFlow:
plan_extlib.txt
logs_extlib.txt
library.py
About the branches:
- write_code: Generates code in an interactive way, the user is able to edit or provide feedback during the process of writing code.
- ask_user: Ask user for info / confirmation, etc.
- re_plan: One branch of the executors, when something goes wrong, re-draft the plan.
- update_plan: One branch of the executors, when the controller realizes that one (or some, depending on the LLM's response) step of the plan is (are) done, it generates a new plan that marks the step(s) as done.
- save_code: Writes the written & tested code to the code library.
SaveCodeAtomicFlow
SaveCodeAtomicFlow Objects
class SaveCodeAtomicFlow(AtomicFlow)
This flow appends the code to the code library file.
Input Interface:
code
(str): the code to be appended to the code librarymemory_files
(dict): the dictionary of memory files
Output Interface:
result
(str): the result of the flow, to be returned to the controller of the callersummary
(str): the summary of the flow, to be appended to logs
Configuration Parameters:
input_interface
: the input interface of the flowoutput_interface
: the output interface of the flow
run
def run(input_data: Dict[str, Any])
Run the flow
Arguments:
input_data
(dict
): the input data
Returns:
dict
: the output data
ExtLibAskUserFlow
ExtLibAskUserFlow Objects
class ExtLibAskUserFlow(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 input string.
Output Interface:
result
: The input of the user.summary
: The summary that will be written by the caller.
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 module.
Arguments:
input_data
(Dict[str, Any]
): The input data.
Returns:
Dict[str, Any]
: The output data.
ExtendLibraryFlow
ExtendLibraryFlow Objects
class ExtendLibraryFlow(AbstractBossFlow)
ExtendLibraryFlow is one branch executor of CoderFlow. At a higher level, it takes the goal from the Coder, writes functions in an interactive way, test the code and append the newly written function to the code library.
Workflow of ExtendLibrary: 0. Coder calls ExtendLibrary with a goal.
- MemoryReading reads logs, plan, and code library.
- Planner makes a plan based on the goal.
- Write code in an interactive fashion.
- Test code.
- Finish, writes code to the library. Step 3-5 is done via prompting the controller.
ExtendLibraryFlow inherits from AbstractBossFlow, visit https://huggingface.co/aiflows/AbstractBossFlowModule/
Input Interface (expected input)
goal
(str): The goal from the caller (source flow, i.e. CoderFlow)
Output Interface (expected output)
result
(str): The result of the flow, the result will be returned to the caller (i.e. CoderFlow).summary
(str): The summary of the flow, the summary will be logged into the logs of the caller flow (i.e. CoderFlow).
Configuration Parameters:
memory_files
: The memory files to be read by the flow. By convention, the memory files should contain plan, logs, and code library.input_interface
: The input interface of the flow. By default, they should begoal
.output_interface
: The output interface of the flow. By default, they should beresult
andsummary
.subflows_config
: Configurations w/ the subflows.
run
def run(input_data: Dict[str, Any]) -> Dict[str, Any]
Run the flow.
Arguments:
input_data
(Dict[str, Any]
): The input data of the flow.
Returns:
Dict[str, Any]
: The output data of the flow.
UpdatePlanAtomicFlow
UpdatePlanAtomicFlow Objects
class UpdatePlanAtomicFlow(AtomicFlow)
Refer to: https://huggingface.co/aiflows/CoderFlowModule/blob/main/UpdatePlanAtomicFlow.py This flow updates the plan file with the updated plan.
Input Interface:
updated_plan
(str): the updated plan
Output Interface:
result
(str): the result of the flow, to be returned to the controller of the caller
Configuration Parameters:
input_interface
: the input interface of the flowoutput_interface
: the output interface of the flow
run
def run(input_data: Dict[str, Any])
Run the flow
Arguments:
input_data
(dict
): the input data
Returns:
dict
: the output data
run_ExtendLibrary
CtrlExMem_ExtLib
CtrlExMem_ExtLib Objects
class CtrlExMem_ExtLib(CtrlExMemFlow)
This class inherits from the CtrlExMemFlow class from AbstractBossFlowModule.
See: https://huggingface.co/aiflows/AbstractBossFlowModule/blob/main/CtrlExMemFlow.py
Input Interface:
plan
logs
memory_files
goal
Output Interface
result
(str): The result of the flow, the result will be returned to the caller.summary
(str): The summary of the flow, the summary will be logged into the logs of the caller flow.
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 method is called when the flow receives a message from the child flow.
Arguments:
output_payload
(Dict[str, Any]
): The output payload of the child flow.src_flow
(AbstractBossFlowModule
): The child flow.
Returns:
Dict[str, Any]
: The processed output payload.
ControllerFlow_ExtLib
ControllerFlow_ExtLib Objects
class ControllerFlow_ExtLib(ChatAtomicFlow)
Refer to: https://huggingface.co/aiflows/JarvisFlowModule/blob/main/Controller_JarvisFlow.py for a detailed doc. This flow inherits from ChatAtomicFlow and is used as a controller of the ExtendLibraryFlow.
Input Interface Non Initialized:
goal
memory_files
plan
logs
Input Interface Initialized:
goal
memory_files
plan
logs
result
Output Interface:
command
command_args
Configuration Parameters:
input_interface_non_initialized
: a list of input interface names when the conversation starts.input_interface_initialized
: a list of input interface names when the conversation is initialized.output_interface
: the output of the controller, it is the command and the command arguments.commands
: a list of commands that the controller can call. Each command has a name, a description, and a list of input arguments.system_message_prompt_template
: the system message prompt template.init_human_message_prompt_template
: the initial human (user) message prompt template.human_message_prompt_template
: the human (user) message prompt template.previous_messages
: the sliding window of previous messages.
__init__
def __init__(commands: List[Command], **kwargs)
The constructor of the ControllerFlow_ExtLib class.
Arguments:
commands
: a list of commands that the controller can call. Each command has a name, a description, and a list of input arguments.kwargs
: the configuration parameters of the ControllerFlow_ExtLib class.
instantiate_from_config
@classmethod
def instantiate_from_config(cls, config)
Instantiate the flow from a configuration.
Arguments:
config
(Dict[str, Any]
): the configuration.
Returns:
ControllerFlow_ExtLib
: the instantiated flow.
run
def run(input_data: Dict[str, Any]) -> Dict[str, Any]
Run the flow.
Arguments:
input_data
(Dict[str, Any]
): the input data.
Returns:
Dict[str, Any]
: the output of the flow.