rasa-pro 3.13.7__py3-none-any.whl → 3.13.8__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,14 +1,16 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
+ import os
4
5
  import shutil
5
6
  import sys
7
+ import tarfile
6
8
  import tempfile
7
9
  import uuid
8
10
  from contextlib import contextmanager
9
11
  from datetime import datetime
10
12
  from pathlib import Path
11
- from typing import Generator, Optional, Text, Tuple, Union
13
+ from typing import Callable, Generator, Optional, Text, Tuple, Union
12
14
 
13
15
  from tarsafe import TarSafe
14
16
 
@@ -57,6 +59,35 @@ def windows_safe_temporary_directory(
57
59
  yield temporary_directory
58
60
 
59
61
 
62
+ def filter_normpath(member: tarfile.TarInfo, dest_path: str) -> tarfile.TarInfo:
63
+ """Normalize tar member paths for safe extraction"""
64
+ if member.name:
65
+ member.name = os.path.normpath(member.name)
66
+ return member
67
+
68
+
69
+ FilterFunction = Callable[[tarfile.TarInfo, str], Optional[tarfile.TarInfo]]
70
+
71
+
72
+ def create_combined_filter(existing_filter: Optional[FilterFunction]) -> FilterFunction:
73
+ """Create a filter that combines existing filter with path normalization"""
74
+
75
+ def combined_filter(
76
+ member: tarfile.TarInfo, dest_path: str
77
+ ) -> Optional[tarfile.TarInfo]:
78
+ """Apply existing filter first, then path normalization"""
79
+ if existing_filter is not None:
80
+ filtered_member = existing_filter(member, dest_path)
81
+ if filtered_member is None:
82
+ return None # Rejected by existing filter
83
+ member = filtered_member # Use the filtered result
84
+
85
+ # Apply our path normalization
86
+ return filter_normpath(member, dest_path)
87
+
88
+ return combined_filter
89
+
90
+
60
91
  class LocalModelStorage(ModelStorage):
61
92
  """Stores and provides output of `GraphComponents` on local disk."""
62
93
 
@@ -122,7 +153,19 @@ class LocalModelStorage(ModelStorage):
122
153
  # this restriction in environments where it's not possible
123
154
  # to override this behavior, mostly for internal policy reasons
124
155
  # reference: https://stackoverflow.com/a/49102229
125
- tar.extractall(f"\\\\?\\{temporary_directory}")
156
+ try:
157
+ # Use extraction filter to normalize paths for compatibility
158
+ # before trying the \\?\ prefix approach first
159
+ prev_filter = getattr(tar, "extraction_filter", None)
160
+ tar.extraction_filter = create_combined_filter(prev_filter)
161
+ tar.extractall(f"\\\\?\\{temporary_directory}")
162
+ except Exception:
163
+ # Fallback for Python versions with tarfile security fix
164
+ logger.warning(
165
+ "Failed to extract model archive with long path support. "
166
+ "Falling back to regular extraction."
167
+ )
168
+ tar.extractall(temporary_directory)
126
169
  else:
127
170
  tar.extractall(temporary_directory)
128
171
  LocalModelStorage._assert_not_rasa2_archive(temporary_directory)
@@ -1,87 +1,103 @@
1
1
  from typing import Any, Dict, Optional
2
2
 
3
+ import boto3
3
4
  import structlog
4
- from litellm import validate_environment
5
+ from botocore.exceptions import BotoCoreError, ClientError
5
6
 
6
7
  from rasa.shared.constants import (
7
8
  API_BASE_CONFIG_KEY,
8
9
  API_VERSION_CONFIG_KEY,
9
10
  AWS_ACCESS_KEY_ID_CONFIG_KEY,
10
- AWS_ACCESS_KEY_ID_ENV_VAR,
11
+ AWS_BEDROCK_PROVIDER,
11
12
  AWS_REGION_NAME_CONFIG_KEY,
12
- AWS_REGION_NAME_ENV_VAR,
13
+ AWS_SAGEMAKER_CHAT_PROVIDER,
14
+ AWS_SAGEMAKER_PROVIDER,
13
15
  AWS_SECRET_ACCESS_KEY_CONFIG_KEY,
14
- AWS_SECRET_ACCESS_KEY_ENV_VAR,
15
16
  AWS_SESSION_TOKEN_CONFIG_KEY,
16
- AWS_SESSION_TOKEN_ENV_VAR,
17
17
  AZURE_API_BASE_ENV_VAR,
18
18
  AZURE_API_VERSION_ENV_VAR,
19
19
  DEPLOYMENT_CONFIG_KEY,
20
20
  )
21
21
  from rasa.shared.exceptions import ProviderClientValidationError
22
- from rasa.shared.providers.embedding._base_litellm_embedding_client import (
23
- _VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY,
24
- )
22
+ from rasa.shared.utils.io import resolve_environment_variables
25
23
 
26
24
  structlogger = structlog.get_logger()
27
25
 
28
26
 
29
27
  def validate_aws_setup_for_litellm_clients(
30
- litellm_model_name: str, litellm_call_kwargs: dict, source_log: str
28
+ litellm_model_name: str, litellm_call_kwargs: Dict, source_log: str, provider: str
31
29
  ) -> None:
32
- """Validates the AWS setup for LiteLLM clients to ensure all required
33
- environment variables or corresponding call kwargs are set.
30
+ """Validates the AWS setup for LiteLLM clients to ensure credentials are set.
34
31
 
35
32
  Args:
36
33
  litellm_model_name (str): The name of the LiteLLM model being validated.
37
34
  litellm_call_kwargs (dict): Additional keyword arguments passed to the client,
38
35
  which may include configuration values for AWS credentials.
39
36
  source_log (str): The source log identifier for structured logging.
37
+ provider (str): The provider for which the validation is being performed.
40
38
 
41
39
  Raises:
42
40
  ProviderClientValidationError: If any required AWS environment variable
43
41
  or corresponding configuration key is missing.
44
42
  """
45
-
46
- # Mapping of environment variable names to their corresponding config keys
47
- envs_to_args = {
48
- AWS_ACCESS_KEY_ID_ENV_VAR: AWS_ACCESS_KEY_ID_CONFIG_KEY,
49
- AWS_SECRET_ACCESS_KEY_ENV_VAR: AWS_SECRET_ACCESS_KEY_CONFIG_KEY,
50
- AWS_REGION_NAME_ENV_VAR: AWS_REGION_NAME_CONFIG_KEY,
51
- AWS_SESSION_TOKEN_ENV_VAR: AWS_SESSION_TOKEN_CONFIG_KEY,
52
- }
53
-
54
- # Validate the environment setup for the model
55
- validation_info = validate_environment(litellm_model_name)
56
- missing_environment_variables = validation_info.get(
57
- _VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY, []
43
+ # expand environment variables if referenced in the config
44
+ resolved_litellm_call_kwargs: Dict = resolve_environment_variables(
45
+ litellm_call_kwargs
46
+ ) # type: ignore[assignment]
47
+
48
+ # boto3 only accepts bedrock and sagemaker as valid clients
49
+ # therefore we need to convert the provider name if it is defined
50
+ # as sagemaker_chat
51
+ provider = (
52
+ AWS_SAGEMAKER_PROVIDER if provider == AWS_SAGEMAKER_CHAT_PROVIDER else provider
58
53
  )
59
- # Filter out missing environment variables that have been set trough arguments
60
- # in extra parameters
61
- missing_environment_variables = [
62
- missing_env_var
63
- for missing_env_var in missing_environment_variables
64
- if litellm_call_kwargs.get(envs_to_args.get(missing_env_var)) is None
65
- ]
66
54
 
67
- if missing_environment_variables:
68
- missing_environment_details = [
69
- (
70
- f"'{missing_env_var}' environment variable or "
71
- f"'{envs_to_args.get(missing_env_var)}' config key"
72
- )
73
- for missing_env_var in missing_environment_variables
55
+ # if the AWS credentials are defined in the endpoints yaml model config,
56
+ # either as referenced secret env vars or direct values, we need to pass them
57
+ # to the boto3 client to ensure that the client can connect to the AWS service.
58
+ additional_kwargs: Dict[str, Any] = {}
59
+ if AWS_ACCESS_KEY_ID_CONFIG_KEY in resolved_litellm_call_kwargs:
60
+ additional_kwargs[AWS_ACCESS_KEY_ID_CONFIG_KEY] = resolved_litellm_call_kwargs[
61
+ AWS_ACCESS_KEY_ID_CONFIG_KEY
74
62
  ]
63
+ if AWS_SECRET_ACCESS_KEY_CONFIG_KEY in resolved_litellm_call_kwargs:
64
+ additional_kwargs[AWS_SECRET_ACCESS_KEY_CONFIG_KEY] = (
65
+ resolved_litellm_call_kwargs[AWS_SECRET_ACCESS_KEY_CONFIG_KEY]
66
+ )
67
+ if AWS_SESSION_TOKEN_CONFIG_KEY in resolved_litellm_call_kwargs:
68
+ additional_kwargs[AWS_SESSION_TOKEN_CONFIG_KEY] = resolved_litellm_call_kwargs[
69
+ AWS_SESSION_TOKEN_CONFIG_KEY
70
+ ]
71
+ if AWS_REGION_NAME_CONFIG_KEY in resolved_litellm_call_kwargs:
72
+ additional_kwargs["region_name"] = resolved_litellm_call_kwargs[
73
+ AWS_REGION_NAME_CONFIG_KEY
74
+ ]
75
+
76
+ try:
77
+ # We are using the boto3 client because it can discover the AWS credentials
78
+ # from the environment variables, credentials file, or IAM roles.
79
+ # This is necessary to ensure that the client can connect to the AWS service.
80
+ aws_client = boto3.client(provider, **additional_kwargs)
81
+
82
+ # Using different method calls available to different AWS clients
83
+ # to test the connection
84
+ if provider == AWS_SAGEMAKER_PROVIDER:
85
+ aws_client.list_models()
86
+ elif provider == AWS_BEDROCK_PROVIDER:
87
+ aws_client.get_model_invocation_logging_configuration()
88
+
89
+ except (ClientError, BotoCoreError) as exc:
75
90
  event_info = (
76
- f"The following environment variables or configuration keys are "
77
- f"missing: "
78
- f"{', '.join(missing_environment_details)}. "
79
- f"These settings are required for API calls."
91
+ f"Failed to validate AWS setup for LiteLLM clients: {exc}. "
92
+ f"Ensure that you are using one of the available authentication methods:"
93
+ f"credentials file, environment variables, or IAM roles. "
94
+ f"Also, ensure that the AWS region is set correctly. "
80
95
  )
81
96
  structlogger.error(
82
- f"{source_log}.validate_aws_environment_variables",
97
+ f"{source_log}.validate_aws_credentials_for_litellm_clients",
83
98
  event_info=event_info,
84
- missing_environment_variables=missing_environment_variables,
99
+ exception=str(exc),
100
+ model_name=litellm_model_name,
85
101
  )
86
102
  raise ProviderClientValidationError(event_info)
87
103
 
@@ -37,6 +37,7 @@ class DefaultLiteLLMEmbeddingClient(_BaseLiteLLMEmbeddingClient):
37
37
 
38
38
  @classmethod
39
39
  def from_config(cls, config: Dict[str, Any]) -> "DefaultLiteLLMEmbeddingClient":
40
+ """Creates a DefaultLiteLLMEmbeddingClient instance from a config dict."""
40
41
  default_config = DefaultLiteLLMClientConfig.from_dict(config)
41
42
  return cls(
42
43
  model=default_config.model,
@@ -121,6 +122,7 @@ class DefaultLiteLLMEmbeddingClient(_BaseLiteLLMEmbeddingClient):
121
122
  self._litellm_model_name,
122
123
  self._litellm_extra_parameters,
123
124
  "default_litellm_embedding_client",
125
+ provider=self.provider,
124
126
  )
125
127
  else:
126
128
  super().validate_client_setup()
@@ -39,6 +39,7 @@ class DefaultLiteLLMClient(_BaseLiteLLMClient):
39
39
 
40
40
  @classmethod
41
41
  def from_config(cls, config: Dict[str, Any]) -> DefaultLiteLLMClient:
42
+ """Creates a DefaultLiteLLMClient instance from a configuration dictionary."""
42
43
  default_config = DefaultLiteLLMClientConfig.from_dict(config)
43
44
  return cls(
44
45
  model=default_config.model,
@@ -110,6 +111,7 @@ class DefaultLiteLLMClient(_BaseLiteLLMClient):
110
111
  self._litellm_model_name,
111
112
  self._litellm_extra_parameters,
112
113
  "default_litellm_llm_client",
114
+ provider=self.provider,
113
115
  )
114
116
  else:
115
117
  super().validate_client_setup()
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.13.7"
3
+ __version__ = "3.13.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rasa-pro
3
- Version: 3.13.7
3
+ Version: 3.13.8
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
@@ -511,7 +511,7 @@ rasa/engine/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
511
511
  rasa/engine/runner/dask.py,sha256=ocmpRpDpRPMaisZcBFDeUPbWGl6oWiU9UXyWimE9074,9476
512
512
  rasa/engine/runner/interface.py,sha256=zkaKe5vjiYrR7Efepr7LVZRJEGNDM959rkdR62vEgTM,1679
513
513
  rasa/engine/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
514
- rasa/engine/storage/local_model_storage.py,sha256=szLUl7h8815G8PWi_eecjJwdEOsvTIB8_2dFzuCHP44,9607
514
+ rasa/engine/storage/local_model_storage.py,sha256=Y2VKg04I63WgIL9XeLhJs7SkQMRqUziKyTj9QnhTWZ8,11382
515
515
  rasa/engine/storage/resource.py,sha256=sUCBNSIrjEr68wCj7D48hzmIih7ezmT88esMhyykA88,3932
516
516
  rasa/engine/storage/storage.py,sha256=mNLptsu9cOXWu8k55CnjZMByv6eqh2rEOqXC9__k8aE,6930
517
517
  rasa/engine/training/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -738,13 +738,13 @@ rasa/shared/providers/_configs/rasa_llm_client_config.py,sha256=UiEVmjkoS3a0AHLQ
738
738
  rasa/shared/providers/_configs/self_hosted_llm_client_config.py,sha256=rxUFj8s4HAukjhILlOs7vrgXL9WNlfvGEcfMVEa-LrA,5952
739
739
  rasa/shared/providers/_configs/utils.py,sha256=AUnvh4qF9VfLoXpTPoZfwYQ9YsVW8HPMbWa-vG6wOHw,453
740
740
  rasa/shared/providers/_ssl_verification_utils.py,sha256=vUnP0vocf0GQ0wG8IQpPcCet4c1C9-wQWQNckNWbDBk,4165
741
- rasa/shared/providers/_utils.py,sha256=EZIrz3ugcI-9PWgC7v0VMUNYondAAOeeRLIE8ZmResw,5886
741
+ rasa/shared/providers/_utils.py,sha256=LVPsZbl6zzF4hZE6bNVwgY4BkbeIWnRD0dhEqA-kWkk,6975
742
742
  rasa/shared/providers/constants.py,sha256=hgV8yNGxIbID_2h65OoSfSjIE4UkazrsqRg4SdkPAmI,234
743
743
  rasa/shared/providers/embedding/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
744
744
  rasa/shared/providers/embedding/_base_litellm_embedding_client.py,sha256=1CUYxps_TrLVyPsPfOw7iDS502fDePseBIKnqc3ncwQ,9005
745
745
  rasa/shared/providers/embedding/_langchain_embedding_client_adapter.py,sha256=IR2Rb3ReJ9C9sxOoOGRXgtz8STWdMREs_4AeSMKFjl4,2135
746
746
  rasa/shared/providers/embedding/azure_openai_embedding_client.py,sha256=HKHMx6m669CC19u6GPnpSLzA0PwvHlquhaK3QhqHI78,12469
747
- rasa/shared/providers/embedding/default_litellm_embedding_client.py,sha256=da17WeHjZp95Uv9jmTKxklNRcNpn-qRsRPcwDQusElg,4397
747
+ rasa/shared/providers/embedding/default_litellm_embedding_client.py,sha256=FQUFglXN9Ty-FnUaA80itdyutDxLk7HRZwzULG02k8s,4520
748
748
  rasa/shared/providers/embedding/embedding_client.py,sha256=LGFlnsf5B0XDn8GRn_mLfCJ5erhf2p3zXiKTdG9jNXY,2839
749
749
  rasa/shared/providers/embedding/embedding_response.py,sha256=H55mSAL3LfVvDlBklaCCQ4AnNwCsQSQ1f2D0oPrx3FY,1204
750
750
  rasa/shared/providers/embedding/huggingface_local_embedding_client.py,sha256=Zo3gyj49h4LxXV7bx39TXpIPKlernG-5xzqXczTCbig,6913
@@ -753,7 +753,7 @@ rasa/shared/providers/embedding/openai_embedding_client.py,sha256=XNRGE7apo2v3kW
753
753
  rasa/shared/providers/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
754
754
  rasa/shared/providers/llm/_base_litellm_client.py,sha256=Ua5Kt6VGe5vRzSzWWWx2Q3LH2PCDd8V7V4zfYD464yU,11634
755
755
  rasa/shared/providers/llm/azure_openai_llm_client.py,sha256=ui85vothxR2P_-eLc4nLgbpjnpEKY2BXnIjLxBZoYz8,12504
756
- rasa/shared/providers/llm/default_litellm_llm_client.py,sha256=mPDehyLxt3Q9fPSyaMArkVAMkMTf5lfSzhgv--pMTt4,4083
756
+ rasa/shared/providers/llm/default_litellm_llm_client.py,sha256=q6QoyPPq0K7V9aeD0zr08ZK69xlH4GseGFdhUxpWcG8,4210
757
757
  rasa/shared/providers/llm/litellm_router_llm_client.py,sha256=_6vAdPLAVSI_sBJLaXLnE87M-0ip_klfQ78fQ_pyoyI,7947
758
758
  rasa/shared/providers/llm/llm_client.py,sha256=-hTCRsL-A3GCMRHtcyCgcCyra-9OJ8GUC-mURoRXH0k,3242
759
759
  rasa/shared/providers/llm/llm_response.py,sha256=8mOpZdmh4-3yM7aOmNO0yEYUmRDErfoP7ZDMUuHr2Cc,3504
@@ -846,9 +846,9 @@ rasa/utils/train_utils.py,sha256=ClJx-6x3-h3Vt6mskacgkcCUJTMXjFPe3zAcy_DfmaU,212
846
846
  rasa/utils/url_tools.py,sha256=dZ1HGkVdWTJB7zYEdwoDIrEuyX9HE5WsxKKFVsXBLE0,1218
847
847
  rasa/utils/yaml.py,sha256=KjbZq5C94ZP7Jdsw8bYYF7HASI6K4-C_kdHfrnPLpSI,2000
848
848
  rasa/validator.py,sha256=fhRlHQvuBkiup0FnNYmwRmqQwC3QpdCJt0TuvW4jMaI,83125
849
- rasa/version.py,sha256=GlcM0pFNhVbXo6QlI3F-A0EzUA4hWRvVKqt9sKLpQJg,117
850
- rasa_pro-3.13.7.dist-info/METADATA,sha256=aiVBXTbG5rIltucREZ_XZdurUzZDyz8X2R__8fYF0dw,10550
851
- rasa_pro-3.13.7.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
852
- rasa_pro-3.13.7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
853
- rasa_pro-3.13.7.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
854
- rasa_pro-3.13.7.dist-info/RECORD,,
849
+ rasa/version.py,sha256=FdIHyq5ZwdevHNe13HjSMW31E-Av-kAZu1zwq_POaKY,117
850
+ rasa_pro-3.13.8.dist-info/METADATA,sha256=rD2Xf2X3gvNlTn6wwUM34JOMNcKrQKFYpu7m2EJsXUs,10550
851
+ rasa_pro-3.13.8.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
852
+ rasa_pro-3.13.8.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
853
+ rasa_pro-3.13.8.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
854
+ rasa_pro-3.13.8.dist-info/RECORD,,