Tachi67 commited on
Commit
6defd55
·
1 Parent(s): 2be9814

Upload 3 files

Browse files
Files changed (3) hide show
  1. ContentWriterFlow.yaml +70 -0
  2. ContentWritrerFlow.py +27 -0
  3. __init__.py +8 -0
ContentWriterFlow.yaml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Abstract class, should provide more config in subclasses
2
+ name: "ContentWriter"
3
+ description: "Generated content, writes content to file and update content with user interaction"
4
+ max_rounds: 30
5
+
6
+
7
+ input_interface:
8
+ - "goal"
9
+ # in subclass, should provide key: file_location e.g. plan_file_location, code_file_location
10
+ output_interface:
11
+ - "answer"
12
+ - "status"
13
+
14
+ ### Subflows specification
15
+ subflows_config:
16
+ Controller:
17
+ _target_: Tachi67.ControllerAtomicFlowModule.ControllerAtomicFlow.instantiate_from_default_config
18
+ finish:
19
+ description: "Signal that the objective has been satisfied, and returns the answer to the user."
20
+ input_args: ["answer"]
21
+ backend:
22
+ api_infos: ???
23
+ model_name:
24
+ openai: gpt-4
25
+ azure: azure/gpt-4
26
+ # In subclasses, should provide specific command and command args.
27
+ # E.g.,
28
+ # commands:
29
+ # wiki_search:
30
+ # description: "Performs a search on Wikipedia."
31
+ # input_args: ["search_term"]
32
+
33
+
34
+ Executor:
35
+ _target_: flows.base_flows.BranchingFlow.instantiate_from_default_config
36
+ # In subclasses, should provide what are the branches of executors
37
+ # E.g.,
38
+ # subflows_config:
39
+ # wiki_search:
40
+ # _target_: .WikiSearchAtomicFlow.instantiate_from_default_config
41
+
42
+
43
+ early_exit_key: "EARLY_EXIT"
44
+
45
+ topology:
46
+ - goal: "Select the next action and prepare the input for the executor."
47
+ input_interface:
48
+ _target_: flows.interfaces.KeyInterface
49
+ additional_transformations:
50
+ - _target_: flows.data_transformations.KeyMatchInput
51
+ flow: Controller
52
+ output_interface:
53
+ # In subclasses, should provide name of function name of output processor
54
+ #_target_: ControllerExecutorFlow.detect_finish_or_continue
55
+ reset: false
56
+
57
+ - goal: "Execute the action specified by the Controller."
58
+ input_interface:
59
+ _target_: flows.interfaces.KeyInterface
60
+ keys_to_rename:
61
+ command: branch
62
+ command_args: branch_input_data
63
+ keys_to_select: ["branch", "branch_input_data"]
64
+ flow: Executor
65
+ output_interface:
66
+ _target_: flows.interfaces.KeyInterface
67
+ keys_to_rename:
68
+ branch_output_data: observation
69
+ keys_to_select: ["observation"]
70
+ reset: false
ContentWritrerFlow.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, Any
2
+
3
+ from flows.base_flows import CircularFlow
4
+ from flows.utils import logging
5
+ from abc import ABC, abstractmethod
6
+
7
+
8
+ logging.set_verbosity_debug()
9
+ log = logging.get_logger(__name__)
10
+
11
+
12
+ class ContentWriterFlow(CircularFlow, ABC):
13
+ @abstractmethod
14
+ def _on_reach_max_round(self):
15
+ """
16
+ should update flow state dictionary about the output variables and status.
17
+ """
18
+ pass
19
+
20
+ @abstractmethod
21
+ @CircularFlow.output_msg_payload_processor
22
+ def detect_finish_or_continue(self, output_payload: Dict[str, Any], src_flow) -> Dict[str, Any]:
23
+ """
24
+ 1. Writing content to file;
25
+ 2. Finish and early exit.
26
+ """
27
+ pass
__init__.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ dependencies = [
2
+ {"url": "Tachi67/ControllerAtomicFlowModule", "revision": "main"},
3
+ ]
4
+ from flows import flow_verse
5
+
6
+ flow_verse.sync_dependencies(dependencies)
7
+
8
+ from .ContentWritrerFlow import ContentWriterFlow