rasa-pro 3.11.3a1.dev7__py3-none-any.whl → 3.12.0.dev2__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.
- rasa/cli/arguments/default_arguments.py +1 -1
- rasa/cli/dialogue_understanding_test.py +251 -0
- rasa/core/actions/action.py +7 -16
- rasa/core/channels/__init__.py +0 -2
- rasa/core/channels/socketio.py +23 -1
- rasa/core/nlg/contextual_response_rephraser.py +9 -62
- rasa/core/policies/enterprise_search_policy.py +12 -77
- rasa/core/policies/flows/flow_executor.py +2 -26
- rasa/core/processor.py +8 -11
- rasa/dialogue_understanding/generator/command_generator.py +49 -43
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +5 -5
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -2
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +15 -34
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +6 -11
- rasa/dialogue_understanding/utils.py +1 -8
- rasa/dialogue_understanding_test/command_metric_calculation.py +12 -0
- rasa/dialogue_understanding_test/constants.py +2 -0
- rasa/dialogue_understanding_test/du_test_runner.py +93 -0
- rasa/dialogue_understanding_test/io.py +54 -0
- rasa/dialogue_understanding_test/validation.py +22 -0
- rasa/e2e_test/e2e_test_runner.py +9 -7
- rasa/hooks.py +9 -15
- rasa/model_manager/socket_bridge.py +2 -7
- rasa/model_manager/warm_rasa_process.py +4 -9
- rasa/plugin.py +0 -11
- rasa/shared/constants.py +2 -21
- rasa/shared/core/events.py +8 -8
- rasa/shared/nlu/constants.py +0 -3
- rasa/shared/providers/_configs/azure_entra_id_client_creds.py +40 -0
- rasa/shared/providers/_configs/azure_entra_id_config.py +533 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +131 -15
- rasa/shared/providers/_configs/client_config.py +3 -1
- rasa/shared/providers/_configs/default_litellm_client_config.py +9 -7
- rasa/shared/providers/_configs/huggingface_local_embedding_client_config.py +13 -11
- rasa/shared/providers/_configs/litellm_router_client_config.py +12 -10
- rasa/shared/providers/_configs/model_group_config.py +11 -5
- rasa/shared/providers/_configs/oauth_config.py +33 -0
- rasa/shared/providers/_configs/openai_client_config.py +14 -12
- rasa/shared/providers/_configs/rasa_llm_client_config.py +5 -3
- rasa/shared/providers/_configs/self_hosted_llm_client_config.py +12 -11
- rasa/shared/providers/constants.py +6 -0
- rasa/shared/providers/embedding/azure_openai_embedding_client.py +30 -7
- rasa/shared/providers/embedding/litellm_router_embedding_client.py +5 -2
- rasa/shared/providers/llm/_base_litellm_client.py +6 -4
- rasa/shared/providers/llm/azure_openai_llm_client.py +88 -34
- rasa/shared/providers/llm/default_litellm_llm_client.py +4 -2
- rasa/shared/providers/llm/litellm_router_llm_client.py +23 -3
- rasa/shared/providers/llm/llm_client.py +4 -2
- rasa/shared/providers/llm/llm_response.py +1 -42
- rasa/shared/providers/llm/openai_llm_client.py +11 -5
- rasa/shared/providers/llm/rasa_llm_client.py +13 -5
- rasa/shared/providers/llm/self_hosted_llm_client.py +17 -10
- rasa/shared/providers/router/_base_litellm_router_client.py +10 -8
- rasa/shared/providers/router/router_client.py +3 -1
- rasa/shared/utils/llm.py +16 -12
- rasa/shared/utils/schemas/events.py +1 -1
- rasa/tracing/instrumentation/attribute_extractors.py +0 -2
- rasa/version.py +1 -1
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.12.0.dev2.dist-info}/METADATA +2 -1
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.12.0.dev2.dist-info}/RECORD +63 -56
- rasa/core/channels/studio_chat.py +0 -192
- rasa/dialogue_understanding/constants.py +0 -1
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.12.0.dev2.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.12.0.dev2.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.12.0.dev2.dist-info}/entry_points.txt +0 -0
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
from functools import partial
|
|
3
|
-
import json
|
|
4
|
-
from typing import (
|
|
5
|
-
TYPE_CHECKING,
|
|
6
|
-
Any,
|
|
7
|
-
Awaitable,
|
|
8
|
-
Callable,
|
|
9
|
-
Dict,
|
|
10
|
-
List,
|
|
11
|
-
Optional,
|
|
12
|
-
Text,
|
|
13
|
-
)
|
|
14
|
-
import structlog
|
|
15
|
-
|
|
16
|
-
from rasa.core.channels.socketio import SocketBlueprint, SocketIOInput
|
|
17
|
-
from rasa.shared.core.trackers import EventVerbosity
|
|
18
|
-
from sanic import Sanic
|
|
19
|
-
from rasa.plugin import plugin_manager
|
|
20
|
-
from rasa.hooks import hookimpl
|
|
21
|
-
|
|
22
|
-
if TYPE_CHECKING:
|
|
23
|
-
from rasa.core.channels.channel import UserMessage
|
|
24
|
-
from rasa.shared.core.trackers import DialogueStateTracker
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
structlogger = structlog.get_logger()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def tracker_as_dump(tracker: "DialogueStateTracker") -> str:
|
|
31
|
-
"""Create a dump of the tracker state."""
|
|
32
|
-
from rasa.shared.core.trackers import get_trackers_for_conversation_sessions
|
|
33
|
-
|
|
34
|
-
multiple_tracker_sessions = get_trackers_for_conversation_sessions(tracker)
|
|
35
|
-
|
|
36
|
-
if 0 <= len(multiple_tracker_sessions) <= 1:
|
|
37
|
-
last_tracker = tracker
|
|
38
|
-
else:
|
|
39
|
-
last_tracker = multiple_tracker_sessions[-1]
|
|
40
|
-
|
|
41
|
-
state = last_tracker.current_state(EventVerbosity.AFTER_RESTART)
|
|
42
|
-
return json.dumps(state)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class StudioTrackerUpdatePlugin:
|
|
46
|
-
"""Plugin for publishing tracker updates a socketio channel."""
|
|
47
|
-
|
|
48
|
-
def __init__(self, socket_channel: "StudioChatInput") -> None:
|
|
49
|
-
self.socket_channel = socket_channel
|
|
50
|
-
self.tasks: List[asyncio.Task] = []
|
|
51
|
-
|
|
52
|
-
def _cancel_tasks(self) -> None:
|
|
53
|
-
"""Cancel all remaining tasks."""
|
|
54
|
-
for task in self.tasks:
|
|
55
|
-
task.cancel()
|
|
56
|
-
self.tasks = []
|
|
57
|
-
|
|
58
|
-
def _cleanup_tasks(self) -> None:
|
|
59
|
-
"""Remove tasks that have already completed."""
|
|
60
|
-
self.tasks = [task for task in self.tasks if not task.done()]
|
|
61
|
-
|
|
62
|
-
@hookimpl # type: ignore[misc]
|
|
63
|
-
def after_new_user_message(self, tracker: "DialogueStateTracker") -> None:
|
|
64
|
-
"""Triggers a tracker update notification after a new user message."""
|
|
65
|
-
self.handle_tracker_update(tracker)
|
|
66
|
-
|
|
67
|
-
@hookimpl # type: ignore[misc]
|
|
68
|
-
def after_action_executed(self, tracker: "DialogueStateTracker") -> None:
|
|
69
|
-
"""Triggers a tracker update notification after an action is executed."""
|
|
70
|
-
self.handle_tracker_update(tracker)
|
|
71
|
-
|
|
72
|
-
def handle_tracker_update(self, tracker: "DialogueStateTracker") -> None:
|
|
73
|
-
"""Handles a tracker update when triggered by a hook."""
|
|
74
|
-
structlogger.info("studio_chat.after_tracker_update", tracker=tracker)
|
|
75
|
-
# directly create a dump to avoid the tracker getting modified by another
|
|
76
|
-
# function before it gets published (since the publishing is scheduled
|
|
77
|
-
# as an async task)
|
|
78
|
-
tracker_dump = tracker_as_dump(tracker)
|
|
79
|
-
task = asyncio.create_task(
|
|
80
|
-
self.socket_channel.publish_tracker_update(tracker.sender_id, tracker_dump)
|
|
81
|
-
)
|
|
82
|
-
self.tasks.append(task)
|
|
83
|
-
self._cleanup_tasks()
|
|
84
|
-
|
|
85
|
-
@hookimpl # type: ignore[misc]
|
|
86
|
-
def after_server_stop(self) -> None:
|
|
87
|
-
"""Cancels all remaining tasks when the server stops."""
|
|
88
|
-
self._cancel_tasks()
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class StudioChatInput(SocketIOInput):
|
|
92
|
-
"""Input channel for the communication between Rasa Studio and Rasa Pro."""
|
|
93
|
-
|
|
94
|
-
@classmethod
|
|
95
|
-
def name(cls) -> Text:
|
|
96
|
-
return "studio_chat"
|
|
97
|
-
|
|
98
|
-
def __init__(
|
|
99
|
-
self,
|
|
100
|
-
*args: Any,
|
|
101
|
-
**kwargs: Any,
|
|
102
|
-
) -> None:
|
|
103
|
-
"""Creates a ``SocketIOInput`` object."""
|
|
104
|
-
from rasa.core.agent import Agent
|
|
105
|
-
|
|
106
|
-
super().__init__(*args, **kwargs)
|
|
107
|
-
self.agent: Optional[Agent] = None
|
|
108
|
-
|
|
109
|
-
self._register_tracker_update_hook()
|
|
110
|
-
|
|
111
|
-
def _register_tracker_update_hook(self) -> None:
|
|
112
|
-
plugin_manager().register(StudioTrackerUpdatePlugin(self))
|
|
113
|
-
|
|
114
|
-
async def on_tracker_updated(self, tracker: "DialogueStateTracker") -> None:
|
|
115
|
-
"""Triggers a tracker update notification after a change to the tracker."""
|
|
116
|
-
await self.publish_tracker_update(tracker.sender_id, tracker_as_dump(tracker))
|
|
117
|
-
|
|
118
|
-
async def publish_tracker_update(self, sender_id: str, tracker_dump: Dict) -> None:
|
|
119
|
-
"""Publishes a tracker update notification to the websocket."""
|
|
120
|
-
if not self.sio:
|
|
121
|
-
structlogger.error("studio_chat.on_tracker_updated.sio_not_initialized")
|
|
122
|
-
return
|
|
123
|
-
await self.sio.emit("tracker", tracker_dump, room=sender_id)
|
|
124
|
-
|
|
125
|
-
async def on_message_proxy(
|
|
126
|
-
self,
|
|
127
|
-
on_new_message: Callable[["UserMessage"], Awaitable[Any]],
|
|
128
|
-
message: "UserMessage",
|
|
129
|
-
) -> None:
|
|
130
|
-
"""Proxies the on_new_message call to the underlying channel.
|
|
131
|
-
|
|
132
|
-
Triggers a tracker update notification after processing the message.
|
|
133
|
-
"""
|
|
134
|
-
await on_new_message(message)
|
|
135
|
-
|
|
136
|
-
if not self.agent:
|
|
137
|
-
structlogger.error("studio_chat.on_message_proxy.agent_not_initialized")
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
tracker = await self.agent.tracker_store.retrieve(message.sender_id)
|
|
141
|
-
if tracker is None:
|
|
142
|
-
structlogger.error("studio_chat.on_message_proxy.tracker_not_found")
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
await self.on_tracker_updated(tracker)
|
|
146
|
-
|
|
147
|
-
async def handle_tracker_update(self, sid: str, data: Dict) -> None:
|
|
148
|
-
from rasa.shared.core.trackers import DialogueStateTracker
|
|
149
|
-
|
|
150
|
-
structlogger.debug(
|
|
151
|
-
"studio_chat.sio.handle_tracker_update",
|
|
152
|
-
sid=sid,
|
|
153
|
-
sender_id=data["sender_id"],
|
|
154
|
-
)
|
|
155
|
-
if self.agent is None:
|
|
156
|
-
structlogger.error("studio_chat.sio.agent_not_initialized")
|
|
157
|
-
return None
|
|
158
|
-
|
|
159
|
-
if not (domain := self.agent.domain):
|
|
160
|
-
structlogger.error("studio_chat.sio.domain_not_initialized")
|
|
161
|
-
return None
|
|
162
|
-
|
|
163
|
-
async with self.agent.lock_store.lock(data["sender_id"]):
|
|
164
|
-
tracker = DialogueStateTracker.from_dict(
|
|
165
|
-
data["sender_id"], data["events"], domain.slots
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
# will override an existing tracker with the same id!
|
|
169
|
-
await self.agent.tracker_store.save(tracker)
|
|
170
|
-
|
|
171
|
-
await self.on_tracker_updated(tracker)
|
|
172
|
-
|
|
173
|
-
def blueprint(
|
|
174
|
-
self, on_new_message: Callable[["UserMessage"], Awaitable[Any]]
|
|
175
|
-
) -> SocketBlueprint:
|
|
176
|
-
socket_blueprint = super().blueprint(
|
|
177
|
-
partial(self.on_message_proxy, on_new_message)
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
if not self.sio:
|
|
181
|
-
structlogger.error("studio_chat.blueprint.sio_not_initialized")
|
|
182
|
-
return socket_blueprint
|
|
183
|
-
|
|
184
|
-
@socket_blueprint.listener("after_server_start") # type: ignore[misc]
|
|
185
|
-
async def after_server_start(app: Sanic, _: asyncio.AbstractEventLoop) -> None:
|
|
186
|
-
self.agent = app.ctx.agent
|
|
187
|
-
|
|
188
|
-
@self.sio.on("update_tracker", namespace=self.namespace)
|
|
189
|
-
async def on_update_tracker(sid: Text, data: Dict) -> None:
|
|
190
|
-
await self.handle_tracker_update(sid, data)
|
|
191
|
-
|
|
192
|
-
return socket_blueprint
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
RASA_RECORD_COMMANDS_AND_PROMPTS_ENV_VAR_NAME = "RASA_RECORD_COMMANDS_AND_PROMPTS"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|