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

@@ -898,7 +898,7 @@ class RemoteAction(Action):
898
898
  draft["buttons"].extend(buttons)
899
899
 
900
900
  # Avoid overwriting `draft` values with empty values
901
- response = {k: v for k, v in response.items() if v}
901
+ response = {k: v for k, v in response.items() if v is not None}
902
902
  draft.update(response)
903
903
  bot_messages.append(create_bot_utterance(draft))
904
904
 
@@ -16,6 +16,7 @@ import structlog
16
16
  from sanic import Sanic
17
17
 
18
18
  from rasa.core.channels.socketio import SocketBlueprint, SocketIOInput
19
+ from rasa.core.exceptions import AgentNotReady
19
20
  from rasa.hooks import hookimpl
20
21
  from rasa.plugin import plugin_manager
21
22
  from rasa.shared.core.constants import ACTION_LISTEN_NAME
@@ -149,8 +150,15 @@ class StudioChatInput(SocketIOInput):
149
150
  """
150
151
  await on_new_message(message)
151
152
 
152
- if not self.agent:
153
+ if not self.agent or not self.agent.is_ready():
153
154
  structlogger.error("studio_chat.on_message_proxy.agent_not_initialized")
155
+ await self.emit_error(
156
+ "The Rasa Pro model could not be loaded. "
157
+ "Please check the training and deployment logs "
158
+ "for more information.",
159
+ message.sender_id,
160
+ AgentNotReady("The Rasa Pro model could not be loaded."),
161
+ )
154
162
  return
155
163
 
156
164
  tracker = await self.agent.tracker_store.retrieve(message.sender_id)
@@ -160,6 +168,17 @@ class StudioChatInput(SocketIOInput):
160
168
 
161
169
  await self.on_tracker_updated(tracker)
162
170
 
171
+ async def emit_error(self, message: str, room: str, e: Exception) -> None:
172
+ await self.emit(
173
+ "error",
174
+ {
175
+ "message": message,
176
+ "error": str(e),
177
+ "exception": str(type(e).__name__),
178
+ },
179
+ room=room,
180
+ )
181
+
163
182
  async def handle_tracker_update(self, sid: str, data: Dict) -> None:
164
183
  from rasa.shared.core.trackers import DialogueStateTracker
165
184
 
@@ -200,15 +219,12 @@ class StudioChatInput(SocketIOInput):
200
219
  error=e,
201
220
  sender_id=data["sender_id"],
202
221
  )
203
- await self.emit(
204
- "error",
205
- {
206
- "message": "An error occurred while updating the conversation.",
207
- "error": str(e),
208
- "exception": str(type(e).__name__),
209
- },
210
- room=sid,
222
+ await self.emit_error(
223
+ "An error occurred while updating the conversation.",
224
+ data["sender_id"],
225
+ e,
211
226
  )
227
+
212
228
  if not tracker:
213
229
  # in case the tracker couldn't be updated, we retrieve the prior
214
230
  # version and use that to populate the update
@@ -6,7 +6,18 @@ import uuid
6
6
  from collections import defaultdict
7
7
  from dataclasses import asdict
8
8
  from datetime import datetime, timedelta, timezone
9
- from typing import Any, Awaitable, Callable, Dict, List, Optional, Set, Text, Union
9
+ from typing import (
10
+ Any,
11
+ Awaitable,
12
+ Callable,
13
+ Dict,
14
+ List,
15
+ Optional,
16
+ Set,
17
+ Text,
18
+ Tuple,
19
+ Union,
20
+ )
10
21
 
11
22
  import structlog
12
23
  from jsonschema import ValidationError, validate
@@ -76,35 +87,45 @@ class Conversation:
76
87
 
77
88
  @staticmethod
78
89
  def get_metadata(activity: Dict[Text, Any]) -> Optional[Dict[Text, Any]]:
79
- """Get metadata from the activity."""
80
- return asdict(map_call_params(activity["parameters"]))
90
+ """Get metadata from the activity.
91
+
92
+ ONLY used for activities NOT for events (see _handle_event)."""
93
+ return activity.get("parameters")
81
94
 
82
95
  @staticmethod
83
- def _handle_event(event: Dict[Text, Any]) -> Text:
84
- """Handle start and DTMF event and return the corresponding text."""
96
+ def _handle_event(event: Dict[Text, Any]) -> Tuple[Text, Dict[Text, Any]]:
97
+ """Handle events and return a tuple of text and metadata.
98
+
99
+ Args:
100
+ event: The event to handle.
101
+
102
+ Returns:
103
+ Tuple of text and metadata.
104
+ text is either /session_start or /vaig_event_<event_name>
105
+ metadata is a dictionary with the event parameters.
106
+ """
85
107
  structlogger.debug("audiocodes.handle.event", event_payload=event)
86
108
  if "name" not in event:
87
109
  structlogger.warning(
88
110
  "audiocodes.handle.event.no_name_key", event_payload=event
89
111
  )
90
- return ""
112
+ return "", {}
91
113
 
92
114
  if event["name"] == EVENT_START:
93
115
  text = f"{INTENT_MESSAGE_PREFIX}{USER_INTENT_SESSION_START}"
116
+ metadata = asdict(map_call_params(event.get("parameters", {})))
94
117
  elif event["name"] == EVENT_DTMF:
95
118
  text = f"{INTENT_MESSAGE_PREFIX}vaig_event_DTMF"
96
- event_params = {"value": event["value"]}
97
- text += json.dumps(event_params)
119
+ metadata = {"value": event["value"]}
98
120
  else:
99
121
  # handle other events described by Audiocodes
100
122
  # https://techdocs.audiocodes.com/voice-ai-connect/#VAIG_Combined/inactivity-detection.htm?TocPath=Bot%2520integration%257CReceiving%2520notifications%257C_____3
101
123
  text = f"{INTENT_MESSAGE_PREFIX}vaig_event_{event['name']}"
102
- event_params = {**event.get("parameters", {})}
124
+ metadata = {**event.get("parameters", {})}
103
125
  if "value" in event:
104
- event_params["value"] = event["value"]
105
- text += json.dumps(event_params)
126
+ metadata["value"] = event["value"]
106
127
 
107
- return text
128
+ return text, metadata
108
129
 
109
130
  def is_active_conversation(self, now: datetime, delta: timedelta) -> bool:
110
131
  """Check if the conversation is active."""
@@ -139,21 +160,29 @@ class Conversation:
139
160
  structlogger.warning(
140
161
  "audiocodes.handle.activities.duplicate_activity",
141
162
  activity_id=activity[ACTIVITY_ID_KEY],
163
+ event_info=(
164
+ "Audiocodes might send duplicate activities if the bot has not "
165
+ "responded to the previous one or responded too late. Please "
166
+ "consider enabling the `use_websocket` option to use"
167
+ " Audiocodes Asynchronous API."
168
+ ),
142
169
  )
143
170
  continue
144
171
  self.activity_ids.append(activity[ACTIVITY_ID_KEY])
145
172
  if activity["type"] == ACTIVITY_MESSAGE:
146
173
  text = activity["text"]
174
+ metadata = self.get_metadata(activity)
147
175
  elif activity["type"] == ACTIVITY_EVENT:
148
- text = self._handle_event(activity)
176
+ text, metadata = self._handle_event(activity)
149
177
  else:
150
178
  structlogger.warning(
151
179
  "audiocodes.handle.activities.unknown_activity_type",
152
180
  activity=activity,
153
181
  )
182
+ continue
183
+
154
184
  if not text:
155
185
  continue
156
- metadata = self.get_metadata(activity)
157
186
  user_msg = UserMessage(
158
187
  text=text,
159
188
  input_channel=input_channel_name,
@@ -392,30 +421,41 @@ class AudiocodesInput(InputChannel):
392
421
  "audiocodes.on_activities.no_conversation", request=request.json
393
422
  )
394
423
  return response.json({})
395
- elif conversation.ws:
424
+
425
+ if self.use_websocket:
426
+ # send an empty response for this request
427
+ # activities are processed in the background
428
+ # chat response is sent via the websocket
396
429
  ac_output: Union[WebsocketOutput, AudiocodesOutput] = WebsocketOutput(
397
430
  conversation.ws, conversation_id
398
431
  )
399
- response_json = {}
400
- else:
401
- # handle non websocket case where messages get returned in json
402
- ac_output = AudiocodesOutput()
403
- response_json = {
432
+ self._create_task(
433
+ conversation_id,
434
+ conversation.handle_activities(
435
+ request.json,
436
+ input_channel_name=self.name(),
437
+ output_channel=ac_output,
438
+ on_new_message=on_new_message,
439
+ ),
440
+ )
441
+ return response.json({})
442
+
443
+ # without websockets, this becomes a blocking call
444
+ # and the response is sent back to the Audiocodes server
445
+ # after the activities are processed
446
+ ac_output = AudiocodesOutput()
447
+ await conversation.handle_activities(
448
+ request.json,
449
+ input_channel_name=self.name(),
450
+ output_channel=ac_output,
451
+ on_new_message=on_new_message,
452
+ )
453
+ return response.json(
454
+ {
404
455
  "conversation": conversation_id,
405
456
  "activities": ac_output.messages,
406
457
  }
407
-
408
- # start a background task to handle activities
409
- self._create_task(
410
- conversation_id,
411
- conversation.handle_activities(
412
- request.json,
413
- input_channel_name=self.name(),
414
- output_channel=ac_output,
415
- on_new_message=on_new_message,
416
- ),
417
458
  )
418
- return response.json(response_json)
419
459
 
420
460
  @ac_webhook.route(
421
461
  "/conversation/<conversation_id>/disconnect", methods=["POST"]
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.12.9"
3
+ __version__ = "3.12.10"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rasa-pro
3
- Version: 3.12.9
3
+ Version: 3.12.10
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
@@ -92,7 +92,7 @@ rasa/cli/x.py,sha256=C7dLtYXAkD-uj7hNj7Pz5YbOupp2yRcMjQbsEVqXUJ8,6825
92
92
  rasa/constants.py,sha256=m6If7alC5obaHU-JQWXEBo4mooVwIMzNRTjyTzzZSVg,1306
93
93
  rasa/core/__init__.py,sha256=wTSmsFlgK0Ylvuyq20q9APwpT5xyVJYZfzhs4rrkciM,456
94
94
  rasa/core/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
95
- rasa/core/actions/action.py,sha256=2mDvSi1pSWipDWhprEFjDXf-X9yoID9DQEvmf0rQcJM,42664
95
+ rasa/core/actions/action.py,sha256=_QfY3ngSF2sf2Y3QDPJo7Nd6F_FA6_zDWgw1OQSLkEk,42676
96
96
  rasa/core/actions/action_clean_stack.py,sha256=xUP-2ipPsPAnAiwP17c-ezmHPSrV4JSUZr-eSgPQwIs,2279
97
97
  rasa/core/actions/action_exceptions.py,sha256=hghzXYN6VeHC-O_O7WiPesCNV86ZTkHgG90ZnQcbai8,724
98
98
  rasa/core/actions/action_hangup.py,sha256=o5iklHG-F9IcRgWis5C6AumVXznxzAV3o9zdduhozEM,994
@@ -263,12 +263,12 @@ rasa/core/channels/rest.py,sha256=ShKGmooXphhcDnHyV8TiQhDhj2r7hxTKNQ57FwFfyUA,72
263
263
  rasa/core/channels/rocketchat.py,sha256=hajaH6549CjEYFM5jSapw1DQKBPKTXbn7cVSuZzknmI,5999
264
264
  rasa/core/channels/slack.py,sha256=jVsTTUu9wUjukPoIsAhbee9o0QFUMCNlQHbR8LTcMBc,24406
265
265
  rasa/core/channels/socketio.py,sha256=Q7Gts30Ulwj90pQQxaUk4NykzagXErXgbHYwOjTmDig,10842
266
- rasa/core/channels/studio_chat.py,sha256=R5lOgOjgf-loXHvH8crN9zI_MSM_y_GV-rs7yoAqnYw,8661
266
+ rasa/core/channels/studio_chat.py,sha256=KUhR0Irst8pJ7zGMoeZuKquAUOYVB45i75wlVsbDqPU,9218
267
267
  rasa/core/channels/telegram.py,sha256=TKVknsk3U9tYeY1a8bzlhqkltWmZfGSOvrcmwa9qozc,12499
268
268
  rasa/core/channels/twilio.py,sha256=2BTQpyx0b0yPpc0A2BHYfxLPgodrLGLs8nq6i3lVGAM,5906
269
269
  rasa/core/channels/vier_cvg.py,sha256=GkrWKu7NRMFtLMyYp-kQ2taWAc_keAwhYrkVPW56iaU,13544
270
270
  rasa/core/channels/voice_ready/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
271
- rasa/core/channels/voice_ready/audiocodes.py,sha256=luO0e-azKlkwnWZ9bQWBF2DlkNHvEAkIQTb8HuouqGQ,21130
271
+ rasa/core/channels/voice_ready/audiocodes.py,sha256=eUUL9awt4P49LA5WC2hbsMZsi_qYHd-S3HL1Kpyj2ew,22353
272
272
  rasa/core/channels/voice_ready/jambonz.py,sha256=bU2yrO6Gw_JcmFXeFVc8f1DK3ZDDYLQVjBB8SM2JjWc,4783
273
273
  rasa/core/channels/voice_ready/jambonz_protocol.py,sha256=E9iwvitSDpVkL7BxbckczF4b0a8lWZt-3zR4Innflow,13116
274
274
  rasa/core/channels/voice_ready/twilio_voice.py,sha256=z2pdausxQnXQP9htGh8AL2q9AvcMIx70Y5tErWpssV4,16224
@@ -821,9 +821,9 @@ rasa/utils/train_utils.py,sha256=ClJx-6x3-h3Vt6mskacgkcCUJTMXjFPe3zAcy_DfmaU,212
821
821
  rasa/utils/url_tools.py,sha256=dZ1HGkVdWTJB7zYEdwoDIrEuyX9HE5WsxKKFVsXBLE0,1218
822
822
  rasa/utils/yaml.py,sha256=KjbZq5C94ZP7Jdsw8bYYF7HASI6K4-C_kdHfrnPLpSI,2000
823
823
  rasa/validator.py,sha256=524VlFTYK0B3iXYveVD6BDC3K0j1QfpzJ9O-TAWczmc,83166
824
- rasa/version.py,sha256=m454ZLl8XbOAWWge-8bKgVAQwInTNWgl72GlxlFATOA,117
825
- rasa_pro-3.12.9.dist-info/METADATA,sha256=ktE3D_-W-F96CQmQh-Atbdry48IUL_l6er0cF_5Bdhw,10615
826
- rasa_pro-3.12.9.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
827
- rasa_pro-3.12.9.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
828
- rasa_pro-3.12.9.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
829
- rasa_pro-3.12.9.dist-info/RECORD,,
824
+ rasa/version.py,sha256=F6TWQP94ECROLtXqlCrwu9xSrvxZDs3JVTp6gPLbxfE,118
825
+ rasa_pro-3.12.10.dist-info/METADATA,sha256=3wU4IxYsMJruxuysovjfW1wt7IOsh0YELYX4uvwhDhY,10616
826
+ rasa_pro-3.12.10.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
827
+ rasa_pro-3.12.10.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
828
+ rasa_pro-3.12.10.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
829
+ rasa_pro-3.12.10.dist-info/RECORD,,