File size: 6,388 Bytes
37dc901 3e0718c 37dc901 3e0718c 37dc901 3e0718c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# Table of Contents
* [Structure of CodeWriterFlow](#structure-of-codewriterflow)
* [run\_codewriter](#run_codewriter)
* [CodeWriterCtrlFlow](#CodeWriterCtrlFlow)
* [CodeWriterCtrlFlow](#CodeWriterCtrlFlow.CodeWriterCtrlFlow)
* [CodeWriterAskUserFlow](#CodeWriterAskUserFlow)
* [CodeWriterAskUserFlow](#CodeWriterAskUserFlow.CodeWriterAskUserFlow)
* [run](#CodeWriterAskUserFlow.CodeWriterAskUserFlow.run)
* [CodeWriterFlow](#CodeWriterFlow)
* [CodeWriterFlow](#CodeWriterFlow.CodeWriterFlow)
* [detect\_finish\_or\_continue](#CodeWriterFlow.CodeWriterFlow.detect_finish_or_continue)
* [run](#CodeWriterFlow.CodeWriterFlow.run)
* [\_\_init\_\_](#__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](https://huggingface.co/Tachi67/CodeWriterFlowModule/blob/main/CodeWriterAskUserFlow.py): Ask user for info / confirmation, etc.
- [write_code](https://huggingface.co/Tachi67/InteractiveCodeGenFlowModule): Generates code (user edit is allowed) and fetches user feedback.
- [test](https://huggingface.co/Tachi67/TestCodeFlowModule): 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.
<a id="run_codewriter"></a>
# run\_codewriter
<a id="CodeWriterCtrlFlow"></a>
# CodeWriterCtrlFlow
<a id="CodeWriterCtrlFlow.CodeWriterCtrlFlow"></a>
## CodeWriterCtrlFlow Objects
```python
class CodeWriterCtrlFlow(ChatAtomicFlow)
```
refer to https://huggingface.co/Tachi67/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`
*Config 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.
<a id="CodeWriterAskUserFlow"></a>
# CodeWriterAskUserFlow
<a id="CodeWriterAskUserFlow.CodeWriterAskUserFlow"></a>
## CodeWriterAskUserFlow Objects
```python
class CodeWriterAskUserFlow(HumanStandardInputFlow)
```
This class is used to ask for user feedback whenever the controller is unsure of something, or need confirmation, etc.
*Expected Input*:
- `question`: The question asked by the controller
*Expected Behaviour*:
- The question is displayed, and the user gives feedback by inputing string.
*Expected Ouput*:
- `feedback`: The input of the user.
- `code`: No code was written.
<a id="CodeWriterAskUserFlow.CodeWriterAskUserFlow.run"></a>
#### run
```python
def run(input_data: Dict[str, Any]) -> Dict[str, Any]
```
Run the flow.
**Arguments**:
- `input_data`: The input data.
**Returns**:
The output data.
<a id="CodeWriterFlow"></a>
# CodeWriterFlow
<a id="CodeWriterFlow.CodeWriterFlow"></a>
## CodeWriterFlow Objects
```python
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/Tachi67/InteractiveCodeGenFlowModule)
*Input Interface*:
- `goal`
*Output Interface*:
- `code`
- `result`
- `summary`
- `status`
*Configuration Parameters*:
- `name`: Name of the flow
- `description`: Description of the flow
- `_target_`: The instantiation target of the flow
- `input_interface`: The input to the flow. Inherited from ContentWriterFlow, in this case, it is `goal`.
- `output_interface`: The output of the flow.
- `subflows_config`: Configurations of subflows
- `early_exit_keys`: The keys that will trigger an early exit of the flow
- `topology`: Configures the topology of the subflows, please have a special look at the I/O interfaces of the subflows.
<a id="CodeWriterFlow.CodeWriterFlow.detect_finish_or_continue"></a>
#### detect\_finish\_or\_continue
```python
@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 subflow
- `src_flow`: The subflow that generated the output payload
**Returns**:
The output payload of the subflow
<a id="CodeWriterFlow.CodeWriterFlow.run"></a>
#### run
```python
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
<a id="__init__"></a>
# \_\_init\_\_
|