File size: 1,655 Bytes
8f80245
 
 
 
 
 
 
 
 
 
 
 
2dccc9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f80245
 
2dccc9b
 
 
 
8f80245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from flow_modules.aiflows.HumanStandardInputFlowModule import HumanStandardInputFlow

from typing import Dict, Any

from aiflows.messages import UpdateMessage_Generic

from aiflows.utils import logging

log = logging.get_logger(f"aiflows.{__name__}")


class ReplanningAskUserFlow(HumanStandardInputFlow):
    """Refer to: https://huggingface.co/aiflows/ExtendLibraryFlowModule/blob/main/ExtLibAskUserFlow.py

    *Input Interface*:
    - `question`

    *Output Interface*:
    - `feedback`
    - `new_plan`

    *Configuration Parameters*:
    - `request_multi_line_input_flag`: if True, the user can input multiple lines of text. Default: False
    - `end_of_input_string`: the string that the user can input to indicate that the input is finished. Default: EOI
    - `query_message_prompt_template`: the template of the message that is sent to the user to ask for input.

    """
    def run(self,
            input_data: Dict[str, Any]) -> Dict[str, Any]:
        """Run the flow module.
        :param input_data: the input data
        :return: the output data
        """

        query_message = self._get_message(self.query_message_prompt_template, input_data)
        state_update_message = UpdateMessage_Generic(
            created_by=self.flow_config['name'],
            updated_flow=self.flow_config["name"],
            data={"query_message": query_message},
        )
        self._log_message(state_update_message)

        log.info(query_message)
        human_input = self._read_input()

        response = {}
        response["feedback"] = human_input
        response["new_plan"] = "no new plan was written"

        return response