Update AbstractBossFlow.py
Browse files- AbstractBossFlow.py +39 -2
AbstractBossFlow.py
CHANGED
|
@@ -10,8 +10,35 @@ logging.set_verbosity_debug()
|
|
| 10 |
log = logging.get_logger(__name__)
|
| 11 |
|
| 12 |
class AbstractBossFlow(SequentialFlow, ABC):
|
| 13 |
-
"""
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
"""
|
| 16 |
REQUIRED_KEYS_CONFIG = ["max_rounds", "early_exit_key", "topology", "memory_files"]
|
| 17 |
|
|
@@ -25,6 +52,11 @@ class AbstractBossFlow(SequentialFlow, ABC):
|
|
| 25 |
|
| 26 |
@classmethod
|
| 27 |
def instantiate_from_config(cls, config):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
flow_config = deepcopy(config)
|
| 29 |
|
| 30 |
kwargs = {"flow_config": flow_config}
|
|
@@ -40,6 +72,11 @@ class AbstractBossFlow(SequentialFlow, ABC):
|
|
| 40 |
return cls(**kwargs)
|
| 41 |
|
| 42 |
def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# ~~~ sets the input_data in the flow_state dict ~~~
|
| 44 |
self._state_update_dict(update_data=input_data)
|
| 45 |
|
|
|
|
| 10 |
log = logging.get_logger(__name__)
|
| 11 |
|
| 12 |
class AbstractBossFlow(SequentialFlow, ABC):
|
| 13 |
+
"""This class is an abstraction of memory-planner-controller-executor flow. At a higher level, it is
|
| 14 |
+
an abstract agent empowered by multiple language models and subsequent tools like code interpreters, etc.
|
| 15 |
+
It is designed to cooperate with memory management mechanisms, lm-powered planner and controller, and
|
| 16 |
+
arbitrary executors.
|
| 17 |
+
|
| 18 |
+
*Configuration Parameters*
|
| 19 |
+
|
| 20 |
+
- `name` (str): Name of the flow.
|
| 21 |
+
- `description` (str): Description of the flow.
|
| 22 |
+
- `memory_files` (dict): A dictionary of memory files. The keys are the names of the memory files and the values
|
| 23 |
+
are the path to the memory files. Typical memory files include plan, logs, code library.
|
| 24 |
+
- `subflows_config`:
|
| 25 |
+
- MemoryReading: reads the content of the memory files into the flow states for later use.
|
| 26 |
+
- Planner: make a step-by-step plan based on the current goal.
|
| 27 |
+
- CtrlExMem: controller-executor agent with memory reading and memory writing, it will execute the plan generated by the planner.
|
| 28 |
+
- `early_exit_key` (str): The key in the flow state that indicates the early exit condition.
|
| 29 |
+
- `topology` (list) : The topology of the flow.
|
| 30 |
+
|
| 31 |
+
*Input Interface (expected input)*
|
| 32 |
+
|
| 33 |
+
- `goal` (str): The goal from the caller (source flow)
|
| 34 |
+
|
| 35 |
+
*Output Interface (expected output)*
|
| 36 |
+
|
| 37 |
+
- `result` (str): The result of the flow, the result will be returned to the caller.
|
| 38 |
+
- `summary` (str): The summary of the flow, the summary will be logged into the logs of the caller flow.
|
| 39 |
+
|
| 40 |
+
:param memory_files: A dictionary of memory files. The keys are the names of the memory files and the values are the path to the memory files.
|
| 41 |
+
:type memory_files: dict
|
| 42 |
"""
|
| 43 |
REQUIRED_KEYS_CONFIG = ["max_rounds", "early_exit_key", "topology", "memory_files"]
|
| 44 |
|
|
|
|
| 52 |
|
| 53 |
@classmethod
|
| 54 |
def instantiate_from_config(cls, config):
|
| 55 |
+
"""This method instantiates the flow from a configuration dictionary.
|
| 56 |
+
|
| 57 |
+
:param config: The configuration dictionary.
|
| 58 |
+
:type config: dict
|
| 59 |
+
"""
|
| 60 |
flow_config = deepcopy(config)
|
| 61 |
|
| 62 |
kwargs = {"flow_config": flow_config}
|
|
|
|
| 72 |
return cls(**kwargs)
|
| 73 |
|
| 74 |
def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 75 |
+
"""This method runs the flow.
|
| 76 |
+
|
| 77 |
+
:param input_data: The input data, the input_data is supposed to contain 'goal'
|
| 78 |
+
:type input_data: dict
|
| 79 |
+
"""
|
| 80 |
# ~~~ sets the input_data in the flow_state dict ~~~
|
| 81 |
self._state_update_dict(update_data=input_data)
|
| 82 |
|