rasa-pro 3.12.2.dev4__py3-none-any.whl → 3.12.3__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/core/actions/action.py +28 -38
- rasa/core/actions/action_run_slot_rejections.py +1 -1
- rasa/core/channels/development_inspector.py +4 -2
- rasa/core/channels/studio_chat.py +43 -16
- rasa/core/nlg/contextual_response_rephraser.py +6 -7
- rasa/core/nlg/generator.py +21 -5
- rasa/core/nlg/response.py +43 -6
- rasa/core/nlg/translate.py +8 -0
- rasa/model_manager/socket_bridge.py +7 -0
- rasa/shared/core/trackers.py +10 -4
- rasa/version.py +1 -1
- {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.3.dist-info}/METADATA +1 -1
- {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.3.dist-info}/RECORD +16 -16
- {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.3.dist-info}/NOTICE +0 -0
- {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.3.dist-info}/WHEEL +0 -0
- {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.3.dist-info}/entry_points.txt +0 -0
rasa/core/actions/action.py
CHANGED
|
@@ -23,11 +23,9 @@ from rasa.core.constants import (
|
|
|
23
23
|
KEY_IS_COEXISTENCE_ASSISTANT,
|
|
24
24
|
UTTER_SOURCE_METADATA_KEY,
|
|
25
25
|
)
|
|
26
|
-
from rasa.core.nlg.translate import get_translated_buttons, get_translated_text
|
|
27
26
|
from rasa.core.policies.policy import PolicyPrediction
|
|
28
27
|
from rasa.core.utils import add_bot_utterance_metadata
|
|
29
28
|
from rasa.e2e_test.constants import KEY_STUB_CUSTOM_ACTIONS
|
|
30
|
-
from rasa.engine.language import Language
|
|
31
29
|
from rasa.nlu.constants import (
|
|
32
30
|
RESPONSE_SELECTOR_DEFAULT_INTENT,
|
|
33
31
|
RESPONSE_SELECTOR_PREDICTION_KEY,
|
|
@@ -84,7 +82,6 @@ from rasa.shared.core.events import (
|
|
|
84
82
|
UserUttered,
|
|
85
83
|
)
|
|
86
84
|
from rasa.shared.core.flows import FlowsList
|
|
87
|
-
from rasa.shared.core.flows.constants import KEY_TRANSLATION
|
|
88
85
|
from rasa.shared.core.slot_mappings import (
|
|
89
86
|
SlotFillingManager,
|
|
90
87
|
extract_slot_value,
|
|
@@ -257,36 +254,25 @@ def action_for_name_or_text(
|
|
|
257
254
|
return RemoteAction(action_name_or_text, action_endpoint)
|
|
258
255
|
|
|
259
256
|
|
|
260
|
-
def create_bot_utterance(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
257
|
+
def create_bot_utterance(message: Dict[Text, Any]) -> BotUttered:
|
|
258
|
+
"""Create BotUttered event from message."""
|
|
259
|
+
bot_message = BotUttered(
|
|
260
|
+
text=message.pop(TEXT, None),
|
|
261
|
+
data={
|
|
262
|
+
ELEMENTS: message.pop(ELEMENTS, None),
|
|
263
|
+
QUICK_REPLIES: message.pop(QUICK_REPLIES, None),
|
|
264
|
+
BUTTONS: message.pop(BUTTONS, None),
|
|
265
|
+
# for legacy / compatibility reasons we need to set the image
|
|
266
|
+
# to be the attachment if there is no other attachment (the
|
|
267
|
+
# `.get` is intentional - no `pop` as we still need the image`
|
|
268
|
+
# property to set it in the following line)
|
|
269
|
+
ATTACHMENT: message.pop(ATTACHMENT, None) or message.get(IMAGE, None),
|
|
270
|
+
IMAGE: message.pop(IMAGE, None),
|
|
271
|
+
CUSTOM: message.pop(CUSTOM, None),
|
|
272
|
+
},
|
|
273
|
+
metadata=message,
|
|
274
274
|
)
|
|
275
|
-
|
|
276
|
-
data = {
|
|
277
|
-
ELEMENTS: message_copy.pop(ELEMENTS, None),
|
|
278
|
-
QUICK_REPLIES: message_copy.pop(QUICK_REPLIES, None),
|
|
279
|
-
BUTTONS: buttons,
|
|
280
|
-
# for legacy / compatibility reasons we need to set the image
|
|
281
|
-
# to be the attachment if there is no other attachment (the
|
|
282
|
-
# `.get` is intentional - no `pop` as we still need the image`
|
|
283
|
-
# property to set it in the following line)
|
|
284
|
-
ATTACHMENT: message_copy.pop(ATTACHMENT, None) or message_copy.get(IMAGE, None),
|
|
285
|
-
IMAGE: message_copy.pop(IMAGE, None),
|
|
286
|
-
CUSTOM: message_copy.pop(CUSTOM, None),
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return BotUttered(text=text, data=data, metadata=message_copy)
|
|
275
|
+
return bot_message
|
|
290
276
|
|
|
291
277
|
|
|
292
278
|
class Action:
|
|
@@ -399,7 +385,7 @@ class ActionBotResponse(Action):
|
|
|
399
385
|
message = add_bot_utterance_metadata(
|
|
400
386
|
message, self.utter_action, nlg, domain, tracker
|
|
401
387
|
)
|
|
402
|
-
return [create_bot_utterance(message
|
|
388
|
+
return [create_bot_utterance(message)]
|
|
403
389
|
|
|
404
390
|
def name(self) -> Text:
|
|
405
391
|
"""Returns action name."""
|
|
@@ -433,7 +419,7 @@ class ActionEndToEndResponse(Action):
|
|
|
433
419
|
) -> List[Event]:
|
|
434
420
|
"""Runs action (see parent class for full docstring)."""
|
|
435
421
|
message = {"text": self.action_text}
|
|
436
|
-
return [create_bot_utterance(message
|
|
422
|
+
return [create_bot_utterance(message)]
|
|
437
423
|
|
|
438
424
|
def event_for_successful_execution(
|
|
439
425
|
self,
|
|
@@ -899,7 +885,10 @@ class RemoteAction(Action):
|
|
|
899
885
|
generated_response = response.pop("response", None)
|
|
900
886
|
if generated_response is not None:
|
|
901
887
|
draft = await nlg.generate(
|
|
902
|
-
generated_response,
|
|
888
|
+
generated_response,
|
|
889
|
+
tracker,
|
|
890
|
+
output_channel.name(),
|
|
891
|
+
**response,
|
|
903
892
|
)
|
|
904
893
|
if not draft:
|
|
905
894
|
continue
|
|
@@ -917,7 +906,7 @@ class RemoteAction(Action):
|
|
|
917
906
|
# Avoid overwriting `draft` values with empty values
|
|
918
907
|
response = {k: v for k, v in response.items() if v}
|
|
919
908
|
draft.update(response)
|
|
920
|
-
bot_messages.append(create_bot_utterance(draft
|
|
909
|
+
bot_messages.append(create_bot_utterance(draft))
|
|
921
910
|
|
|
922
911
|
return bot_messages
|
|
923
912
|
|
|
@@ -1074,6 +1063,7 @@ def _revert_rephrasing_events() -> List[Event]:
|
|
|
1074
1063
|
]
|
|
1075
1064
|
|
|
1076
1065
|
|
|
1066
|
+
# TODO: this should be removed, e.g. it uses a hardcoded message and no translation
|
|
1077
1067
|
class ActionDefaultAskAffirmation(Action):
|
|
1078
1068
|
"""Default implementation which asks the user to affirm his intent.
|
|
1079
1069
|
|
|
@@ -1125,7 +1115,7 @@ class ActionDefaultAskAffirmation(Action):
|
|
|
1125
1115
|
"utter_action": self.name(),
|
|
1126
1116
|
}
|
|
1127
1117
|
|
|
1128
|
-
return [create_bot_utterance(message
|
|
1118
|
+
return [create_bot_utterance(message)]
|
|
1129
1119
|
|
|
1130
1120
|
|
|
1131
1121
|
class ActionDefaultAskRephrase(ActionBotResponse):
|
|
@@ -1158,7 +1148,7 @@ class ActionSendText(Action):
|
|
|
1158
1148
|
fallback = {"text": ""}
|
|
1159
1149
|
metadata_copy = copy.deepcopy(metadata) if metadata else {}
|
|
1160
1150
|
message = metadata_copy.get("message", fallback)
|
|
1161
|
-
return [create_bot_utterance(message
|
|
1151
|
+
return [create_bot_utterance(message)]
|
|
1162
1152
|
|
|
1163
1153
|
|
|
1164
1154
|
class ActionExtractSlots(Action):
|
|
@@ -217,6 +217,6 @@ class ActionRunSlotRejections(Action):
|
|
|
217
217
|
message = add_bot_utterance_metadata(
|
|
218
218
|
message, utterance, nlg, domain, tracker
|
|
219
219
|
)
|
|
220
|
-
events.append(create_bot_utterance(message
|
|
220
|
+
events.append(create_bot_utterance(message))
|
|
221
221
|
|
|
222
222
|
return events
|
|
@@ -134,13 +134,15 @@ class DevelopmentInspectProxy(InputChannel):
|
|
|
134
134
|
|
|
135
135
|
tracker = await self.processor.get_tracker(sender_id)
|
|
136
136
|
state = tracker.current_state(EventVerbosity.AFTER_RESTART)
|
|
137
|
-
return orjson.dumps(state).decode("utf-8")
|
|
137
|
+
return orjson.dumps(state, option=orjson.OPT_SERIALIZE_NUMPY).decode("utf-8")
|
|
138
138
|
|
|
139
139
|
async def on_tracker_updated(self, tracker: DialogueStateTracker) -> None:
|
|
140
140
|
"""Notifies all clients about tracker updates in real-time."""
|
|
141
141
|
if self.tracker_stream and tracker.sender_id:
|
|
142
142
|
state = tracker.current_state(EventVerbosity.AFTER_RESTART)
|
|
143
|
-
tracker_dump = orjson.dumps(
|
|
143
|
+
tracker_dump = orjson.dumps(
|
|
144
|
+
state, option=orjson.OPT_SERIALIZE_NUMPY
|
|
145
|
+
).decode("utf-8")
|
|
144
146
|
await self.tracker_stream.broadcast(tracker_dump)
|
|
145
147
|
|
|
146
148
|
async def on_message_proxy(
|
|
@@ -120,6 +120,13 @@ class StudioChatInput(SocketIOInput):
|
|
|
120
120
|
|
|
121
121
|
self._register_tracker_update_hook()
|
|
122
122
|
|
|
123
|
+
async def emit(self, event: str, data: Dict, room: str) -> None:
|
|
124
|
+
"""Emits an event to the websocket."""
|
|
125
|
+
if not self.sio:
|
|
126
|
+
structlogger.error("studio_chat.emit.sio_not_initialized")
|
|
127
|
+
return
|
|
128
|
+
await self.sio.emit(event, data, room=room)
|
|
129
|
+
|
|
123
130
|
def _register_tracker_update_hook(self) -> None:
|
|
124
131
|
plugin_manager().register(StudioTrackerUpdatePlugin(self))
|
|
125
132
|
|
|
@@ -129,10 +136,7 @@ class StudioChatInput(SocketIOInput):
|
|
|
129
136
|
|
|
130
137
|
async def publish_tracker_update(self, sender_id: str, tracker_dump: Dict) -> None:
|
|
131
138
|
"""Publishes a tracker update notification to the websocket."""
|
|
132
|
-
|
|
133
|
-
structlogger.error("studio_chat.on_tracker_updated.sio_not_initialized")
|
|
134
|
-
return
|
|
135
|
-
await self.sio.emit("tracker", tracker_dump, room=sender_id)
|
|
139
|
+
await self.emit("tracker", tracker_dump, room=sender_id)
|
|
136
140
|
|
|
137
141
|
async def on_message_proxy(
|
|
138
142
|
self,
|
|
@@ -172,22 +176,45 @@ class StudioChatInput(SocketIOInput):
|
|
|
172
176
|
structlogger.error("studio_chat.sio.domain_not_initialized")
|
|
173
177
|
return None
|
|
174
178
|
|
|
175
|
-
|
|
176
|
-
tracker = DialogueStateTracker.from_dict(
|
|
177
|
-
data["sender_id"], data["events"], domain.slots
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
# will override an existing tracker with the same id!
|
|
181
|
-
await self.agent.tracker_store.save(tracker)
|
|
179
|
+
tracker: Optional[DialogueStateTracker] = None
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
async with self.agent.lock_store.lock(data["sender_id"]):
|
|
182
|
+
try:
|
|
183
|
+
tracker = DialogueStateTracker.from_dict(
|
|
184
|
+
data["sender_id"], data["events"], domain.slots
|
|
185
|
+
)
|
|
186
186
|
|
|
187
|
-
|
|
188
|
-
await processor.run_anonymization_pipeline(tracker)
|
|
187
|
+
# will override an existing tracker with the same id!
|
|
189
188
|
await self.agent.tracker_store.save(tracker)
|
|
190
189
|
|
|
190
|
+
processor = self.agent.processor
|
|
191
|
+
if processor and does_need_action_prediction(tracker):
|
|
192
|
+
output_channel = self.get_output_channel()
|
|
193
|
+
|
|
194
|
+
await processor._run_prediction_loop(output_channel, tracker)
|
|
195
|
+
await processor.run_anonymization_pipeline(tracker)
|
|
196
|
+
await self.agent.tracker_store.save(tracker)
|
|
197
|
+
except Exception as e:
|
|
198
|
+
structlogger.error(
|
|
199
|
+
"studio_chat.sio.handle_tracker_update.error",
|
|
200
|
+
error=e,
|
|
201
|
+
sender_id=data["sender_id"],
|
|
202
|
+
)
|
|
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,
|
|
211
|
+
)
|
|
212
|
+
if not tracker:
|
|
213
|
+
# in case the tracker couldn't be updated, we retrieve the prior
|
|
214
|
+
# version and use that to populate the update
|
|
215
|
+
tracker = await self.agent.tracker_store.get_or_create_tracker(
|
|
216
|
+
data["sender_id"]
|
|
217
|
+
)
|
|
191
218
|
await self.on_tracker_updated(tracker)
|
|
192
219
|
|
|
193
220
|
def blueprint(
|
|
@@ -200,8 +200,10 @@ class ContextualResponseRephraser(
|
|
|
200
200
|
|
|
201
201
|
@measure_llm_latency
|
|
202
202
|
async def _generate_llm_response(self, prompt: str) -> Optional[LLMResponse]:
|
|
203
|
-
"""Use LLM to generate a response
|
|
204
|
-
|
|
203
|
+
"""Use LLM to generate a response.
|
|
204
|
+
|
|
205
|
+
Returns an LLMResponse object containing both the generated text
|
|
206
|
+
(choices) and metadata.
|
|
205
207
|
|
|
206
208
|
Args:
|
|
207
209
|
prompt: The prompt to send to the LLM.
|
|
@@ -367,12 +369,9 @@ class ContextualResponseRephraser(
|
|
|
367
369
|
Returns:
|
|
368
370
|
The generated response.
|
|
369
371
|
"""
|
|
370
|
-
|
|
371
|
-
stack_context = tracker.stack.current_context()
|
|
372
|
-
templated_response = self.generate_from_slots(
|
|
372
|
+
templated_response = await super().generate(
|
|
373
373
|
utter_action=utter_action,
|
|
374
|
-
|
|
375
|
-
stack_context=stack_context,
|
|
374
|
+
tracker=tracker,
|
|
376
375
|
output_channel=output_channel,
|
|
377
376
|
**kwargs,
|
|
378
377
|
)
|
rasa/core/nlg/generator.py
CHANGED
|
@@ -6,6 +6,8 @@ from pypred import Predicate
|
|
|
6
6
|
|
|
7
7
|
import rasa.shared.utils.common
|
|
8
8
|
import rasa.shared.utils.io
|
|
9
|
+
from rasa.core.nlg.translate import has_translation
|
|
10
|
+
from rasa.engine.language import Language
|
|
9
11
|
from rasa.shared.constants import CHANNEL, RESPONSE_CONDITION
|
|
10
12
|
from rasa.shared.core.domain import Domain
|
|
11
13
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
@@ -131,11 +133,23 @@ class ResponseVariationFilter:
|
|
|
131
133
|
|
|
132
134
|
return True
|
|
133
135
|
|
|
136
|
+
def _filter_by_language(
|
|
137
|
+
self, responses: List[Dict[Text, Any]], language: Optional[Language] = None
|
|
138
|
+
) -> List[Dict[Text, Any]]:
|
|
139
|
+
if not language:
|
|
140
|
+
return responses
|
|
141
|
+
|
|
142
|
+
if filtered := [r for r in responses if has_translation(r, language)]:
|
|
143
|
+
return filtered
|
|
144
|
+
# if no translation is found, return the original response variations
|
|
145
|
+
return responses
|
|
146
|
+
|
|
134
147
|
def responses_for_utter_action(
|
|
135
148
|
self,
|
|
136
149
|
utter_action: Text,
|
|
137
150
|
output_channel: Text,
|
|
138
151
|
filled_slots: Dict[Text, Any],
|
|
152
|
+
language: Optional[Language] = None,
|
|
139
153
|
) -> List[Dict[Text, Any]]:
|
|
140
154
|
"""Returns array of responses that fit the channel, action and condition."""
|
|
141
155
|
# filter responses without a condition
|
|
@@ -176,16 +190,16 @@ class ResponseVariationFilter:
|
|
|
176
190
|
)
|
|
177
191
|
|
|
178
192
|
if conditional_channel:
|
|
179
|
-
return conditional_channel
|
|
193
|
+
return self._filter_by_language(conditional_channel, language)
|
|
180
194
|
|
|
181
195
|
if default_channel:
|
|
182
|
-
return default_channel
|
|
196
|
+
return self._filter_by_language(default_channel, language)
|
|
183
197
|
|
|
184
198
|
if conditional_no_channel:
|
|
185
|
-
return conditional_no_channel
|
|
199
|
+
return self._filter_by_language(conditional_no_channel, language)
|
|
186
200
|
|
|
187
201
|
if default_no_channel:
|
|
188
|
-
return default_no_channel
|
|
202
|
+
return self._filter_by_language(default_no_channel, language)
|
|
189
203
|
|
|
190
204
|
# if there is no response variation selected,
|
|
191
205
|
# return the internal error response to prevent
|
|
@@ -198,7 +212,9 @@ class ResponseVariationFilter:
|
|
|
198
212
|
f"a default variation and that all the conditions are valid. "
|
|
199
213
|
f"Returning the internal error response.",
|
|
200
214
|
)
|
|
201
|
-
return self.
|
|
215
|
+
return self._filter_by_language(
|
|
216
|
+
self.responses.get("utter_internal_error_rasa", []), language
|
|
217
|
+
)
|
|
202
218
|
|
|
203
219
|
def get_response_variation_id(
|
|
204
220
|
self,
|
rasa/core/nlg/response.py
CHANGED
|
@@ -5,8 +5,11 @@ from typing import Any, Dict, List, Optional, Text
|
|
|
5
5
|
from rasa.core.constants import DEFAULT_TEMPLATE_ENGINE, TEMPLATE_ENGINE_CONFIG_KEY
|
|
6
6
|
from rasa.core.nlg import interpolator
|
|
7
7
|
from rasa.core.nlg.generator import NaturalLanguageGenerator, ResponseVariationFilter
|
|
8
|
-
from rasa.
|
|
8
|
+
from rasa.core.nlg.translate import get_translated_buttons, get_translated_text
|
|
9
|
+
from rasa.engine.language import Language
|
|
10
|
+
from rasa.shared.constants import BUTTONS, RESPONSE_CONDITION, TEXT
|
|
9
11
|
from rasa.shared.core.domain import RESPONSE_KEYS_TO_INTERPOLATE
|
|
12
|
+
from rasa.shared.core.flows.constants import KEY_TRANSLATION
|
|
10
13
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
11
14
|
from rasa.shared.nlu.constants import METADATA
|
|
12
15
|
|
|
@@ -30,7 +33,11 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
30
33
|
|
|
31
34
|
# noinspection PyUnusedLocal
|
|
32
35
|
def _random_response_for(
|
|
33
|
-
self,
|
|
36
|
+
self,
|
|
37
|
+
utter_action: Text,
|
|
38
|
+
output_channel: Text,
|
|
39
|
+
filled_slots: Dict[Text, Any],
|
|
40
|
+
language: Optional[Language] = None,
|
|
34
41
|
) -> Optional[Dict[Text, Any]]:
|
|
35
42
|
"""Select random response for the utter action from available ones.
|
|
36
43
|
|
|
@@ -42,7 +49,7 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
42
49
|
if utter_action in self.responses:
|
|
43
50
|
response_filter = ResponseVariationFilter(self.responses)
|
|
44
51
|
suitable_responses = response_filter.responses_for_utter_action(
|
|
45
|
-
utter_action, output_channel, filled_slots
|
|
52
|
+
utter_action, output_channel, filled_slots, language
|
|
46
53
|
)
|
|
47
54
|
|
|
48
55
|
if suitable_responses:
|
|
@@ -75,9 +82,36 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
75
82
|
"""Generate a response for the requested utter action."""
|
|
76
83
|
filled_slots = tracker.current_slot_values()
|
|
77
84
|
stack_context = tracker.stack.current_context()
|
|
78
|
-
|
|
79
|
-
utter_action,
|
|
85
|
+
response = self.generate_from_slots(
|
|
86
|
+
utter_action,
|
|
87
|
+
filled_slots,
|
|
88
|
+
stack_context,
|
|
89
|
+
output_channel,
|
|
90
|
+
tracker.current_language,
|
|
91
|
+
**kwargs,
|
|
80
92
|
)
|
|
93
|
+
if response is not None:
|
|
94
|
+
return self.translate_response(response, tracker.current_language)
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
def translate_response(
|
|
98
|
+
self, response: Dict[Text, Any], language: Optional[Language] = None
|
|
99
|
+
) -> Dict[Text, Any]:
|
|
100
|
+
message_copy = copy.deepcopy(response)
|
|
101
|
+
|
|
102
|
+
text = get_translated_text(
|
|
103
|
+
text=message_copy.pop(TEXT, None),
|
|
104
|
+
translation=message_copy.pop(KEY_TRANSLATION, {}),
|
|
105
|
+
language=language,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
buttons = get_translated_buttons(
|
|
109
|
+
buttons=message_copy.pop(BUTTONS, None), language=language
|
|
110
|
+
)
|
|
111
|
+
message_copy[TEXT] = text
|
|
112
|
+
if buttons:
|
|
113
|
+
message_copy[BUTTONS] = buttons
|
|
114
|
+
return message_copy
|
|
81
115
|
|
|
82
116
|
def generate_from_slots(
|
|
83
117
|
self,
|
|
@@ -85,12 +119,15 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
85
119
|
filled_slots: Dict[Text, Any],
|
|
86
120
|
stack_context: Dict[Text, Any],
|
|
87
121
|
output_channel: Text,
|
|
122
|
+
language: Optional[Language] = None,
|
|
88
123
|
**kwargs: Any,
|
|
89
124
|
) -> Optional[Dict[Text, Any]]:
|
|
90
125
|
"""Generate a response for the requested utter action."""
|
|
91
126
|
# Fetching a random response for the passed utter action
|
|
92
127
|
r = copy.deepcopy(
|
|
93
|
-
self._random_response_for(
|
|
128
|
+
self._random_response_for(
|
|
129
|
+
utter_action, output_channel, filled_slots, language
|
|
130
|
+
)
|
|
94
131
|
)
|
|
95
132
|
# Filling the slots in the response with placeholders and returning the response
|
|
96
133
|
if r is not None:
|
rasa/core/nlg/translate.py
CHANGED
|
@@ -23,6 +23,14 @@ def get_translated_text(
|
|
|
23
23
|
return translation.get(language_code, text)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
def has_translation(
|
|
27
|
+
message: Dict[Text, Any], language: Optional[Language] = None
|
|
28
|
+
) -> bool:
|
|
29
|
+
"""Check if the message has a translation for the given language."""
|
|
30
|
+
language_code = language.code if language else None
|
|
31
|
+
return language_code in message.get(KEY_TRANSLATION, {})
|
|
32
|
+
|
|
33
|
+
|
|
26
34
|
def get_translated_buttons(
|
|
27
35
|
buttons: Optional[List[Dict[Text, Any]]], language: Optional[Language] = None
|
|
28
36
|
) -> Optional[List[Dict[Text, Any]]]:
|
|
@@ -131,6 +131,13 @@ async def create_bridge_client(
|
|
|
131
131
|
structlogger.debug("model_runner.bot_message", deployment_id=deployment_id)
|
|
132
132
|
await sio.emit("bot_message", data, room=sid)
|
|
133
133
|
|
|
134
|
+
@client.event # type: ignore[misc]
|
|
135
|
+
async def error(data: Dict[str, Any]) -> None:
|
|
136
|
+
structlogger.debug(
|
|
137
|
+
"model_runner.bot_error", deployment_id=deployment_id, data=data
|
|
138
|
+
)
|
|
139
|
+
await sio.emit("error", data, room=sid)
|
|
140
|
+
|
|
134
141
|
@client.event # type: ignore[misc]
|
|
135
142
|
async def tracker(data: Dict[str, Any]) -> None:
|
|
136
143
|
await sio.emit("tracker", json.loads(data), room=sid)
|
rasa/shared/core/trackers.py
CHANGED
|
@@ -1123,10 +1123,16 @@ class DialogueStateTracker:
|
|
|
1123
1123
|
f"Please update the slot configuration accordingly."
|
|
1124
1124
|
)
|
|
1125
1125
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1126
|
+
supported_languages = []
|
|
1127
|
+
for language_code in language_slot.values:
|
|
1128
|
+
is_default = language_code == language_slot.initial_value
|
|
1129
|
+
language = Language.from_language_code(
|
|
1130
|
+
language_code=language_code,
|
|
1131
|
+
is_default=is_default,
|
|
1132
|
+
)
|
|
1133
|
+
supported_languages.append(language)
|
|
1134
|
+
|
|
1135
|
+
return supported_languages
|
|
1130
1136
|
|
|
1131
1137
|
@property
|
|
1132
1138
|
def current_language(self) -> Optional[Language]:
|
rasa/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rasa-pro
|
|
3
|
-
Version: 3.12.
|
|
3
|
+
Version: 3.12.3
|
|
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
|
Home-page: https://rasa.com
|
|
6
6
|
Keywords: nlp,machine-learning,machine-learning-library,bot,bots,botkit,rasa conversational-agents,conversational-ai,chatbot,chatbot-framework,bot-framework
|
|
@@ -93,13 +93,13 @@ rasa/cli/x.py,sha256=C7dLtYXAkD-uj7hNj7Pz5YbOupp2yRcMjQbsEVqXUJ8,6825
|
|
|
93
93
|
rasa/constants.py,sha256=m6If7alC5obaHU-JQWXEBo4mooVwIMzNRTjyTzzZSVg,1306
|
|
94
94
|
rasa/core/__init__.py,sha256=wTSmsFlgK0Ylvuyq20q9APwpT5xyVJYZfzhs4rrkciM,456
|
|
95
95
|
rasa/core/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
96
|
-
rasa/core/actions/action.py,sha256=
|
|
96
|
+
rasa/core/actions/action.py,sha256=SEaD1VtelZeBgxZ9Dj6LpmXXXxHOJRoxXUiQ_xb0TJM,42868
|
|
97
97
|
rasa/core/actions/action_clean_stack.py,sha256=xUP-2ipPsPAnAiwP17c-ezmHPSrV4JSUZr-eSgPQwIs,2279
|
|
98
98
|
rasa/core/actions/action_exceptions.py,sha256=hghzXYN6VeHC-O_O7WiPesCNV86ZTkHgG90ZnQcbai8,724
|
|
99
99
|
rasa/core/actions/action_handle_digressions.py,sha256=p3cjzTfT0GEsJlYip-TPnr-PJQ545vQnNp0JPKBUs8A,5234
|
|
100
100
|
rasa/core/actions/action_hangup.py,sha256=o5iklHG-F9IcRgWis5C6AumVXznxzAV3o9zdduhozEM,994
|
|
101
101
|
rasa/core/actions/action_repeat_bot_messages.py,sha256=2DZFHPS7SKslz_Pm3Tyn0154xTws3E7lMYKl2ktQPTQ,3522
|
|
102
|
-
rasa/core/actions/action_run_slot_rejections.py,sha256=
|
|
102
|
+
rasa/core/actions/action_run_slot_rejections.py,sha256=Rng5h-h5b63HisUeSFZXQ3FnNi-jPoqSbqnDo8M-jTk,7248
|
|
103
103
|
rasa/core/actions/action_trigger_chitchat.py,sha256=krOPqCXBihxOskqmm05A4mFEm4lj4ohvzuddy7rELVQ,1084
|
|
104
104
|
rasa/core/actions/action_trigger_flow.py,sha256=IydYAGafTtoY6XSgCX124xJQhzudUg8JAICstqsV3VA,3487
|
|
105
105
|
rasa/core/actions/action_trigger_search.py,sha256=QfYqnaGRCqRYJ4msYsLAbnVYW5ija_tqhCcKIN8aEfw,1064
|
|
@@ -125,7 +125,7 @@ rasa/core/channels/botframework.py,sha256=qEuh19OJYPBcX4PN1hhPwMznKbi0_zj4hotV5E
|
|
|
125
125
|
rasa/core/channels/callback.py,sha256=Llt5TGimf_5P29s2KxEPOZUX6_df7u8uBCsNSFy7CQA,2750
|
|
126
126
|
rasa/core/channels/channel.py,sha256=Ih2s0Jf_dQluzeFvOgrXVx9RK4YBkcbNOfIeYkAnexI,15107
|
|
127
127
|
rasa/core/channels/console.py,sha256=13bjhsmnuKoShYVdtt2VHzzt9xylER-hDTONC1MiQG0,8075
|
|
128
|
-
rasa/core/channels/development_inspector.py,sha256=
|
|
128
|
+
rasa/core/channels/development_inspector.py,sha256=D7AmmdhqVtdoOSGAXZK22o70xpNCax8KUiRtjtB8cqs,9288
|
|
129
129
|
rasa/core/channels/facebook.py,sha256=CGlmPYsiSCPDMDU_2DuiXAxll8bEzZI3_ny5LGBeK-Q,15816
|
|
130
130
|
rasa/core/channels/hangouts.py,sha256=W5i_P2OsGk5Ciax38FFcIYd8GMMZZUx-l1E9fn5FT3c,11561
|
|
131
131
|
rasa/core/channels/inspector/.eslintrc.cjs,sha256=MXLV2wxhPZqg3wvFlyi1fM363_7XxtWsB87RqWN4gzY,580
|
|
@@ -264,7 +264,7 @@ rasa/core/channels/rest.py,sha256=ShKGmooXphhcDnHyV8TiQhDhj2r7hxTKNQ57FwFfyUA,72
|
|
|
264
264
|
rasa/core/channels/rocketchat.py,sha256=hajaH6549CjEYFM5jSapw1DQKBPKTXbn7cVSuZzknmI,5999
|
|
265
265
|
rasa/core/channels/slack.py,sha256=jVsTTUu9wUjukPoIsAhbee9o0QFUMCNlQHbR8LTcMBc,24406
|
|
266
266
|
rasa/core/channels/socketio.py,sha256=Q7Gts30Ulwj90pQQxaUk4NykzagXErXgbHYwOjTmDig,10842
|
|
267
|
-
rasa/core/channels/studio_chat.py,sha256=
|
|
267
|
+
rasa/core/channels/studio_chat.py,sha256=R5lOgOjgf-loXHvH8crN9zI_MSM_y_GV-rs7yoAqnYw,8661
|
|
268
268
|
rasa/core/channels/telegram.py,sha256=TKVknsk3U9tYeY1a8bzlhqkltWmZfGSOvrcmwa9qozc,12499
|
|
269
269
|
rasa/core/channels/twilio.py,sha256=2BTQpyx0b0yPpc0A2BHYfxLPgodrLGLs8nq6i3lVGAM,5906
|
|
270
270
|
rasa/core/channels/vier_cvg.py,sha256=GkrWKu7NRMFtLMyYp-kQ2taWAc_keAwhYrkVPW56iaU,13544
|
|
@@ -319,12 +319,12 @@ rasa/core/lock_store.py,sha256=weupfBiYMz-B_N-LAONCvp-po1uPRdie9imLYn7hFDU,12504
|
|
|
319
319
|
rasa/core/migrate.py,sha256=h1dOpXxmVmZlbLVGy1yOU_Obp2KzRiOiL0iuEacA0Cg,14618
|
|
320
320
|
rasa/core/nlg/__init__.py,sha256=jZuQAhOUcxO-KqqHGqICHSY3oDeXlUiGr2trQDYfG6o,240
|
|
321
321
|
rasa/core/nlg/callback.py,sha256=0zDQsOa3uV66G3smCVQ9cUdvj-it8tFneIzqShM7NeI,5208
|
|
322
|
-
rasa/core/nlg/contextual_response_rephraser.py,sha256=
|
|
323
|
-
rasa/core/nlg/generator.py,sha256=
|
|
322
|
+
rasa/core/nlg/contextual_response_rephraser.py,sha256=u38r7ZVnuafqGUwg6QtZqVQ4GLn0wa683PwHP3v6TXM,13375
|
|
323
|
+
rasa/core/nlg/generator.py,sha256=iMTqt0sPRMc55ontZU1svQVPKixDojBXN-cFuOvLMGo,11647
|
|
324
324
|
rasa/core/nlg/interpolator.py,sha256=hEOhqfMXrAqTZiqjg2t6ZfTK6DJQ5IiX4tJIz2b8Fbw,5190
|
|
325
|
-
rasa/core/nlg/response.py,sha256=
|
|
325
|
+
rasa/core/nlg/response.py,sha256=SecKyoBQjEnZr4t-Gg5fkUpkozwGT2lzswIKgD63Dac,7248
|
|
326
326
|
rasa/core/nlg/summarize.py,sha256=liXcbJMBm0NaaSH0LwlSs1l0dTby0OEprSzeKeyRyv0,2109
|
|
327
|
-
rasa/core/nlg/translate.py,sha256=
|
|
327
|
+
rasa/core/nlg/translate.py,sha256=ZXRvysqXGdtHBJ7x3YkW6zfmnb9DuEGHCMTL41v-M8M,2112
|
|
328
328
|
rasa/core/persistor.py,sha256=EP8kaGQQbRJKkxw2GCZkjJk-O2n4PgIHXa9F9a5MjVk,20337
|
|
329
329
|
rasa/core/policies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
330
330
|
rasa/core/policies/ensemble.py,sha256=XoHxU0jcb_io_LBOpjJffylzqtGEB7CH9ivhRyO8pDc,12960
|
|
@@ -558,7 +558,7 @@ rasa/model_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
|
558
558
|
rasa/model_manager/config.py,sha256=FziaDSyDB-qr40pU46QrvfnScviJaqExfQKUezqlroE,1159
|
|
559
559
|
rasa/model_manager/model_api.py,sha256=zACwxiURsJU9BG1lxCRG8eSNwzeNwshlcjRjqvhPYsk,20275
|
|
560
560
|
rasa/model_manager/runner_service.py,sha256=Lw0shswAekncsQcYriGaPPPL4fJhP9ry6XDUMv0buqU,8811
|
|
561
|
-
rasa/model_manager/socket_bridge.py,sha256=
|
|
561
|
+
rasa/model_manager/socket_bridge.py,sha256=luU0EzzuM77jthUZUWobW2dMocz-TM_DGrfUSUTqozk,5554
|
|
562
562
|
rasa/model_manager/studio_jwt_auth.py,sha256=uls2QiHUlUrR3fOzZssW4UaAMJMfnPMZeV1aDmZIT0E,2645
|
|
563
563
|
rasa/model_manager/trainer_service.py,sha256=kz6OJlFJvfic4wLBChOKe1O0ysBx2rozL1mEALZwvg0,10320
|
|
564
564
|
rasa/model_manager/utils.py,sha256=rS0ST-rJMuZOna90r_Ioz7gOkZ8r8vm4XAhzI0iUZOA,2643
|
|
@@ -662,7 +662,7 @@ rasa/shared/core/flows/yaml_flows_io.py,sha256=85ln95jpkh7ZqDl1cheFa8Q21gnadLjWr
|
|
|
662
662
|
rasa/shared/core/generator.py,sha256=UAuBPu5UjUhL9djVK-PvrWZcNhRACOEgnRsTleV7eeY,35686
|
|
663
663
|
rasa/shared/core/slot_mappings.py,sha256=0jOIk-iSKI-pJObYdk-Bmf-2SPTYFUuCA4H6SONthRA,25847
|
|
664
664
|
rasa/shared/core/slots.py,sha256=2tOpUGLMY3a24zL8pqJ_U38x-h5Du-KpZoNxEGoFOqY,29198
|
|
665
|
-
rasa/shared/core/trackers.py,sha256=
|
|
665
|
+
rasa/shared/core/trackers.py,sha256=fgSBpaoVm98dQjFhfJGxaDiQN7Gg94AnT_Rk4z_UEms,45271
|
|
666
666
|
rasa/shared/core/training_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
667
667
|
rasa/shared/core/training_data/loading.py,sha256=RCx1uTI9iDejFI_sWg3qPzhjln7-hu78f3EDAT6K0No,2894
|
|
668
668
|
rasa/shared/core/training_data/story_reader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -822,9 +822,9 @@ rasa/utils/train_utils.py,sha256=ClJx-6x3-h3Vt6mskacgkcCUJTMXjFPe3zAcy_DfmaU,212
|
|
|
822
822
|
rasa/utils/url_tools.py,sha256=dZ1HGkVdWTJB7zYEdwoDIrEuyX9HE5WsxKKFVsXBLE0,1218
|
|
823
823
|
rasa/utils/yaml.py,sha256=KjbZq5C94ZP7Jdsw8bYYF7HASI6K4-C_kdHfrnPLpSI,2000
|
|
824
824
|
rasa/validator.py,sha256=tAFzUKVbCPRPx0LjCUKY0zSCaX2hgINuaMfK123FCyc,88716
|
|
825
|
-
rasa/version.py,sha256=
|
|
826
|
-
rasa_pro-3.12.
|
|
827
|
-
rasa_pro-3.12.
|
|
828
|
-
rasa_pro-3.12.
|
|
829
|
-
rasa_pro-3.12.
|
|
830
|
-
rasa_pro-3.12.
|
|
825
|
+
rasa/version.py,sha256=cXo1SRWrUs5dimtC3o6U2AaOk-k-_ZUbvhu34B2cJoQ,117
|
|
826
|
+
rasa_pro-3.12.3.dist-info/METADATA,sha256=YCi6vX_x3mw93ZKVstJSP0fNsvznvoHL0rZuBJ17qSc,10688
|
|
827
|
+
rasa_pro-3.12.3.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
|
|
828
|
+
rasa_pro-3.12.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
829
|
+
rasa_pro-3.12.3.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
|
|
830
|
+
rasa_pro-3.12.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|