Download ControllerExecutorFlow.py from aiflows/ControllerExecutorFlowModule: direct link, hf CLI and curl.
- Browser
- Download file 958 Bytes
-
https://huggingface.co/aiflows/ControllerExecutorFlowModule/resolve/cbb225c3ad9452d0d2ba4a4d2554d359fbe0e0d3/ControllerExecutorFlow.py
- Command line
-
hf download hf://aiflows/ControllerExecutorFlowModule@cbb225c3ad9452d0d2ba4a4d2554d359fbe0e0d3/ControllerExecutorFlow.py
-
curl -L -o ControllerExecutorFlow.py https://huggingface.co/aiflows/ControllerExecutorFlowModule/resolve/cbb225c3ad9452d0d2ba4a4d2554d359fbe0e0d3/ControllerExecutorFlow.py
958 Bytes
| from typing import Dict, Any | |
| from flows.base_flows import CircularFlow | |
| from flows.utils import logging | |
| from .ControllerAtomicFlow import ControllerAtomicFlow | |
| logging.set_verbosity_debug() | |
| log = logging.get_logger(__name__) | |
| class ControllerExecutorFlow(CircularFlow): | |
| def _on_reach_max_round(self): | |
| self._state_update_dict({ | |
| "answer": "The maximum amount of rounds was reached before the model found an answer.", | |
| "status": "unfinished" | |
| }) | |
| def detect_finish_or_continue(self, output_payload: Dict[str, Any], src_flow: ControllerAtomicFlow) -> Dict[str, Any]: | |
| command = output_payload["command"] | |
| if command == "finish": | |
| return { | |
| "EARLY_EXIT": True, | |
| "answer": output_payload["command_args"]["answer"], | |
| "status": "finished" | |
| } | |
| else: | |
| return output_payload | |