rasa-pro 3.13.0.dev20250612__py3-none-any.whl → 3.13.0rc1__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/__main__.py +0 -3
- rasa/api.py +1 -1
- rasa/cli/dialogue_understanding_test.py +1 -1
- rasa/cli/e2e_test.py +1 -8
- rasa/cli/evaluate.py +1 -1
- rasa/cli/export.py +3 -1
- rasa/cli/llm_fine_tuning.py +12 -11
- rasa/cli/project_templates/defaults.py +133 -0
- rasa/cli/project_templates/tutorial/config.yml +1 -1
- rasa/cli/project_templates/tutorial/endpoints.yml +1 -1
- rasa/cli/run.py +1 -1
- rasa/cli/studio/download.py +1 -23
- rasa/cli/studio/link.py +52 -0
- rasa/cli/studio/pull.py +79 -0
- rasa/cli/studio/push.py +78 -0
- rasa/cli/studio/studio.py +12 -0
- rasa/cli/studio/train.py +0 -1
- rasa/cli/studio/upload.py +8 -0
- rasa/cli/train.py +1 -1
- rasa/cli/utils.py +1 -1
- rasa/cli/x.py +1 -1
- rasa/constants.py +2 -0
- rasa/core/__init__.py +0 -16
- rasa/core/actions/action.py +5 -1
- rasa/core/actions/action_repeat_bot_messages.py +18 -22
- rasa/core/actions/action_run_slot_rejections.py +0 -1
- rasa/core/agent.py +16 -1
- rasa/core/available_endpoints.py +146 -0
- rasa/core/brokers/pika.py +1 -2
- rasa/core/channels/__init__.py +2 -0
- rasa/core/channels/botframework.py +2 -2
- rasa/core/channels/channel.py +2 -2
- rasa/core/channels/development_inspector.py +1 -1
- rasa/core/channels/facebook.py +1 -4
- rasa/core/channels/hangouts.py +8 -5
- rasa/core/channels/inspector/README.md +3 -3
- rasa/core/channels/inspector/dist/assets/{arc-c4b064fc.js → arc-371401b1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-215b5026.js → blockDiagram-38ab4fdb-3f126156.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-2b54a0a3.js → c4Diagram-3d4e48cf-12f22eb7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-f1efda17.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-daacea5f.js → classDiagram-70f12bd4-03b1d386.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-930d4dc2.js → classDiagram-v2-f2320105-84f69d63.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-fdf164e2.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-83c206ba.js → createText-2e5e7dd3-ca47fd38.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b0eb01d0.js → edges-e0da2a9e-f837ca8a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-17586500.js → erDiagram-9861fffd-8717ac54.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-be2a1776.js → flowDb-956e92f1-94f38b83.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-c2120ebd.js → flowDiagram-66a62f08-b616f9fb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-7d7a1629.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-a6ab5c48.js → flowchart-elk-definition-4a651766-f5d24bb8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-ef613457.js → ganttDiagram-c361ad54-b43ba8d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-d59185b3.js → gitGraphDiagram-72cf32ee-c3aafaa5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-0f155405.js → graph-0d0a2c10.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-d5f1d1b7.js → index-3862675e-58ea0305.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-47737d3a.js → index-cce6f8a1.js} +3 -3
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b07d141f.js → infoDiagram-f8f76790-b8f60461.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-1936d429.js → journeyDiagram-49397b02-95be5545.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-dde8d0f3.js → layout-da885b9b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-0c2c7ee0.js → line-f1c817d3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-35dd89a4.js → linear-d42801e6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-56192851.js → mindmap-definition-fc14e90a-a38923a6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-fc21ed78.js → pieDiagram-8a3498a8-ca6e71e9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-25e98518.js → quadrantDiagram-120e2f19-b290dae9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-546ff1f5.js → requirementDiagram-deff3bca-03f02ceb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-02d8b82d.js → sankeyDiagram-04a897e0-c49eee40.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-3ca5a92e.js → sequenceDiagram-704730f1-b2cd6a3d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-128ea07c.js → stateDiagram-587899a1-e53a2028.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-95f290af.js → stateDiagram-v2-d93cdb3a-e1982a03.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-4984898a.js → styles-6aaf32cf-d0226ca5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-1bf266ba.js → styles-9a916d00-0e21dc00.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-60521c63.js → styles-c10674c1-9588494e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-a25b6e12.js → svgDrawCommon-08f97a94-be478d4f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-0fc086bf.js → timeline-definition-85554ec2-74631749.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-44ee592e.js → xychartDiagram-e933f94c-a043552f.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +1 -1
- rasa/core/channels/mattermost.py +1 -1
- rasa/core/channels/rasa_chat.py +2 -4
- rasa/core/channels/rest.py +5 -4
- rasa/core/channels/socketio.py +56 -41
- rasa/core/channels/studio_chat.py +314 -10
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +2 -9
- rasa/core/channels/voice_stream/asr/azure.py +9 -0
- rasa/core/channels/voice_stream/audiocodes.py +8 -5
- rasa/core/channels/voice_stream/browser_audio.py +1 -1
- rasa/core/channels/voice_stream/genesys.py +2 -2
- rasa/core/channels/voice_stream/jambonz.py +166 -0
- rasa/core/channels/voice_stream/tts/__init__.py +8 -0
- rasa/core/channels/voice_stream/twilio_media_streams.py +17 -5
- rasa/core/channels/voice_stream/voice_channel.py +44 -24
- rasa/core/exporter.py +36 -0
- rasa/core/http_interpreter.py +3 -7
- rasa/core/information_retrieval/faiss.py +18 -11
- rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
- rasa/core/jobs.py +2 -1
- rasa/core/nlg/contextual_response_rephraser.py +48 -12
- rasa/core/nlg/generator.py +0 -1
- rasa/core/nlg/interpolator.py +2 -3
- rasa/core/nlg/summarize.py +39 -5
- rasa/core/policies/enterprise_search_policy.py +298 -184
- rasa/core/policies/enterprise_search_policy_config.py +241 -0
- rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +64 -0
- rasa/core/policies/flow_policy.py +1 -1
- rasa/core/policies/flows/flow_executor.py +96 -17
- rasa/core/policies/intentless_policy.py +71 -26
- rasa/core/processor.py +104 -51
- rasa/core/run.py +33 -11
- rasa/core/tracker_stores/tracker_store.py +1 -1
- rasa/core/training/interactive.py +1 -1
- rasa/core/utils.py +35 -99
- rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
- rasa/dialogue_understanding/coexistence/llm_based_router.py +13 -17
- rasa/dialogue_understanding/commands/__init__.py +4 -0
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +6 -2
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/clarify_command.py +7 -3
- rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
- rasa/dialogue_understanding/commands/correct_slots_command.py +5 -6
- rasa/dialogue_understanding/commands/error_command.py +1 -1
- rasa/dialogue_understanding/commands/human_handoff_command.py +3 -3
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
- rasa/dialogue_understanding/commands/set_slot_command.py +15 -5
- rasa/dialogue_understanding/commands/skip_question_command.py +3 -3
- rasa/dialogue_understanding/commands/start_flow_command.py +7 -3
- rasa/dialogue_understanding/commands/utils.py +26 -2
- rasa/dialogue_understanding/generator/__init__.py +7 -1
- rasa/dialogue_understanding/generator/command_generator.py +15 -3
- rasa/dialogue_understanding/generator/command_parser.py +2 -2
- rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
- rasa/dialogue_understanding/generator/constants.py +2 -2
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_template.jinja2 +0 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +1 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +1 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +79 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +79 -0
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +28 -463
- rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +461 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +11 -64
- rasa/dialogue_understanding/patterns/cancel.py +1 -2
- rasa/dialogue_understanding/patterns/clarify.py +1 -1
- rasa/dialogue_understanding/patterns/correction.py +2 -2
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +37 -25
- rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
- rasa/dialogue_understanding/processor/command_processor.py +11 -12
- rasa/dialogue_understanding/processor/command_processor_component.py +3 -3
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
- rasa/dialogue_understanding/stack/utils.py +3 -1
- rasa/dialogue_understanding/utils.py +68 -12
- rasa/dialogue_understanding_test/du_test_case.py +1 -1
- rasa/dialogue_understanding_test/du_test_runner.py +4 -22
- rasa/dialogue_understanding_test/test_case_simulation/test_case_tracker_simulator.py +2 -6
- rasa/e2e_test/e2e_test_coverage_report.py +1 -1
- rasa/e2e_test/e2e_test_runner.py +1 -1
- rasa/engine/constants.py +1 -1
- rasa/engine/graph.py +2 -2
- rasa/engine/recipes/default_recipe.py +26 -2
- rasa/engine/validation.py +3 -2
- rasa/hooks.py +0 -28
- rasa/llm_fine_tuning/annotation_module.py +39 -9
- rasa/llm_fine_tuning/conversations.py +3 -0
- rasa/llm_fine_tuning/llm_data_preparation_module.py +66 -49
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +5 -7
- rasa/llm_fine_tuning/paraphrasing/rephrase_validator.py +52 -44
- rasa/llm_fine_tuning/paraphrasing_module.py +10 -12
- rasa/llm_fine_tuning/storage.py +4 -4
- rasa/llm_fine_tuning/utils.py +63 -1
- rasa/model_manager/model_api.py +88 -0
- rasa/model_manager/trainer_service.py +4 -4
- rasa/plugin.py +1 -11
- rasa/privacy/__init__.py +0 -0
- rasa/privacy/constants.py +83 -0
- rasa/privacy/event_broker_utils.py +77 -0
- rasa/privacy/privacy_config.py +281 -0
- rasa/privacy/privacy_config_schema.json +86 -0
- rasa/privacy/privacy_filter.py +340 -0
- rasa/privacy/privacy_manager.py +576 -0
- rasa/server.py +23 -2
- rasa/shared/constants.py +18 -0
- rasa/shared/core/command_payload_reader.py +1 -5
- rasa/shared/core/constants.py +4 -3
- rasa/shared/core/domain.py +7 -0
- rasa/shared/core/events.py +38 -10
- rasa/shared/core/flows/constants.py +2 -0
- rasa/shared/core/flows/flow.py +127 -14
- rasa/shared/core/flows/flows_list.py +18 -1
- rasa/shared/core/flows/flows_yaml_schema.json +3 -0
- rasa/shared/core/flows/steps/collect.py +46 -2
- rasa/shared/core/flows/steps/link.py +7 -2
- rasa/shared/core/flows/validation.py +25 -5
- rasa/shared/core/slots.py +28 -0
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
- rasa/shared/exceptions.py +4 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +6 -2
- rasa/shared/providers/_configs/default_litellm_client_config.py +1 -1
- rasa/shared/providers/_configs/huggingface_local_embedding_client_config.py +1 -1
- rasa/shared/providers/_configs/openai_client_config.py +5 -1
- rasa/shared/providers/_configs/rasa_llm_client_config.py +1 -1
- rasa/shared/providers/_configs/self_hosted_llm_client_config.py +1 -1
- rasa/shared/providers/_configs/utils.py +0 -99
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
- rasa/shared/providers/llm/_base_litellm_client.py +5 -2
- rasa/shared/utils/common.py +1 -1
- rasa/shared/utils/configs.py +110 -0
- rasa/shared/utils/constants.py +0 -3
- rasa/shared/utils/llm.py +195 -9
- rasa/shared/utils/pykwalify_extensions.py +0 -9
- rasa/shared/utils/yaml.py +32 -0
- rasa/studio/constants.py +1 -0
- rasa/studio/data_handler.py +11 -4
- rasa/studio/download.py +167 -0
- rasa/studio/link.py +200 -0
- rasa/studio/prompts.py +223 -0
- rasa/studio/pull/__init__.py +0 -0
- rasa/studio/{download/flows.py → pull/data.py} +23 -160
- rasa/studio/{download → pull}/domains.py +1 -1
- rasa/studio/pull/pull.py +235 -0
- rasa/studio/push.py +136 -0
- rasa/studio/train.py +1 -1
- rasa/studio/upload.py +117 -67
- rasa/telemetry.py +82 -25
- rasa/tracing/config.py +3 -4
- rasa/tracing/constants.py +19 -1
- rasa/tracing/instrumentation/attribute_extractors.py +30 -8
- rasa/tracing/instrumentation/instrumentation.py +53 -2
- rasa/tracing/instrumentation/metrics.py +98 -15
- rasa/tracing/metric_instrument_provider.py +75 -3
- rasa/utils/common.py +7 -22
- rasa/utils/log_utils.py +1 -45
- rasa/validator.py +2 -8
- rasa/version.py +1 -1
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/METADATA +8 -9
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/RECORD +241 -220
- rasa/anonymization/__init__.py +0 -2
- rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
- rasa/anonymization/anonymization_pipeline.py +0 -286
- rasa/anonymization/anonymization_rule_executor.py +0 -266
- rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
- rasa/anonymization/schemas/config.yml +0 -47
- rasa/anonymization/utils.py +0 -118
- rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-e847561e.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +0 -1
- rasa/studio/download/download.py +0 -439
- /rasa/{studio/download → core/information_retrieval/ingestion}/__init__.py +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/entry_points.txt +0 -0
rasa/core/utils.py
CHANGED
|
@@ -2,7 +2,7 @@ import logging
|
|
|
2
2
|
import os
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from socket import SOCK_DGRAM, SOCK_STREAM
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Dict,
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional, Set, Text, Tuple, Union
|
|
6
6
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import structlog
|
|
@@ -11,6 +11,7 @@ from sanic import Sanic
|
|
|
11
11
|
import rasa.cli.utils as cli_utils
|
|
12
12
|
import rasa.shared.utils.io
|
|
13
13
|
from rasa.constants import DEFAULT_SANIC_WORKERS, ENV_SANIC_WORKERS
|
|
14
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
14
15
|
from rasa.core.constants import (
|
|
15
16
|
ACTIVE_FLOW_METADATA_KEY,
|
|
16
17
|
DOMAIN_GROUND_TRUTH_METADATA_KEY,
|
|
@@ -19,12 +20,12 @@ from rasa.core.constants import (
|
|
|
19
20
|
)
|
|
20
21
|
from rasa.core.lock_store import InMemoryLockStore, LockStore, RedisLockStore
|
|
21
22
|
from rasa.shared.constants import DEFAULT_ENDPOINTS_PATH, TCP_PROTOCOL
|
|
22
|
-
from rasa.shared.core.constants import
|
|
23
|
+
from rasa.shared.core.constants import (
|
|
24
|
+
SlotMappingType,
|
|
25
|
+
)
|
|
23
26
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
24
27
|
from rasa.utils.endpoints import (
|
|
25
28
|
EndpointConfig,
|
|
26
|
-
read_endpoint_config,
|
|
27
|
-
read_property_config_from_endpoints_file,
|
|
28
29
|
)
|
|
29
30
|
from rasa.utils.io import write_yaml
|
|
30
31
|
|
|
@@ -36,6 +37,25 @@ if TYPE_CHECKING:
|
|
|
36
37
|
structlogger = structlog.get_logger()
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
def read_endpoints_from_path(
|
|
41
|
+
endpoints_path: Optional[Union[Path, str]] = None,
|
|
42
|
+
) -> AvailableEndpoints:
|
|
43
|
+
"""Get `AvailableEndpoints` object from specified path.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
endpoints_path: Path of the endpoints file to be read. If `None` the
|
|
47
|
+
default path for that file is used (`endpoints.yml`).
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
`AvailableEndpoints` object read from endpoints file.
|
|
51
|
+
|
|
52
|
+
"""
|
|
53
|
+
endpoints_config_path = cli_utils.get_validated_path(
|
|
54
|
+
endpoints_path, "endpoints", DEFAULT_ENDPOINTS_PATH, True
|
|
55
|
+
)
|
|
56
|
+
return AvailableEndpoints.get_instance(endpoints_config_path)
|
|
57
|
+
|
|
58
|
+
|
|
39
59
|
def configure_file_logging(
|
|
40
60
|
logger_obj: logging.Logger,
|
|
41
61
|
log_file: Optional[Text],
|
|
@@ -177,99 +197,6 @@ def is_limit_reached(num_messages: int, limit: Optional[int]) -> bool:
|
|
|
177
197
|
return limit is not None and num_messages >= limit
|
|
178
198
|
|
|
179
199
|
|
|
180
|
-
class AvailableEndpoints:
|
|
181
|
-
"""Collection of configured endpoints."""
|
|
182
|
-
|
|
183
|
-
_instance = None
|
|
184
|
-
|
|
185
|
-
@classmethod
|
|
186
|
-
def read_endpoints(cls, endpoint_file: Text) -> "AvailableEndpoints":
|
|
187
|
-
"""Read the different endpoints from a yaml file."""
|
|
188
|
-
nlg = read_endpoint_config(endpoint_file, endpoint_type="nlg")
|
|
189
|
-
nlu = read_endpoint_config(endpoint_file, endpoint_type="nlu")
|
|
190
|
-
action = read_endpoint_config(endpoint_file, endpoint_type="action_endpoint")
|
|
191
|
-
model = read_endpoint_config(endpoint_file, endpoint_type="models")
|
|
192
|
-
tracker_store = read_endpoint_config(
|
|
193
|
-
endpoint_file, endpoint_type="tracker_store"
|
|
194
|
-
)
|
|
195
|
-
lock_store = read_endpoint_config(endpoint_file, endpoint_type="lock_store")
|
|
196
|
-
event_broker = read_endpoint_config(endpoint_file, endpoint_type="event_broker")
|
|
197
|
-
vector_store = read_endpoint_config(endpoint_file, endpoint_type="vector_store")
|
|
198
|
-
model_groups = read_property_config_from_endpoints_file(
|
|
199
|
-
endpoint_file, property_name="model_groups"
|
|
200
|
-
)
|
|
201
|
-
privacy = read_property_config_from_endpoints_file(
|
|
202
|
-
endpoint_file, property_name="privacy"
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
return cls(
|
|
206
|
-
nlg,
|
|
207
|
-
nlu,
|
|
208
|
-
action,
|
|
209
|
-
model,
|
|
210
|
-
tracker_store,
|
|
211
|
-
lock_store,
|
|
212
|
-
event_broker,
|
|
213
|
-
vector_store,
|
|
214
|
-
model_groups,
|
|
215
|
-
privacy,
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
def __init__(
|
|
219
|
-
self,
|
|
220
|
-
nlg: Optional[EndpointConfig] = None,
|
|
221
|
-
nlu: Optional[EndpointConfig] = None,
|
|
222
|
-
action: Optional[EndpointConfig] = None,
|
|
223
|
-
model: Optional[EndpointConfig] = None,
|
|
224
|
-
tracker_store: Optional[EndpointConfig] = None,
|
|
225
|
-
lock_store: Optional[EndpointConfig] = None,
|
|
226
|
-
event_broker: Optional[EndpointConfig] = None,
|
|
227
|
-
vector_store: Optional[EndpointConfig] = None,
|
|
228
|
-
model_groups: Optional[List[Dict[str, Any]]] = None,
|
|
229
|
-
privacy: Optional[Dict[Text, Any]] = None,
|
|
230
|
-
) -> None:
|
|
231
|
-
"""Create an `AvailableEndpoints` object."""
|
|
232
|
-
self.model = model
|
|
233
|
-
self.action = action
|
|
234
|
-
self.nlu = nlu
|
|
235
|
-
self.nlg = nlg
|
|
236
|
-
self.tracker_store = tracker_store
|
|
237
|
-
self.lock_store = lock_store
|
|
238
|
-
self.event_broker = event_broker
|
|
239
|
-
self.vector_store = vector_store
|
|
240
|
-
self.model_groups = model_groups
|
|
241
|
-
self.privacy = privacy
|
|
242
|
-
|
|
243
|
-
@classmethod
|
|
244
|
-
def get_instance(
|
|
245
|
-
cls, endpoint_file: Optional[Text] = DEFAULT_ENDPOINTS_PATH
|
|
246
|
-
) -> "AvailableEndpoints":
|
|
247
|
-
"""Get the singleton instance of AvailableEndpoints."""
|
|
248
|
-
# Ensure that the instance is initialized only once.
|
|
249
|
-
if cls._instance is None:
|
|
250
|
-
cls._instance = cls.read_endpoints(endpoint_file)
|
|
251
|
-
return cls._instance
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
def read_endpoints_from_path(
|
|
255
|
-
endpoints_path: Optional[Union[Path, Text]] = None,
|
|
256
|
-
) -> AvailableEndpoints:
|
|
257
|
-
"""Get `AvailableEndpoints` object from specified path.
|
|
258
|
-
|
|
259
|
-
Args:
|
|
260
|
-
endpoints_path: Path of the endpoints file to be read. If `None` the
|
|
261
|
-
default path for that file is used (`endpoints.yml`).
|
|
262
|
-
|
|
263
|
-
Returns:
|
|
264
|
-
`AvailableEndpoints` object read from endpoints file.
|
|
265
|
-
|
|
266
|
-
"""
|
|
267
|
-
endpoints_config_path = cli_utils.get_validated_path(
|
|
268
|
-
endpoints_path, "endpoints", DEFAULT_ENDPOINTS_PATH, True
|
|
269
|
-
)
|
|
270
|
-
return AvailableEndpoints.get_instance(endpoints_config_path)
|
|
271
|
-
|
|
272
|
-
|
|
273
200
|
def _lock_store_is_multi_worker_compatible(
|
|
274
201
|
lock_store: Union[EndpointConfig, LockStore, None],
|
|
275
202
|
) -> bool:
|
|
@@ -391,16 +318,25 @@ def should_force_slot_filling(
|
|
|
391
318
|
and the name of the slot if applicable.
|
|
392
319
|
"""
|
|
393
320
|
from rasa.dialogue_understanding.processor.command_processor import (
|
|
321
|
+
find_updated_flows,
|
|
394
322
|
get_current_collect_step,
|
|
395
323
|
)
|
|
396
324
|
|
|
397
325
|
if tracker is None:
|
|
398
|
-
structlogger.
|
|
399
|
-
"slot.force_slot_filling.
|
|
326
|
+
structlogger.debug(
|
|
327
|
+
"slot.force_slot_filling.no_found_tracker",
|
|
400
328
|
event_info="Tracker is None. Cannot force slot filling.",
|
|
401
329
|
)
|
|
402
330
|
return False, None
|
|
403
331
|
|
|
332
|
+
updated_flows = find_updated_flows(tracker, flows)
|
|
333
|
+
if updated_flows:
|
|
334
|
+
structlogger.debug(
|
|
335
|
+
"slot.force_slot_filling.running_flows_were_updated",
|
|
336
|
+
updated_flow_ids=updated_flows,
|
|
337
|
+
)
|
|
338
|
+
return False, None
|
|
339
|
+
|
|
404
340
|
stack = tracker.stack
|
|
405
341
|
step = get_current_collect_step(stack, flows)
|
|
406
342
|
if step is None or not step.force_slot_filling:
|
|
@@ -143,7 +143,8 @@ class IntentBasedRouter(GraphComponent):
|
|
|
143
143
|
if route_session_to_calm is None:
|
|
144
144
|
commands = self._generate_command_using_intent(message, flows, tracker)
|
|
145
145
|
structlogger.info(
|
|
146
|
-
"intent_based_router.predicated_commands",
|
|
146
|
+
"intent_based_router.predicated_commands",
|
|
147
|
+
commands=commands, # doesn't contain PII
|
|
147
148
|
)
|
|
148
149
|
return commands
|
|
149
150
|
elif route_session_to_calm is True:
|
|
@@ -15,19 +15,20 @@ from rasa.dialogue_understanding.coexistence.constants import (
|
|
|
15
15
|
)
|
|
16
16
|
from rasa.dialogue_understanding.commands import Command, SetSlotCommand
|
|
17
17
|
from rasa.dialogue_understanding.commands.noop_command import NoopCommand
|
|
18
|
-
from rasa.dialogue_understanding.generator.constants import
|
|
19
|
-
LLM_CONFIG_KEY,
|
|
20
|
-
)
|
|
18
|
+
from rasa.dialogue_understanding.generator.constants import LLM_CONFIG_KEY
|
|
21
19
|
from rasa.engine.graph import ExecutionContext, GraphComponent
|
|
22
20
|
from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
23
21
|
from rasa.engine.storage.resource import Resource
|
|
24
22
|
from rasa.engine.storage.storage import ModelStorage
|
|
25
23
|
from rasa.shared.constants import (
|
|
24
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
26
25
|
MODEL_CONFIG_KEY,
|
|
27
26
|
OPENAI_PROVIDER,
|
|
28
27
|
PROMPT_CONFIG_KEY,
|
|
28
|
+
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
29
29
|
PROVIDER_CONFIG_KEY,
|
|
30
30
|
ROUTE_TO_CALM_SLOT,
|
|
31
|
+
TEMPERATURE_CONFIG_KEY,
|
|
31
32
|
TIMEOUT_CONFIG_KEY,
|
|
32
33
|
)
|
|
33
34
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
@@ -43,6 +44,7 @@ from rasa.shared.utils.health_check.llm_health_check_mixin import LLMHealthCheck
|
|
|
43
44
|
from rasa.shared.utils.io import deep_container_fingerprint
|
|
44
45
|
from rasa.shared.utils.llm import (
|
|
45
46
|
DEFAULT_OPENAI_CHAT_MODEL_NAME,
|
|
47
|
+
check_prompt_config_keys_and_warn_if_deprecated,
|
|
46
48
|
get_prompt_template,
|
|
47
49
|
llm_factory,
|
|
48
50
|
resolve_model_client_config,
|
|
@@ -55,20 +57,12 @@ DEFAULT_COMMAND_PROMPT_TEMPLATE = importlib.resources.read_text(
|
|
|
55
57
|
)
|
|
56
58
|
LLM_BASED_ROUTER_CONFIG_FILE_NAME = "config.json"
|
|
57
59
|
|
|
58
|
-
# Token ids for gpt 3.5 and gpt 4 corresponding to space + capitalized Letter
|
|
59
|
-
A_TO_C_TOKEN_IDS_CHATGPT = [
|
|
60
|
-
362, # " A"
|
|
61
|
-
426, # " B"
|
|
62
|
-
356, # " C"
|
|
63
|
-
]
|
|
64
|
-
|
|
65
60
|
DEFAULT_LLM_CONFIG = {
|
|
66
61
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
67
62
|
MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME,
|
|
68
63
|
TIMEOUT_CONFIG_KEY: 7,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"logit_bias": {str(token_id): 100 for token_id in A_TO_C_TOKEN_IDS_CHATGPT},
|
|
64
|
+
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
65
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: 1,
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
structlogger = structlog.get_logger()
|
|
@@ -85,7 +79,7 @@ class LLMBasedRouter(LLMHealthCheckMixin, GraphComponent):
|
|
|
85
79
|
def get_default_config() -> Dict[str, Any]:
|
|
86
80
|
"""The component's default config (see parent class for full docstring)."""
|
|
87
81
|
return {
|
|
88
|
-
|
|
82
|
+
PROMPT_TEMPLATE_CONFIG_KEY: None, # TODO: remove in Rasa 4.0.0
|
|
89
83
|
CALM_ENTRY: {STICKY: None},
|
|
90
84
|
NLU_ENTRY: {
|
|
91
85
|
NON_STICKY: "handles chitchat",
|
|
@@ -106,10 +100,13 @@ class LLMBasedRouter(LLMHealthCheckMixin, GraphComponent):
|
|
|
106
100
|
self.config.get(LLM_CONFIG_KEY), LLMBasedRouter.__name__
|
|
107
101
|
)
|
|
108
102
|
|
|
103
|
+
# Warn if the prompt config key is used to set the prompt template
|
|
104
|
+
check_prompt_config_keys_and_warn_if_deprecated(config, "llm_based_router")
|
|
105
|
+
|
|
109
106
|
self.prompt_template = (
|
|
110
107
|
prompt_template
|
|
111
108
|
or get_prompt_template(
|
|
112
|
-
config.get(PROMPT_CONFIG_KEY),
|
|
109
|
+
config.get(PROMPT_TEMPLATE_CONFIG_KEY) or config.get(PROMPT_CONFIG_KEY),
|
|
113
110
|
DEFAULT_COMMAND_PROMPT_TEMPLATE,
|
|
114
111
|
log_source_component=LLMBasedRouter.__name__,
|
|
115
112
|
log_source_method=LOG_COMPONENT_SOURCE_METHOD_INIT,
|
|
@@ -166,7 +163,6 @@ class LLMBasedRouter(LLMHealthCheckMixin, GraphComponent):
|
|
|
166
163
|
**kwargs: Any,
|
|
167
164
|
) -> "LLMBasedRouter":
|
|
168
165
|
"""Loads trained component (see parent class for full docstring)."""
|
|
169
|
-
|
|
170
166
|
# Perform health check on the resolved LLM client config
|
|
171
167
|
llm_config = resolve_model_client_config(config.get(LLM_CONFIG_KEY, {}))
|
|
172
168
|
cls.perform_llm_health_check(
|
|
@@ -322,7 +318,7 @@ class LLMBasedRouter(LLMHealthCheckMixin, GraphComponent):
|
|
|
322
318
|
def fingerprint_addon(cls, config: Dict[str, Any]) -> Optional[str]:
|
|
323
319
|
"""Add a fingerprint of llm based router for the graph."""
|
|
324
320
|
prompt_template = get_prompt_template(
|
|
325
|
-
config.get(PROMPT_CONFIG_KEY),
|
|
321
|
+
config.get(PROMPT_TEMPLATE_CONFIG_KEY) or config.get(PROMPT_CONFIG_KEY),
|
|
326
322
|
DEFAULT_COMMAND_PROMPT_TEMPLATE,
|
|
327
323
|
log_source_component=LLMBasedRouter.__name__,
|
|
328
324
|
log_source_method=LOG_COMPONENT_SOURCE_METHOD_FINGERPRINT_ADDON,
|
|
@@ -16,6 +16,9 @@ from rasa.dialogue_understanding.commands.error_command import ErrorCommand
|
|
|
16
16
|
from rasa.dialogue_understanding.commands.free_form_answer_command import (
|
|
17
17
|
FreeFormAnswerCommand,
|
|
18
18
|
)
|
|
19
|
+
from rasa.dialogue_understanding.commands.handle_code_change_command import (
|
|
20
|
+
HandleCodeChangeCommand,
|
|
21
|
+
)
|
|
19
22
|
from rasa.dialogue_understanding.commands.human_handoff_command import (
|
|
20
23
|
HumanHandoffCommand,
|
|
21
24
|
)
|
|
@@ -49,6 +52,7 @@ __all__ = [
|
|
|
49
52
|
"SetSlotCommand",
|
|
50
53
|
"StartFlowCommand",
|
|
51
54
|
"HumanHandoffCommand",
|
|
55
|
+
"HandleCodeChangeCommand",
|
|
52
56
|
"CorrectSlotsCommand",
|
|
53
57
|
"CorrectedSlot",
|
|
54
58
|
"ErrorCommand",
|
|
@@ -81,6 +81,7 @@ class CannotHandleCommand(Command):
|
|
|
81
81
|
mapper = {
|
|
82
82
|
CommandSyntaxVersion.v1: "CannotHandle()",
|
|
83
83
|
CommandSyntaxVersion.v2: "cannot handle",
|
|
84
|
+
CommandSyntaxVersion.v3: "cannot handle",
|
|
84
85
|
}
|
|
85
86
|
return mapper.get(
|
|
86
87
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -100,6 +101,7 @@ class CannotHandleCommand(Command):
|
|
|
100
101
|
mapper = {
|
|
101
102
|
CommandSyntaxVersion.v1: r"CannotHandle\(\)",
|
|
102
103
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*cannot handle['"`]*$""",
|
|
104
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*cannot handle['"`]*$""",
|
|
103
105
|
}
|
|
104
106
|
return mapper.get(
|
|
105
107
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -95,12 +95,14 @@ class CancelFlowCommand(Command):
|
|
|
95
95
|
original_stack = original_tracker.stack
|
|
96
96
|
|
|
97
97
|
applied_events: List[Event] = []
|
|
98
|
-
user_frame = top_user_flow_frame(
|
|
98
|
+
user_frame = top_user_flow_frame(
|
|
99
|
+
original_stack, ignore_call_and_link_frames=False
|
|
100
|
+
)
|
|
99
101
|
current_flow = user_frame.flow(all_flows) if user_frame else None
|
|
100
102
|
|
|
101
103
|
if not current_flow:
|
|
102
104
|
structlogger.debug(
|
|
103
|
-
"
|
|
105
|
+
"cancel_command.skip_cancel_flow.no_active_flow", command=self
|
|
104
106
|
)
|
|
105
107
|
return []
|
|
106
108
|
|
|
@@ -134,6 +136,7 @@ class CancelFlowCommand(Command):
|
|
|
134
136
|
mapper = {
|
|
135
137
|
CommandSyntaxVersion.v1: "CancelFlow()",
|
|
136
138
|
CommandSyntaxVersion.v2: "cancel flow",
|
|
139
|
+
CommandSyntaxVersion.v3: "cancel flow",
|
|
137
140
|
}
|
|
138
141
|
return mapper.get(
|
|
139
142
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -150,6 +153,7 @@ class CancelFlowCommand(Command):
|
|
|
150
153
|
mapper = {
|
|
151
154
|
CommandSyntaxVersion.v1: r"CancelFlow\(\)",
|
|
152
155
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*cancel flow['"`]*$""",
|
|
156
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*cancel flow['"`]*$""",
|
|
153
157
|
}
|
|
154
158
|
return mapper.get(
|
|
155
159
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -66,6 +66,7 @@ class ChitChatAnswerCommand(FreeFormAnswerCommand):
|
|
|
66
66
|
mapper = {
|
|
67
67
|
CommandSyntaxVersion.v1: "ChitChat()",
|
|
68
68
|
CommandSyntaxVersion.v2: "offtopic reply",
|
|
69
|
+
CommandSyntaxVersion.v3: "offtopic reply",
|
|
69
70
|
}
|
|
70
71
|
return mapper.get(
|
|
71
72
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -82,6 +83,7 @@ class ChitChatAnswerCommand(FreeFormAnswerCommand):
|
|
|
82
83
|
mapper = {
|
|
83
84
|
CommandSyntaxVersion.v1: r"ChitChat\(\)",
|
|
84
85
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*offtopic reply['"`]*$""",
|
|
86
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*offtopic reply['"`]*$""",
|
|
85
87
|
}
|
|
86
88
|
return mapper.get(
|
|
87
89
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -65,14 +65,14 @@ class ClarifyCommand(Command):
|
|
|
65
65
|
clean_options = [flow.id for flow in flows if flow is not None]
|
|
66
66
|
if len(clean_options) != len(self.options):
|
|
67
67
|
structlogger.debug(
|
|
68
|
-
"
|
|
68
|
+
"clarify_command.altered_command.dropped_clarification_options",
|
|
69
69
|
command=self,
|
|
70
70
|
original_options=self.options,
|
|
71
71
|
cleaned_options=clean_options,
|
|
72
72
|
)
|
|
73
73
|
if len(clean_options) == 0:
|
|
74
74
|
structlogger.debug(
|
|
75
|
-
"
|
|
75
|
+
"clarify_command.skip_command.empty_clarification", command=self
|
|
76
76
|
)
|
|
77
77
|
return []
|
|
78
78
|
|
|
@@ -102,6 +102,7 @@ class ClarifyCommand(Command):
|
|
|
102
102
|
mapper = {
|
|
103
103
|
CommandSyntaxVersion.v1: f"Clarify({', '.join(self.options)})",
|
|
104
104
|
CommandSyntaxVersion.v2: f"disambiguate flows {' '.join(self.options)}",
|
|
105
|
+
CommandSyntaxVersion.v3: f"disambiguate flows {' '.join(self.options)}",
|
|
105
106
|
}
|
|
106
107
|
return mapper.get(
|
|
107
108
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -119,7 +120,10 @@ class ClarifyCommand(Command):
|
|
|
119
120
|
mapper = {
|
|
120
121
|
CommandSyntaxVersion.v1: r"Clarify\(([\"\'a-zA-Z0-9_, -]*)\)",
|
|
121
122
|
CommandSyntaxVersion.v2: (
|
|
122
|
-
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)[
|
|
123
|
+
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)[\W]*$"""
|
|
124
|
+
),
|
|
125
|
+
CommandSyntaxVersion.v3: (
|
|
126
|
+
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)[\W]*$"""
|
|
123
127
|
),
|
|
124
128
|
}
|
|
125
129
|
return mapper.get(
|
|
@@ -144,7 +144,8 @@ class CorrectSlotsCommand(Command):
|
|
|
144
144
|
}
|
|
145
145
|
else:
|
|
146
146
|
structlogger.debug(
|
|
147
|
-
"
|
|
147
|
+
"correct_slots_command.skip_correction.slot_already_set",
|
|
148
|
+
command=self,
|
|
148
149
|
)
|
|
149
150
|
return proposed_slots
|
|
150
151
|
|
|
@@ -236,7 +237,7 @@ class CorrectSlotsCommand(Command):
|
|
|
236
237
|
# previously set, and we also don't want to reset the slots, do
|
|
237
238
|
# not correct the slots.
|
|
238
239
|
structlogger.debug(
|
|
239
|
-
"
|
|
240
|
+
"correct_slots_command.skip_correction",
|
|
240
241
|
is_reset_only=is_reset_only,
|
|
241
242
|
)
|
|
242
243
|
return None
|
|
@@ -274,12 +275,10 @@ class CorrectSlotsCommand(Command):
|
|
|
274
275
|
# we shouldn't end up here as a correction shouldn't be triggered
|
|
275
276
|
# if we are not in any flow. but just in case we do, we
|
|
276
277
|
# just skip the command.
|
|
277
|
-
structlogger.warning(
|
|
278
|
-
"command_executor.correct_slots.no_active_flow", command=self
|
|
279
|
-
)
|
|
278
|
+
structlogger.warning("correct_slots_command.no_active_flow")
|
|
280
279
|
return []
|
|
281
280
|
|
|
282
|
-
structlogger.debug("
|
|
281
|
+
structlogger.debug("correct_slots_command", command=self)
|
|
283
282
|
proposed_slots = self.corrected_slots_dict(tracker)
|
|
284
283
|
|
|
285
284
|
correction_frame = self.create_correction_frame(
|
|
@@ -58,7 +58,7 @@ class ErrorCommand(Command):
|
|
|
58
58
|
The events to apply to the tracker.
|
|
59
59
|
"""
|
|
60
60
|
stack = tracker.stack
|
|
61
|
-
structlogger.debug("
|
|
61
|
+
structlogger.debug("error_command.error", command=self)
|
|
62
62
|
stack.push(
|
|
63
63
|
InternalErrorPatternFlowStackFrame(
|
|
64
64
|
error_type=self.error_type, info=self.info
|
|
@@ -57,9 +57,7 @@ class HumanHandoffCommand(Command):
|
|
|
57
57
|
"""
|
|
58
58
|
stack = tracker.stack
|
|
59
59
|
stack.push(HumanHandoffPatternFlowStackFrame())
|
|
60
|
-
structlogger.debug(
|
|
61
|
-
"command_executor.human_handoff.pushed_to_stack", command=self
|
|
62
|
-
)
|
|
60
|
+
structlogger.debug("human_handoff_command.pushed_to_stack", command=self)
|
|
63
61
|
return tracker.create_stack_updated_events(stack)
|
|
64
62
|
|
|
65
63
|
def __hash__(self) -> int:
|
|
@@ -73,6 +71,7 @@ class HumanHandoffCommand(Command):
|
|
|
73
71
|
mapper = {
|
|
74
72
|
CommandSyntaxVersion.v1: "HumanHandoff()",
|
|
75
73
|
CommandSyntaxVersion.v2: "hand over",
|
|
74
|
+
CommandSyntaxVersion.v3: "hand over",
|
|
76
75
|
}
|
|
77
76
|
return mapper.get(
|
|
78
77
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -89,6 +88,7 @@ class HumanHandoffCommand(Command):
|
|
|
89
88
|
mapper = {
|
|
90
89
|
CommandSyntaxVersion.v1: r"HumanHandoff\(\)",
|
|
91
90
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*hand over['"`]*$""",
|
|
91
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*hand over['"`]*$""",
|
|
92
92
|
}
|
|
93
93
|
return mapper.get(
|
|
94
94
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -66,6 +66,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
|
|
|
66
66
|
mapper = {
|
|
67
67
|
CommandSyntaxVersion.v1: "SearchAndReply()",
|
|
68
68
|
CommandSyntaxVersion.v2: "provide info",
|
|
69
|
+
CommandSyntaxVersion.v3: "search and reply",
|
|
69
70
|
}
|
|
70
71
|
return mapper.get(
|
|
71
72
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -82,6 +83,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
|
|
|
82
83
|
mapper = {
|
|
83
84
|
CommandSyntaxVersion.v1: r"SearchAndReply\(\)",
|
|
84
85
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*provide info['"`]*$""",
|
|
86
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*search and reply['"`]*$""",
|
|
85
87
|
}
|
|
86
88
|
return mapper.get(
|
|
87
89
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -67,6 +67,7 @@ class RepeatBotMessagesCommand(Command):
|
|
|
67
67
|
mapper = {
|
|
68
68
|
CommandSyntaxVersion.v1: "RepeatLastBotMessages()",
|
|
69
69
|
CommandSyntaxVersion.v2: "repeat message",
|
|
70
|
+
CommandSyntaxVersion.v3: "repeat message",
|
|
70
71
|
}
|
|
71
72
|
return mapper.get(
|
|
72
73
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -83,6 +84,7 @@ class RepeatBotMessagesCommand(Command):
|
|
|
83
84
|
mapper = {
|
|
84
85
|
CommandSyntaxVersion.v1: r"RepeatLastBotMessages\(\)",
|
|
85
86
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*repeat message['"`]*$""",
|
|
87
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*repeat message['"`]*$""",
|
|
86
88
|
}
|
|
87
89
|
return mapper.get(
|
|
88
90
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -13,6 +13,7 @@ from rasa.dialogue_understanding.commands.command_syntax_manager import (
|
|
|
13
13
|
)
|
|
14
14
|
from rasa.dialogue_understanding.commands.utils import (
|
|
15
15
|
clean_extracted_value,
|
|
16
|
+
find_default_flows_collecting_slot,
|
|
16
17
|
get_nullable_slot_value,
|
|
17
18
|
)
|
|
18
19
|
from rasa.dialogue_understanding.patterns.collect_information import (
|
|
@@ -99,14 +100,14 @@ class SetSlotCommand(Command):
|
|
|
99
100
|
slot = tracker.slots.get(self.name)
|
|
100
101
|
if slot is None:
|
|
101
102
|
structlogger.debug(
|
|
102
|
-
"
|
|
103
|
+
"set_slot_command.skip_command.slot_not_in_domain", command=self
|
|
103
104
|
)
|
|
104
105
|
return []
|
|
105
106
|
|
|
106
107
|
if slot.has_same_coerced_value(self.value):
|
|
107
108
|
# value hasn't changed, skip this one
|
|
108
109
|
structlogger.debug(
|
|
109
|
-
"
|
|
110
|
+
"set_slot_command.skip_command.slot_already_set", command=self
|
|
110
111
|
)
|
|
111
112
|
return []
|
|
112
113
|
|
|
@@ -136,6 +137,11 @@ class SetSlotCommand(Command):
|
|
|
136
137
|
):
|
|
137
138
|
# Get the other predicted flows from the most recent message on the tracker.
|
|
138
139
|
predicted_flows = get_flows_predicted_to_start_from_tracker(tracker)
|
|
140
|
+
if not predicted_flows:
|
|
141
|
+
# If no predicted flows, check for default flows collecting the slot.
|
|
142
|
+
predicted_flows = find_default_flows_collecting_slot(
|
|
143
|
+
self.name, all_flows
|
|
144
|
+
)
|
|
139
145
|
use_slot_fill = any(
|
|
140
146
|
step.collect == self.name and not step.ask_before_filling
|
|
141
147
|
for flow in all_flows.underlying_flows
|
|
@@ -144,11 +150,11 @@ class SetSlotCommand(Command):
|
|
|
144
150
|
)
|
|
145
151
|
if not use_slot_fill:
|
|
146
152
|
structlogger.debug(
|
|
147
|
-
"
|
|
153
|
+
"set_slot_command.skip_command.slot_not_asked_for", command=self
|
|
148
154
|
)
|
|
149
155
|
return []
|
|
150
156
|
|
|
151
|
-
structlogger.debug("
|
|
157
|
+
structlogger.debug("set_slot_command.set_slot", command=self)
|
|
152
158
|
return [
|
|
153
159
|
SlotSet(self.name, slot.coerce_value(self.value), filled_by=self.extractor)
|
|
154
160
|
]
|
|
@@ -170,6 +176,7 @@ class SetSlotCommand(Command):
|
|
|
170
176
|
mapper = {
|
|
171
177
|
CommandSyntaxVersion.v1: f"SetSlot({self.name}, {self.value})",
|
|
172
178
|
CommandSyntaxVersion.v2: f"set slot {self.name} {self.value}",
|
|
179
|
+
CommandSyntaxVersion.v3: f"set slot {self.name} {self.value}",
|
|
173
180
|
}
|
|
174
181
|
return mapper.get(
|
|
175
182
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -190,7 +197,10 @@ class SetSlotCommand(Command):
|
|
|
190
197
|
r"""SetSlot\(['"]?([a-zA-Z_][a-zA-Z0-9_-]*)['"]?, ?['"]?(.*)['"]?\)"""
|
|
191
198
|
),
|
|
192
199
|
CommandSyntaxVersion.v2: (
|
|
193
|
-
r"""^[\s\W\d]*set slot ['"`]?([a-zA-Z_][a-zA-Z0-9_-]*)['"`]? ['"`]?(.+?)[
|
|
200
|
+
r"""^[\s\W\d]*set slot ['"`]?([a-zA-Z_][a-zA-Z0-9_-]*)['"`]? ['"`]?(.+?)[\W]*$""" # noqa: E501
|
|
201
|
+
),
|
|
202
|
+
CommandSyntaxVersion.v3: (
|
|
203
|
+
r"""^[\s\W\d]*set slot ['"`]?([a-zA-Z_][a-zA-Z0-9_-]*)['"`]? ['"`]?(.+?)[\W]*$""" # noqa: E501
|
|
194
204
|
),
|
|
195
205
|
}
|
|
196
206
|
return mapper.get(
|
|
@@ -63,9 +63,7 @@ class SkipQuestionCommand(Command):
|
|
|
63
63
|
current_flow = user_frame.flow(all_flows) if user_frame else None
|
|
64
64
|
|
|
65
65
|
if not current_flow:
|
|
66
|
-
structlogger.debug(
|
|
67
|
-
"command_executor.skip_question.no_active_flow", command=self
|
|
68
|
-
)
|
|
66
|
+
structlogger.debug("skip_question_command.no_active_flow", command=self)
|
|
69
67
|
return []
|
|
70
68
|
|
|
71
69
|
stack.push(SkipQuestionPatternFlowStackFrame())
|
|
@@ -82,6 +80,7 @@ class SkipQuestionCommand(Command):
|
|
|
82
80
|
mapper = {
|
|
83
81
|
CommandSyntaxVersion.v1: "SkipQuestion()",
|
|
84
82
|
CommandSyntaxVersion.v2: "skip question",
|
|
83
|
+
CommandSyntaxVersion.v3: "skip question",
|
|
85
84
|
}
|
|
86
85
|
return mapper.get(
|
|
87
86
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -98,6 +97,7 @@ class SkipQuestionCommand(Command):
|
|
|
98
97
|
mapper = {
|
|
99
98
|
CommandSyntaxVersion.v1: r"SkipQuestion\(\)",
|
|
100
99
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*skip question['"`]*$""",
|
|
100
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*skip question['"`]*$""",
|
|
101
101
|
}
|
|
102
102
|
return mapper.get(
|
|
103
103
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -73,12 +73,12 @@ class StartFlowCommand(Command):
|
|
|
73
73
|
|
|
74
74
|
if self.flow in user_flows_on_the_stack(stack):
|
|
75
75
|
structlogger.debug(
|
|
76
|
-
"
|
|
76
|
+
"start_flow_command.skip_command.already_started_flow", command=self
|
|
77
77
|
)
|
|
78
78
|
return []
|
|
79
79
|
elif self.flow not in all_flows.flow_ids:
|
|
80
80
|
structlogger.debug(
|
|
81
|
-
"
|
|
81
|
+
"start_flow_command.skip_command.start_invalid_flow_id", command=self
|
|
82
82
|
)
|
|
83
83
|
return []
|
|
84
84
|
|
|
@@ -99,7 +99,7 @@ class StartFlowCommand(Command):
|
|
|
99
99
|
)
|
|
100
100
|
)
|
|
101
101
|
|
|
102
|
-
structlogger.debug("
|
|
102
|
+
structlogger.debug("start_flow_command.start_flow", command=self)
|
|
103
103
|
stack.push(UserFlowStackFrame(flow_id=self.flow, frame_type=frame_type))
|
|
104
104
|
return applied_events + tracker.create_stack_updated_events(stack)
|
|
105
105
|
|
|
@@ -117,6 +117,7 @@ class StartFlowCommand(Command):
|
|
|
117
117
|
mapper = {
|
|
118
118
|
CommandSyntaxVersion.v1: f"StartFlow({self.flow})",
|
|
119
119
|
CommandSyntaxVersion.v2: f"start flow {self.flow}",
|
|
120
|
+
CommandSyntaxVersion.v3: f"start flow {self.flow}",
|
|
120
121
|
}
|
|
121
122
|
return mapper.get(
|
|
122
123
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -135,6 +136,9 @@ class StartFlowCommand(Command):
|
|
|
135
136
|
CommandSyntaxVersion.v2: (
|
|
136
137
|
r"""^[\s\W\d]*start flow ['"`]?([a-zA-Z0-9_-]+)['"`]*"""
|
|
137
138
|
),
|
|
139
|
+
CommandSyntaxVersion.v3: (
|
|
140
|
+
r"""^[\s\W\d]*start flow ['"`]?([a-zA-Z0-9_-]+)['"`]*"""
|
|
141
|
+
),
|
|
138
142
|
}
|
|
139
143
|
return mapper.get(
|
|
140
144
|
CommandSyntaxManager.get_syntax_version(),
|