Tachi67 commited on
Commit
075da16
·
verified ·
1 Parent(s): 6618112

Upload 6 files

Browse files
Files changed (2) hide show
  1. InteractiveCodeGenFlow.py +30 -0
  2. README.md +68 -43
InteractiveCodeGenFlow.py CHANGED
@@ -21,6 +21,15 @@ class InteractiveCodeGenFlow(SequentialFlow):
21
  - `code`
22
  - `feedback`
23
  - `temp_code_file_location`
 
 
 
 
 
 
 
 
 
24
  """
25
  REQUIRED_KEYS_CONFIG = ["max_rounds", "early_exit_key", "topology", "memory_files"]
26
 
@@ -29,11 +38,25 @@ class InteractiveCodeGenFlow(SequentialFlow):
29
  memory_files: Dict[str, Any],
30
  **kwargs
31
  ):
 
 
 
 
 
 
 
32
  super().__init__(**kwargs)
33
  self.memory_files = memory_files
34
 
35
  @classmethod
36
  def instantiate_from_config(cls, config):
 
 
 
 
 
 
 
37
  flow_config = deepcopy(config)
38
 
39
  kwargs = {"flow_config": flow_config}
@@ -49,6 +72,13 @@ class InteractiveCodeGenFlow(SequentialFlow):
49
  return cls(**kwargs)
50
 
51
  def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
 
 
 
 
 
 
 
52
  # ~~~ sets the input_data in the flow_state dict ~~~
53
  self._state_update_dict(update_data=input_data)
54
 
 
21
  - `code`
22
  - `feedback`
23
  - `temp_code_file_location`
24
+
25
+
26
+ *Configuration Parameters*:
27
+ - `input_interface`: the input interface of the flow.
28
+ - `output_interface`: the output interface of the flow.
29
+ - `subflows_config`: the configuration of the subflows.
30
+ - `early_exit_key`: the key in the state dict that indicates whether the flow should exit early.
31
+ - `topology`: the topology of the subflows.
32
+
33
  """
34
  REQUIRED_KEYS_CONFIG = ["max_rounds", "early_exit_key", "topology", "memory_files"]
35
 
 
38
  memory_files: Dict[str, Any],
39
  **kwargs
40
  ):
41
+ """
42
+ This function initializes the flow.
43
+ :param memory_files: the memory files that are used in the flow.
44
+ :type memory_files: Dict[str, Any]
45
+ :param kwargs: the keyword arguments.
46
+ :type kwargs: Any
47
+ """
48
  super().__init__(**kwargs)
49
  self.memory_files = memory_files
50
 
51
  @classmethod
52
  def instantiate_from_config(cls, config):
53
+ """
54
+ This function instantiates the flow from a configuration.
55
+ :param config: the configuration of the flow.
56
+ :type config: Dict[str, Any]
57
+ :return: the instantiated flow.
58
+ :rtype: Flow
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
+ """
76
+ This function runs the flow.
77
+ :param input_data: the input data to the flow.
78
+ :type input_data: Dict[str, Any]
79
+ :return: the output data from the flow.
80
+ :rtype: Dict[str, Any]
81
+ """
82
  # ~~~ sets the input_data in the flow_state dict ~~~
83
  self._state_update_dict(update_data=input_data)
84
 
README.md CHANGED
@@ -1,50 +1,11 @@
1
- ### Structure of InteractiveCodeGenFlow
2
-
3
- ```
4
- goal
5
- |
6
- |
7
- |
8
- v
9
- +------------------+
10
- | MemReading | Reads in the memory in the memory files. (https://huggingface.co/Tachi67/MemoryReadingFlowModule)https://huggingface.co/Tachi67/MemoryReadingFlowModule
11
- +------------------+
12
- |
13
- | (code_library: function signatures of the library)
14
- |
15
- v
16
- +------------------+
17
- | CodeGenerator | Generates code given goal, function signatures of the library. (https://huggingface.co/Tachi67/CodeGeneratorFlowModule)
18
- +------------------+
19
- |
20
- | (code, language_of_code)
21
- |
22
- v
23
- +-------------------+
24
- | CodeFileEdit | Edit a temp code file with the code generated. (https://huggingface.co/Tachi67/CodeFileEditFlowModule)
25
- +-------------------+
26
- |
27
- | (temp_code_file_location)
28
- |
29
- v
30
- +------------------+
31
- | ParseFeedback | Opens up the temp file until user closes the file, parse for user feedback. (https://huggingface.co/Tachi67/ParseFeedbackFlowModule)
32
- +------------------+
33
- |
34
- | (code, feedback)
35
- |
36
- v
37
- code, feedback
38
-
39
- ```
40
-
41
- Memory_files:
42
- - library.py
43
-
44
  # Table of Contents
45
 
46
  * [InteractiveCodeGenFlow](#InteractiveCodeGenFlow)
47
  * [InteractiveCodeGenFlow](#InteractiveCodeGenFlow.InteractiveCodeGenFlow)
 
 
 
 
48
  * [\_\_init\_\_](#__init__)
49
 
50
  <a id="InteractiveCodeGenFlow"></a>
@@ -73,6 +34,70 @@ This flow writes code in an interactive manner. It is a sequential flow composed
73
  - `feedback`
74
  - `temp_code_file_location`
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  <a id="__init__"></a>
77
 
78
  # \_\_init\_\_
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Table of Contents
2
 
3
  * [InteractiveCodeGenFlow](#InteractiveCodeGenFlow)
4
  * [InteractiveCodeGenFlow](#InteractiveCodeGenFlow.InteractiveCodeGenFlow)
5
+ * [\_\_init\_\_](#InteractiveCodeGenFlow.InteractiveCodeGenFlow.__init__)
6
+ * [instantiate\_from\_config](#InteractiveCodeGenFlow.InteractiveCodeGenFlow.instantiate_from_config)
7
+ * [run](#InteractiveCodeGenFlow.InteractiveCodeGenFlow.run)
8
+ * [run](#run)
9
  * [\_\_init\_\_](#__init__)
10
 
11
  <a id="InteractiveCodeGenFlow"></a>
 
34
  - `feedback`
35
  - `temp_code_file_location`
36
 
37
+
38
+ *Configuration Parameters*:
39
+ - `input_interface`: the input interface of the flow.
40
+ - `output_interface`: the output interface of the flow.
41
+ - `subflows_config`: the configuration of the subflows.
42
+ - `early_exit_key`: the key in the state dict that indicates whether the flow should exit early.
43
+ - `topology`: the topology of the subflows.
44
+
45
+ <a id="InteractiveCodeGenFlow.InteractiveCodeGenFlow.__init__"></a>
46
+
47
+ #### \_\_init\_\_
48
+
49
+ ```python
50
+ def __init__(memory_files: Dict[str, Any], **kwargs)
51
+ ```
52
+
53
+ This function initializes the flow.
54
+
55
+ **Arguments**:
56
+
57
+ - `memory_files` (`Dict[str, Any]`): the memory files that are used in the flow.
58
+ - `kwargs` (`Any`): the keyword arguments.
59
+
60
+ <a id="InteractiveCodeGenFlow.InteractiveCodeGenFlow.instantiate_from_config"></a>
61
+
62
+ #### instantiate\_from\_config
63
+
64
+ ```python
65
+ @classmethod
66
+ def instantiate_from_config(cls, config)
67
+ ```
68
+
69
+ This function instantiates the flow from a configuration.
70
+
71
+ **Arguments**:
72
+
73
+ - `config` (`Dict[str, Any]`): the configuration of the flow.
74
+
75
+ **Returns**:
76
+
77
+ `Flow`: the instantiated flow.
78
+
79
+ <a id="InteractiveCodeGenFlow.InteractiveCodeGenFlow.run"></a>
80
+
81
+ #### run
82
+
83
+ ```python
84
+ def run(input_data: Dict[str, Any]) -> Dict[str, Any]
85
+ ```
86
+
87
+ This function runs the flow.
88
+
89
+ **Arguments**:
90
+
91
+ - `input_data` (`Dict[str, Any]`): the input data to the flow.
92
+
93
+ **Returns**:
94
+
95
+ `Dict[str, Any]`: the output data from the flow.
96
+
97
+ <a id="run"></a>
98
+
99
+ # run
100
+
101
  <a id="__init__"></a>
102
 
103
  # \_\_init\_\_