Upload 5 files
Browse files- AbstractBossFlow.yaml +1 -1
- CtrlExMemFlow.py +20 -0
- CtrlExMemFlow.yaml +91 -0
- __init__.py +4 -2
AbstractBossFlow.yaml
CHANGED
|
@@ -21,7 +21,7 @@ subflows_config:
|
|
| 21 |
|
| 22 |
# the flow with a controller, few executors in a branch, memory reading and memory writing
|
| 23 |
CtrlExMem:
|
| 24 |
-
_target_: Tachi67.
|
| 25 |
|
| 26 |
early_exit_key: "EARLY_EXIT"
|
| 27 |
|
|
|
|
| 21 |
|
| 22 |
# the flow with a controller, few executors in a branch, memory reading and memory writing
|
| 23 |
CtrlExMem:
|
| 24 |
+
_target_: Tachi67.AbstractBossFlowModule.CtrlExMemFlow.instantiate_from_default_config
|
| 25 |
|
| 26 |
early_exit_key: "EARLY_EXIT"
|
| 27 |
|
CtrlExMemFlow.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 CtrlExMemFlow(CircularFlow, ABC):
|
| 13 |
+
@abstractmethod
|
| 14 |
+
def _on_reach_max_round(self):
|
| 15 |
+
pass
|
| 16 |
+
|
| 17 |
+
@abstractmethod
|
| 18 |
+
@CircularFlow.output_msg_payload_processor
|
| 19 |
+
def detect_finish_or_continue(self, output_payload: Dict[str, Any], src_flow) -> Dict[str, Any]:
|
| 20 |
+
pass
|
CtrlExMemFlow.yaml
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Abstract class, should provide more information in subclasses
|
| 2 |
+
|
| 3 |
+
_target_: Tachi67.AbstractBossFlowModule.CtrlExMemFlow.instantiate_from_default_config
|
| 4 |
+
|
| 5 |
+
name: "AbstractCtrlExMemFlow"
|
| 6 |
+
description: "Abstract class of controller-executor flow with mem reading and mem writing"
|
| 7 |
+
max_rounds: 30
|
| 8 |
+
|
| 9 |
+
input_interface:
|
| 10 |
+
- "plan"
|
| 11 |
+
- "memory_files"
|
| 12 |
+
|
| 13 |
+
output_interface:
|
| 14 |
+
- "summary"
|
| 15 |
+
- "answer"
|
| 16 |
+
|
| 17 |
+
subflows_config:
|
| 18 |
+
Controller:
|
| 19 |
+
_target_: ??? # controller of the flow, could be a subclass of ChatAtomic flow, see https://huggingface.co/Tachi67/CodeWriterFlowModule/blob/main/CodeWriterCtrlFlow.py
|
| 20 |
+
backend:
|
| 21 |
+
api_infos: ???
|
| 22 |
+
model_name:
|
| 23 |
+
openai: gpt-4
|
| 24 |
+
azure: azure/gpt-4
|
| 25 |
+
# In subclasses, should provide specific command and command args.
|
| 26 |
+
# E.g.,
|
| 27 |
+
# commands:
|
| 28 |
+
# wiki_search:
|
| 29 |
+
# description: "Performs a search on Wikipedia."
|
| 30 |
+
# input_args: ["search_term"]
|
| 31 |
+
|
| 32 |
+
Executor:
|
| 33 |
+
_target_: flows.base_flows.BranchingFlow.instantiate_from_default_config
|
| 34 |
+
# In subclasses, should provide what are the branches of executors
|
| 35 |
+
# E.g.,
|
| 36 |
+
# subflows_config:
|
| 37 |
+
# wiki_search:
|
| 38 |
+
# _target_: .WikiSearchAtomicFlow.instantiate_from_default_config
|
| 39 |
+
|
| 40 |
+
MemoryWriting:
|
| 41 |
+
_target_: Tachi67.MemoryWritingFlowModule.MemoryWritingFlow.instantiate_from_default_config
|
| 42 |
+
# default input interface is summary & memory_files
|
| 43 |
+
|
| 44 |
+
MemoryReading:
|
| 45 |
+
_target_: Tachi67.MemoryReadingFlowModule.MemoryReadingAtomicFlow.instantiate_from_default_config
|
| 46 |
+
# should provide the output of MemRead in the CtrlExMem flow e.g. plan, logs, code_library
|
| 47 |
+
# output is then like {"plan":"plan string", "code_library": "function signatures in the code library"}
|
| 48 |
+
# default output interface is code_library
|
| 49 |
+
|
| 50 |
+
topology:
|
| 51 |
+
- goal: "Select the next action and prepare the input for the executor."
|
| 52 |
+
input_interface:
|
| 53 |
+
_target_: flows.interfaces.KeyInterface
|
| 54 |
+
additional_transformations:
|
| 55 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
| 56 |
+
flow: Controller
|
| 57 |
+
output_interface: ???
|
| 58 |
+
# In subclasses, should provide name of function name of output processor
|
| 59 |
+
#_target_: Controller.detect_finish_or_continue
|
| 60 |
+
reset: false
|
| 61 |
+
|
| 62 |
+
- goal: "Execute the action specified by the Controller."
|
| 63 |
+
input_interface:
|
| 64 |
+
_target_: flows.interfaces.KeyInterface
|
| 65 |
+
keys_to_rename:
|
| 66 |
+
command: branch
|
| 67 |
+
command_args: branch_input_data
|
| 68 |
+
keys_to_select: ["branch", "branch_input_data"]
|
| 69 |
+
flow: Executor
|
| 70 |
+
output_interface:
|
| 71 |
+
_target_: flows.interfaces.KeyInterface
|
| 72 |
+
keys_to_rename:
|
| 73 |
+
branch_output_data: observation
|
| 74 |
+
keys_to_unpack: ["observation"]
|
| 75 |
+
reset: false
|
| 76 |
+
|
| 77 |
+
- goal: "Write memory to memory files"
|
| 78 |
+
input_interface:
|
| 79 |
+
_target_: flows.interfaces.KeyInterface
|
| 80 |
+
additional_transformations:
|
| 81 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
| 82 |
+
flow: MemoryWriting
|
| 83 |
+
reset: false
|
| 84 |
+
|
| 85 |
+
- goal: "Read memory from memory files (flow_state)"
|
| 86 |
+
input_interface:
|
| 87 |
+
_target_: flows.interfaces.KeyInterface
|
| 88 |
+
additional_transformations:
|
| 89 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
| 90 |
+
flow: MemoryReading
|
| 91 |
+
reset: false
|
__init__.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
dependencies = [
|
| 2 |
{"url": "Tachi67/MemoryReadingFlowModule", "revision": "main"},
|
| 3 |
{"url": "Tachi67/PlanWriterFlowModule", "revision":"main"},
|
| 4 |
-
{"url": "Tachi67/
|
|
|
|
| 5 |
]
|
| 6 |
from flows import flow_verse
|
| 7 |
|
| 8 |
flow_verse.sync_dependencies(dependencies)
|
| 9 |
-
from .AbstractBossFlow import AbstractBossFlow
|
|
|
|
|
|
| 1 |
dependencies = [
|
| 2 |
{"url": "Tachi67/MemoryReadingFlowModule", "revision": "main"},
|
| 3 |
{"url": "Tachi67/PlanWriterFlowModule", "revision":"main"},
|
| 4 |
+
{"url": "Tachi67/MemoryReadingFlowModule", "revision":"main"},
|
| 5 |
+
{"url": "Tachi67/MemoryWritingFlowModule", "revision":"main"},
|
| 6 |
]
|
| 7 |
from flows import flow_verse
|
| 8 |
|
| 9 |
flow_verse.sync_dependencies(dependencies)
|
| 10 |
+
from .AbstractBossFlow import AbstractBossFlow
|
| 11 |
+
from .CtrlExMemFlow import CtrlExMemFlow
|