rasa-pro 3.10.24__py3-none-any.whl → 3.10.25__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.

Potentially problematic release.


This version of rasa-pro might be problematic. Click here for more details.

@@ -1,10 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
- from collections import OrderedDict
4
- from enum import Enum
5
3
  import logging
4
+ import shutil
6
5
  import typing
7
- from typing import Any, Dict, List, Optional, Text, Tuple, Callable, Type
6
+ from collections import OrderedDict
7
+ from enum import Enum
8
+ from pathlib import Path
9
+ from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Type
8
10
 
9
11
  import numpy as np
10
12
 
@@ -43,6 +45,10 @@ if typing.TYPE_CHECKING:
43
45
 
44
46
  CONFIG_FEATURES = "features"
45
47
 
48
+ TAGGERS_DIR = "taggers"
49
+ CRFSUITE_MODEL_FILE_NAME = "model.crfsuite"
50
+ PLAIN_CRF_MODEL_FILE_NAME = "model.txt"
51
+
46
52
 
47
53
  class CRFToken:
48
54
  def __init__(
@@ -419,19 +425,11 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
419
425
  """Loads trained component (see parent class for full docstring)."""
420
426
  try:
421
427
  with model_storage.read_from(resource) as model_dir:
422
- dataset = rasa.shared.utils.io.read_json_file(
423
- model_dir / "crf_dataset.json"
424
- )
425
428
  crf_order = rasa.shared.utils.io.read_json_file(
426
429
  model_dir / "crf_order.json"
427
430
  )
428
431
 
429
- dataset = [
430
- [CRFToken.create_from_dict(token_data) for token_data in sub_list]
431
- for sub_list in dataset
432
- ]
433
-
434
- entity_taggers = cls.train_model(dataset, config, crf_order)
432
+ entity_taggers = cls._load_taggers(model_dir, config)
435
433
 
436
434
  entity_extractor = cls(config, model_storage, resource, entity_taggers)
437
435
  entity_extractor.crf_order = crf_order
@@ -443,19 +441,71 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
443
441
  )
444
442
  return cls(config, model_storage, resource)
445
443
 
444
+ @classmethod
445
+ def _load_taggers(
446
+ cls, model_dir: Path, config: Dict[Text, Any]
447
+ ) -> Dict[str, "CRF"]:
448
+ """
449
+ Load taggers from model directory that persists trained binary
450
+ `model.crfsuite` files.
451
+ """
452
+
453
+ import pycrfsuite
454
+ import sklearn_crfsuite
455
+
456
+ # Get tagger directories
457
+ taggers_base = model_dir / TAGGERS_DIR
458
+ if not taggers_base.exists():
459
+ return {}
460
+
461
+ taggers_dirs = [
462
+ directory for directory in taggers_base.iterdir() if directory.is_dir()
463
+ ]
464
+
465
+ entity_taggers: Dict[str, "CRF"] = {}
466
+
467
+ for tagger_dir in taggers_dirs:
468
+ # Instantiate sklearns CRF wrapper for the pycrfsuite's Tagger
469
+ entity_tagger = sklearn_crfsuite.CRF(
470
+ algorithm="lbfgs",
471
+ # coefficient for L1 penalty
472
+ c1=config["L1_c"],
473
+ # coefficient for L2 penalty
474
+ c2=config["L2_c"],
475
+ # stop earlier
476
+ max_iterations=config["max_iterations"],
477
+ # include transitions that are possible, but not observed
478
+ all_possible_transitions=True,
479
+ )
480
+
481
+ # Load pycrfsuite tagger from the persisted binary model.crfsuite file
482
+ entity_tagger._tagger = pycrfsuite.Tagger()
483
+ entity_tagger._tagger.open(str(tagger_dir / CRFSUITE_MODEL_FILE_NAME))
484
+
485
+ entity_taggers[tagger_dir.name] = entity_tagger
486
+
487
+ return entity_taggers
488
+
446
489
  def persist(self, dataset: List[List[CRFToken]]) -> None:
447
490
  """Persist this model into the passed directory."""
448
491
  with self._model_storage.write_to(self._resource) as model_dir:
449
- data_to_store = [
450
- [token.to_dict() for token in sub_list] for sub_list in dataset
451
- ]
452
-
453
- rasa.shared.utils.io.dump_obj_as_json_to_file(
454
- model_dir / "crf_dataset.json", data_to_store
455
- )
456
492
  rasa.shared.utils.io.dump_obj_as_json_to_file(
457
493
  model_dir / "crf_order.json", self.crf_order
458
494
  )
495
+ if self.entity_taggers is not None:
496
+ for tag_name, entity_tagger in self.entity_taggers.items():
497
+ # Create the directories for storing the CRF model
498
+ tagger_dir = model_dir / TAGGERS_DIR / tag_name
499
+ tagger_dir.mkdir(parents=True, exist_ok=True)
500
+ # Create a plain text version of the CRF model
501
+ entity_tagger.tagger_.dump(
502
+ str(tagger_dir / PLAIN_CRF_MODEL_FILE_NAME)
503
+ )
504
+ # Persist binary version of the model.crfsuite
505
+ shutil.copy2(
506
+ src=entity_tagger.modelfile.name,
507
+ dst=tagger_dir / CRFSUITE_MODEL_FILE_NAME,
508
+ )
459
509
 
460
510
  @classmethod
461
511
  def _crf_tokens_to_features(
rasa/telemetry.py CHANGED
@@ -894,7 +894,7 @@ def initialize_error_reporting() -> None:
894
894
  OSError,
895
895
  ],
896
896
  in_app_include=["rasa"], # only submit errors in this package
897
- with_locals=False, # don't submit local variables
897
+ include_local_variables=False, # don't submit local variables
898
898
  release=f"rasa-{rasa.__version__}",
899
899
  default_integrations=False,
900
900
  environment="development" if in_continuous_integration() else "production",
rasa/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  # this file will automatically be changed,
2
2
  # do not add anything but the version number here!
3
- __version__ = "3.10.24"
3
+ __version__ = "3.10.25"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rasa-pro
3
- Version: 3.10.24
3
+ Version: 3.10.25
4
4
  Summary: State-of-the-art open-core Conversational AI framework for Enterprises that natively leverages generative AI for effortless assistant development.
5
5
  Keywords: nlp,machine-learning,machine-learning-library,bot,bots,botkit,rasa conversational-agents,conversational-ai,chatbot,chatbot-framework,bot-framework
6
6
  Author: Rasa Technologies GmbH
@@ -26,7 +26,7 @@ Requires-Dist: SQLAlchemy (>=2.0.22,<2.1.0)
26
26
  Requires-Dist: absl-py (>=2.0,<2.1)
27
27
  Requires-Dist: aio-pika (>=8.2.3,<8.2.4)
28
28
  Requires-Dist: aiogram (>=2.15,<2.26)
29
- Requires-Dist: aiohttp (>=3.9.4,<3.10)
29
+ Requires-Dist: aiohttp (>=3.10.11,<3.11)
30
30
  Requires-Dist: apscheduler (>=3.10,<3.11)
31
31
  Requires-Dist: attrs (>=23.1,<23.2)
32
32
  Requires-Dist: azure-storage-blob (>=12.16.0,<12.17.0)
@@ -113,7 +113,7 @@ Requires-Dist: sanic-routing (>=22.8.0,<23.0.0)
113
113
  Requires-Dist: scikit-learn (>=1.1.3,<1.2) ; python_version >= "3.9" and python_version < "3.11"
114
114
  Requires-Dist: scipy (>=1.10.1,<1.11.0) ; python_version >= "3.9" and python_version < "3.11"
115
115
  Requires-Dist: sentencepiece[sentencepiece] (>=0.1.99,<0.2.0) ; extra == "transformers" or extra == "full"
116
- Requires-Dist: sentry-sdk (>=1.14.0,<1.15.0)
116
+ Requires-Dist: sentry-sdk (>=2.8.0,<3)
117
117
  Requires-Dist: setuptools (>=78.1.0,<78.2.0)
118
118
  Requires-Dist: sklearn-crfsuite (>=0.3.6,<0.4.0)
119
119
  Requires-Dist: skops (>=0.10.0,<0.11.0)
@@ -509,7 +509,7 @@ rasa/nlu/emulators/luis.py,sha256=AWMGI17Su1q6PcE8l1S1mDJpwfVtx7ibY9rwBmg3Maw,30
509
509
  rasa/nlu/emulators/no_emulator.py,sha256=tLJ2DyWhOtaIBudVf7mJGsubca9Vunb6VhJB_tWJ8wU,334
510
510
  rasa/nlu/emulators/wit.py,sha256=0eMj_q49JGj0Z6JZjR7rHIABNF-F3POX7s5W5OkANyo,1930
511
511
  rasa/nlu/extractors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
512
- rasa/nlu/extractors/crf_entity_extractor.py,sha256=5IW7Fa4lLLUxMrbHiRmBD7Y6B7TmS_o66USoSxYBOZk,27532
512
+ rasa/nlu/extractors/crf_entity_extractor.py,sha256=pLiM6vEybqSW4refbBRr68QbE-9haxyHQo7vslymyI0,29400
513
513
  rasa/nlu/extractors/duckling_entity_extractor.py,sha256=XooWjw6eDC0sxZ-T1YgDnrLcRTBx6B40SFGLjHTHg-w,7686
514
514
  rasa/nlu/extractors/entity_synonyms.py,sha256=WShheUF7wbP7VWfpCNw3J4NouAcFjAupDsT4oAj_TUc,7148
515
515
  rasa/nlu/extractors/extractor.py,sha256=m6p07GDBZi1VhgYCkYJrWs_Zk87okV77hvoiwG_1xxA,17539
@@ -683,7 +683,7 @@ rasa/studio/download.py,sha256=9uE4KKaHnID_3-Tt_E5_D00XTwhLlj4oxORY8CZRrZc,17188
683
683
  rasa/studio/results_logger.py,sha256=0gCkEaZ1CeFmxRHArK5my_DsLYjApZrxfiRMT5asE6A,4963
684
684
  rasa/studio/train.py,sha256=gfPtirITzBDo9gV4hqDNSwPYtVp_22cq8OWI6YIBgyk,4243
685
685
  rasa/studio/upload.py,sha256=5hvj_DUzxq5JkZswro-KaLE4QAKwbMLGb8TakzS1etk,14290
686
- rasa/telemetry.py,sha256=Q6MQnDhOY6cKRVs3PayiM6WYWb8QJ_Hb3_eOm12n0tI,61093
686
+ rasa/telemetry.py,sha256=6CMcbQ241zoTPzhtmBsPMfW8Glc2tm8uD6cd3J8t99A,61105
687
687
  rasa/tracing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
688
688
  rasa/tracing/config.py,sha256=O4iHkE4kF6r4uVAt3JUb--TniK7pWD4j3d08Vf_GuYY,12736
689
689
  rasa/tracing/constants.py,sha256=N_MJLStE3IkmPKQCQv42epd3jdBMJ4Ith1dVO65N5ho,2425
@@ -728,9 +728,9 @@ rasa/utils/train_utils.py,sha256=f1NWpp5y6al0dzoQyyio4hc4Nf73DRoRSHDzEK6-C4E,212
728
728
  rasa/utils/url_tools.py,sha256=JQcHL2aLqLHu82k7_d9imUoETCm2bmlHaDpOJ-dKqBc,1218
729
729
  rasa/utils/yaml.py,sha256=KjbZq5C94ZP7Jdsw8bYYF7HASI6K4-C_kdHfrnPLpSI,2000
730
730
  rasa/validator.py,sha256=AsFJ8e1zWHW-hnH_IB3SGBBl68vstKPrrqbAydgjVhQ,63149
731
- rasa/version.py,sha256=xhBga-JTNnvCJXBHczNZMXAx6evYUpEiLJj1yvWVto0,118
732
- rasa_pro-3.10.24.dist-info/METADATA,sha256=d3LOzpxaEL6JzWWFX53OrqLUYj-UvIWm8Mu2qILmCsI,10856
733
- rasa_pro-3.10.24.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
734
- rasa_pro-3.10.24.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
735
- rasa_pro-3.10.24.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
736
- rasa_pro-3.10.24.dist-info/RECORD,,
731
+ rasa/version.py,sha256=GWHwGypLvbRd-D94Ljby0tnp6afbxH7wn_u0DTC-sKA,118
732
+ rasa_pro-3.10.25.dist-info/METADATA,sha256=rBmzUv8f5_vktUAhp1pNCqP6e2kaEhfG8udVtySLHXo,10852
733
+ rasa_pro-3.10.25.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
734
+ rasa_pro-3.10.25.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
735
+ rasa_pro-3.10.25.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
736
+ rasa_pro-3.10.25.dist-info/RECORD,,