add more docs & comments
Browse files- InteractivePlanGenFlow.py +27 -0
- README.md +77 -8
InteractivePlanGenFlow.py
CHANGED
@@ -21,6 +21,14 @@ class InteractivePlanGenFlow(SequentialFlow):
|
|
21 |
- `plan`
|
22 |
- `feedback`
|
23 |
- `temp_plan_file_location`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
"""
|
25 |
REQUIRED_KEYS_CONFIG = ["max_rounds", "early_exit_key", "topology"]
|
26 |
|
@@ -28,10 +36,22 @@ class InteractivePlanGenFlow(SequentialFlow):
|
|
28 |
self,
|
29 |
**kwargs
|
30 |
):
|
|
|
|
|
|
|
|
|
|
|
31 |
super().__init__(**kwargs)
|
32 |
|
33 |
@classmethod
|
34 |
def instantiate_from_config(cls, config):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
flow_config = deepcopy(config)
|
36 |
|
37 |
kwargs = {"flow_config": flow_config}
|
@@ -43,6 +63,13 @@ class InteractivePlanGenFlow(SequentialFlow):
|
|
43 |
return cls(**kwargs)
|
44 |
|
45 |
def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# ~~~ sets the input_data in the flow_state dict ~~~
|
47 |
self._state_update_dict(update_data=input_data)
|
48 |
|
|
|
21 |
- `plan`
|
22 |
- `feedback`
|
23 |
- `temp_plan_file_location`
|
24 |
+
|
25 |
+
*Configuration Parameters*:
|
26 |
+
- `input_interface`: the input interface of the flow.
|
27 |
+
- `output_interface`: the output interface of the flow.
|
28 |
+
- `subflows_config`: the configuration of the subflows.
|
29 |
+
- `early_exit_key`: the key in the state dict that indicates whether the flow should exit early.
|
30 |
+
- `topology`: the topology of the subflows.
|
31 |
+
|
32 |
"""
|
33 |
REQUIRED_KEYS_CONFIG = ["max_rounds", "early_exit_key", "topology"]
|
34 |
|
|
|
36 |
self,
|
37 |
**kwargs
|
38 |
):
|
39 |
+
"""
|
40 |
+
This function initializes the flow.
|
41 |
+
:param kwargs: the configuration of the flow.
|
42 |
+
:type kwargs: Dict[str, Any]
|
43 |
+
"""
|
44 |
super().__init__(**kwargs)
|
45 |
|
46 |
@classmethod
|
47 |
def instantiate_from_config(cls, config):
|
48 |
+
"""
|
49 |
+
This function instantiates the flow from a configuration.
|
50 |
+
:param config: the configuration of the flow.
|
51 |
+
:type config: Dict[str, Any]
|
52 |
+
:return: the instantiated flow.
|
53 |
+
:rtype: InteractivePlanGenFlow
|
54 |
+
"""
|
55 |
flow_config = deepcopy(config)
|
56 |
|
57 |
kwargs = {"flow_config": flow_config}
|
|
|
63 |
return cls(**kwargs)
|
64 |
|
65 |
def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
66 |
+
"""
|
67 |
+
This function runs the flow.
|
68 |
+
:param input_data: the input data of the flow.
|
69 |
+
:type input_data: Dict[str, Any]
|
70 |
+
:return: the output data of the flow.
|
71 |
+
:rtype: Dict[str, Any]
|
72 |
+
"""
|
73 |
# ~~~ sets the input_data in the flow_state dict ~~~
|
74 |
self._state_update_dict(update_data=input_data)
|
75 |
|
README.md
CHANGED
@@ -1,4 +1,16 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
```
|
4 |
goal
|
@@ -7,21 +19,21 @@
|
|
7 |
|
|
8 |
v
|
9 |
+------------------+
|
10 |
-
| PlanGenerator | Generates plan given goal. (https://huggingface.co/
|
11 |
+------------------+
|
12 |
|
|
13 |
| (plan)
|
14 |
|
|
15 |
v
|
16 |
+-------------------+
|
17 |
-
| PlanFileEdit | Edit a temp file with the plan generated. (https://huggingface.co/
|
18 |
+-------------------+
|
19 |
|
|
20 |
| (temp_plan_file_location)
|
21 |
|
|
22 |
v
|
23 |
+------------------+
|
24 |
-
| ParseFeedback | Opens up the temp file until user closes the file, parse for user feedback. (https://huggingface.co/
|
25 |
+------------------+
|
26 |
|
|
27 |
| (plan, feedback)
|
@@ -32,11 +44,10 @@
|
|
32 |
```
|
33 |
|
34 |
|
35 |
-
# Table of Contents
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
<a id="InteractivePlanGenFlow"></a>
|
42 |
|
@@ -64,6 +75,64 @@ This flow writes code in an interactive manner. It is a sequential flow composed
|
|
64 |
- `feedback`
|
65 |
- `temp_plan_file_location`
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
<a id="__init__"></a>
|
68 |
|
69 |
# \_\_init\_\_
|
|
|
1 |
+
# Table of Contents
|
2 |
+
|
3 |
+
* [Structure of InteractivePlanGenFlow](#structure-of-interactiveplangenflow)
|
4 |
+
* [run](#run)
|
5 |
+
* [InteractivePlanGenFlow](#InteractivePlanGenFlow)
|
6 |
+
* [InteractivePlanGenFlow](#InteractivePlanGenFlow.InteractivePlanGenFlow)
|
7 |
+
* [\_\_init\_\_](#InteractivePlanGenFlow.InteractivePlanGenFlow.__init__)
|
8 |
+
* [instantiate\_from\_config](#InteractivePlanGenFlow.InteractivePlanGenFlow.instantiate_from_config)
|
9 |
+
* [run](#InteractivePlanGenFlow.InteractivePlanGenFlow.run)
|
10 |
+
* [\_\_init\_\_](#__init__)
|
11 |
+
|
12 |
+
|
13 |
+
# Structure of InteractivePlanGenFlow
|
14 |
|
15 |
```
|
16 |
goal
|
|
|
19 |
|
|
20 |
v
|
21 |
+------------------+
|
22 |
+
| PlanGenerator | Generates plan given goal. (https://huggingface.co/aiflows/PlanGeneratorFlowModule)
|
23 |
+------------------+
|
24 |
|
|
25 |
| (plan)
|
26 |
|
|
27 |
v
|
28 |
+-------------------+
|
29 |
+
| PlanFileEdit | Edit a temp file with the plan generated. (https://huggingface.co/aiflows/PlanFileEditFlowModule)
|
30 |
+-------------------+
|
31 |
|
|
32 |
| (temp_plan_file_location)
|
33 |
|
|
34 |
v
|
35 |
+------------------+
|
36 |
+
| ParseFeedback | Opens up the temp file until user closes the file, parse for user feedback. (https://huggingface.co/aiflows/ParseFeedbackFlowModule)
|
37 |
+------------------+
|
38 |
|
|
39 |
| (plan, feedback)
|
|
|
44 |
```
|
45 |
|
46 |
|
|
|
47 |
|
48 |
+
<a id="run"></a>
|
49 |
+
|
50 |
+
# run
|
51 |
|
52 |
<a id="InteractivePlanGenFlow"></a>
|
53 |
|
|
|
75 |
- `feedback`
|
76 |
- `temp_plan_file_location`
|
77 |
|
78 |
+
*Configuration Parameters*:
|
79 |
+
- `input_interface`: the input interface of the flow.
|
80 |
+
- `output_interface`: the output interface of the flow.
|
81 |
+
- `subflows_config`: the configuration of the subflows.
|
82 |
+
- `early_exit_key`: the key in the state dict that indicates whether the flow should exit early.
|
83 |
+
- `topology`: the topology of the subflows.
|
84 |
+
|
85 |
+
<a id="InteractivePlanGenFlow.InteractivePlanGenFlow.__init__"></a>
|
86 |
+
|
87 |
+
#### \_\_init\_\_
|
88 |
+
|
89 |
+
```python
|
90 |
+
def __init__(**kwargs)
|
91 |
+
```
|
92 |
+
|
93 |
+
This function initializes the flow.
|
94 |
+
|
95 |
+
**Arguments**:
|
96 |
+
|
97 |
+
- `kwargs` (`Dict[str, Any]`): the configuration of the flow.
|
98 |
+
|
99 |
+
<a id="InteractivePlanGenFlow.InteractivePlanGenFlow.instantiate_from_config"></a>
|
100 |
+
|
101 |
+
#### instantiate\_from\_config
|
102 |
+
|
103 |
+
```python
|
104 |
+
@classmethod
|
105 |
+
def instantiate_from_config(cls, config)
|
106 |
+
```
|
107 |
+
|
108 |
+
This function instantiates the flow from a configuration.
|
109 |
+
|
110 |
+
**Arguments**:
|
111 |
+
|
112 |
+
- `config` (`Dict[str, Any]`): the configuration of the flow.
|
113 |
+
|
114 |
+
**Returns**:
|
115 |
+
|
116 |
+
`InteractivePlanGenFlow`: the instantiated flow.
|
117 |
+
|
118 |
+
<a id="InteractivePlanGenFlow.InteractivePlanGenFlow.run"></a>
|
119 |
+
|
120 |
+
#### run
|
121 |
+
|
122 |
+
```python
|
123 |
+
def run(input_data: Dict[str, Any]) -> Dict[str, Any]
|
124 |
+
```
|
125 |
+
|
126 |
+
This function runs the flow.
|
127 |
+
|
128 |
+
**Arguments**:
|
129 |
+
|
130 |
+
- `input_data` (`Dict[str, Any]`): the input data of the flow.
|
131 |
+
|
132 |
+
**Returns**:
|
133 |
+
|
134 |
+
`Dict[str, Any]`: the output data of the flow.
|
135 |
+
|
136 |
<a id="__init__"></a>
|
137 |
|
138 |
# \_\_init\_\_
|