rasa-pro 3.13.0.dev5__py3-none-any.whl → 3.13.0.dev8__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 +5 -1
- rasa/cli/arguments/default_arguments.py +13 -1
- rasa/cli/arguments/train.py +2 -0
- rasa/cli/dialogue_understanding_test.py +1 -1
- rasa/cli/e2e_test.py +1 -1
- rasa/cli/evaluate.py +2 -2
- rasa/cli/export.py +3 -3
- rasa/cli/llm_fine_tuning.py +12 -11
- rasa/cli/project_templates/defaults.py +133 -0
- rasa/cli/run.py +1 -1
- rasa/cli/studio/link.py +53 -0
- rasa/cli/studio/pull.py +78 -0
- rasa/cli/studio/push.py +78 -0
- rasa/cli/studio/studio.py +12 -0
- rasa/cli/studio/upload.py +8 -0
- rasa/cli/train.py +2 -1
- rasa/cli/utils.py +1 -1
- rasa/cli/x.py +1 -1
- rasa/constants.py +4 -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 +18 -3
- rasa/core/available_endpoints.py +146 -0
- rasa/core/brokers/kafka.py +4 -0
- rasa/core/brokers/pika.py +5 -2
- rasa/core/brokers/sql.py +1 -1
- rasa/core/channels/botframework.py +2 -2
- rasa/core/channels/channel.py +2 -2
- rasa/core/channels/hangouts.py +8 -5
- rasa/core/channels/inspector/.eslintrc.cjs +12 -6
- rasa/core/channels/inspector/.prettierrc +5 -0
- rasa/core/channels/inspector/README.md +10 -4
- rasa/core/channels/inspector/dist/assets/{arc-9f75cc3b.js → arc-c4b064fc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-215b5026.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-2b54a0a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-daacea5f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-930d4dc2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-e847561e.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-83c206ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-b0eb01d0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-17586500.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-be2a1776.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-c2120ebd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-a6ab5c48.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-ef613457.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-d59185b3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-0f155405.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-d5f1d1b7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-47737d3a.js} +123 -123
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-b07d141f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-1936d429.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-dde8d0f3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-0c2c7ee0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-35dd89a4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-56192851.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-fc21ed78.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-25e98518.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-546ff1f5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-02d8b82d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-3ca5a92e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-128ea07c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-95f290af.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-4984898a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-1bf266ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-60521c63.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-a25b6e12.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-0fc086bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-44ee592e.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/package.json +3 -1
- rasa/core/channels/inspector/src/App.tsx +91 -90
- rasa/core/channels/inspector/src/components/Chat.tsx +45 -41
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -40
- rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
- rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
- rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
- rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
- rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
- rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
- rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
- rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
- rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
- rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
- rasa/core/channels/inspector/src/helpers/conversation.ts +7 -7
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
- rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
- rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
- rasa/core/channels/inspector/src/main.tsx +8 -8
- rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
- rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
- rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
- rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
- rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
- rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
- rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
- rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
- rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
- rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
- rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
- rasa/core/channels/inspector/src/theme/index.ts +38 -38
- rasa/core/channels/inspector/src/types.ts +56 -50
- rasa/core/channels/inspector/yarn.lock +5 -0
- 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/studio_chat.py +3 -2
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +35 -25
- rasa/core/channels/voice_stream/audiocodes.py +7 -4
- rasa/core/channels/voice_stream/genesys.py +2 -2
- rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
- rasa/core/channels/voice_stream/voice_channel.py +33 -22
- rasa/core/evaluation/marker_tracker_loader.py +1 -1
- rasa/core/exporter.py +1 -1
- rasa/core/http_interpreter.py +3 -7
- rasa/core/jobs.py +2 -1
- rasa/core/nlg/contextual_response_rephraser.py +38 -11
- rasa/core/nlg/generator.py +0 -1
- rasa/core/nlg/interpolator.py +2 -3
- rasa/core/nlg/summarize.py +40 -6
- rasa/core/persistor.py +55 -20
- rasa/core/policies/enterprise_search_policy.py +290 -66
- rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +63 -0
- rasa/core/policies/flow_policy.py +1 -1
- rasa/core/policies/flows/flow_executor.py +96 -17
- rasa/core/policies/intentless_policy.py +24 -16
- rasa/core/processor.py +106 -53
- rasa/core/run.py +40 -13
- rasa/core/tracker_stores/__init__.py +0 -0
- rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
- rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
- rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
- rasa/core/tracker_stores/redis_tracker_store.py +219 -0
- rasa/core/tracker_stores/sql_tracker_store.py +555 -0
- rasa/core/tracker_stores/tracker_store.py +805 -0
- rasa/core/training/interactive.py +1 -1
- rasa/core/utils.py +24 -91
- rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
- rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +2 -0
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/clarify_command.py +6 -2
- rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
- rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
- 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 +11 -1
- rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
- rasa/dialogue_understanding/commands/utils.py +26 -2
- rasa/dialogue_understanding/generator/__init__.py +7 -1
- rasa/dialogue_understanding/generator/command_generator.py +4 -2
- 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/llm_based_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +78 -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 +477 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +8 -58
- 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 +3 -3
- rasa/dialogue_understanding/processor/command_processor_component.py +3 -3
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
- 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_runner.py +1 -1
- rasa/engine/constants.py +1 -1
- rasa/engine/recipes/default_recipe.py +26 -2
- rasa/engine/validation.py +3 -2
- rasa/hooks.py +2 -30
- rasa/keys +1 -0
- 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 +4 -2
- 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/config.py +3 -1
- rasa/model_manager/model_api.py +89 -2
- rasa/model_manager/runner_service.py +8 -4
- rasa/model_manager/trainer_service.py +5 -4
- rasa/model_training.py +12 -3
- rasa/nlu/extractors/crf_entity_extractor.py +66 -16
- rasa/plugin.py +2 -12
- 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 +29 -4
- rasa/shared/constants.py +6 -0
- rasa/shared/core/constants.py +4 -3
- rasa/shared/core/domain.py +7 -0
- rasa/shared/core/events.py +99 -3
- rasa/shared/core/flows/flow.py +1 -2
- rasa/shared/core/flows/flows_yaml_schema.json +3 -0
- rasa/shared/core/flows/steps/collect.py +46 -2
- rasa/shared/core/slots.py +28 -0
- rasa/shared/exceptions.py +4 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
- rasa/shared/providers/_configs/openai_client_config.py +4 -0
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
- rasa/shared/providers/llm/_base_litellm_client.py +5 -2
- rasa/shared/utils/llm.py +161 -6
- rasa/shared/utils/yaml.py +32 -0
- rasa/studio/data_handler.py +3 -3
- rasa/studio/download/download.py +37 -60
- rasa/studio/download/flows.py +23 -31
- rasa/studio/link.py +200 -0
- rasa/studio/pull.py +94 -0
- rasa/studio/push.py +131 -0
- rasa/studio/upload.py +117 -67
- rasa/telemetry.py +84 -27
- rasa/tracing/config.py +4 -5
- rasa/tracing/constants.py +19 -1
- rasa/tracing/instrumentation/attribute_extractors.py +11 -3
- rasa/tracing/instrumentation/instrumentation.py +54 -3
- rasa/tracing/instrumentation/metrics.py +98 -15
- rasa/tracing/metric_instrument_provider.py +75 -3
- rasa/utils/common.py +1 -27
- rasa/utils/licensing.py +1 -2
- rasa/utils/log_utils.py +1 -45
- rasa/validator.py +2 -8
- rasa/version.py +1 -1
- {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev8.dist-info}/METADATA +8 -9
- {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev8.dist-info}/RECORD +254 -231
- 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-dfa68278.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-edb7f119.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-65e7c670.js +0 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
- rasa/core/tracker_store.py +0 -1792
- {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev8.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev8.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev8.dist-info}/entry_points.txt +0 -0
|
@@ -47,8 +47,8 @@ import rasa.shared.utils.io
|
|
|
47
47
|
import rasa.utils.io as io_utils
|
|
48
48
|
from rasa import telemetry
|
|
49
49
|
from rasa.core import run, utils
|
|
50
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
50
51
|
from rasa.core.constants import DEFAULT_SERVER_FORMAT, DEFAULT_SERVER_PORT
|
|
51
|
-
from rasa.core.utils import AvailableEndpoints
|
|
52
52
|
from rasa.shared.constants import (
|
|
53
53
|
DEFAULT_SENDER_ID,
|
|
54
54
|
DOCS_URL_NLU_BASED_POLICIES,
|
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,93 +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
|
-
|
|
202
|
-
return cls(
|
|
203
|
-
nlg,
|
|
204
|
-
nlu,
|
|
205
|
-
action,
|
|
206
|
-
model,
|
|
207
|
-
tracker_store,
|
|
208
|
-
lock_store,
|
|
209
|
-
event_broker,
|
|
210
|
-
vector_store,
|
|
211
|
-
model_groups,
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
def __init__(
|
|
215
|
-
self,
|
|
216
|
-
nlg: Optional[EndpointConfig] = None,
|
|
217
|
-
nlu: Optional[EndpointConfig] = None,
|
|
218
|
-
action: Optional[EndpointConfig] = None,
|
|
219
|
-
model: Optional[EndpointConfig] = None,
|
|
220
|
-
tracker_store: Optional[EndpointConfig] = None,
|
|
221
|
-
lock_store: Optional[EndpointConfig] = None,
|
|
222
|
-
event_broker: Optional[EndpointConfig] = None,
|
|
223
|
-
vector_store: Optional[EndpointConfig] = None,
|
|
224
|
-
model_groups: Optional[List[Dict[str, Any]]] = None,
|
|
225
|
-
) -> None:
|
|
226
|
-
"""Create an `AvailableEndpoints` object."""
|
|
227
|
-
self.model = model
|
|
228
|
-
self.action = action
|
|
229
|
-
self.nlu = nlu
|
|
230
|
-
self.nlg = nlg
|
|
231
|
-
self.tracker_store = tracker_store
|
|
232
|
-
self.lock_store = lock_store
|
|
233
|
-
self.event_broker = event_broker
|
|
234
|
-
self.vector_store = vector_store
|
|
235
|
-
self.model_groups = model_groups
|
|
236
|
-
|
|
237
|
-
@classmethod
|
|
238
|
-
def get_instance(
|
|
239
|
-
cls, endpoint_file: Optional[Text] = DEFAULT_ENDPOINTS_PATH
|
|
240
|
-
) -> "AvailableEndpoints":
|
|
241
|
-
"""Get the singleton instance of AvailableEndpoints."""
|
|
242
|
-
# Ensure that the instance is initialized only once.
|
|
243
|
-
if cls._instance is None:
|
|
244
|
-
cls._instance = cls.read_endpoints(endpoint_file)
|
|
245
|
-
return cls._instance
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
def read_endpoints_from_path(
|
|
249
|
-
endpoints_path: Optional[Union[Path, Text]] = None,
|
|
250
|
-
) -> AvailableEndpoints:
|
|
251
|
-
"""Get `AvailableEndpoints` object from specified path.
|
|
252
|
-
|
|
253
|
-
Args:
|
|
254
|
-
endpoints_path: Path of the endpoints file to be read. If `None` the
|
|
255
|
-
default path for that file is used (`endpoints.yml`).
|
|
256
|
-
|
|
257
|
-
Returns:
|
|
258
|
-
`AvailableEndpoints` object read from endpoints file.
|
|
259
|
-
|
|
260
|
-
"""
|
|
261
|
-
endpoints_config_path = cli_utils.get_validated_path(
|
|
262
|
-
endpoints_path, "endpoints", DEFAULT_ENDPOINTS_PATH, True
|
|
263
|
-
)
|
|
264
|
-
return AvailableEndpoints.get_instance(endpoints_config_path)
|
|
265
|
-
|
|
266
|
-
|
|
267
200
|
def _lock_store_is_multi_worker_compatible(
|
|
268
201
|
lock_store: Union[EndpointConfig, LockStore, None],
|
|
269
202
|
) -> bool:
|
|
@@ -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:
|
|
@@ -23,11 +23,14 @@ from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
|
23
23
|
from rasa.engine.storage.resource import Resource
|
|
24
24
|
from rasa.engine.storage.storage import ModelStorage
|
|
25
25
|
from rasa.shared.constants import (
|
|
26
|
+
LOGIT_BIAS_CONFIG_KEY,
|
|
27
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
26
28
|
MODEL_CONFIG_KEY,
|
|
27
29
|
OPENAI_PROVIDER,
|
|
28
30
|
PROMPT_CONFIG_KEY,
|
|
29
31
|
PROVIDER_CONFIG_KEY,
|
|
30
32
|
ROUTE_TO_CALM_SLOT,
|
|
33
|
+
TEMPERATURE_CONFIG_KEY,
|
|
31
34
|
TIMEOUT_CONFIG_KEY,
|
|
32
35
|
)
|
|
33
36
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
@@ -66,9 +69,11 @@ DEFAULT_LLM_CONFIG = {
|
|
|
66
69
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
67
70
|
MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME,
|
|
68
71
|
TIMEOUT_CONFIG_KEY: 7,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
73
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: 1,
|
|
74
|
+
LOGIT_BIAS_CONFIG_KEY: {
|
|
75
|
+
str(token_id): 100 for token_id in A_TO_C_TOKEN_IDS_CHATGPT
|
|
76
|
+
},
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
structlogger = structlog.get_logger()
|
|
@@ -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(),
|
|
@@ -134,6 +134,7 @@ class CancelFlowCommand(Command):
|
|
|
134
134
|
mapper = {
|
|
135
135
|
CommandSyntaxVersion.v1: "CancelFlow()",
|
|
136
136
|
CommandSyntaxVersion.v2: "cancel flow",
|
|
137
|
+
CommandSyntaxVersion.v3: "cancel flow",
|
|
137
138
|
}
|
|
138
139
|
return mapper.get(
|
|
139
140
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -150,6 +151,7 @@ class CancelFlowCommand(Command):
|
|
|
150
151
|
mapper = {
|
|
151
152
|
CommandSyntaxVersion.v1: r"CancelFlow\(\)",
|
|
152
153
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*cancel flow['"`]*$""",
|
|
154
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*cancel flow['"`]*$""",
|
|
153
155
|
}
|
|
154
156
|
return mapper.get(
|
|
155
157
|
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(),
|
|
@@ -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(),
|
|
@@ -117,9 +118,12 @@ class ClarifyCommand(Command):
|
|
|
117
118
|
@staticmethod
|
|
118
119
|
def regex_pattern() -> str:
|
|
119
120
|
mapper = {
|
|
120
|
-
CommandSyntaxVersion.v1: r"Clarify\(([\"\'a-zA-Z0-9_, ]*)\)",
|
|
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(
|
|
@@ -73,6 +73,7 @@ class HumanHandoffCommand(Command):
|
|
|
73
73
|
mapper = {
|
|
74
74
|
CommandSyntaxVersion.v1: "HumanHandoff()",
|
|
75
75
|
CommandSyntaxVersion.v2: "hand over",
|
|
76
|
+
CommandSyntaxVersion.v3: "hand over",
|
|
76
77
|
}
|
|
77
78
|
return mapper.get(
|
|
78
79
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -89,6 +90,7 @@ class HumanHandoffCommand(Command):
|
|
|
89
90
|
mapper = {
|
|
90
91
|
CommandSyntaxVersion.v1: r"HumanHandoff\(\)",
|
|
91
92
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*hand over['"`]*$""",
|
|
93
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*hand over['"`]*$""",
|
|
92
94
|
}
|
|
93
95
|
return mapper.get(
|
|
94
96
|
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 (
|
|
@@ -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
|
|
@@ -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(
|
|
@@ -82,6 +82,7 @@ class SkipQuestionCommand(Command):
|
|
|
82
82
|
mapper = {
|
|
83
83
|
CommandSyntaxVersion.v1: "SkipQuestion()",
|
|
84
84
|
CommandSyntaxVersion.v2: "skip question",
|
|
85
|
+
CommandSyntaxVersion.v3: "skip question",
|
|
85
86
|
}
|
|
86
87
|
return mapper.get(
|
|
87
88
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -98,6 +99,7 @@ class SkipQuestionCommand(Command):
|
|
|
98
99
|
mapper = {
|
|
99
100
|
CommandSyntaxVersion.v1: r"SkipQuestion\(\)",
|
|
100
101
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*skip question['"`]*$""",
|
|
102
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*skip question['"`]*$""",
|
|
101
103
|
}
|
|
102
104
|
return mapper.get(
|
|
103
105
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -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(),
|
|
@@ -7,18 +7,18 @@ from rasa.dialogue_understanding.patterns.validate_slot import (
|
|
|
7
7
|
)
|
|
8
8
|
from rasa.shared.constants import ACTION_ASK_PREFIX, UTTER_ASK_PREFIX
|
|
9
9
|
from rasa.shared.core.events import Event, SlotSet
|
|
10
|
+
from rasa.shared.core.flows import FlowsList
|
|
10
11
|
from rasa.shared.core.slots import Slot
|
|
11
12
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
12
13
|
|
|
13
14
|
if TYPE_CHECKING:
|
|
14
15
|
from rasa.dialogue_understanding.commands import StartFlowCommand
|
|
15
|
-
from rasa.shared.core.flows import FlowsList
|
|
16
16
|
|
|
17
17
|
structlogger = structlog.get_logger()
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def start_flow_by_name(
|
|
21
|
-
flow_name: str, flows:
|
|
21
|
+
flow_name: str, flows: FlowsList
|
|
22
22
|
) -> Optional["StartFlowCommand"]:
|
|
23
23
|
from rasa.dialogue_understanding.commands import StartFlowCommand
|
|
24
24
|
|
|
@@ -126,3 +126,27 @@ def create_validate_frames_from_slot_set_events(
|
|
|
126
126
|
validate_frames.append(frame)
|
|
127
127
|
|
|
128
128
|
return tracker, validate_frames
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def find_default_flows_collecting_slot(
|
|
132
|
+
slot_name: str, all_flows: FlowsList
|
|
133
|
+
) -> List[str]:
|
|
134
|
+
"""Find default flows that have collect steps matching the specified slot name.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
slot_name: The name of the slot to search for.
|
|
138
|
+
all_flows: All flows in the assistant.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
List of flow IDs for default flows that collect the specified slot
|
|
142
|
+
without asking before filling.
|
|
143
|
+
"""
|
|
144
|
+
return [
|
|
145
|
+
flow.id
|
|
146
|
+
for flow in all_flows.underlying_flows
|
|
147
|
+
if flow.is_rasa_default_flow
|
|
148
|
+
and any(
|
|
149
|
+
step.collect == slot_name and not step.ask_before_filling
|
|
150
|
+
for step in flow.get_collect_steps()
|
|
151
|
+
)
|
|
152
|
+
]
|
|
@@ -8,8 +8,13 @@ from rasa.dialogue_understanding.generator.llm_command_generator import (
|
|
|
8
8
|
from rasa.dialogue_understanding.generator.multi_step.multi_step_llm_command_generator import ( # noqa: E501
|
|
9
9
|
MultiStepLLMCommandGenerator,
|
|
10
10
|
)
|
|
11
|
-
from rasa.dialogue_understanding.generator.single_step.
|
|
11
|
+
from rasa.dialogue_understanding.generator.single_step.compact_llm_command_generator import ( # noqa: E501
|
|
12
12
|
CompactLLMCommandGenerator,
|
|
13
|
+
)
|
|
14
|
+
from rasa.dialogue_understanding.generator.single_step.search_ready_llm_command_generator import ( # noqa: E501
|
|
15
|
+
SearchReadyLLMCommandGenerator,
|
|
16
|
+
)
|
|
17
|
+
from rasa.dialogue_understanding.generator.single_step.single_step_llm_command_generator import ( # noqa: E501
|
|
13
18
|
SingleStepLLMCommandGenerator,
|
|
14
19
|
)
|
|
15
20
|
|
|
@@ -20,4 +25,5 @@ __all__ = [
|
|
|
20
25
|
"MultiStepLLMCommandGenerator",
|
|
21
26
|
"SingleStepLLMCommandGenerator",
|
|
22
27
|
"CompactLLMCommandGenerator",
|
|
28
|
+
"SearchReadyLLMCommandGenerator",
|
|
23
29
|
]
|
|
@@ -321,7 +321,10 @@ class CommandGenerator:
|
|
|
321
321
|
if commands and len(checked_commands) != len(commands):
|
|
322
322
|
structlogger.info(
|
|
323
323
|
"command_generator.check_commands_against_startable_flows.startable_commands",
|
|
324
|
-
commands=
|
|
324
|
+
commands=[
|
|
325
|
+
checked_command.__class__.__name__
|
|
326
|
+
for checked_command in checked_commands
|
|
327
|
+
],
|
|
325
328
|
)
|
|
326
329
|
|
|
327
330
|
return checked_commands
|
|
@@ -357,7 +360,6 @@ class CommandGenerator:
|
|
|
357
360
|
"command_generator.evaluate_message.error",
|
|
358
361
|
event_info="Invalid message",
|
|
359
362
|
errors=[e.as_dict() for e in errors],
|
|
360
|
-
message=message.get(TEXT),
|
|
361
363
|
)
|
|
362
364
|
return errors
|
|
363
365
|
|
|
@@ -81,7 +81,7 @@ def _get_additional_parsing_logic(
|
|
|
81
81
|
|
|
82
82
|
def validate_custom_commands(command_classes: List[Type[PromptCommand]]) -> None:
|
|
83
83
|
clz_not_inheriting_from_command_clz = [
|
|
84
|
-
command_clz
|
|
84
|
+
command_clz.__name__
|
|
85
85
|
for command_clz in command_classes
|
|
86
86
|
if not issubclass(command_clz, Command)
|
|
87
87
|
]
|
|
@@ -99,7 +99,7 @@ def validate_custom_commands(command_classes: List[Type[PromptCommand]]) -> None
|
|
|
99
99
|
sys.exit(1)
|
|
100
100
|
|
|
101
101
|
clz_not_adhering_to_prompt_command_protocol = [
|
|
102
|
-
command_clz
|
|
102
|
+
command_clz.__name__
|
|
103
103
|
for command_clz in command_classes
|
|
104
104
|
if not isinstance(command_clz, PromptCommand)
|
|
105
105
|
]
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
import structlog
|
|
4
|
+
|
|
5
|
+
from rasa.dialogue_understanding.commands import (
|
|
6
|
+
Command,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
structlogger = structlog.get_logger()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CommandParserValidatorSingleton:
|
|
13
|
+
"""Singleton class to validate the command parser.
|
|
14
|
+
|
|
15
|
+
This class is used to validate the command parser. It keeps track of the number of
|
|
16
|
+
consecutive turns where no commands are parsed by the command parser. If the
|
|
17
|
+
number of consecutive turns exceeds a certain threshold, a warning is logged.
|
|
18
|
+
The prompt can use a DSL syntax that can be incompatible with the command syntax
|
|
19
|
+
used by the command parser. This class helps to detect such incompatibilities.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
MAX_CONSECUTIVE_TURNS_NO_COMMAND_PREDICTED = 5
|
|
23
|
+
_NO_COMMAND_PREDICTED_TURN_COUNTER = 0
|
|
24
|
+
_command_parser_validated = False
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def get_no_command_predicted_turn_counter(cls) -> int:
|
|
28
|
+
return cls._NO_COMMAND_PREDICTED_TURN_COUNTER
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def should_validate_command_parser(cls) -> bool:
|
|
32
|
+
return not cls._command_parser_validated
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def reset_command_parser_validation(cls) -> None:
|
|
36
|
+
cls._NO_COMMAND_PREDICTED_TURN_COUNTER = 0
|
|
37
|
+
cls._command_parser_validated = False
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def validate_if_commands_are_parsed_from_llm_response(
|
|
41
|
+
cls, commands: List[Command], llm_response: str
|
|
42
|
+
) -> None:
|
|
43
|
+
if llm_response and not commands:
|
|
44
|
+
cls._NO_COMMAND_PREDICTED_TURN_COUNTER += 1
|
|
45
|
+
else:
|
|
46
|
+
# Reset the counter if commands are generated, and mark
|
|
47
|
+
# the command parser as validated.
|
|
48
|
+
cls._NO_COMMAND_PREDICTED_TURN_COUNTER = 0
|
|
49
|
+
cls._command_parser_validated = True
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
cls._NO_COMMAND_PREDICTED_TURN_COUNTER
|
|
54
|
+
>= cls.MAX_CONSECUTIVE_TURNS_NO_COMMAND_PREDICTED
|
|
55
|
+
):
|
|
56
|
+
structlogger.warning(
|
|
57
|
+
"llm_command_generator.predict_commands.command_parser_not_working",
|
|
58
|
+
event_info=(
|
|
59
|
+
f"No commands were generated by the command parser for the last "
|
|
60
|
+
f"{cls._NO_COMMAND_PREDICTED_TURN_COUNTER} times. Check if you "
|
|
61
|
+
"are running incompatible prompt and LLM command generator."
|
|
62
|
+
),
|
|
63
|
+
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from rasa.shared.constants import (
|
|
2
|
-
|
|
2
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
3
3
|
MODEL_CONFIG_KEY,
|
|
4
4
|
OPENAI_PROVIDER,
|
|
5
5
|
PROVIDER_CONFIG_KEY,
|
|
@@ -15,7 +15,7 @@ DEFAULT_LLM_CONFIG = {
|
|
|
15
15
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
16
16
|
MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME_ADVANCED,
|
|
17
17
|
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
18
|
-
|
|
18
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
|
|
19
19
|
TIMEOUT_CONFIG_KEY: 7,
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -527,7 +527,7 @@ class LLMBasedCommandGenerator(
|
|
|
527
527
|
either contain a StartFlowCommand or a SetSlot command
|
|
528
528
|
for the current collect step.
|
|
529
529
|
"""
|
|
530
|
-
return self.config.get(KEY_MINIMIZE_NUM_CALLS,
|
|
530
|
+
return self.config.get(KEY_MINIMIZE_NUM_CALLS, True) and (
|
|
531
531
|
self._prior_commands_contain_start_flow(prior_commands)
|
|
532
532
|
or self._prior_commands_contain_set_slot_for_active_collect_step(
|
|
533
533
|
prior_commands, flows, tracker
|