user-simulator 0.1.11__py3-none-any.whl → 0.2.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.
@@ -4,8 +4,8 @@ import pandas as pd
4
4
  from collections import Counter
5
5
  from argparse import ArgumentParser
6
6
  from colorama import Fore, Style
7
- from technologies.chatbot_connectors import (Chatbot, ChatbotRasa, ChatbotTaskyto, ChatbotMillionBot,
8
- ChatbotServiceform)
7
+ # from technologies.chatbot_connectors import (Chatbot, ChatbotRasa, ChatbotTaskyto, ChatbotMillionBot,
8
+ # ChatbotServiceform)
9
9
  from user_sim.core.data_extraction import DataExtraction
10
10
  from user_sim.core.role_structure import *
11
11
  from user_sim.core.user_simulator import UserSimulator
@@ -14,6 +14,14 @@ from user_sim.utils.utilities import *
14
14
  from user_sim.utils.token_cost_calculator import create_cost_dataset
15
15
  from user_sim.utils.register_management import clean_temp_files
16
16
 
17
+ from chatbot_connectors.implementations.custom import CustomChatbot
18
+ from chatbot_connectors.implementations.taskyto import ChatbotTaskyto
19
+ from chatbot_connectors.implementations.rasa import RasaChatbot
20
+ from chatbot_connectors.implementations.millionbot import MillionBot
21
+
22
+ from chatbot_connectors import ChatbotFactory, parse_connector_params
23
+
24
+
17
25
  # check_keys(["OPENAI_API_KEY"])
18
26
  current_script_dir = os.path.dirname(os.path.abspath(__file__))
19
27
  root_path = os.path.abspath(os.path.join(current_script_dir, ".."))
@@ -233,17 +241,18 @@ def parse_profiles(user_path):
233
241
  raise Exception(f'Invalid path for user profile operation: {user_path}')
234
242
 
235
243
 
236
- def build_chatbot(technology, connector) -> Chatbot:
237
- chatbot_builder = {
238
- 'rasa': ChatbotRasa,
239
- 'taskyto': ChatbotTaskyto,
240
- 'serviceform': ChatbotServiceform,
241
- 'millionbot': ChatbotMillionBot
242
- }
243
- chatbot_class = chatbot_builder.get(technology, Chatbot)
244
- return chatbot_class(connector)
245
-
246
-
244
+ def build_chatbot(technology, connector):
245
+ # chatbot_builder = {
246
+ # 'rasa': RasaChatbot,
247
+ # 'taskyto': ChatbotTaskyto,
248
+ # # 'serviceform': ChatbotServiceform(connector),
249
+ # 'millionbot': MillionBot,
250
+ # 'custom': CustomChatbot
251
+ # }
252
+ # chatbot_class = chatbot_builder.get(technology, CustomChatbot)
253
+ parsed_connector = parse_connector_params(connector)
254
+ chatbot = ChatbotFactory.create_chatbot(chatbot_type=technology, **parsed_connector)
255
+ return chatbot
247
256
 
248
257
  def generate_conversation(technology, connector, user,
249
258
  personality, extract, project_folder):
@@ -412,13 +421,12 @@ def main():
412
421
  parser.add_argument('--technology', required=False,
413
422
  choices=['rasa', 'taskyto', 'ada-uam', 'millionbot', 'genion', 'lola', 'serviceform', 'kuki', 'julie', 'rivas_catalina', 'saic_malaga'],
414
423
  help='Technology the chatbot is implemented in')
415
- # parser.add_argument('--chatbot', required=False, help='URL where the chatbot is deployed')
416
- parser.add_argument('--connector', required=False, help='path to the connector configuration file')
417
- parser.add_argument('--connector_parameters', required=False, help='dynamic parameters for the selected chatbot connector')
424
+ # parser.add_argument('--connector', required=False, help='path to the connector configuration file')
425
+ parser.add_argument('--connector-params', required=False, help='dynamic parameters for the selected chatbot connector')
418
426
  parser.add_argument('--project_path', required=False, help='Project folder PATH where all testing data is stored')
419
427
  parser.add_argument('--user_profile', required=False, help='User profile file or user profile folder to test the chatbot')
420
428
  parser.add_argument('--personality', required=False, help='Personality file')
421
- parser.add_argument("--extract", default=False, help='Path to store conversation user-chatbot')
429
+ parser.add_argument('--extract', default=False, help='Path to store conversation user-chatbot')
422
430
  parser.add_argument('--verbose', action='store_true', help='Shows debug prints')
423
431
  parser.add_argument('--clean_cache', action='store_true', help='Deletes temporary files.')
424
432
  parser.add_argument('--ignore_cache', action='store_true', help='Ignores cache for temporary files')
@@ -449,7 +457,7 @@ def main():
449
457
  parser_args = ArgsNamespace(**yaml_args)
450
458
 
451
459
  else:
452
- required_args = ['technology', 'user_profile', 'connector']
460
+ required_args = ['technology', 'user_profile', 'connector_params']
453
461
  missing_args = [arg for arg in required_args if getattr(parser_args, arg) is None]
454
462
 
455
463
  if missing_args:
@@ -468,14 +476,18 @@ def main():
468
476
  config.update_cache = parser_args.update_cache
469
477
  config.clean_cache = parser_args.clean_cache
470
478
 
471
- if parser_args.connector_parameters:
472
- connector = configure_connector(parser_args.connector, parser_args.connector_parameters)
473
- else:
474
- connector = configure_connector(parser_args.connector)
479
+ # if parser_args.connector_parameters:
480
+ # connector = configure_connector(parser_args.connector, parser_args.connector_parameters)
481
+ # else:
482
+ # connector = configure_connector(parser_args.connector)
475
483
 
476
- generate_conversation(parser_args.technology, connector, profile_path,
477
- parser_args.personality, parser_args.extract, parser_args.project_path)
484
+ connector = parser_args.connector_params
478
485
 
486
+ try:
487
+ generate_conversation(parser_args.technology, connector, profile_path,
488
+ parser_args.personality, parser_args.extract, parser_args.project_path)
489
+ except Exception as e:
490
+ logger.error(f"An error occurred while generating the conversation: {e}")
479
491
 
480
492
  if __name__ == '__main__':
481
493
  main()
@@ -9,6 +9,7 @@ import importlib.util
9
9
  import logging
10
10
  import platform
11
11
 
12
+ from typing import Any
12
13
  from datetime import datetime, timedelta, date
13
14
  from sklearn.feature_extraction.text import TfidfVectorizer
14
15
  from sklearn.metrics.pairwise import cosine_similarity
@@ -63,6 +64,52 @@ def init_model():
63
64
  return model, llm
64
65
 
65
66
 
67
+ # def parse_connector_params(connector_params_str: str | None) -> dict[str, Any]:
68
+ # """Parse connector parameters from string input.
69
+ #
70
+ # Args:
71
+ # connector_params_str: JSON string or key=value pairs
72
+ #
73
+ # Returns:
74
+ # Dictionary of connector parameters
75
+ #
76
+ # Raises:
77
+ # ValueError: If parameter parsing fails
78
+ # """
79
+ # params = {}
80
+ #
81
+ # if connector_params_str:
82
+ # try:
83
+ # # Try to parse as JSON first
84
+ # if connector_params_str.strip().startswith("{"):
85
+ # params = json.loads(connector_params_str)
86
+ # else:
87
+ # # Parse as key=value pairs
88
+ # for pair in connector_params_str.split(","):
89
+ # if "=" not in pair:
90
+ # continue
91
+ # key, value = pair.split("=", 1)
92
+ # key = key.strip()
93
+ # value = value.strip()
94
+ #
95
+ # # Try to convert to appropriate types
96
+ # if value.lower() in ("true", "false"):
97
+ # params[key] = value.lower() == "true"
98
+ # elif value.isdigit():
99
+ # params[key] = int(value)
100
+ # else:
101
+ # try:
102
+ # params[key] = float(value)
103
+ # except ValueError:
104
+ # params[key] = value
105
+ #
106
+ # except (json.JSONDecodeError, ValueError) as e:
107
+ # logger.exception("Failed to parse connector parameters: %s", connector_params_str)
108
+ # msg = f"Invalid connector parameters format: {e}"
109
+ # raise ValueError(msg) from e
110
+ #
111
+ # return params
112
+
66
113
 
67
114
  def parse_content_to_text(messages):
68
115
  return " ".join([message["content"] for message in messages if "content" in message])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: user-simulator
3
- Version: 0.1.11
3
+ Version: 0.2.0
4
4
  Summary: LLM-based user simulator for chatbot testing.
5
5
  Author: Alejandro Del Pozzo Escalera, Juan de Lara Jaramillo, Esther Guerra Sánchez
6
6
  License: MIT License
@@ -30,6 +30,8 @@ Description-Content-Type: text/markdown
30
30
  License-File: LICENSE.txt
31
31
  Requires-Dist: allpairspy>=2.5.1
32
32
  Requires-Dist: beautifulsoup4>=4.13.4
33
+ Requires-Dist: build>=1.3.0
34
+ Requires-Dist: chatbot-connectors>=0.2.2
33
35
  Requires-Dist: colorama>=0.4.6
34
36
  Requires-Dist: httpx>=0.28.1
35
37
  Requires-Dist: inflect>=7.0.0
@@ -44,6 +46,7 @@ Requires-Dist: pyyaml>=6.0.2
44
46
  Requires-Dist: requests>=2.32.4
45
47
  Requires-Dist: scikit-learn>=1.7.0
46
48
  Requires-Dist: selenium>=4.33.0
49
+ Requires-Dist: twine>=6.1.0
47
50
  Requires-Dist: webdriver-manager>=4.0.2
48
51
  Dynamic: license-file
49
52
 
@@ -12,7 +12,7 @@ user_sim/__init__.py,sha256=hLzeYUaZDKIQet60JxHFB7Bhe3CL23yUmbJQPcfQFGE,479
12
12
  user_sim/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  user_sim/cli/gen_user_profile.py,sha256=PSm9wi2OhflLWHM1TNxL5W2xYFR82z2-24NhOQRye2M,1462
14
14
  user_sim/cli/init_project.py,sha256=t4z4Omfo2_uh-mNjVOpFIxnnlWdtH9VUa3mD3q14v6A,1947
15
- user_sim/cli/sensei_chat.py,sha256=YsuZJPc9TJRlAmOP3PV56mlBUPfaZOeH5o_SBV_8fwA,20512
15
+ user_sim/cli/sensei_chat.py,sha256=bmRS7Zrp0qutL50gsvavgnx0nHRuQMpX8ELXVL7dz0c,21132
16
16
  user_sim/cli/sensei_check.py,sha256=l_HIAPTw621MxXJ9fwmdE8BzDABt1XdalHVaKYH_QsQ,3900
17
17
  user_sim/cli/validation_check.py,sha256=VUJlePbTfBJOgOx2sDamKD4cplvUlS7VKqr-v1rvFPE,5363
18
18
  user_sim/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -38,10 +38,10 @@ user_sim/utils/register_management.py,sha256=ZUmnPZLzNZQs17GezD5iM9hxMHNW1rZyeBz
38
38
  user_sim/utils/show_logs.py,sha256=pqwksfYYFZEu3pb-4KJrV4OEaiAUrfc5-G1qz8akJmo,1754
39
39
  user_sim/utils/token_cost_calculator.py,sha256=4vFUh6OHgoZJcfxaRGARFUbyLkXPYUug6YJCM7luw6s,12540
40
40
  user_sim/utils/url_management.py,sha256=MeUoT-O7XCPWJJ-1r3T_n1zFjj3NyeJXRt_b9Nkpzdw,1998
41
- user_sim/utils/utilities.py,sha256=MBviUg1xCyJeDbIDPIQWWno-3jhTwwpn-z6TB5zM63s,19792
42
- user_simulator-0.1.11.dist-info/licenses/LICENSE.txt,sha256=Qv2ilebwoUtMJnRsZwRy729xS5JZQzLauJ0tQzkAkTA,1088
43
- user_simulator-0.1.11.dist-info/METADATA,sha256=uubTAy5xcmHKm4yT3gttZp77Ucw6cDBYI6OrHmII0zE,31799
44
- user_simulator-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
- user_simulator-0.1.11.dist-info/entry_points.txt,sha256=kfr0rD6mglTGGzYRfUwMTGfTtTOBnLjv3R-Uy61vvDQ,283
46
- user_simulator-0.1.11.dist-info/top_level.txt,sha256=IGlrGt_QHrM2G3Mlo76gMp8ArUR_F9k4RrzJd8YHpE4,34
47
- user_simulator-0.1.11.dist-info/RECORD,,
41
+ user_sim/utils/utilities.py,sha256=ixv48MMPaIaj12aBO0pIxIgwWie0oEMX2lckPm1_SeU,21568
42
+ user_simulator-0.2.0.dist-info/licenses/LICENSE.txt,sha256=Qv2ilebwoUtMJnRsZwRy729xS5JZQzLauJ0tQzkAkTA,1088
43
+ user_simulator-0.2.0.dist-info/METADATA,sha256=nrOOEB9GsUBCUIr4S0ywV_lzHrzRBq3hI0VIewzNErg,31898
44
+ user_simulator-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ user_simulator-0.2.0.dist-info/entry_points.txt,sha256=kfr0rD6mglTGGzYRfUwMTGfTtTOBnLjv3R-Uy61vvDQ,283
46
+ user_simulator-0.2.0.dist-info/top_level.txt,sha256=IGlrGt_QHrM2G3Mlo76gMp8ArUR_F9k4RrzJd8YHpE4,34
47
+ user_simulator-0.2.0.dist-info/RECORD,,