Tachi67 commited on
Commit
c2a8690
·
verified ·
1 Parent(s): 8c1f947

add docs and comments

Browse files
Files changed (2) hide show
  1. PlanGeneratorAtomicFlow.py +37 -0
  2. README.md +69 -0
PlanGeneratorAtomicFlow.py CHANGED
@@ -14,8 +14,24 @@ class PlanGeneratorAtomicFlow(ChatAtomicFlow):
14
 
15
  *Output Interface*:
16
  - `plan`
 
 
 
 
 
 
 
 
 
 
 
17
  """
18
  def __init__(self, **kwargs):
 
 
 
 
 
19
  super().__init__(**kwargs)
20
  self.hint_for_model = """
21
  Make sure your response is in the following format:
@@ -27,6 +43,13 @@ class PlanGeneratorAtomicFlow(ChatAtomicFlow):
27
 
28
  @classmethod
29
  def instantiate_from_config(cls, config):
 
 
 
 
 
 
 
30
  flow_config = deepcopy(config)
31
 
32
  kwargs = {"flow_config": flow_config}
@@ -41,10 +64,24 @@ class PlanGeneratorAtomicFlow(ChatAtomicFlow):
41
  return cls(**kwargs)
42
 
43
  def _update_prompts_and_input(self, input_data: Dict[str, Any]):
 
 
 
 
 
 
 
44
  if 'goal' in input_data:
45
  input_data['goal'] += self.hint_for_model
46
 
47
  def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
 
 
 
 
 
 
 
48
  self._update_prompts_and_input(input_data)
49
  while True:
50
  api_output = super().run(input_data)["api_output"].strip()
 
14
 
15
  *Output Interface*:
16
  - `plan`
17
+
18
+ *Configuration Parameters*:
19
+ - Also refer to ChatAtomicFlow (https://huggingface.co/aiflows/ChatFlowModule/blob/main/ChatAtomicFlow.py)
20
+ - `input_interface_non_initialized`: The input interface when the conversation is not initialized.
21
+ - `input_interface_initialized`: The input interface when the conversation is initialized.
22
+ - `output_interface`: The output interface.
23
+ - `backend`: The backend to use for the Chat API.
24
+ - `system_message_prompt_template`: The template for the system message prompt.
25
+ - `human_message_prompt_template`: The template for the human message prompt.
26
+ - `init_human_message_prompt_template`: The initial human message prompt.
27
+
28
  """
29
  def __init__(self, **kwargs):
30
+ """
31
+ This function instantiates the class.
32
+ :param kwargs: The configuration parameters.
33
+ :type kwargs: Dict[str, Any]
34
+ """
35
  super().__init__(**kwargs)
36
  self.hint_for_model = """
37
  Make sure your response is in the following format:
 
43
 
44
  @classmethod
45
  def instantiate_from_config(cls, config):
46
+ """
47
+ This function instantiates the class from a configuration.
48
+ :param config: The configuration.
49
+ :type config: Dict[str, Any]
50
+ :return: The instantiated class.
51
+ :rtype: ChatAtomicFlow
52
+ """
53
  flow_config = deepcopy(config)
54
 
55
  kwargs = {"flow_config": flow_config}
 
64
  return cls(**kwargs)
65
 
66
  def _update_prompts_and_input(self, input_data: Dict[str, Any]):
67
+ """
68
+ This function updates the prompts and input data.
69
+ :param input_data: The input data.
70
+ :type input_data: Dict[str, Any]
71
+ :return: None
72
+ :rtype: None
73
+ """
74
  if 'goal' in input_data:
75
  input_data['goal'] += self.hint_for_model
76
 
77
  def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
78
+ """
79
+ This function runs the flow.
80
+ :param input_data: The input data.
81
+ :type input_data: Dict[str, Any]
82
+ :return: The output data.
83
+ :rtype: Dict[str, Any]
84
+ """
85
  self._update_prompts_and_input(input_data)
86
  while True:
87
  api_output = super().run(input_data)["api_output"].strip()
README.md CHANGED
@@ -2,6 +2,10 @@
2
 
3
  * [PlanGeneratorAtomicFlow](#PlanGeneratorAtomicFlow)
4
  * [PlanGeneratorAtomicFlow](#PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow)
 
 
 
 
5
  * [\_\_init\_\_](#__init__)
6
 
7
  <a id="PlanGeneratorAtomicFlow"></a>
@@ -27,6 +31,71 @@ This class wraps around the Chat API to generate plan from a goal.
27
  *Output Interface*:
28
  - `plan`
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  <a id="__init__"></a>
31
 
32
  # \_\_init\_\_
 
2
 
3
  * [PlanGeneratorAtomicFlow](#PlanGeneratorAtomicFlow)
4
  * [PlanGeneratorAtomicFlow](#PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow)
5
+ * [\_\_init\_\_](#PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow.__init__)
6
+ * [instantiate\_from\_config](#PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow.instantiate_from_config)
7
+ * [run](#PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow.run)
8
+ * [run](#run)
9
  * [\_\_init\_\_](#__init__)
10
 
11
  <a id="PlanGeneratorAtomicFlow"></a>
 
31
  *Output Interface*:
32
  - `plan`
33
 
34
+ *Configuration Parameters*:
35
+ - Also refer to ChatAtomicFlow (https://huggingface.co/aiflows/ChatFlowModule/blob/main/ChatAtomicFlow.py)
36
+ - `input_interface_non_initialized`: The input interface when the conversation is not initialized.
37
+ - `input_interface_initialized`: The input interface when the conversation is initialized.
38
+ - `output_interface`: The output interface.
39
+ - `backend`: The backend to use for the Chat API.
40
+ - `system_message_prompt_template`: The template for the system message prompt.
41
+ - `human_message_prompt_template`: The template for the human message prompt.
42
+ - `init_human_message_prompt_template`: The initial human message prompt.
43
+
44
+ <a id="PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow.__init__"></a>
45
+
46
+ #### \_\_init\_\_
47
+
48
+ ```python
49
+ def __init__(**kwargs)
50
+ ```
51
+
52
+ This function instantiates the class.
53
+
54
+ **Arguments**:
55
+
56
+ - `kwargs` (`Dict[str, Any]`): The configuration parameters.
57
+
58
+ <a id="PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow.instantiate_from_config"></a>
59
+
60
+ #### instantiate\_from\_config
61
+
62
+ ```python
63
+ @classmethod
64
+ def instantiate_from_config(cls, config)
65
+ ```
66
+
67
+ This function instantiates the class from a configuration.
68
+
69
+ **Arguments**:
70
+
71
+ - `config` (`Dict[str, Any]`): The configuration.
72
+
73
+ **Returns**:
74
+
75
+ `ChatAtomicFlow`: The instantiated class.
76
+
77
+ <a id="PlanGeneratorAtomicFlow.PlanGeneratorAtomicFlow.run"></a>
78
+
79
+ #### run
80
+
81
+ ```python
82
+ def run(input_data: Dict[str, Any]) -> Dict[str, Any]
83
+ ```
84
+
85
+ This function runs the flow.
86
+
87
+ **Arguments**:
88
+
89
+ - `input_data` (`Dict[str, Any]`): The input data.
90
+
91
+ **Returns**:
92
+
93
+ `Dict[str, Any]`: The output data.
94
+
95
+ <a id="run"></a>
96
+
97
+ # run
98
+
99
  <a id="__init__"></a>
100
 
101
  # \_\_init\_\_