Tachi67 commited on
Commit
a78872d
·
1 Parent(s): 932138d

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +157 -3
README.md CHANGED
@@ -1,3 +1,157 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Table of Contents
2
+
3
+ * [AbstractBossFlow](#AbstractBossFlow)
4
+ * [AbstractBossFlow](#AbstractBossFlow.AbstractBossFlow)
5
+ * [instantiate\_from\_config](#AbstractBossFlow.AbstractBossFlow.instantiate_from_config)
6
+ * [run](#AbstractBossFlow.AbstractBossFlow.run)
7
+ * [CtrlExMemFlow](#CtrlExMemFlow)
8
+ * [CtrlExMemFlow](#CtrlExMemFlow.CtrlExMemFlow)
9
+ * [detect\_finish\_or\_continue](#CtrlExMemFlow.CtrlExMemFlow.detect_finish_or_continue)
10
+ * [\_\_init\_\_](#__init__)
11
+
12
+ <a id="AbstractBossFlow"></a>
13
+
14
+ # AbstractBossFlow
15
+
16
+ <a id="AbstractBossFlow.AbstractBossFlow"></a>
17
+
18
+ ## AbstractBossFlow Objects
19
+
20
+ ```python
21
+ class AbstractBossFlow(SequentialFlow, ABC)
22
+ ```
23
+
24
+ This class is an abstraction of memory-planner-controller-executor flow. At a higher level, it is
25
+
26
+ an abstract agent empowered by multiple language models and subsequent tools like code interpreters, etc.
27
+ It is designed to cooperate with memory management mechanisms, lm-powered planner and controller, and
28
+ arbitrary executors.
29
+
30
+ *Configuration Parameters*
31
+
32
+ - `name` (str): Name of the flow.
33
+ - `description` (str): Description of the flow.
34
+ - `memory_files` (dict): A dictionary of memory files. The keys are the names of the memory files and the values
35
+ are the path to the memory files. Typical memory files include plan, logs, code library.
36
+ - `subflows_config`:
37
+ - MemoryReading: reads the content of the memory files into the flow states for later use.
38
+ - Planner: make a step-by-step plan based on the current goal.
39
+ - CtrlExMem: controller-executor agent with memory reading and memory writing, it will execute the plan generated by the planner.
40
+ - `early_exit_key` (str): The key in the flow state that indicates the early exit condition.
41
+ - `topology` (list) : The topology of the flow.
42
+
43
+ *Input Interface (expected input)*
44
+
45
+ - `goal` (str): The goal from the caller (source flow)
46
+
47
+ *Output Interface (expected output)*
48
+
49
+ - `result` (str): The result of the flow, the result will be returned to the caller.
50
+ - `summary` (str): The summary of the flow, the summary will be logged into the logs of the caller flow.
51
+
52
+ **Arguments**:
53
+
54
+ - `memory_files` (`dict`): A dictionary of memory files. The keys are the names of the memory files and the values are the path to the memory files.
55
+
56
+ <a id="AbstractBossFlow.AbstractBossFlow.instantiate_from_config"></a>
57
+
58
+ #### instantiate\_from\_config
59
+
60
+ ```python
61
+ @classmethod
62
+ def instantiate_from_config(cls, config)
63
+ ```
64
+
65
+ This method instantiates the flow from a configuration dictionary.
66
+
67
+ **Arguments**:
68
+
69
+ - `config` (`dict`): The configuration dictionary.
70
+
71
+ <a id="AbstractBossFlow.AbstractBossFlow.run"></a>
72
+
73
+ #### run
74
+
75
+ ```python
76
+ def run(input_data: Dict[str, Any]) -> Dict[str, Any]
77
+ ```
78
+
79
+ This method runs the flow.
80
+
81
+ **Arguments**:
82
+
83
+ - `input_data` (`dict`): The input data, the input_data is supposed to contain 'goal'
84
+
85
+ <a id="CtrlExMemFlow"></a>
86
+
87
+ # CtrlExMemFlow
88
+
89
+ <a id="CtrlExMemFlow.CtrlExMemFlow"></a>
90
+
91
+ ## CtrlExMemFlow Objects
92
+
93
+ ```python
94
+ class CtrlExMemFlow(CircularFlow, ABC)
95
+ ```
96
+
97
+ This class is the controller-executor agent with memory reading and memory writing, it will execute the plan
98
+ generated by the planner. This flow is, at a higher level, a circular flow, it runs until either max_round is
99
+ reached, or the controller decides to early exit (see: detect_finish_or_continue)
100
+
101
+ The brain of the flow is the controller, the controller decides what action (which branch of the branching flow)
102
+ to take next. The controller can also decide to early exit the flow, in which case the flow will stop. After the
103
+ controller decides what action to take, the controller will pass the action to the executor, the executor will
104
+ execute the action, yielding `result` and `summary`, which respectively will be passed to the controller and the
105
+ memory writer (into logs of the upper layer of flow). Depending on the `result`, the controller will decide what
106
+ action to take next.
107
+
108
+ *Configuration Parameters*:
109
+ - `name` (str): Name of the flow.
110
+ - `description` (str): Description of the flow.
111
+ - `max_round` (int): The maximum number of rounds the flow will run. Default: 30.
112
+ - `subflows_config` (dict): The configuration of the subflows.
113
+ - `Controller` (dict): The configuration of the controller. It is important that the target of the controller (instance customizable by the user) and the api information should be specified.
114
+ - `Executor` (dict): The executor of the flow, it is supposed to be a branching flow. To instantiate the executor, the user needs to specify the subflows of the executor (i.e. the actual tools that can be used by the agent, e.g. a flow for interpreting code)
115
+ - `MemoryWriting` (dict): The configuration of the memory writer. There is an existing memory writing flow implemented.
116
+ - 'MemoryReading' (dict): The configuration of the memory reader. There is an existing memory reading flow implemented.
117
+ - `topology` (List): The topology of the subflows, notice that the output interface of the Controller must be implemented and specified.
118
+
119
+ *Input Interface*:
120
+ - `plan` (str): The plan generated by the planner, the CtrlExMem flow should follow the plan.
121
+ - `memory_files` (dict): mem_name - memfile_path pairs, the memory files that the memory reader will read from.
122
+ - `goal` (str): The goal of the flow
123
+ - `logs` (str): Execution history of the flow, contains all actions taken by each subflow of the flow.
124
+
125
+ *Output Interface*:
126
+ - `result` (str): The result of the flow, will be returned to the controller of the caller flow.
127
+ - `summary` (str): The summary of the flow, will be written to the logs of the caller flow.
128
+
129
+ <a id="CtrlExMemFlow.CtrlExMemFlow.detect_finish_or_continue"></a>
130
+
131
+ #### detect\_finish\_or\_continue
132
+
133
+ ```python
134
+ @abstractmethod
135
+ @CircularFlow.output_msg_payload_processor
136
+ def detect_finish_or_continue(output_payload: Dict[str, Any],
137
+ src_flow) -> Dict[str, Any]
138
+ ```
139
+
140
+ This function is called after the Controller, it is used to:
141
+
142
+ 1. Check if the Controller decides to early-exit, if so, implement necessary logics for exiting e.g. drafting result and summary, etc.
143
+ 2. For other commands called by the controller, implement necessary logics for the flow to continue e.g. providing necessary information to the branching flow.
144
+
145
+ **Arguments**:
146
+
147
+ - `output_payload` (`Dict[str, Any]`): The output payload of the Controller.
148
+ - `src_flow` (`Flow`): The source flow of the Controller.
149
+
150
+ **Returns**:
151
+
152
+ The input payload of the Executor.
153
+
154
+ <a id="__init__"></a>
155
+
156
+ # \_\_init\_\_
157
+