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.
- rasa/__init__.py +0 -6
- rasa/cli/run.py +10 -6
- rasa/cli/utils.py +7 -0
- rasa/core/actions/action.py +0 -6
- rasa/core/channels/channel.py +93 -0
- rasa/core/channels/inspector/dist/assets/{arc-c7691751.js → arc-351bec79.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-ab99dff7.js → blockDiagram-38ab4fdb-2567f3e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-08c35a6b.js → c4Diagram-3d4e48cf-c94acad0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-96a753ef.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-9e9c71c9.js → classDiagram-70f12bd4-a2c4f658.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-15e7e2bf.js → classDiagram-v2-f2320105-4036ee82.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-5bbb0c7d.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-9c105cb1.js → createText-2e5e7dd3-01f8708a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-77e89e48.js → edges-e0da2a9e-17b4c582.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-7a011646.js → erDiagram-9861fffd-5b382730.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-b6f105ac.js → flowDb-956e92f1-c9dd4758.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-ce4f18c2.js → flowDiagram-66a62f08-014c7159.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-72082386.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-cb5f6da4.js → flowchart-elk-definition-4a651766-bc13fd64.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-e4d19e28.js → ganttDiagram-c361ad54-a3bc832f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-727b1c33.js → gitGraphDiagram-72cf32ee-4f0983dd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-6e2ab9a7.js → graph-0069f93e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-84ec700f.js → index-3862675e-7ddaa093.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-098a1a24.js → index-d77a19b4.js} +129 -116
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-78dda442.js → infoDiagram-f8f76790-c3e28742.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-f1cc6dd1.js → journeyDiagram-49397b02-6d36c64c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-d98dcd0c.js → layout-3d27f9c0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-838e3d82.js → line-e8cb25c5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-eae72406.js → linear-4321e9fa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-c96fd84b.js → mindmap-definition-fc14e90a-47e328b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-c936d4e2.js → pieDiagram-8a3498a8-647edbaf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b338eb8f.js → quadrantDiagram-120e2f19-0703ad7d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-c6b6c0d5.js → requirementDiagram-deff3bca-59312f87.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-b9372e19.js → sankeyDiagram-04a897e0-8e170e1c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-479e0a3f.js → sequenceDiagram-704730f1-b2b42696.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-fd26eebc.js → stateDiagram-587899a1-239f7e55.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-3233e0ae.js → stateDiagram-v2-d93cdb3a-9cb9c726.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-1fdd392b.js → styles-6aaf32cf-d15a0f74.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-6d7bfa1b.js → styles-9a916d00-d7c52634.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-f86aab11.js → styles-c10674c1-cf79ea88.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-e3e49d7a.js → svgDrawCommon-08f97a94-52b3b9f9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-6fe08b4d.js → timeline-definition-85554ec2-c8e3cd8c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-c2e06fd6.js → xychartDiagram-e933f94c-300afa53.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/Chat.tsx +23 -2
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +2 -5
- rasa/core/channels/inspector/src/helpers/conversation.ts +16 -0
- rasa/core/channels/inspector/src/types.ts +1 -1
- rasa/core/channels/voice_ready/audiocodes.py +53 -21
- rasa/core/channels/voice_ready/jambonz.py +25 -5
- rasa/core/channels/voice_ready/jambonz_protocol.py +4 -0
- rasa/core/channels/voice_ready/twilio_voice.py +48 -1
- rasa/core/channels/voice_stream/tts/azure.py +11 -2
- rasa/core/channels/voice_stream/twilio_media_streams.py +101 -26
- rasa/core/nlg/contextual_response_rephraser.py +4 -21
- rasa/core/nlg/summarize.py +1 -15
- rasa/core/policies/enterprise_search_policy.py +3 -16
- rasa/core/policies/flows/flow_executor.py +3 -38
- rasa/core/policies/intentless_policy.py +4 -17
- rasa/core/policies/policy.py +0 -2
- rasa/core/processor.py +19 -5
- rasa/core/utils.py +53 -0
- rasa/dialogue_understanding/coexistence/llm_based_router.py +4 -18
- rasa/dialogue_understanding/commands/cancel_flow_command.py +4 -59
- rasa/dialogue_understanding/commands/start_flow_command.py +0 -41
- rasa/dialogue_understanding/generator/command_generator.py +67 -0
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +4 -20
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -3
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +1 -12
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -61
- rasa/dialogue_understanding/processor/command_processor.py +7 -65
- rasa/dialogue_understanding/stack/utils.py +0 -38
- rasa/e2e_test/utils/validation.py +3 -3
- rasa/hooks.py +0 -55
- rasa/shared/constants.py +0 -5
- rasa/shared/core/constants.py +0 -8
- rasa/shared/core/domain.py +12 -3
- rasa/shared/core/flows/flow.py +0 -17
- rasa/shared/core/flows/flows_yaml_schema.json +3 -38
- rasa/shared/core/flows/steps/collect.py +5 -18
- rasa/shared/core/flows/utils.py +1 -16
- rasa/shared/core/slot_mappings.py +11 -5
- rasa/shared/nlu/constants.py +0 -1
- rasa/shared/providers/constants.py +0 -9
- rasa/shared/providers/llm/_base_litellm_client.py +4 -14
- rasa/shared/providers/llm/litellm_router_llm_client.py +7 -17
- rasa/shared/providers/llm/llm_client.py +15 -24
- rasa/shared/providers/llm/self_hosted_llm_client.py +2 -10
- rasa/shared/utils/common.py +11 -1
- rasa/shared/utils/health_check/health_check.py +1 -7
- rasa/tracing/instrumentation/attribute_extractors.py +4 -4
- rasa/tracing/instrumentation/intentless_policy_instrumentation.py +1 -2
- rasa/utils/licensing.py +0 -15
- rasa/validator.py +1 -123
- rasa/version.py +1 -1
- {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/METADATA +3 -4
- {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/RECORD +100 -103
- rasa/core/actions/action_handle_digressions.py +0 -164
- rasa/core/channels/inspector/dist/assets/channel-11268142.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-ff7f2ce7.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-cba7ae20.js +0 -1
- rasa/dialogue_understanding/commands/handle_digressions_command.py +0 -144
- rasa/dialogue_understanding/patterns/handle_digressions.py +0 -81
- rasa/monkey_patches.py +0 -91
- {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/NOTICE +0 -0
- {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/WHEEL +0 -0
- {rasa_pro-3.12.6.dev2.dist-info → rasa_pro-3.12.7.dist-info}/entry_points.txt +0 -0
|
@@ -12,9 +12,6 @@ from rasa.dialogue_understanding.commands import (
|
|
|
12
12
|
SetSlotCommand,
|
|
13
13
|
StartFlowCommand,
|
|
14
14
|
)
|
|
15
|
-
from rasa.dialogue_understanding.commands.handle_digressions_command import (
|
|
16
|
-
HandleDigressionsCommand,
|
|
17
|
-
)
|
|
18
15
|
from rasa.dialogue_understanding.constants import KEY_MINIMIZE_NUM_CALLS
|
|
19
16
|
from rasa.dialogue_understanding.generator import CommandGenerator
|
|
20
17
|
from rasa.dialogue_understanding.generator._jinja_filters import to_json_escaped_string
|
|
@@ -49,7 +46,6 @@ from rasa.shared.utils.llm import (
|
|
|
49
46
|
llm_factory,
|
|
50
47
|
resolve_model_client_config,
|
|
51
48
|
)
|
|
52
|
-
from rasa.utils.licensing import get_human_readable_licence_owner
|
|
53
49
|
from rasa.utils.log_utils import log_llm
|
|
54
50
|
|
|
55
51
|
structlogger = structlog.get_logger()
|
|
@@ -93,8 +89,6 @@ class LLMBasedCommandGenerator(
|
|
|
93
89
|
else:
|
|
94
90
|
self.flow_retrieval = None
|
|
95
91
|
|
|
96
|
-
self.user_id = get_human_readable_licence_owner()
|
|
97
|
-
|
|
98
92
|
### Abstract methods
|
|
99
93
|
@staticmethod
|
|
100
94
|
@abstractmethod
|
|
@@ -334,9 +328,7 @@ class LLMBasedCommandGenerator(
|
|
|
334
328
|
|
|
335
329
|
@measure_llm_latency
|
|
336
330
|
async def invoke_llm(
|
|
337
|
-
self,
|
|
338
|
-
prompt: Union[List[dict], List[str], str],
|
|
339
|
-
metadata: Optional[Dict[str, Any]] = None,
|
|
331
|
+
self, prompt: Union[List[dict], List[str], str]
|
|
340
332
|
) -> Optional[LLMResponse]:
|
|
341
333
|
"""Use LLM to generate a response.
|
|
342
334
|
|
|
@@ -349,7 +341,6 @@ class LLMBasedCommandGenerator(
|
|
|
349
341
|
- a list of messages. Each message is a string and will be formatted
|
|
350
342
|
as a user message.
|
|
351
343
|
- a single message as a string which will be formatted as user message.
|
|
352
|
-
metadata: Optional metadata to be passed to the LLM call.
|
|
353
344
|
|
|
354
345
|
Returns:
|
|
355
346
|
An LLMResponse object.
|
|
@@ -361,7 +352,7 @@ class LLMBasedCommandGenerator(
|
|
|
361
352
|
self.config.get(LLM_CONFIG_KEY), self.get_default_llm_config()
|
|
362
353
|
)
|
|
363
354
|
try:
|
|
364
|
-
return await llm.acompletion(prompt
|
|
355
|
+
return await llm.acompletion(prompt)
|
|
365
356
|
except Exception as e:
|
|
366
357
|
# unfortunately, langchain does not wrap LLM exceptions which means
|
|
367
358
|
# we have to catch all exceptions here
|
|
@@ -616,16 +607,9 @@ class LLMBasedCommandGenerator(
|
|
|
616
607
|
) -> bool:
|
|
617
608
|
"""Check if the LLM current commands should be merged with the prior commands.
|
|
618
609
|
|
|
619
|
-
This can be done if there are no prior start flow commands
|
|
620
|
-
no prior handle digressions commands.
|
|
610
|
+
This can be done if there are no prior start flow commands.
|
|
621
611
|
"""
|
|
622
|
-
|
|
623
|
-
command
|
|
624
|
-
for command in prior_commands
|
|
625
|
-
if isinstance(command, HandleDigressionsCommand)
|
|
626
|
-
]
|
|
627
|
-
|
|
628
|
-
return not prior_start_flow_names and not prior_handle_digressions
|
|
612
|
+
return not prior_start_flow_names
|
|
629
613
|
|
|
630
614
|
def _check_start_flow_command_overlap(
|
|
631
615
|
self,
|
|
@@ -55,9 +55,7 @@ class LLMCommandGenerator(SingleStepLLMCommandGenerator):
|
|
|
55
55
|
)
|
|
56
56
|
|
|
57
57
|
async def invoke_llm(
|
|
58
|
-
self,
|
|
59
|
-
prompt: Union[List[dict], List[str], str],
|
|
60
|
-
metadata: Optional[Dict[str, Any]] = None,
|
|
58
|
+
self, prompt: Union[List[dict], List[str], str]
|
|
61
59
|
) -> Optional[LLMResponse]:
|
|
62
60
|
try:
|
|
63
61
|
return await super().invoke_llm(prompt)
|
|
@@ -47,10 +47,6 @@ from rasa.shared.constants import (
|
|
|
47
47
|
AWS_BEDROCK_PROVIDER,
|
|
48
48
|
AZURE_OPENAI_PROVIDER,
|
|
49
49
|
EMBEDDINGS_CONFIG_KEY,
|
|
50
|
-
LANGFUSE_CUSTOM_METADATA_DICT,
|
|
51
|
-
LANGFUSE_METADATA_SESSION_ID,
|
|
52
|
-
LANGFUSE_METADATA_USER_ID,
|
|
53
|
-
LANGFUSE_TAGS,
|
|
54
50
|
MAX_TOKENS_CONFIG_KEY,
|
|
55
51
|
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
56
52
|
ROUTE_TO_CALM_SLOT,
|
|
@@ -366,14 +362,7 @@ class CompactLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
366
362
|
prompt=flow_prompt,
|
|
367
363
|
)
|
|
368
364
|
|
|
369
|
-
|
|
370
|
-
LANGFUSE_METADATA_USER_ID: self.user_id,
|
|
371
|
-
LANGFUSE_METADATA_SESSION_ID: tracker.sender_id if tracker else "",
|
|
372
|
-
LANGFUSE_CUSTOM_METADATA_DICT: {"component": self.__class__.__name__},
|
|
373
|
-
LANGFUSE_TAGS: [self.__class__.__name__],
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
response = await self.invoke_llm(flow_prompt, metadata)
|
|
365
|
+
response = await self.invoke_llm(flow_prompt)
|
|
377
366
|
llm_response = LLMResponse.ensure_llm_response(response)
|
|
378
367
|
# The check for 'None' maintains compatibility with older versions
|
|
379
368
|
# of LLMCommandGenerator. In previous implementations, 'invoke_llm'
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
version: "3.1"
|
|
2
2
|
responses:
|
|
3
3
|
|
|
4
|
-
utter_ask_continue_previous_flow:
|
|
5
|
-
- text: "Confirm if you would like to continue with the initial topic: {{context.interrupted_flow_id}}?"
|
|
6
|
-
metadata:
|
|
7
|
-
rephrase: True
|
|
8
|
-
template: jinja
|
|
9
|
-
buttons:
|
|
10
|
-
- title: Continue with the previous topic.
|
|
11
|
-
payload: /SetSlots(continue_previous_flow=True)
|
|
12
|
-
- title: Switch to new topic.
|
|
13
|
-
payload: /SetSlots(continue_previous_flow=False)
|
|
14
|
-
|
|
15
4
|
utter_ask_rephrase:
|
|
16
5
|
- text: I’m sorry I am unable to understand you, could you please rephrase?
|
|
17
6
|
|
|
@@ -20,20 +9,6 @@ responses:
|
|
|
20
9
|
metadata:
|
|
21
10
|
rephrase: True
|
|
22
11
|
|
|
23
|
-
utter_block_digressions:
|
|
24
|
-
- text: "We can look into {{ context.interrupting_flow_id }} later. Let's focus on the current topic: {{ context.interrupted_flow_id }}."
|
|
25
|
-
metadata:
|
|
26
|
-
rephrase: True
|
|
27
|
-
template: jinja
|
|
28
|
-
- text: "Let's continue with the current topic: {{ context.interrupted_flow_id }}."
|
|
29
|
-
condition:
|
|
30
|
-
- type: slot
|
|
31
|
-
name: continue_previous_flow
|
|
32
|
-
value: True
|
|
33
|
-
metadata:
|
|
34
|
-
rephrase: True
|
|
35
|
-
template: jinja
|
|
36
|
-
|
|
37
12
|
utter_boolean_slot_rejection:
|
|
38
13
|
- text: "Sorry, the value you provided, `{{value}}`, is not valid. Please respond with a valid value."
|
|
39
14
|
metadata:
|
|
@@ -60,12 +35,6 @@ responses:
|
|
|
60
35
|
rephrase: True
|
|
61
36
|
template: jinja
|
|
62
37
|
|
|
63
|
-
utter_continue_interruption:
|
|
64
|
-
- text: "Let's continue with the chosen topic instead: {{ context.interrupting_flow_id }}."
|
|
65
|
-
metadata:
|
|
66
|
-
rephrase: True
|
|
67
|
-
template: jinja
|
|
68
|
-
|
|
69
38
|
utter_corrected_previous_input:
|
|
70
39
|
- text: "Ok, I am updating {{ context.corrected_slots.keys()|join(', ') }} to {{ context.new_slot_values | join(', ') }} respectively."
|
|
71
40
|
metadata:
|
|
@@ -150,10 +119,6 @@ slots:
|
|
|
150
119
|
type: float
|
|
151
120
|
initial_value: 0.0
|
|
152
121
|
max_value: 1000000
|
|
153
|
-
continue_previous_flow:
|
|
154
|
-
type: bool
|
|
155
|
-
mappings:
|
|
156
|
-
- type: from_llm
|
|
157
122
|
|
|
158
123
|
flows:
|
|
159
124
|
pattern_cancel_flow:
|
|
@@ -197,7 +162,6 @@ flows:
|
|
|
197
162
|
steps:
|
|
198
163
|
- action: action_clarify_flows
|
|
199
164
|
- action: utter_clarification_options_rasa
|
|
200
|
-
- action: action_listen
|
|
201
165
|
|
|
202
166
|
pattern_code_change:
|
|
203
167
|
description: Conversation repair flow for cleaning the stack after an assistant update
|
|
@@ -247,31 +211,6 @@ flows:
|
|
|
247
211
|
next: END
|
|
248
212
|
- else: END
|
|
249
213
|
|
|
250
|
-
pattern_handle_digressions:
|
|
251
|
-
description: Conversation repair flow for handling digressions
|
|
252
|
-
name: pattern handle digressions
|
|
253
|
-
steps:
|
|
254
|
-
- noop: true
|
|
255
|
-
id: branching
|
|
256
|
-
next:
|
|
257
|
-
- if: context.ask_confirm_digressions contains context.interrupting_flow_id
|
|
258
|
-
then: continue_previous_flow
|
|
259
|
-
- if: context.block_digressions contains context.interrupting_flow_id
|
|
260
|
-
then: block_digression
|
|
261
|
-
- else: continue_digression
|
|
262
|
-
- id: continue_previous_flow
|
|
263
|
-
collect: continue_previous_flow
|
|
264
|
-
next:
|
|
265
|
-
- if: slots.continue_previous_flow
|
|
266
|
-
then: block_digression
|
|
267
|
-
- else: continue_digression
|
|
268
|
-
- id: block_digression
|
|
269
|
-
action: action_block_digression
|
|
270
|
-
next: END
|
|
271
|
-
- id: continue_digression
|
|
272
|
-
action: action_continue_digression
|
|
273
|
-
next: END
|
|
274
|
-
|
|
275
214
|
pattern_human_handoff:
|
|
276
215
|
description: Conversation repair flow for switching users to a human agent if their request can't be handled
|
|
277
216
|
name: pattern human handoff
|
|
@@ -18,9 +18,6 @@ from rasa.dialogue_understanding.commands import (
|
|
|
18
18
|
from rasa.dialogue_understanding.commands.handle_code_change_command import (
|
|
19
19
|
HandleCodeChangeCommand,
|
|
20
20
|
)
|
|
21
|
-
from rasa.dialogue_understanding.commands.handle_digressions_command import (
|
|
22
|
-
HandleDigressionsCommand,
|
|
23
|
-
)
|
|
24
21
|
from rasa.dialogue_understanding.commands.set_slot_command import SetSlotExtractor
|
|
25
22
|
from rasa.dialogue_understanding.commands.utils import (
|
|
26
23
|
create_validate_frames_from_slot_set_events,
|
|
@@ -454,21 +451,7 @@ def clean_up_commands(
|
|
|
454
451
|
)
|
|
455
452
|
continue
|
|
456
453
|
|
|
457
|
-
|
|
458
|
-
handle_digression_command = HandleDigressionsCommand(flow=command.flow)
|
|
459
|
-
if handle_digression_command in clean_commands:
|
|
460
|
-
structlogger.debug(
|
|
461
|
-
"command_processor.clean_up_commands.skip_handle_digressions.command_already_present",
|
|
462
|
-
command=handle_digression_command,
|
|
463
|
-
)
|
|
464
|
-
continue
|
|
465
|
-
clean_commands.append(handle_digression_command)
|
|
466
|
-
structlogger.debug(
|
|
467
|
-
"command_processor.clean_up_commands.push_handle_digressions",
|
|
468
|
-
command=command,
|
|
469
|
-
)
|
|
470
|
-
else:
|
|
471
|
-
clean_commands.append(command)
|
|
454
|
+
clean_commands.append(command)
|
|
472
455
|
|
|
473
456
|
# handle chitchat command differently from other free-form answer commands
|
|
474
457
|
elif isinstance(command, ChitChatAnswerCommand):
|
|
@@ -503,21 +486,9 @@ def clean_up_commands(
|
|
|
503
486
|
# when coexistence is enabled, by default there will be a SetSlotCommand
|
|
504
487
|
# for the ROUTE_TO_CALM_SLOT slot.
|
|
505
488
|
if tracker.has_coexistence_routing_slot and len(clean_commands) > 2:
|
|
506
|
-
clean_commands =
|
|
489
|
+
clean_commands = filter_cannot_handle_command(clean_commands)
|
|
507
490
|
elif not tracker.has_coexistence_routing_slot and len(clean_commands) > 1:
|
|
508
|
-
clean_commands =
|
|
509
|
-
|
|
510
|
-
# remove cancel flow when there is a handle digression command
|
|
511
|
-
# otherwise the cancel command will cancel the active flow which defined a specific
|
|
512
|
-
# behavior for the digression
|
|
513
|
-
if contains_command(clean_commands, HandleDigressionsCommand) and contains_command(
|
|
514
|
-
clean_commands, CancelFlowCommand
|
|
515
|
-
):
|
|
516
|
-
clean_commands = [
|
|
517
|
-
command
|
|
518
|
-
for command in clean_commands
|
|
519
|
-
if not isinstance(command, CancelFlowCommand)
|
|
520
|
-
]
|
|
491
|
+
clean_commands = filter_cannot_handle_command(clean_commands)
|
|
521
492
|
|
|
522
493
|
clean_commands = ensure_max_number_of_command_type(
|
|
523
494
|
clean_commands, RepeatBotMessagesCommand, 1
|
|
@@ -857,12 +828,12 @@ def should_slot_be_set(
|
|
|
857
828
|
return True
|
|
858
829
|
|
|
859
830
|
|
|
860
|
-
def
|
|
831
|
+
def filter_cannot_handle_command(
|
|
861
832
|
clean_commands: List[Command],
|
|
862
833
|
) -> List[Command]:
|
|
863
|
-
"""Filter out a 'cannot handle' command
|
|
834
|
+
"""Filter out a 'cannot handle' command.
|
|
864
835
|
|
|
865
|
-
This is used to filter out a 'cannot handle' command
|
|
836
|
+
This is used to filter out a 'cannot handle' command
|
|
866
837
|
in case other commands are present.
|
|
867
838
|
|
|
868
839
|
Returns:
|
|
@@ -871,34 +842,5 @@ def filter_cannot_handle_command_for_skipped_slots(
|
|
|
871
842
|
return [
|
|
872
843
|
command
|
|
873
844
|
for command in clean_commands
|
|
874
|
-
if not (
|
|
875
|
-
isinstance(command, CannotHandleCommand)
|
|
876
|
-
and command.reason
|
|
877
|
-
and CANNOT_HANDLE_REASON == command.reason
|
|
878
|
-
)
|
|
845
|
+
if not isinstance(command, CannotHandleCommand)
|
|
879
846
|
]
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
def should_add_handle_digressions_command(
|
|
883
|
-
tracker: DialogueStateTracker, all_flows: FlowsList, top_flow_id: str
|
|
884
|
-
) -> bool:
|
|
885
|
-
"""Check if a handle digressions command should be added to the commands.
|
|
886
|
-
|
|
887
|
-
The command should replace a StartFlow command only if we are at a collect step of
|
|
888
|
-
a flow and a new flow is predicted by the command generator to start.
|
|
889
|
-
"""
|
|
890
|
-
current_flow = all_flows.flow_by_id(top_flow_id)
|
|
891
|
-
current_flow_condition = current_flow and (
|
|
892
|
-
current_flow.ask_confirm_digressions or current_flow.block_digressions
|
|
893
|
-
)
|
|
894
|
-
|
|
895
|
-
collect_info = get_current_collect_step(tracker.stack, all_flows)
|
|
896
|
-
|
|
897
|
-
if collect_info and (
|
|
898
|
-
collect_info.ask_confirm_digressions
|
|
899
|
-
or collect_info.block_digressions
|
|
900
|
-
or current_flow_condition
|
|
901
|
-
):
|
|
902
|
-
return True
|
|
903
|
-
|
|
904
|
-
return False
|
|
@@ -4,9 +4,6 @@ from typing import List, Optional, Set, Tuple
|
|
|
4
4
|
from rasa.dialogue_understanding.patterns.collect_information import (
|
|
5
5
|
CollectInformationPatternFlowStackFrame,
|
|
6
6
|
)
|
|
7
|
-
from rasa.dialogue_understanding.patterns.continue_interrupted import (
|
|
8
|
-
ContinueInterruptedPatternFlowStackFrame,
|
|
9
|
-
)
|
|
10
7
|
from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
|
|
11
8
|
from rasa.dialogue_understanding.stack.frames import (
|
|
12
9
|
BaseFlowStackFrame,
|
|
@@ -221,38 +218,3 @@ def get_collect_steps_excluding_ask_before_filling_for_active_flow(
|
|
|
221
218
|
for step in active_flow.get_collect_steps()
|
|
222
219
|
if not step.ask_before_filling
|
|
223
220
|
)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
def remove_digression_from_stack(stack: DialogueStack, flow_id: str) -> DialogueStack:
|
|
227
|
-
"""Remove a specific flow frame from the stack and other frames that reference it.
|
|
228
|
-
|
|
229
|
-
The main use-case is to prevent duplicate digressions from being added to the stack.
|
|
230
|
-
|
|
231
|
-
Args:
|
|
232
|
-
stack: The dialogue stack.
|
|
233
|
-
flow_id: The flow to remove.
|
|
234
|
-
|
|
235
|
-
Returns:
|
|
236
|
-
The updated dialogue stack.
|
|
237
|
-
"""
|
|
238
|
-
updated_stack = stack.copy()
|
|
239
|
-
original_frames = updated_stack.frames[:]
|
|
240
|
-
found_digression_index = -1
|
|
241
|
-
for index, frame in enumerate(original_frames):
|
|
242
|
-
if isinstance(frame, BaseFlowStackFrame) and frame.flow_id == flow_id:
|
|
243
|
-
updated_stack.frames.pop(index)
|
|
244
|
-
found_digression_index = index
|
|
245
|
-
|
|
246
|
-
# we also need to remove the `ContinueInterruptedPatternFlowStackFrame`
|
|
247
|
-
elif (
|
|
248
|
-
isinstance(frame, ContinueInterruptedPatternFlowStackFrame)
|
|
249
|
-
and frame.previous_flow_name == flow_id
|
|
250
|
-
and found_digression_index + 1 == index
|
|
251
|
-
):
|
|
252
|
-
# we know that this frame is always added after the digressing flow frame
|
|
253
|
-
# that was blocked previously by action_block_digressions,
|
|
254
|
-
# so this check would occur after the digressing flow was popped.
|
|
255
|
-
# Therefore, we need to update the index dynamically before popping.
|
|
256
|
-
updated_stack.frames.pop(index - 1)
|
|
257
|
-
|
|
258
|
-
return updated_stack
|
|
@@ -7,6 +7,7 @@ import structlog
|
|
|
7
7
|
import rasa.shared.utils.io
|
|
8
8
|
from rasa.e2e_test.constants import SCHEMA_FILE_PATH
|
|
9
9
|
from rasa.e2e_test.e2e_test_case import Fixture, Metadata
|
|
10
|
+
from rasa.exceptions import ModelNotFound
|
|
10
11
|
from rasa.shared.utils.yaml import read_schema_file
|
|
11
12
|
|
|
12
13
|
if TYPE_CHECKING:
|
|
@@ -152,10 +153,9 @@ def validate_model_path(model_path: Optional[str], parameter: str, default: str)
|
|
|
152
153
|
return model_path
|
|
153
154
|
|
|
154
155
|
if model_path and not Path(model_path).exists():
|
|
155
|
-
|
|
156
|
+
raise ModelNotFound(
|
|
156
157
|
f"The provided model path '{model_path}' could not be found. "
|
|
157
|
-
|
|
158
|
-
UserWarning,
|
|
158
|
+
"Provide an existing model path."
|
|
159
159
|
)
|
|
160
160
|
|
|
161
161
|
elif model_path is None:
|
rasa/hooks.py
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import logging
|
|
3
|
-
import os
|
|
4
3
|
from typing import TYPE_CHECKING, List, Optional, Text, Union
|
|
5
4
|
|
|
6
|
-
import litellm
|
|
7
5
|
import pluggy
|
|
8
|
-
import structlog
|
|
9
|
-
|
|
10
|
-
from rasa.shared.providers.constants import (
|
|
11
|
-
LANGFUSE_CALLBACK_NAME,
|
|
12
|
-
LANGFUSE_HOST_ENV_VAR,
|
|
13
|
-
LANGFUSE_PROJECT_ID_ENV_VAR,
|
|
14
|
-
LANGFUSE_PUBLIC_KEY_ENV_VAR,
|
|
15
|
-
LANGFUSE_SECRET_KEY_ENV_VAR,
|
|
16
|
-
RASA_LANGFUSE_INTEGRATION_ENABLED_ENV_VAR,
|
|
17
|
-
)
|
|
18
6
|
|
|
19
7
|
# IMPORTANT: do not import anything from rasa here - use scoped imports
|
|
20
8
|
# this avoids circular imports, as the hooks are used in different places
|
|
@@ -30,7 +18,6 @@ if TYPE_CHECKING:
|
|
|
30
18
|
|
|
31
19
|
hookimpl = pluggy.HookimplMarker("rasa")
|
|
32
20
|
logger = logging.getLogger(__name__)
|
|
33
|
-
structlogger = structlog.get_logger()
|
|
34
21
|
|
|
35
22
|
|
|
36
23
|
@hookimpl # type: ignore[misc]
|
|
@@ -70,8 +57,6 @@ def configure_commandline(cmdline_arguments: argparse.Namespace) -> Optional[Tex
|
|
|
70
57
|
config.configure_tracing(tracer_provider)
|
|
71
58
|
config.configure_metrics(endpoints_file)
|
|
72
59
|
|
|
73
|
-
_init_langfuse_integration()
|
|
74
|
-
|
|
75
60
|
return endpoints_file
|
|
76
61
|
|
|
77
62
|
|
|
@@ -130,43 +115,3 @@ def after_server_stop() -> None:
|
|
|
130
115
|
|
|
131
116
|
if anon_pipeline is not None:
|
|
132
117
|
anon_pipeline.stop()
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def _is_langfuse_integration_enabled() -> bool:
|
|
136
|
-
return (
|
|
137
|
-
os.environ.get(RASA_LANGFUSE_INTEGRATION_ENABLED_ENV_VAR, "false").lower()
|
|
138
|
-
== "true"
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def _init_langfuse_integration() -> None:
|
|
143
|
-
if not _is_langfuse_integration_enabled():
|
|
144
|
-
structlogger.info(
|
|
145
|
-
"hooks._init_langfuse_integration.disabled",
|
|
146
|
-
event_info="Langfuse integration is disabled.",
|
|
147
|
-
)
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
not os.environ.get(LANGFUSE_HOST_ENV_VAR)
|
|
152
|
-
or not os.environ.get(LANGFUSE_PROJECT_ID_ENV_VAR)
|
|
153
|
-
or not os.environ.get(LANGFUSE_PUBLIC_KEY_ENV_VAR)
|
|
154
|
-
or not os.environ.get(LANGFUSE_SECRET_KEY_ENV_VAR)
|
|
155
|
-
):
|
|
156
|
-
structlogger.warning(
|
|
157
|
-
"hooks._init_langfuse_integration.missing_langfuse_keys",
|
|
158
|
-
event_info=(
|
|
159
|
-
"Langfuse integration is enabled, but some environment variables"
|
|
160
|
-
"are missing. Please set LANGFUSE_HOST, LANGFUSE_PROJECT_ID, "
|
|
161
|
-
"LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY environment "
|
|
162
|
-
"variables to use Langfuse integration."
|
|
163
|
-
),
|
|
164
|
-
)
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
litellm.success_callback = [LANGFUSE_CALLBACK_NAME]
|
|
168
|
-
litellm.failure_callback = [LANGFUSE_CALLBACK_NAME]
|
|
169
|
-
structlogger.info(
|
|
170
|
-
"hooks.langfuse_callbacks_initialized",
|
|
171
|
-
event_info="Langfuse integration initialized.",
|
|
172
|
-
)
|
rasa/shared/constants.py
CHANGED
|
@@ -338,8 +338,3 @@ ROLE_SYSTEM = "system"
|
|
|
338
338
|
# Used for key values in ValidateSlotPatternFlowStackFrame
|
|
339
339
|
REFILL_UTTER = "refill_utter"
|
|
340
340
|
REJECTIONS = "rejections"
|
|
341
|
-
|
|
342
|
-
LANGFUSE_METADATA_USER_ID = "trace_user_id"
|
|
343
|
-
LANGFUSE_METADATA_SESSION_ID = "session_id"
|
|
344
|
-
LANGFUSE_CUSTOM_METADATA_DICT = "trace_metadata"
|
|
345
|
-
LANGFUSE_TAGS = "tags"
|
rasa/shared/core/constants.py
CHANGED
|
@@ -52,8 +52,6 @@ ACTION_TRIGGER_CHITCHAT = "action_trigger_chitchat"
|
|
|
52
52
|
ACTION_RESET_ROUTING = "action_reset_routing"
|
|
53
53
|
ACTION_HANGUP = "action_hangup"
|
|
54
54
|
ACTION_REPEAT_BOT_MESSAGES = "action_repeat_bot_messages"
|
|
55
|
-
ACTION_BLOCK_DIGRESSION = "action_block_digression"
|
|
56
|
-
ACTION_CONTINUE_DIGRESSION = "action_continue_digression"
|
|
57
55
|
|
|
58
56
|
ACTION_METADATA_EXECUTION_SUCCESS = "execution_success"
|
|
59
57
|
ACTION_METADATA_EXECUTION_ERROR_MESSAGE = "execution_error_message"
|
|
@@ -84,8 +82,6 @@ DEFAULT_ACTION_NAMES = [
|
|
|
84
82
|
ACTION_RESET_ROUTING,
|
|
85
83
|
ACTION_HANGUP,
|
|
86
84
|
ACTION_REPEAT_BOT_MESSAGES,
|
|
87
|
-
ACTION_BLOCK_DIGRESSION,
|
|
88
|
-
ACTION_CONTINUE_DIGRESSION,
|
|
89
85
|
]
|
|
90
86
|
|
|
91
87
|
ACTION_SHOULD_SEND_DOMAIN = "send_domain"
|
|
@@ -205,8 +201,4 @@ CLASSIFIER_NAME_FALLBACK = "FallbackClassifier"
|
|
|
205
201
|
|
|
206
202
|
POLICIES_THAT_EXTRACT_ENTITIES = {"TEDPolicy"}
|
|
207
203
|
|
|
208
|
-
# digression constants
|
|
209
|
-
KEY_ASK_CONFIRM_DIGRESSIONS = "ask_confirm_digressions"
|
|
210
|
-
KEY_BLOCK_DIGRESSIONS = "block_digressions"
|
|
211
|
-
|
|
212
204
|
ERROR_CODE_KEY = "error_code"
|
rasa/shared/core/domain.py
CHANGED
|
@@ -1678,6 +1678,14 @@ class Domain:
|
|
|
1678
1678
|
"""Write domain to a file."""
|
|
1679
1679
|
as_yaml = self.as_yaml()
|
|
1680
1680
|
rasa.shared.utils.io.write_text_file(as_yaml, filename)
|
|
1681
|
+
# run the check again on the written domain to catch any errors
|
|
1682
|
+
# that may have been missed in the user defined domain files
|
|
1683
|
+
structlogger.info(
|
|
1684
|
+
"domain.persist.domain_written_to_file",
|
|
1685
|
+
event_info="The entire domain content has been written to file.",
|
|
1686
|
+
filename=filename,
|
|
1687
|
+
)
|
|
1688
|
+
Domain.is_domain_file(filename)
|
|
1681
1689
|
|
|
1682
1690
|
def as_yaml(self) -> Text:
|
|
1683
1691
|
"""Dump the `Domain` object as a YAML string.
|
|
@@ -1972,17 +1980,18 @@ class Domain:
|
|
|
1972
1980
|
|
|
1973
1981
|
try:
|
|
1974
1982
|
content = read_yaml_file(filename, expand_env_vars=cls.expand_env_vars)
|
|
1975
|
-
except (RasaException, YamlSyntaxException):
|
|
1976
|
-
structlogger.
|
|
1983
|
+
except (RasaException, YamlSyntaxException) as error:
|
|
1984
|
+
structlogger.error(
|
|
1977
1985
|
"domain.cannot_load_domain_file",
|
|
1978
1986
|
file=filename,
|
|
1987
|
+
error=error,
|
|
1979
1988
|
event_info=(
|
|
1980
1989
|
f"The file {filename} could not be loaded as domain file. "
|
|
1981
1990
|
f"You can use https://yamlchecker.com/ to validate "
|
|
1982
1991
|
f"the YAML syntax of your file."
|
|
1983
1992
|
),
|
|
1984
1993
|
)
|
|
1985
|
-
|
|
1994
|
+
raise RasaException(f"Domain could not be loaded: {error}")
|
|
1986
1995
|
|
|
1987
1996
|
return any(key in content for key in ALL_DOMAIN_KEYS)
|
|
1988
1997
|
|
rasa/shared/core/flows/flow.py
CHANGED
|
@@ -13,10 +13,6 @@ from pypred import Predicate
|
|
|
13
13
|
import rasa.shared.utils.io
|
|
14
14
|
from rasa.engine.language import Language
|
|
15
15
|
from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
|
|
16
|
-
from rasa.shared.core.constants import (
|
|
17
|
-
KEY_ASK_CONFIRM_DIGRESSIONS,
|
|
18
|
-
KEY_BLOCK_DIGRESSIONS,
|
|
19
|
-
)
|
|
20
16
|
from rasa.shared.core.flows.constants import (
|
|
21
17
|
KEY_ALWAYS_INCLUDE_IN_PROMPT,
|
|
22
18
|
KEY_DESCRIPTION,
|
|
@@ -52,7 +48,6 @@ from rasa.shared.core.flows.steps.constants import (
|
|
|
52
48
|
START_STEP,
|
|
53
49
|
)
|
|
54
50
|
from rasa.shared.core.flows.steps.continuation import ContinueFlowStep
|
|
55
|
-
from rasa.shared.core.flows.utils import extract_digression_prop
|
|
56
51
|
from rasa.shared.core.slots import Slot
|
|
57
52
|
|
|
58
53
|
structlogger = structlog.get_logger()
|
|
@@ -94,10 +89,6 @@ class Flow:
|
|
|
94
89
|
"""The path to the file where the flow is stored."""
|
|
95
90
|
persisted_slots: List[str] = field(default_factory=list)
|
|
96
91
|
"""The list of slots that should be persisted after the flow ends."""
|
|
97
|
-
ask_confirm_digressions: List[str] = field(default_factory=list)
|
|
98
|
-
"""The flow ids for which the assistant should ask for confirmation."""
|
|
99
|
-
block_digressions: List[str] = field(default_factory=list)
|
|
100
|
-
"""The flow ids that the assistant should block from digressing to."""
|
|
101
92
|
run_pattern_completed: bool = True
|
|
102
93
|
"""Whether the pattern_completed flow should be run after the flow ends."""
|
|
103
94
|
|
|
@@ -138,10 +129,6 @@ class Flow:
|
|
|
138
129
|
# data. When the model is trained, take the provided file_path.
|
|
139
130
|
file_path=data.get(KEY_FILE_PATH) if KEY_FILE_PATH in data else file_path,
|
|
140
131
|
persisted_slots=data.get(KEY_PERSISTED_SLOTS, []),
|
|
141
|
-
ask_confirm_digressions=extract_digression_prop(
|
|
142
|
-
KEY_ASK_CONFIRM_DIGRESSIONS, data
|
|
143
|
-
),
|
|
144
|
-
block_digressions=extract_digression_prop(KEY_BLOCK_DIGRESSIONS, data),
|
|
145
132
|
run_pattern_completed=data.get(KEY_RUN_PATTERN_COMPLETED, True),
|
|
146
133
|
translation=extract_translations(
|
|
147
134
|
translation_data=data.get(KEY_TRANSLATION, {})
|
|
@@ -220,10 +207,6 @@ class Flow:
|
|
|
220
207
|
data[KEY_FILE_PATH] = self.file_path
|
|
221
208
|
if self.persisted_slots:
|
|
222
209
|
data[KEY_PERSISTED_SLOTS] = self.persisted_slots
|
|
223
|
-
if self.ask_confirm_digressions:
|
|
224
|
-
data[KEY_ASK_CONFIRM_DIGRESSIONS] = self.ask_confirm_digressions
|
|
225
|
-
if self.block_digressions:
|
|
226
|
-
data[KEY_BLOCK_DIGRESSIONS] = self.block_digressions
|
|
227
210
|
if self.run_pattern_completed is not None:
|
|
228
211
|
data["run_pattern_completed"] = self.run_pattern_completed
|
|
229
212
|
if self.translation:
|
|
@@ -217,15 +217,12 @@
|
|
|
217
217
|
"reset_after_flow_ends": {
|
|
218
218
|
"type": "boolean"
|
|
219
219
|
},
|
|
220
|
-
"ask_confirm_digressions": {
|
|
221
|
-
"$ref": "#/$defs/ask_confirm_digressions"
|
|
222
|
-
},
|
|
223
|
-
"block_digressions": {
|
|
224
|
-
"$ref": "#/$defs/block_digressions"
|
|
225
|
-
},
|
|
226
220
|
"utter": {
|
|
227
221
|
"type": "string"
|
|
228
222
|
},
|
|
223
|
+
"force_slot_filling": {
|
|
224
|
+
"type": "boolean"
|
|
225
|
+
},
|
|
229
226
|
"rejections": {
|
|
230
227
|
"type": "array",
|
|
231
228
|
"schema_name": "list of rejections",
|
|
@@ -253,32 +250,6 @@
|
|
|
253
250
|
}
|
|
254
251
|
}
|
|
255
252
|
},
|
|
256
|
-
"ask_confirm_digressions": {
|
|
257
|
-
"oneOf": [
|
|
258
|
-
{
|
|
259
|
-
"type": "boolean"
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
"type": "array",
|
|
263
|
-
"items": {
|
|
264
|
-
"type": "string"
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
]
|
|
268
|
-
},
|
|
269
|
-
"block_digressions": {
|
|
270
|
-
"oneOf": [
|
|
271
|
-
{
|
|
272
|
-
"type": "boolean"
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
"type": "array",
|
|
276
|
-
"items": {
|
|
277
|
-
"type": "string"
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
]
|
|
281
|
-
},
|
|
282
253
|
"flow": {
|
|
283
254
|
"required": [
|
|
284
255
|
"steps",
|
|
@@ -340,12 +311,6 @@
|
|
|
340
311
|
"persisted_slots": {
|
|
341
312
|
"$ref": "#/$defs/persisted_slots"
|
|
342
313
|
},
|
|
343
|
-
"ask_confirm_digressions": {
|
|
344
|
-
"$ref": "#/$defs/ask_confirm_digressions"
|
|
345
|
-
},
|
|
346
|
-
"block_digressions": {
|
|
347
|
-
"$ref": "#/$defs/block_digressions"
|
|
348
|
-
},
|
|
349
314
|
"run_pattern_completed": {
|
|
350
315
|
"type": "boolean"
|
|
351
316
|
}
|