user-simulator 0.2.4__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. config/__init__.py +0 -0
  2. config/__pycache__/__init__.cpython-312.pyc +0 -0
  3. config/asr_configuration/__init__.py +0 -0
  4. config/asr_configuration/default_asr_config.yml +8 -0
  5. config/misc/__init__.py +0 -0
  6. config/misc/sound/__init__.py +0 -0
  7. config/misc/sound/c1bccaed.wav +0 -0
  8. config/models/__init__.py +0 -0
  9. config/models/models.yml +15 -0
  10. config/patterns/__init__.py +0 -0
  11. config/patterns/end_conversation_patterns.yml +40 -0
  12. config/patterns/fallback_patterns.yml +9 -0
  13. config/personalities/__init__.py +0 -0
  14. config/personalities/conversational-user.yml +6 -0
  15. config/personalities/curious-user.yml +5 -0
  16. config/personalities/direct-user.yml +4 -0
  17. config/personalities/disorganized-user.yml +5 -0
  18. config/personalities/elderly-user.yml +6 -0
  19. config/personalities/formal-user.yml +4 -0
  20. config/personalities/impatient-user.yml +4 -0
  21. config/personalities/rude-user.yml +6 -0
  22. config/personalities/sarcastic-user.yml +4 -0
  23. config/personalities/skeptical-user.yml +5 -0
  24. config/types/__init__.py +0 -0
  25. config/types/currency.yml +10 -0
  26. config/types/phone_number.yml +4 -0
  27. data/__init__.py +0 -0
  28. data/__pycache__/__init__.cpython-312.pyc +0 -0
  29. data/audio_files/__init__.py +0 -0
  30. data/audio_files/output.mp3 +0 -0
  31. data/audio_files/output.wav +0 -0
  32. data/cache/__init__.py +0 -0
  33. data/cache/image_register.json +238 -0
  34. data/cache/pdf_register.json +3 -0
  35. data/cache/webpage_register.json +67 -0
  36. data/connectors/__init__.py +0 -0
  37. data/connectors/dialogflow.yml +16 -0
  38. data/connectors/julie.yml +37 -0
  39. data/connectors/kuki.yml +16 -0
  40. data/connectors/millionbot_ada.yml +25 -0
  41. data/connectors/rasa.yml +8 -0
  42. data/connectors/serviceform.yml +17 -0
  43. data/connectors/taskyto.yml +8 -0
  44. data/element_lists/__init__.py +0 -0
  45. data/element_lists/list_of_things.yml +7 -0
  46. data/list_functions/__init__.py +0 -0
  47. data/pdfs/Normativa_TFMs_EPS.pdf +0 -0
  48. data/pdfs/__init__.py +0 -0
  49. data/readme_data/__init__.py +0 -0
  50. data/readme_data/img.png +0 -0
  51. user_sim/cli/cli.py +116 -20
  52. user_sim/cli/sensei_chat.py +58 -230
  53. user_sim/core/role_structure.py +4 -3
  54. user_sim/handlers/asr_module.py +5 -2
  55. user_sim/handlers/pdf_parser_module.py +1 -0
  56. user_sim/utils/config.py +10 -2
  57. user_sim/utils/register_management.py +2 -3
  58. user_sim/utils/utilities.py +60 -46
  59. {user_simulator-0.2.4.dist-info → user_simulator-0.3.0.dist-info}/METADATA +5 -2
  60. user_simulator-0.3.0.dist-info/RECORD +99 -0
  61. {user_simulator-0.2.4.dist-info → user_simulator-0.3.0.dist-info}/top_level.txt +1 -0
  62. user_simulator-0.2.4.dist-info/RECORD +0 -49
  63. {user_simulator-0.2.4.dist-info → user_simulator-0.3.0.dist-info}/WHEEL +0 -0
  64. {user_simulator-0.2.4.dist-info → user_simulator-0.3.0.dist-info}/entry_points.txt +0 -0
  65. {user_simulator-0.2.4.dist-info → user_simulator-0.3.0.dist-info}/licenses/LICENSE.txt +0 -0
File without changes
@@ -0,0 +1,16 @@
1
+ config:
2
+ api_url: "aaa"
3
+ headers:
4
+ Content-Type: 'application/json'
5
+ timeout: 10000
6
+ request_key: "queryInput.text.text"
7
+ response_key: "queryResult.fulfillmentText"
8
+
9
+ payload:
10
+ queryInput:
11
+ text:
12
+ text:
13
+ languageCode: "en"
14
+
15
+ parameters:
16
+ - api_url
@@ -0,0 +1,37 @@
1
+ config:
2
+ api_url: 'https://askjulie2.nextit.com/AlmeAPI/api/Conversation/Converse'
3
+ headers:
4
+ Content-Type: 'application/json'
5
+ timeout: 10000
6
+ request_key: ["question", "displayText"]
7
+ response_key: "text"
8
+
9
+
10
+ payload:
11
+ userId: "4b62a896-85f0-45dd-b94c-a6496f831107"
12
+ sessionId: "724e371e-9917-4ab2-9da4-6809199366eb"
13
+ question: "How are you?"
14
+ origin: "Typed"
15
+ displayText: "How are you?"
16
+ channel: "Web"
17
+ language: "en-US"
18
+ accessKey: "00000000-0000-0000-0000-000000000000"
19
+ parameters:
20
+ UiVersion: "1.33.17"
21
+ Context:
22
+ CurrentUrl:
23
+ AbsolutePath: "https://www.amtrak.com/home.html"
24
+ Protocol: "https:"
25
+ Host: "www.amtrak.com"
26
+ HostName: "www.amtrak.com"
27
+ Port: ""
28
+ Uri: "/home.html"
29
+ Query: ""
30
+ Fragment: ""
31
+ Origin: "https://www.amtrak.com"
32
+ Type: "embedded"
33
+ PageName: "Amtrak Tickets, Schedules and Train Routes"
34
+
35
+ parameters:
36
+ - userId
37
+ - sessionId
@@ -0,0 +1,16 @@
1
+ config:
2
+ api_url: "https://kuli.kuki.ai/cptalk"
3
+ headers:
4
+ Content-Type: 'application/x-www-form-urlencoded' # Standard for form data
5
+ timeout: 10000
6
+ request_key: "input"
7
+ response_key: "responses"
8
+
9
+ payload:
10
+ uid: ''
11
+ input: 'Hello'
12
+ sessionid: ''
13
+
14
+ parameters:
15
+ - sessionid
16
+ - uid
@@ -0,0 +1,25 @@
1
+ config:
2
+ timeout: 20
3
+
4
+ payload:
5
+ bot: "60a3be81f9a6b98f7659a6f9"
6
+
7
+ parameters:
8
+ - bot
9
+
10
+
11
+ #api_url: "https://api.1millionbot.com/api/public/users"
12
+ #headers:
13
+ # ContentType: 'application/json'
14
+ # Authorization: 'API-KEY 60553d58c41f5dfa095b34b5'
15
+ #
16
+ #
17
+ #payload:
18
+ # conversation: "670577afe0d59bbc894897b2"
19
+ # sender_type: "User"
20
+ # sender: "670577af4e61b2bc9462703f"
21
+ # bot: "60a3be81f9a6b98f7659a6f9"
22
+ # language: "es"
23
+ # url: "https://www.uam.es/uam/tecnologias-informacion"
24
+ # message:
25
+ # text: "Hola"
@@ -0,0 +1,8 @@
1
+ config:
2
+ api_url: "http://localhost:5005/webhooks/rest/webhook"
3
+ timeout: 60
4
+
5
+ payload: ''
6
+
7
+ parameters:
8
+ - api_url
@@ -0,0 +1,17 @@
1
+ config:
2
+ api_url: "https://dash.serviceform.com/api/ai"
3
+ headers:
4
+ Content-Type: 'text/plain;charset=UTF-8'
5
+ timeout: 10000
6
+
7
+ payload:
8
+ sid: "1729589460223tvzbcxe5zocgr5hs"
9
+ tid: "haGDRXUPY9tQOsOS44jY"
10
+ message: "Hello"
11
+ extraTraining: ""
12
+ assistant_id: "asst_PUNPPDAFOgHRLrlmHhDuQhCM"
13
+
14
+ parameters:
15
+ - sid
16
+ - tid
17
+ - assistant_id
@@ -0,0 +1,8 @@
1
+ config:
2
+ api_url: http://127.0.0.1:5000
3
+ timeout: 60
4
+
5
+ payload: ''
6
+
7
+ parameters:
8
+ - api_url
File without changes
@@ -0,0 +1,7 @@
1
+ pizzas:
2
+ - margarita
3
+ - pepperoni
4
+ - marinara
5
+ - carbonara
6
+ - bbq
7
+ - four cheese
File without changes
Binary file
data/pdfs/__init__.py ADDED
File without changes
File without changes
Binary file
user_sim/cli/cli.py CHANGED
@@ -1,34 +1,61 @@
1
+ import os
2
+ import yaml
3
+ import sys
1
4
  import argparse
2
5
  from argparse import Namespace
3
6
  from chatbot_connectors import parse_connector_params
4
7
 
5
- def parse_chat_arguments() -> Namespace:
8
+ def load_yaml_arguments(project_path):
9
+ files = os.listdir(project_path)
10
+
11
+ run_file = next((f for f in files if f in ["run.yml", "run.yaml"]), None)
12
+
13
+ if not run_file:
14
+ raise FileNotFoundError(f"Couldn't find run.yml file.")
15
+
16
+ run_yaml_path = os.path.join(project_path, run_file)
17
+
18
+ with open(run_yaml_path, 'r', encoding='utf-8') as f:
19
+ yaml_args = yaml.safe_load(f) or {}
20
+
21
+ if "execution_parameters" in yaml_args:
22
+ parameters = yaml_args.pop("execution_parameters") or []
23
+ yaml_args.update({param: True for param in parameters})
24
+
25
+ normalized = {}
26
+ for k, v in yaml_args.items():
27
+ normalized[k.replace("-", "_")] = v
28
+
29
+ normalized["project_path"] = project_path
30
+ return normalized
31
+
32
+
33
+ def parse_chat_arguments(argv=None) -> Namespace:
6
34
  """Parse command line arguments."""
7
35
  parser = argparse.ArgumentParser(description="User Simulator - Converses with chatbots to test capabilities")
8
36
 
9
- # default_sessions = 3
10
- # default_turns = 8
11
- # default_model = "gpt-4o-mini"
12
37
  default_output_dir = "output"
13
38
  default_technology = "taskyto"
14
39
 
15
-
16
40
  parser.add_argument(
17
- "-rfy"
41
+ "-rfy",
18
42
  "--run-from-yaml",
43
+ dest="run_from_yaml",
19
44
  type=str,
20
45
  default=None,
21
- help="Path to the project folder which contains run.yaml."
46
+ help=(
47
+ "Path to the project folder which contains run.yaml."
22
48
  "Runs Sensei with CLI arguments contained in the run.yaml file."
23
- "Example: --run-from-yaml /path/to/project/folder",
49
+ "Example: --run-from-yaml /path/to/project/folder"
50
+ ),
24
51
  )
25
52
 
26
53
  parser.add_argument(
27
54
  "-ic",
28
55
  "--ignore-cache",
29
- type=int,
30
- default=0,
31
- help=f"Cache is ignored during the testing process.",
56
+ dest="ignore_cache",
57
+ action="store_true",
58
+ help="Cache is ignored during the testing process.",
32
59
  )
33
60
 
34
61
  parser.add_argument(
@@ -42,24 +69,27 @@ def parse_chat_arguments() -> Namespace:
42
69
  parser.add_argument(
43
70
  "-cp",
44
71
  "--connector-params",
72
+ dest="connector_params",
45
73
  type=parse_connector_params,
46
- default=None,
47
- help="Connector parameters as JSON string or key=value pairs separated by commas. "
48
- 'Examples: \'{"base_url": "http://localhost", "port": 8080}\' or '
49
- '"base_url=http://localhost,port=8080". Use --list-connector-params <technology> to see required parameters for each connector.',
74
+ help=(
75
+ 'Connector parameters as JSON string or key=value pairs separated by commas. '
76
+ 'Examples: \'{"base_url": "http://localhost", "port": 8080}\' or '
77
+ '"base_url=http://localhost,port=8080". '
78
+ "Use --list-connector-params <technology> to see required parameters for each connector."
79
+ ),
50
80
  )
51
81
 
52
82
  parser.add_argument(
53
- "-pp",
54
- "--project-path",
83
+ "-pp", "--project-path",
84
+ dest="project_path",
55
85
  type=str,
56
86
  default=None,
57
87
  help="The project path where all testing content is stored for a specific project."
58
88
  )
59
89
 
60
90
  parser.add_argument(
61
- "-up",
62
- "--user-profile",
91
+ "-up", "--user-profile",
92
+ dest="user_profile",
63
93
  type=str,
64
94
  default=None,
65
95
  help="Name of the user profile YAML or the folder containing user profiles to use in the testing process."
@@ -84,6 +114,7 @@ def parse_chat_arguments() -> Namespace:
84
114
  parser.add_argument(
85
115
  "-cc",
86
116
  "--clean-cache",
117
+ dest="clean_cache",
87
118
  action="store_true",
88
119
  help=f"Cache is cleaned after the testing process",
89
120
  )
@@ -91,6 +122,7 @@ def parse_chat_arguments() -> Namespace:
91
122
  parser.add_argument(
92
123
  "-uc",
93
124
  "--update-cache",
125
+ dest="update_cache",
94
126
  action="store_true",
95
127
  help=f"Cache is updated with new content if previous cache was saved",
96
128
  )
@@ -98,6 +130,7 @@ def parse_chat_arguments() -> Namespace:
98
130
  #todo: implement
99
131
  parser.add_argument(
100
132
  "--list-connector-params",
133
+ dest="list_connector_params",
101
134
  type=str,
102
135
  metavar="TECHNOLOGY",
103
136
  help="List the available parameters for a specific chatbot technology and exit",
@@ -106,8 +139,71 @@ def parse_chat_arguments() -> Namespace:
106
139
  #todo: implement
107
140
  parser.add_argument(
108
141
  "--list-connectors",
142
+ dest="list_connectors",
109
143
  action="store_true",
110
144
  help="List all available chatbot connector technologies and exit",
111
145
  )
112
146
 
113
- return parser.parse_args()
147
+ args, unknown = parser.parse_known_args(argv) # if argv, uses argv arguments
148
+
149
+ if args.run_from_yaml:
150
+ # Detect if the user passed other non-default options besides the YAML
151
+ # Define here the "default" values that should NOT be considered as "user passed something extra"
152
+ defaults_guard = {
153
+ "technology": default_technology,
154
+ "output": default_output_dir,
155
+ "connector_params": None,
156
+ "project_path": None,
157
+ "user_profile": None,
158
+ "verbose": False,
159
+ "clean_cache": False,
160
+ "ignore_cache": False,
161
+ "update_cache": False,
162
+ "list_connector_params": None,
163
+ "list_connectors": False,
164
+ }
165
+
166
+
167
+ non_default_passed = []
168
+ for k, default_v in defaults_guard.items():
169
+ if k == "run_from_yaml":
170
+ continue
171
+ current_v = getattr(args, k, None)
172
+ if current_v != default_v:
173
+ non_default_passed.append(k)
174
+
175
+ if non_default_passed or unknown:
176
+ parser.error(
177
+ "No other arguments can be provided when using --run-from-yaml. "
178
+ f"Detected: {', '.join(non_default_passed + unknown)}"
179
+ )
180
+
181
+ yaml_args = load_yaml_arguments(args.run_from_yaml)
182
+
183
+ # Minimum default values if the YAML does not provide them
184
+ yaml_defaults = {
185
+ "technology": default_technology,
186
+ "connector_params": None,
187
+ "user_profile": None,
188
+ "output": default_output_dir,
189
+ "verbose": False,
190
+ "clean_cache": False,
191
+ "ignore_cache": False,
192
+ "update_cache": False,
193
+ }
194
+ for k, v in yaml_defaults.items():
195
+ yaml_args.setdefault(k, v)
196
+
197
+ return argparse.Namespace(**yaml_args)
198
+
199
+
200
+ # Normal CLI mode: validate required arguments
201
+ required_args = ["technology", "user_profile", "connector_params"]
202
+ missing = [arg for arg in required_args if getattr(args, arg) in (None, "")]
203
+ if missing:
204
+ parser.error(
205
+ "The following arguments are required when not using --run-from-yaml: "
206
+ + ", ".join(missing)
207
+ )
208
+
209
+ return args