forked from microsoft/UFO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractor.py
87 lines (67 loc) · 2.04 KB
/
interactor.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from .. import utils
from art import text2art
from typing import Tuple
WELCOME_TEXT = """
Welcome to use UFO🛸, A UI-focused Agent for Windows OS Interaction.
{art}
Please enter your request to be completed🛸: """.format(
art=text2art("UFO")
)
def first_request() -> str:
"""
Ask for the first request.
:return: The first request.
"""
return input()
def new_request() -> Tuple[str, bool]:
"""
Ask for a new request.
:return: The new request and whether the conversation is complete.
"""
utils.print_with_color(
"""Please enter your new request. Enter 'N' for exit.""", "cyan"
)
request = input()
if request.upper() == "N":
complete = True
else:
complete = False
return request, complete
def experience_asker() -> bool:
"""
Ask for saving the conversation flow for future reference.
:return: Whether to save the conversation flow.
"""
utils.print_with_color(
"""Would you like to save the current conversation flow for future reference by the agent?
[Y] for yes, any other key for no.""",
"magenta",
)
ans = input()
if ans.upper() == "Y":
return True
else:
return False
def sensitive_step_asker(action, control_text) -> bool:
"""
Ask for confirmation for sensitive steps.
:param action: The action to be performed.
:param control_text: The control text.
:return: Whether to proceed.
"""
utils.print_with_color(
"[Input Required:] UFO🛸 will apply {action} on the [{control_text}] item. Please confirm whether to proceed or not. Please input Y or N.".format(
action=action, control_text=control_text
),
"magenta",
)
while True:
user_input = input().upper()
if user_input == "Y":
return True
elif user_input == "N":
return False
else:
print("Invalid choice. Please enter either Y or N. Try again.")