rasa-pro 3.12.6.dev2__py3-none-any.whl → 3.12.7__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.

Files changed (107) hide show
  1. rasa/__init__.py +0 -6
  2. rasa/cli/run.py +10 -6
  3. rasa/cli/utils.py +7 -0
  4. rasa/core/actions/action.py +0 -6
  5. rasa/core/channels/channel.py +93 -0
  6. rasa/core/channels/inspector/dist/assets/{arc-c7691751.js → arc-351bec79.js} +1 -1
  7. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-ab99dff7.js → blockDiagram-38ab4fdb-2567f3e5.js} +1 -1
  8. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-08c35a6b.js → c4Diagram-3d4e48cf-c94acad0.js} +1 -1
  9. rasa/core/channels/inspector/dist/assets/channel-96a753ef.js +1 -0
  10. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-9e9c71c9.js → classDiagram-70f12bd4-a2c4f658.js} +1 -1
  11. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-15e7e2bf.js → classDiagram-v2-f2320105-4036ee82.js} +1 -1
  12. rasa/core/channels/inspector/dist/assets/clone-5bbb0c7d.js +1 -0
  13. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-9c105cb1.js → createText-2e5e7dd3-01f8708a.js} +1 -1
  14. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-77e89e48.js → edges-e0da2a9e-17b4c582.js} +1 -1
  15. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-7a011646.js → erDiagram-9861fffd-5b382730.js} +1 -1
  16. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-b6f105ac.js → flowDb-956e92f1-c9dd4758.js} +1 -1
  17. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-ce4f18c2.js → flowDiagram-66a62f08-014c7159.js} +1 -1
  18. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-72082386.js +1 -0
  19. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-cb5f6da4.js → flowchart-elk-definition-4a651766-bc13fd64.js} +1 -1
  20. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-e4d19e28.js → ganttDiagram-c361ad54-a3bc832f.js} +1 -1
  21. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-727b1c33.js → gitGraphDiagram-72cf32ee-4f0983dd.js} +1 -1
  22. rasa/core/channels/inspector/dist/assets/{graph-6e2ab9a7.js → graph-0069f93e.js} +1 -1
  23. rasa/core/channels/inspector/dist/assets/{index-3862675e-84ec700f.js → index-3862675e-7ddaa093.js} +1 -1
  24. rasa/core/channels/inspector/dist/assets/{index-098a1a24.js → index-d77a19b4.js} +129 -116
  25. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-78dda442.js → infoDiagram-f8f76790-c3e28742.js} +1 -1
  26. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-f1cc6dd1.js → journeyDiagram-49397b02-6d36c64c.js} +1 -1
  27. rasa/core/channels/inspector/dist/assets/{layout-d98dcd0c.js → layout-3d27f9c0.js} +1 -1
  28. rasa/core/channels/inspector/dist/assets/{line-838e3d82.js → line-e8cb25c5.js} +1 -1
  29. rasa/core/channels/inspector/dist/assets/{linear-eae72406.js → linear-4321e9fa.js} +1 -1
  30. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-c96fd84b.js → mindmap-definition-fc14e90a-47e328b2.js} +1 -1
  31. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-c936d4e2.js → pieDiagram-8a3498a8-647edbaf.js} +1 -1
  32. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b338eb8f.js → quadrantDiagram-120e2f19-0703ad7d.js} +1 -1
  33. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-c6b6c0d5.js → requirementDiagram-deff3bca-59312f87.js} +1 -1
  34. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-b9372e19.js → sankeyDiagram-04a897e0-8e170e1c.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-479e0a3f.js → sequenceDiagram-704730f1-b2b42696.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-fd26eebc.js → stateDiagram-587899a1-239f7e55.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-3233e0ae.js → stateDiagram-v2-d93cdb3a-9cb9c726.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-1fdd392b.js → styles-6aaf32cf-d15a0f74.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-6d7bfa1b.js → styles-9a916d00-d7c52634.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-f86aab11.js → styles-c10674c1-cf79ea88.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-e3e49d7a.js → svgDrawCommon-08f97a94-52b3b9f9.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-6fe08b4d.js → timeline-definition-85554ec2-c8e3cd8c.js} +1 -1
  43. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-c2e06fd6.js → xychartDiagram-e933f94c-300afa53.js} +1 -1
  44. rasa/core/channels/inspector/dist/index.html +1 -1
  45. rasa/core/channels/inspector/src/components/Chat.tsx +23 -2
  46. rasa/core/channels/inspector/src/components/DiagramFlow.tsx +2 -5
  47. rasa/core/channels/inspector/src/helpers/conversation.ts +16 -0
  48. rasa/core/channels/inspector/src/types.ts +1 -1
  49. rasa/core/channels/voice_ready/audiocodes.py +53 -21
  50. rasa/core/channels/voice_ready/jambonz.py +25 -5
  51. rasa/core/channels/voice_ready/jambonz_protocol.py +4 -0
  52. rasa/core/channels/voice_ready/twilio_voice.py +48 -1
  53. rasa/core/channels/voice_stream/tts/azure.py +11 -2
  54. rasa/core/channels/voice_stream/twilio_media_streams.py +101 -26
  55. rasa/core/nlg/contextual_response_rephraser.py +4 -21
  56. rasa/core/nlg/summarize.py +1 -15
  57. rasa/core/policies/enterprise_search_policy.py +3 -16
  58. rasa/core/policies/flows/flow_executor.py +3 -38
  59. rasa/core/policies/intentless_policy.py +4 -17
  60. rasa/core/policies/policy.py +0 -2
  61. rasa/core/processor.py +19 -5
  62. rasa/core/utils.py +53 -0
  63. rasa/dialogue_understanding/coexistence/llm_based_router.py +4 -18
  64. rasa/dialogue_understanding/commands/cancel_flow_command.py +4 -59
  65. rasa/dialogue_understanding/commands/start_flow_command.py +0 -41
  66. rasa/dialogue_understanding/generator/command_generator.py +67 -0
  67. rasa/dialogue_understanding/generator/llm_based_command_generator.py +4 -20
  68. rasa/dialogue_understanding/generator/llm_command_generator.py +1 -3
  69. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +1 -12
  70. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -61
  71. rasa/dialogue_understanding/processor/command_processor.py +7 -65
  72. rasa/dialogue_understanding/stack/utils.py +0 -38
  73. rasa/e2e_test/utils/validation.py +3 -3
  74. rasa/hooks.py +0 -55
  75. rasa/shared/constants.py +0 -5
  76. rasa/shared/core/constants.py +0 -8
  77. rasa/shared/core/domain.py +12 -3
  78. rasa/shared/core/flows/flow.py +0 -17
  79. rasa/shared/core/flows/flows_yaml_schema.json +3 -38
  80. rasa/shared/core/flows/steps/collect.py +5 -18
  81. rasa/shared/core/flows/utils.py +1 -16
  82. rasa/shared/core/slot_mappings.py +11 -5
  83. rasa/shared/nlu/constants.py +0 -1
  84. rasa/shared/providers/constants.py +0 -9
  85. rasa/shared/providers/llm/_base_litellm_client.py +4 -14
  86. rasa/shared/providers/llm/litellm_router_llm_client.py +7 -17
  87. rasa/shared/providers/llm/llm_client.py +15 -24
  88. rasa/shared/providers/llm/self_hosted_llm_client.py +2 -10
  89. rasa/shared/utils/common.py +11 -1
  90. rasa/shared/utils/health_check/health_check.py +1 -7
  91. rasa/tracing/instrumentation/attribute_extractors.py +4 -4
  92. rasa/tracing/instrumentation/intentless_policy_instrumentation.py +1 -2
  93. rasa/utils/licensing.py +0 -15
  94. rasa/validator.py +1 -123
  95. rasa/version.py +1 -1
  96. {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/METADATA +3 -4
  97. {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/RECORD +100 -103
  98. rasa/core/actions/action_handle_digressions.py +0 -164
  99. rasa/core/channels/inspector/dist/assets/channel-11268142.js +0 -1
  100. rasa/core/channels/inspector/dist/assets/clone-ff7f2ce7.js +0 -1
  101. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-cba7ae20.js +0 -1
  102. rasa/dialogue_understanding/commands/handle_digressions_command.py +0 -144
  103. rasa/dialogue_understanding/patterns/handle_digressions.py +0 -81
  104. rasa/monkey_patches.py +0 -91
  105. {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/NOTICE +0 -0
  106. {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/WHEEL +0 -0
  107. {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/entry_points.txt +0 -0
@@ -1,15 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
- from dataclasses import dataclass, field
3
+ from dataclasses import dataclass
4
4
  from typing import Any, Dict, List, Set, Text
5
5
 
6
6
  from rasa.shared.constants import ACTION_ASK_PREFIX, UTTER_ASK_PREFIX
7
- from rasa.shared.core.constants import (
8
- KEY_ASK_CONFIRM_DIGRESSIONS,
9
- KEY_BLOCK_DIGRESSIONS,
10
- )
11
7
  from rasa.shared.core.flows.flow_step import FlowStep
12
- from rasa.shared.core.flows.utils import extract_digression_prop
13
8
  from rasa.shared.core.slots import SlotRejection
14
9
 
15
10
 
@@ -29,10 +24,8 @@ class CollectInformationFlowStep(FlowStep):
29
24
  """Whether to always ask the question even if the slot is already filled."""
30
25
  reset_after_flow_ends: bool = True
31
26
  """Whether to reset the slot value at the end of the flow."""
32
- ask_confirm_digressions: List[str] = field(default_factory=list)
33
- """The flow id digressions for which the assistant should ask for confirmation."""
34
- block_digressions: List[str] = field(default_factory=list)
35
- """The flow id digressions that should be blocked during the flow step."""
27
+ force_slot_filling: bool = False
28
+ """Whether to keep only the SetSlot command for the collected slot."""
36
29
 
37
30
  @classmethod
38
31
  def from_json(
@@ -60,10 +53,7 @@ class CollectInformationFlowStep(FlowStep):
60
53
  SlotRejection.from_dict(rejection)
61
54
  for rejection in data.get("rejections", [])
62
55
  ],
63
- ask_confirm_digressions=extract_digression_prop(
64
- KEY_ASK_CONFIRM_DIGRESSIONS, data
65
- ),
66
- block_digressions=extract_digression_prop(KEY_BLOCK_DIGRESSIONS, data),
56
+ force_slot_filling=data.get("force_slot_filling", False),
67
57
  **base.__dict__,
68
58
  )
69
59
 
@@ -79,10 +69,7 @@ class CollectInformationFlowStep(FlowStep):
79
69
  data["ask_before_filling"] = self.ask_before_filling
80
70
  data["reset_after_flow_ends"] = self.reset_after_flow_ends
81
71
  data["rejections"] = [rejection.as_dict() for rejection in self.rejections]
82
- data["ask_confirm_digressions"] = self.ask_confirm_digressions
83
- data["block_digressions"] = (
84
- self.block_digressions if self.block_digressions else False
85
- )
72
+ data["force_slot_filling"] = self.force_slot_filling
86
73
 
87
74
  return data
88
75
 
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, Any, Dict, List, Set, Text
1
+ from typing import TYPE_CHECKING, Any, Dict, Set, Text
2
2
 
3
3
  from rasa.shared.utils.io import raise_deprecation_warning
4
4
 
@@ -8,7 +8,6 @@ if TYPE_CHECKING:
8
8
 
9
9
  RESET_PROPERTY_NAME = "reset_after_flow_ends"
10
10
  PERSIST_PROPERTY_NAME = "persisted_slots"
11
- ALL_LABEL = "ALL"
12
11
 
13
12
 
14
13
  def warn_deprecated_collect_step_config() -> None:
@@ -45,20 +44,6 @@ def get_invalid_slot_persistence_config_error_message(
45
44
  )
46
45
 
47
46
 
48
- def extract_digression_prop(prop: str, data: Dict[str, Any]) -> List[str]:
49
- """Extracts the digression property from the data.
50
-
51
- There can be two types of properties: ask_confirm_digressions and
52
- block_digressions.
53
- """
54
- digression_property = data.get(prop, [])
55
-
56
- if isinstance(digression_property, bool):
57
- digression_property = [ALL_LABEL] if digression_property else []
58
-
59
- return digression_property
60
-
61
-
62
47
  def extract_translations(
63
48
  translation_data: Dict[Text, Any],
64
49
  ) -> Dict[Text, "FlowLanguageTranslation"]:
@@ -648,12 +648,14 @@ class SlotFillingManager:
648
648
  output_channel: "OutputChannel",
649
649
  nlg: "NaturalLanguageGenerator",
650
650
  recreate_tracker: bool = False,
651
+ slot_events: Optional[List[Event]] = None,
651
652
  ) -> List[Event]:
652
653
  from rasa.core.actions.action import RemoteAction
653
654
  from rasa.shared.core.trackers import DialogueStateTracker
654
655
  from rasa.utils.endpoints import ClientResponseError
655
656
 
656
- slot_events: List[Event] = []
657
+ validated_slot_events: List[Event] = []
658
+ slot_events = slot_events if slot_events is not None else []
657
659
  remote_action = RemoteAction(custom_action, self._action_endpoint)
658
660
  disallowed_types = set()
659
661
 
@@ -673,9 +675,9 @@ class SlotFillingManager:
673
675
  )
674
676
  for event in custom_events:
675
677
  if isinstance(event, SlotSet):
676
- slot_events.append(event)
678
+ validated_slot_events.append(event)
677
679
  elif isinstance(event, BotUttered):
678
- slot_events.append(event)
680
+ validated_slot_events.append(event)
679
681
  else:
680
682
  disallowed_types.add(event.type_name)
681
683
  except (RasaException, ClientResponseError) as e:
@@ -699,7 +701,7 @@ class SlotFillingManager:
699
701
  f"updated with this event.",
700
702
  )
701
703
 
702
- return slot_events
704
+ return validated_slot_events
703
705
 
704
706
  async def execute_validation_action(
705
707
  self,
@@ -722,7 +724,11 @@ class SlotFillingManager:
722
724
  return cast(List[Event], slot_events)
723
725
 
724
726
  validate_events = await self._run_custom_action(
725
- ACTION_VALIDATE_SLOT_MAPPINGS, output_channel, nlg, recreate_tracker=True
727
+ ACTION_VALIDATE_SLOT_MAPPINGS,
728
+ output_channel,
729
+ nlg,
730
+ recreate_tracker=True,
731
+ slot_events=cast(List[Event], slot_events),
726
732
  )
727
733
  validated_slot_names = [
728
734
  event.key for event in validate_events if isinstance(event, SlotSet)
@@ -55,4 +55,3 @@ SPLIT_ENTITIES_BY_COMMA_DEFAULT_VALUE = True
55
55
  SINGLE_ENTITY_ALLOWED_INTERLEAVING_CHARSET = {".", ",", " ", ";"}
56
56
 
57
57
  SET_SLOT_COMMAND = "set slot"
58
- HANDLE_DIGRESSIONS_COMMAND = "handle digressions"
@@ -4,12 +4,3 @@ LITE_LLM_API_KEY_FIELD = "api_key"
4
4
  LITE_LLM_API_VERSION_FIELD = "api_version"
5
5
  LITE_LLM_MODEL_FIELD = "model"
6
6
  LITE_LLM_AZURE_AD_TOKEN = "azure_ad_token"
7
-
8
- # Enable or disable Langfuse integration
9
- RASA_LANGFUSE_INTEGRATION_ENABLED_ENV_VAR = "RASA_LANGFUSE_INTEGRATION_ENABLED"
10
- # Langfuse configuration
11
- LANGFUSE_CALLBACK_NAME = "langfuse"
12
- LANGFUSE_HOST_ENV_VAR = "LANGFUSE_HOST"
13
- LANGFUSE_PROJECT_ID_ENV_VAR = "LANGFUSE_PROJECT_ID"
14
- LANGFUSE_PUBLIC_KEY_ENV_VAR = "LANGFUSE_PUBLIC_KEY"
15
- LANGFUSE_SECRET_KEY_ENV_VAR = "LANGFUSE_SECRET_KEY"
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import logging
4
4
  from abc import abstractmethod
5
- from typing import Any, Dict, List, Optional, Union, cast
5
+ from typing import Any, Dict, List, Union, cast
6
6
 
7
7
  import structlog
8
8
  from litellm import acompletion, completion, validate_environment
@@ -120,11 +120,7 @@ class _BaseLiteLLMClient:
120
120
  raise ProviderClientValidationError(event_info)
121
121
 
122
122
  @suppress_logs(log_level=logging.WARNING)
123
- def completion(
124
- self,
125
- messages: Union[List[dict], List[str], str],
126
- metadata: Optional[Dict[str, Any]] = None,
127
- ) -> LLMResponse:
123
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
128
124
  """Synchronously generate completions for given list of messages.
129
125
 
130
126
  Args:
@@ -136,7 +132,6 @@ class _BaseLiteLLMClient:
136
132
  - a list of messages. Each message is a string and will be formatted
137
133
  as a user message.
138
134
  - a single message as a string which will be formatted as user message.
139
- metadata: Optional metadata to be passed to the LLM call.
140
135
 
141
136
  Returns:
142
137
  List of message completions.
@@ -154,9 +149,7 @@ class _BaseLiteLLMClient:
154
149
 
155
150
  @suppress_logs(log_level=logging.WARNING)
156
151
  async def acompletion(
157
- self,
158
- messages: Union[List[dict], List[str], str],
159
- metadata: Optional[Dict[str, Any]] = None,
152
+ self, messages: Union[List[dict], List[str], str]
160
153
  ) -> LLMResponse:
161
154
  """Asynchronously generate completions for given list of messages.
162
155
 
@@ -169,7 +162,6 @@ class _BaseLiteLLMClient:
169
162
  - a list of messages. Each message is a string and will be formatted
170
163
  as a user message.
171
164
  - a single message as a string which will be formatted as user message.
172
- metadata: Optional metadata to be passed to the LLM call.
173
165
 
174
166
  Returns:
175
167
  List of message completions.
@@ -180,9 +172,7 @@ class _BaseLiteLLMClient:
180
172
  try:
181
173
  formatted_messages = self._get_formatted_messages(messages)
182
174
  arguments = resolve_environment_variables(self._completion_fn_args)
183
- response = await acompletion(
184
- messages=formatted_messages, metadata=metadata, **arguments
185
- )
175
+ response = await acompletion(messages=formatted_messages, **arguments)
186
176
  return self._format_response(response)
187
177
  except Exception as e:
188
178
  message = ""
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
- from typing import Any, Dict, List, Optional, Union
4
+ from typing import Any, Dict, List, Union
5
5
 
6
6
  import structlog
7
7
 
@@ -122,12 +122,9 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
122
122
  raise ProviderClientAPIException(e)
123
123
 
124
124
  @suppress_logs(log_level=logging.WARNING)
125
- def completion(
126
- self,
127
- messages: Union[List[dict], List[str], str],
128
- metadata: Optional[Dict[str, Any]] = None,
129
- ) -> LLMResponse:
130
- """Synchronously generate completions for given list of messages.
125
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
126
+ """
127
+ Synchronously generate completions for given list of messages.
131
128
 
132
129
  Method overrides the base class method to call the appropriate
133
130
  completion method based on the configuration. If the chat completions
@@ -143,11 +140,8 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
143
140
  - a list of messages. Each message is a string and will be formatted
144
141
  as a user message.
145
142
  - a single message as a string which will be formatted as user message.
146
- metadata: Optional metadata to be passed to the LLM call.
147
-
148
143
  Returns:
149
144
  List of message completions.
150
-
151
145
  Raises:
152
146
  ProviderClientAPIException: If the API request fails.
153
147
  """
@@ -164,11 +158,10 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
164
158
 
165
159
  @suppress_logs(log_level=logging.WARNING)
166
160
  async def acompletion(
167
- self,
168
- messages: Union[List[dict], List[str], str],
169
- metadata: Optional[Dict[str, Any]] = None,
161
+ self, messages: Union[List[dict], List[str], str]
170
162
  ) -> LLMResponse:
171
- """Asynchronously generate completions for given list of messages.
163
+ """
164
+ Asynchronously generate completions for given list of messages.
172
165
 
173
166
  Method overrides the base class method to call the appropriate
174
167
  completion method based on the configuration. If the chat completions
@@ -184,11 +177,8 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
184
177
  - a list of messages. Each message is a string and will be formatted
185
178
  as a user message.
186
179
  - a single message as a string which will be formatted as user message.
187
- metadata: Optional metadata to be passed to the LLM call.
188
-
189
180
  Returns:
190
181
  List of message completions.
191
-
192
182
  Raises:
193
183
  ProviderClientAPIException: If the API request fails.
194
184
  """
@@ -1,19 +1,21 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Dict, List, Optional, Protocol, Union, runtime_checkable
3
+ from typing import Dict, List, Protocol, Union, runtime_checkable
4
4
 
5
5
  from rasa.shared.providers.llm.llm_response import LLMResponse
6
6
 
7
7
 
8
8
  @runtime_checkable
9
9
  class LLMClient(Protocol):
10
- """Protocol for an LLM client that specifies the interface for interacting
10
+ """
11
+ Protocol for an LLM client that specifies the interface for interacting
11
12
  with the API.
12
13
  """
13
14
 
14
15
  @classmethod
15
16
  def from_config(cls, config: dict) -> LLMClient:
16
- """Initializes the llm client with the given configuration.
17
+ """
18
+ Initializes the llm client with the given configuration.
17
19
 
18
20
  This class method should be implemented to parse the given
19
21
  configuration and create an instance of an llm client.
@@ -22,24 +24,17 @@ class LLMClient(Protocol):
22
24
 
23
25
  @property
24
26
  def config(self) -> Dict:
25
- """Returns the configuration for that the llm client is initialized with.
27
+ """
28
+ Returns the configuration for that the llm client is initialized with.
26
29
 
27
30
  This property should be implemented to return a dictionary containing
28
31
  the configuration settings for the llm client.
29
32
  """
30
33
  ...
31
34
 
32
- def completion(
33
- self,
34
- messages: Union[List[dict], List[str], str],
35
- metadata: Optional[Dict[str, Any]] = None,
36
- ) -> LLMResponse:
37
- """Synchronously generate completions for given list of messages.
38
- def completion(
39
- self,
40
- messages: Union[List[dict], List[str], str],
41
- metadata: Optional[Dict[str, Any]] = None,
42
- ) -> LLMResponse:
35
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
36
+ """
37
+ Synchronously generate completions for given list of messages.
43
38
 
44
39
  This method should be implemented to take a list of messages (as
45
40
  strings) and return a list of completions (as strings).
@@ -53,19 +48,16 @@ class LLMClient(Protocol):
53
48
  - a list of messages. Each message is a string and will be formatted
54
49
  as a user message.
55
50
  - a single message as a string which will be formatted as user message.
56
- metadata: Optional metadata to be passed to the LLM call.
57
-
58
51
  Returns:
59
52
  LLMResponse
60
53
  """
61
54
  ...
62
55
 
63
56
  async def acompletion(
64
- self,
65
- messages: Union[List[dict], List[str], str],
66
- metadata: Optional[Dict[str, Any]] = None,
57
+ self, messages: Union[List[dict], List[str], str]
67
58
  ) -> LLMResponse:
68
- """Asynchronously generate completions for given list of messages.
59
+ """
60
+ Asynchronously generate completions for given list of messages.
69
61
 
70
62
  This method should be implemented to take a list of messages (as
71
63
  strings) and return a list of completions (as strings).
@@ -79,15 +71,14 @@ class LLMClient(Protocol):
79
71
  - a list of messages. Each message is a string and will be formatted
80
72
  as a user message.
81
73
  - a single message as a string which will be formatted as user message.
82
- metadata: Optional metadata to be passed to the LLM call.
83
-
84
74
  Returns:
85
75
  LLMResponse
86
76
  """
87
77
  ...
88
78
 
89
79
  def validate_client_setup(self, *args, **kwargs) -> None: # type: ignore
90
- """Perform client setup validation.
80
+ """
81
+ Perform client setup validation.
91
82
 
92
83
  This method should be implemented to validate whether the client can be
93
84
  used with the parameters provided through configuration or environment
@@ -237,9 +237,7 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
237
237
  raise ProviderClientAPIException(e)
238
238
 
239
239
  async def acompletion(
240
- self,
241
- messages: Union[List[dict], List[str], str],
242
- metadata: Optional[Dict[str, Any]] = None,
240
+ self, messages: Union[List[dict], List[str], str]
243
241
  ) -> LLMResponse:
244
242
  """Asynchronous completion of the model with the given messages.
245
243
 
@@ -257,7 +255,6 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
257
255
  - a list of messages. Each message is a string and will be formatted
258
256
  as a user message.
259
257
  - a single message as a string which will be formatted as user message.
260
- metadata: Optional metadata to be passed to the LLM call.
261
258
 
262
259
  Returns:
263
260
  The completion response.
@@ -266,11 +263,7 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
266
263
  return await super().acompletion(messages)
267
264
  return await self._atext_completion(messages)
268
265
 
269
- def completion(
270
- self,
271
- messages: Union[List[dict], List[str], str],
272
- metadata: Optional[Dict[str, Any]] = None,
273
- ) -> LLMResponse:
266
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
274
267
  """Completion of the model with the given messages.
275
268
 
276
269
  Method overrides the base class method to call the appropriate
@@ -280,7 +273,6 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
280
273
 
281
274
  Args:
282
275
  messages: The messages to be used for completion.
283
- metadata: Optional metadata to be passed to the LLM call.
284
276
 
285
277
  Returns:
286
278
  The completion response.
@@ -7,7 +7,17 @@ import os
7
7
  import pkgutil
8
8
  import sys
9
9
  from types import ModuleType
10
- from typing import Any, Callable, Collection, Dict, List, Optional, Sequence, Text, Type
10
+ from typing import (
11
+ Any,
12
+ Callable,
13
+ Collection,
14
+ Dict,
15
+ List,
16
+ Optional,
17
+ Sequence,
18
+ Text,
19
+ Type,
20
+ )
11
21
 
12
22
  import rasa.shared.utils.io
13
23
  from rasa.exceptions import MissingDependencyException
@@ -3,7 +3,6 @@ import sys
3
3
  from typing import Any, Dict, Optional
4
4
 
5
5
  from rasa.shared.constants import (
6
- LANGFUSE_CUSTOM_METADATA_DICT,
7
6
  LLM_API_HEALTH_CHECK_DEFAULT_VALUE,
8
7
  LLM_API_HEALTH_CHECK_ENV_VAR,
9
8
  MODELS_CONFIG_KEY,
@@ -199,12 +198,7 @@ def send_test_llm_api_request(
199
198
  config=llm_client.config,
200
199
  )
201
200
  try:
202
- llm_client.completion(
203
- "hello",
204
- metadata={
205
- LANGFUSE_CUSTOM_METADATA_DICT: {"component": log_source_component}
206
- },
207
- )
201
+ llm_client.completion("hello")
208
202
  except Exception as e:
209
203
  structlogger.error(
210
204
  f"{log_source_function}.send_test_llm_api_request_failed",
@@ -372,7 +372,6 @@ def extract_llm_config(
372
372
  def extract_attrs_for_llm_based_command_generator(
373
373
  self: "LLMBasedCommandGenerator",
374
374
  prompt: str,
375
- metadata: Optional[Dict[str, Any]] = None,
376
375
  ) -> Dict[str, Any]:
377
376
  from rasa.dialogue_understanding.generator.flow_retrieval import (
378
377
  DEFAULT_EMBEDDINGS_CONFIG,
@@ -388,7 +387,8 @@ def extract_attrs_for_llm_based_command_generator(
388
387
 
389
388
 
390
389
  def extract_attrs_for_contextual_response_rephraser(
391
- self: Any, prompt: str, sender_id: str
390
+ self: Any,
391
+ prompt: str,
392
392
  ) -> Dict[str, Any]:
393
393
  from rasa.core.nlg.contextual_response_rephraser import DEFAULT_LLM_CONFIG
394
394
 
@@ -721,7 +721,7 @@ def extract_attrs_for_intentless_policy_find_closest_response(
721
721
 
722
722
 
723
723
  def extract_attrs_for_intentless_policy_generate_llm_answer(
724
- self: "IntentlessPolicy", llm: "BaseLLM", prompt: str, sender_id: str
724
+ self: "IntentlessPolicy", llm: "BaseLLM", prompt: str
725
725
  ) -> Dict[str, Any]:
726
726
  from rasa.core.policies.intentless_policy import (
727
727
  DEFAULT_EMBEDDINGS_CONFIG,
@@ -738,7 +738,7 @@ def extract_attrs_for_intentless_policy_generate_llm_answer(
738
738
 
739
739
 
740
740
  def extract_attrs_for_enterprise_search_generate_llm_answer(
741
- self: "EnterpriseSearchPolicy", llm: "BaseLLM", prompt: str, sender_id: str
741
+ self: "EnterpriseSearchPolicy", llm: "BaseLLM", prompt: str
742
742
  ) -> Dict[str, Any]:
743
743
  from rasa.core.policies.enterprise_search_policy import (
744
744
  DEFAULT_EMBEDDINGS_CONFIG,
@@ -121,13 +121,12 @@ def _instrument_generate_answer(
121
121
  response_examples: List[str],
122
122
  conversation_samples: List[str],
123
123
  history: str,
124
- sender_id: str,
125
124
  ) -> Optional[str]:
126
125
  with tracer.start_as_current_span(
127
126
  f"{self.__class__.__name__}.{fn.__name__}"
128
127
  ) as span:
129
128
  llm_response = await fn(
130
- self, response_examples, conversation_samples, history, sender_id
129
+ self, response_examples, conversation_samples, history
131
130
  )
132
131
  span.set_attributes(
133
132
  {
rasa/utils/licensing.py CHANGED
@@ -539,18 +539,3 @@ async def _count_conversations_after(
539
539
  return 0
540
540
 
541
541
  return await tracker_store.count_conversations(after_timestamp=after_timestamp)
542
-
543
-
544
- def get_human_readable_licence_owner() -> str:
545
- user_id = "unknown"
546
-
547
- try:
548
- retrieved_license = retrieve_license_from_env()
549
- if retrieved_license:
550
- decoded = License.decode(retrieved_license)
551
- if decoded:
552
- user_id = (
553
- f"{decoded.company or ''}_{decoded.email or ''}_{decoded.jti or ''}"
554
- )
555
- finally:
556
- return user_id