Flow card was missing
Browse files
README.md
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
---
|
4 |
+
|
5 |
+
# Table of Contents
|
6 |
+
|
7 |
+
* [\_\_init\_\_](#__init__)
|
8 |
+
* [DemonstrationsAtomicFlow](#DemonstrationsAtomicFlow)
|
9 |
+
* [DemonstrationsAtomicFlow](#DemonstrationsAtomicFlow.DemonstrationsAtomicFlow)
|
10 |
+
* [instantiate\_from\_config](#DemonstrationsAtomicFlow.DemonstrationsAtomicFlow.instantiate_from_config)
|
11 |
+
* [run](#DemonstrationsAtomicFlow.DemonstrationsAtomicFlow.run)
|
12 |
+
* [ChatWithDemonstrationsFlow](#ChatWithDemonstrationsFlow)
|
13 |
+
* [ChatWithDemonstrationsFlow](#ChatWithDemonstrationsFlow.ChatWithDemonstrationsFlow)
|
14 |
+
|
15 |
+
<a id="__init__"></a>
|
16 |
+
|
17 |
+
# \_\_init\_\_
|
18 |
+
|
19 |
+
<a id="DemonstrationsAtomicFlow"></a>
|
20 |
+
|
21 |
+
# DemonstrationsAtomicFlow
|
22 |
+
|
23 |
+
<a id="DemonstrationsAtomicFlow.DemonstrationsAtomicFlow"></a>
|
24 |
+
|
25 |
+
## DemonstrationsAtomicFlow Objects
|
26 |
+
|
27 |
+
```python
|
28 |
+
class DemonstrationsAtomicFlow(AtomicFlow)
|
29 |
+
```
|
30 |
+
|
31 |
+
This class implements a Demonstrations Atomic Flow. It is a flow which is usually used to pass demonstrations (of user assistant interactions)
|
32 |
+
|
33 |
+
to the ChatAtomicFlow.
|
34 |
+
|
35 |
+
*Configuration Parameters*:
|
36 |
+
|
37 |
+
- `name` (str): The name of the flow. Default: "DemonstrationsAtomicFlow"
|
38 |
+
- `description` (str): A description of the flow. This description is used to generate the help message of the flow.
|
39 |
+
Default: "A flow that passes demonstrations to the ChatFlow"
|
40 |
+
- `data` (List[Dict[str, Any]]): The data of the demonstrations.
|
41 |
+
If data is None, the data is loaded from the file specified in the params["data_dir"].
|
42 |
+
Default: No default value this field must be set.
|
43 |
+
- `params` (Dict[str, Any]): The parameters specific to the dataset of the demonstrations. Its default parameters are:
|
44 |
+
- `data_dir` (str): The directory where the demonstrations are stored. If the data is not directly passed to the flow through `data` then
|
45 |
+
the data is loaded from this directory. Default: No default value this field must be set.
|
46 |
+
- `demonstrations_id` (str): The id of the demonstrations (name of the data file). If the data is not directly passed to the flow through `data` then
|
47 |
+
the data is loaded from this file. Default: No default value this field must be set.
|
48 |
+
- `demonstrations_k` (int): The number of demonstrations to pass to the ChatFlow.
|
49 |
+
If None, all the demonstrations are passed to the ChatFlow. Default: None
|
50 |
+
- `query_prompt_template` (Dict[str, Any]): The prompt template used to generate the query of the demonstrations.
|
51 |
+
By default its of type flows.prompt_template.JinjaPrompt. None of the parameters of the prompt are defined by default and therefore need to be defined if one
|
52 |
+
wants to use the query_prompt_template. Default parameters are defined in flows.prompt_template.jinja2_prompts.JinjaPrompt.
|
53 |
+
- `response_prompt_template` (Dict[str, Any]): The prompt template used to generate the response of the demonstrations. By default its of type flows.prompt_template.JinjaPrompt.
|
54 |
+
None of the parameters of the prompt are defined by default and therefore need to be defined if one
|
55 |
+
wants to use the response_prompt_template. Default parameters are defined in flows.prompt_template.jinja2_prompts.JinjaPrompt.
|
56 |
+
|
57 |
+
*Input Interface*:
|
58 |
+
|
59 |
+
- The input interface expected by its successor flow (e.g. typically ChatAtomicFlow so the input interface is the one expected by ChatAtomicFlow)
|
60 |
+
|
61 |
+
*Output Interface*:
|
62 |
+
|
63 |
+
- The input interface expected by its successor flow (e.g. typically ChatAtomicFlow so the input interface expected by ChatAtomicFlow))
|
64 |
+
- `demonstrations` (List[Dict[str, Any]]): A list of demonstrations. Each demonstration is a dictionary with the following keys:
|
65 |
+
- idx (int): The index of the demonstration
|
66 |
+
- query (str): The query of the demonstration
|
67 |
+
- response (str): The response of the demonstration
|
68 |
+
|
69 |
+
**Arguments**:
|
70 |
+
|
71 |
+
- `params` (`Dict[str, Any]`): The parameters specific to the dataset of the demonstrations. It must sould contain the following keys:
|
72 |
+
- 'data_dir' (str): The directory where the demonstrations are stored. This field is used if the data is not directly passed to the flow through the 'data' field.
|
73 |
+
- 'demonstrations_id' (str): The id of the demonstrations (name of the data file). This field is used if the data is not directly passed to the flow through the 'data' field.
|
74 |
+
- 'demonstrations_k' (int): The number of demonstrations to pass to the ChatFlow. If None, all the demonstrations are passed to the ChatFlow.
|
75 |
+
- 'ids_to_keep' (Optional[Union[str, List[str]]]): The ids of the demonstrations to keep. If None, all the demonstrations are kept.
|
76 |
+
- `query_prompt_template` (`JinjaPrompt`): The prompt template used to generate the query of the demonstrations.
|
77 |
+
- `response_prompt_template` (`JinjaPrompt`): The prompt template used to generate the response of the demonstrations.
|
78 |
+
- `data` (`Optional[List[Dict[str, Any]]]`): The data of the demonstrations. If None, the data is loaded from the file specified in the params.
|
79 |
+
|
80 |
+
<a id="DemonstrationsAtomicFlow.DemonstrationsAtomicFlow.instantiate_from_config"></a>
|
81 |
+
|
82 |
+
#### instantiate\_from\_config
|
83 |
+
|
84 |
+
```python
|
85 |
+
@classmethod
|
86 |
+
def instantiate_from_config(cls, config)
|
87 |
+
```
|
88 |
+
|
89 |
+
This method instantiates the flow from a config file.
|
90 |
+
|
91 |
+
**Arguments**:
|
92 |
+
|
93 |
+
- `config` (`Dict[str, Any]`): The configuration of the flow.
|
94 |
+
|
95 |
+
**Returns**:
|
96 |
+
|
97 |
+
`Flow`: The instantiated flow.
|
98 |
+
|
99 |
+
<a id="DemonstrationsAtomicFlow.DemonstrationsAtomicFlow.run"></a>
|
100 |
+
|
101 |
+
#### run
|
102 |
+
|
103 |
+
```python
|
104 |
+
def run(input_data: Dict[str, Any]) -> Dict[str, Any]
|
105 |
+
```
|
106 |
+
|
107 |
+
This method runs the flow. It returns the input data of the flow with the demonstrations added to it.
|
108 |
+
|
109 |
+
**Arguments**:
|
110 |
+
|
111 |
+
- `input_data` (`Dict[str, Any]`): The input data of the flow.
|
112 |
+
|
113 |
+
**Returns**:
|
114 |
+
|
115 |
+
`Dict[str, Any]`: The input data of the flow with the demonstrations added to it.
|
116 |
+
|
117 |
+
<a id="ChatWithDemonstrationsFlow"></a>
|
118 |
+
|
119 |
+
# ChatWithDemonstrationsFlow
|
120 |
+
|
121 |
+
<a id="ChatWithDemonstrationsFlow.ChatWithDemonstrationsFlow"></a>
|
122 |
+
|
123 |
+
## ChatWithDemonstrationsFlow Objects
|
124 |
+
|
125 |
+
```python
|
126 |
+
class ChatWithDemonstrationsFlow(SequentialFlow)
|
127 |
+
```
|
128 |
+
|
129 |
+
A Chat with Demonstrations Flow. It is a flow that consists of multiple sub-flows that are executed sequentially.
|
130 |
+
|
131 |
+
It's parent class is SequentialFlow.
|
132 |
+
|
133 |
+
It Contains the following subflows:
|
134 |
+
- A Demonstration Flow: It is a flow that passes demonstrations to the ChatFlow
|
135 |
+
- A Chat Flow: It is a flow that uses the demonstrations to answer queries asked by the user/human.
|
136 |
+
|
137 |
+
An illustration of the flow is as follows:
|
138 |
+
|
139 |
+
-------> Demonstration Flow -------> Chat Flow ------->
|
140 |
+
|
141 |
+
*Configuration Parameters*:
|
142 |
+
|
143 |
+
- `name` (str): The name of the flow. Default: "ChatAtomic_Flow_with_Demonstrations"
|
144 |
+
- `description` (str): A description of the flow. This description is used to generate the help message of the flow.
|
145 |
+
Default: "A sequential flow that answers questions with demonstrations"
|
146 |
+
- `subflows_config` (Dict[str,Any]): A dictionary of subflows configurations of the sequential Flow. Default:
|
147 |
+
- `Demonstration Flow`: The configuration of the Demonstration Flow. By default, it a DemonstrationsAtomicFlow.
|
148 |
+
Its default parmaters are defined in DemonstrationsAtomicFlow).
|
149 |
+
- `Chat Flow`: The configuration of the Chat Flow. By default, its a ChatAtomicFlow.
|
150 |
+
Its default parmaters are defined in ChatAtomicFlowModule (see Flowcard, i.e. README.md, of ChatAtomicFlowModule).
|
151 |
+
- `topology` (str): The topology of the flow which is "sequential". By default, the topology is the one shown in the
|
152 |
+
illustration above (the topology is also described in ChatWithDemonstrationsFlow.yaml).
|
153 |
+
|
154 |
+
*Input Interface*:
|
155 |
+
|
156 |
+
- `query` (str): A query asked to the flow (e.g. "What is the capital of France?")
|
157 |
+
|
158 |
+
Output Interface:
|
159 |
+
|
160 |
+
- `answer` (str): The answer of the flow to the query
|
161 |
+
|
162 |
+
**Arguments**:
|
163 |
+
|
164 |
+
- `\**kwargs`: Arguments to be passed to the parent class SequentialFlow constructor.
|
165 |
+
|