rasa-pro 3.14.0a20__py3-none-any.whl → 3.14.0a23__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 +15 -3
- rasa/agents/__init__.py +0 -0
- rasa/agents/agent_factory.py +122 -0
- rasa/agents/agent_manager.py +211 -0
- rasa/agents/constants.py +43 -0
- rasa/agents/core/__init__.py +0 -0
- rasa/agents/core/agent_protocol.py +107 -0
- rasa/agents/core/types.py +81 -0
- rasa/agents/exceptions.py +38 -0
- rasa/agents/protocol/__init__.py +5 -0
- rasa/agents/protocol/a2a/__init__.py +0 -0
- rasa/agents/protocol/a2a/a2a_agent.py +879 -0
- rasa/agents/protocol/mcp/__init__.py +0 -0
- rasa/agents/protocol/mcp/mcp_base_agent.py +726 -0
- rasa/agents/protocol/mcp/mcp_open_agent.py +327 -0
- rasa/agents/protocol/mcp/mcp_task_agent.py +522 -0
- rasa/agents/schemas/__init__.py +13 -0
- rasa/agents/schemas/agent_input.py +38 -0
- rasa/agents/schemas/agent_output.py +26 -0
- rasa/agents/schemas/agent_tool_result.py +65 -0
- rasa/agents/schemas/agent_tool_schema.py +186 -0
- rasa/agents/templates/__init__.py +0 -0
- rasa/agents/templates/mcp_open_agent_prompt_template.jinja2 +20 -0
- rasa/agents/templates/mcp_task_agent_prompt_template.jinja2 +22 -0
- rasa/agents/utils.py +206 -0
- rasa/agents/validation.py +485 -0
- rasa/api.py +24 -9
- rasa/builder/config.py +6 -2
- rasa/builder/guardrails/{lakera.py → clients.py} +55 -5
- rasa/builder/guardrails/constants.py +3 -0
- rasa/builder/guardrails/models.py +45 -10
- rasa/builder/guardrails/policy_checker.py +324 -0
- rasa/builder/guardrails/utils.py +42 -276
- rasa/builder/llm_service.py +32 -5
- rasa/builder/models.py +1 -0
- rasa/builder/project_generator.py +6 -1
- rasa/builder/service.py +16 -13
- rasa/builder/training_service.py +18 -24
- rasa/builder/validation_service.py +1 -1
- rasa/cli/arguments/default_arguments.py +12 -0
- rasa/cli/arguments/run.py +2 -0
- rasa/cli/arguments/train.py +2 -0
- rasa/cli/data.py +10 -8
- rasa/cli/dialogue_understanding_test.py +10 -7
- rasa/cli/e2e_test.py +9 -6
- rasa/cli/evaluate.py +4 -2
- rasa/cli/export.py +5 -2
- rasa/cli/inspect.py +8 -4
- rasa/cli/interactive.py +5 -4
- rasa/cli/llm_fine_tuning.py +11 -6
- rasa/cli/project_templates/finance/actions/general/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/general/action_human_handoff.py +49 -0
- rasa/cli/project_templates/finance/data/general/bot_challenge.yml +6 -0
- rasa/cli/project_templates/finance/data/general/goodbye.yml +1 -1
- rasa/cli/project_templates/finance/data/general/human_handoff.yml +1 -1
- rasa/cli/project_templates/finance/data/system/patterns/pattern_session_start.yml +1 -1
- rasa/cli/project_templates/finance/domain/general/_shared.yml +0 -14
- rasa/cli/project_templates/finance/domain/general/bot_challenge.yml +4 -0
- rasa/cli/project_templates/finance/domain/general/goodbye.yml +7 -0
- rasa/cli/project_templates/finance/domain/general/human_handoff.yml +3 -6
- rasa/cli/project_templates/finance/domain/general/welcome.yml +29 -1
- rasa/cli/project_templates/finance/tests/e2e_test_cases/accounts/check_balance.yml +9 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/accounts/download_statements.yml +43 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/cards/block_card.yml +55 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/general/bot_challenge.yml +8 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/general/feedback.yml +46 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/general/goodbye.yml +9 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/general/hello.yml +8 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/general/human_handoff.yml +35 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/general/patterns.yml +22 -0
- rasa/cli/project_templates/finance/tests/e2e_test_cases/transfers/transfer_money.yml +56 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/feedback.yml +1 -1
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/hello.yml +1 -1
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/human_handoff.yml +1 -1
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/patterns.yml +1 -1
- rasa/cli/project_templates/tutorial/credentials.yml +10 -0
- rasa/cli/run.py +12 -10
- rasa/cli/scaffold.py +4 -4
- rasa/cli/shell.py +9 -5
- rasa/cli/studio/studio.py +1 -1
- rasa/cli/test.py +34 -14
- rasa/cli/train.py +41 -28
- rasa/cli/utils.py +1 -393
- rasa/cli/validation/__init__.py +0 -0
- rasa/cli/validation/bot_config.py +223 -0
- rasa/cli/validation/config_path_validation.py +257 -0
- rasa/cli/x.py +8 -4
- rasa/constants.py +7 -1
- rasa/core/actions/action.py +51 -10
- rasa/core/actions/action_run_slot_rejections.py +1 -1
- rasa/core/actions/direct_custom_actions_executor.py +9 -2
- rasa/core/actions/grpc_custom_action_executor.py +1 -1
- rasa/core/agent.py +19 -2
- rasa/core/available_agents.py +229 -0
- rasa/core/brokers/kafka.py +1 -1
- rasa/core/channels/__init__.py +82 -35
- rasa/core/channels/development_inspector.py +3 -3
- rasa/core/channels/inspector/README.md +25 -13
- rasa/core/channels/inspector/dist/assets/{arc-35222594.js → arc-6177260a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-a0efbfd3.js → blockDiagram-38ab4fdb-b054f038.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-0584c0f2.js → c4Diagram-3d4e48cf-f25427d5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-bf9cbb34.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-39f40dbe.js → classDiagram-70f12bd4-c7a2af53.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-1ad755f3.js → classDiagram-v2-f2320105-58db65c0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-8f9083bb.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-b0f4f0fe.js → createText-2e5e7dd3-088372e2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-9039bff9.js → edges-e0da2a9e-58676240.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-65c9b127.js → erDiagram-9861fffd-0c14d7c6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-4f08b38e.js → flowDb-956e92f1-ea63f85c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-e95c362a.js → flowDiagram-66a62f08-a2af48cd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-9ecd5b59.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-703c3015.js → flowchart-elk-definition-4a651766-6937abe7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-699328ea.js → ganttDiagram-c361ad54-7473f357.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-04cf4b05.js → gitGraphDiagram-72cf32ee-d0c9405e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-ee94449e.js → graph-0a6f8466.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-940162b4.js → index-3862675e-7610671a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/index-74e01d94.js +1354 -0
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-c79c2866.js → infoDiagram-f8f76790-be397dc7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-84489d30.js → journeyDiagram-49397b02-4cefbf62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-a9aa9858.js → layout-e7fbc2bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-eb73cf26.js → line-a8aa457c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-b3399f9a.js → linear-3351e0d2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-b095bf1a.js → mindmap-definition-fc14e90a-b8cbf605.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-07644b66.js → pieDiagram-8a3498a8-f327f774.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-573a3f9c.js → quadrantDiagram-120e2f19-2854c591.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-d457e1e1.js → requirementDiagram-deff3bca-964985d5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-9d26e1a2.js → sankeyDiagram-04a897e0-edeb4f33.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-3a9cde10.js → sequenceDiagram-704730f1-fcf70125.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-4f3e8cec.js → stateDiagram-587899a1-0e770395.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-e617e5bf.js → stateDiagram-v2-d93cdb3a-af8dcd22.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-eab30d2f.js → styles-6aaf32cf-36a9e70d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-09994be2.js → styles-9a916d00-884a8b5b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-b7110364.js → styles-c10674c1-dc097813.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-3ebc92ad.js → svgDrawCommon-08f97a94-5a2c7eed.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-7d13d2f2.js → timeline-definition-85554ec2-e89c4f6e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-488385e1.js → xychartDiagram-e933f94c-afb6fe56.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/package.json +18 -18
- rasa/core/channels/inspector/src/App.tsx +29 -4
- rasa/core/channels/inspector/src/components/DialogueAgentStack.tsx +108 -0
- rasa/core/channels/inspector/src/components/{DialogueStack.tsx → DialogueHistoryStack.tsx} +4 -2
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +7 -4
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +4 -0
- rasa/core/channels/inspector/src/helpers/formatters.ts +24 -3
- rasa/core/channels/inspector/src/helpers/utils.test.ts +127 -0
- rasa/core/channels/inspector/src/helpers/utils.ts +66 -1
- rasa/core/channels/inspector/src/theme/base/styles.ts +19 -1
- rasa/core/channels/inspector/src/types.ts +21 -0
- rasa/core/channels/inspector/yarn.lock +336 -189
- rasa/core/channels/studio_chat.py +6 -6
- rasa/core/channels/telegram.py +4 -9
- rasa/core/channels/voice_stream/browser_audio.py +2 -0
- rasa/core/channels/voice_stream/genesys.py +1 -1
- rasa/core/channels/voice_stream/tts/deepgram.py +140 -0
- rasa/core/channels/voice_stream/twilio_media_streams.py +5 -1
- rasa/core/channels/voice_stream/voice_channel.py +3 -0
- rasa/core/config/__init__.py +0 -0
- rasa/core/{available_endpoints.py → config/available_endpoints.py} +51 -16
- rasa/core/config/configuration.py +260 -0
- rasa/core/config/credentials.py +19 -0
- rasa/core/config/message_procesing_config.py +34 -0
- rasa/core/constants.py +5 -0
- rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +88 -3
- rasa/core/iam_credentials_providers/credentials_provider_protocol.py +2 -1
- rasa/core/lock_store.py +6 -4
- rasa/core/nlg/generator.py +1 -1
- rasa/core/policies/enterprise_search_policy.py +5 -3
- rasa/core/policies/flow_policy.py +4 -4
- rasa/core/policies/flows/agent_executor.py +632 -0
- rasa/core/policies/flows/flow_executor.py +137 -76
- rasa/core/policies/flows/mcp_tool_executor.py +298 -0
- rasa/core/policies/intentless_policy.py +1 -1
- rasa/core/policies/ted_policy.py +20 -12
- rasa/core/policies/unexpected_intent_policy.py +6 -0
- rasa/core/processor.py +68 -44
- rasa/core/redis_connection_factory.py +78 -20
- rasa/core/run.py +37 -8
- rasa/core/test.py +4 -0
- rasa/core/tracker_stores/sql_tracker_store.py +1 -1
- rasa/core/tracker_stores/tracker_store.py +3 -7
- rasa/core/train.py +1 -1
- rasa/core/training/interactive.py +20 -18
- rasa/core/training/story_conflict.py +5 -5
- rasa/core/utils.py +22 -23
- rasa/dialogue_understanding/commands/__init__.py +8 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +19 -5
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +21 -2
- rasa/dialogue_understanding/commands/clarify_command.py +20 -2
- rasa/dialogue_understanding/commands/continue_agent_command.py +91 -0
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +21 -2
- rasa/dialogue_understanding/commands/restart_agent_command.py +162 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +68 -7
- rasa/dialogue_understanding/commands/utils.py +124 -2
- rasa/dialogue_understanding/generator/command_parser.py +4 -0
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +50 -12
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +66 -0
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +66 -0
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +89 -0
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +88 -0
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +42 -7
- rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +40 -3
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +20 -3
- rasa/dialogue_understanding/patterns/cancel.py +27 -6
- rasa/dialogue_understanding/patterns/clarify.py +3 -14
- rasa/dialogue_understanding/patterns/continue_interrupted.py +239 -6
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +46 -8
- rasa/dialogue_understanding/processor/command_processor.py +136 -15
- rasa/dialogue_understanding/stack/dialogue_stack.py +98 -2
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +57 -0
- rasa/dialogue_understanding/stack/utils.py +57 -3
- rasa/dialogue_understanding/utils.py +24 -4
- rasa/dialogue_understanding_test/du_test_runner.py +8 -3
- rasa/e2e_test/e2e_test_runner.py +13 -3
- rasa/engine/caching.py +2 -2
- rasa/engine/constants.py +1 -1
- rasa/engine/loader.py +12 -0
- rasa/engine/recipes/default_components.py +138 -49
- rasa/engine/recipes/default_recipe.py +108 -11
- rasa/engine/runner/dask.py +8 -5
- rasa/engine/validation.py +19 -6
- rasa/graph_components/validators/default_recipe_validator.py +86 -28
- rasa/hooks.py +5 -5
- rasa/llm_fine_tuning/utils.py +2 -2
- rasa/model_training.py +60 -47
- rasa/nlu/classifiers/diet_classifier.py +198 -98
- rasa/nlu/classifiers/logistic_regression_classifier.py +1 -4
- rasa/nlu/classifiers/mitie_intent_classifier.py +3 -0
- rasa/nlu/classifiers/sklearn_intent_classifier.py +1 -3
- rasa/nlu/extractors/crf_entity_extractor.py +9 -10
- rasa/nlu/extractors/mitie_entity_extractor.py +3 -0
- rasa/nlu/extractors/spacy_entity_extractor.py +3 -0
- rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py +4 -0
- rasa/nlu/featurizers/dense_featurizer/lm_featurizer.py +5 -0
- rasa/nlu/featurizers/dense_featurizer/mitie_featurizer.py +2 -0
- rasa/nlu/featurizers/dense_featurizer/spacy_featurizer.py +3 -0
- rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +4 -2
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +4 -0
- rasa/nlu/selectors/response_selector.py +10 -2
- rasa/nlu/tokenizers/jieba_tokenizer.py +3 -4
- rasa/nlu/tokenizers/mitie_tokenizer.py +3 -2
- rasa/nlu/tokenizers/spacy_tokenizer.py +3 -2
- rasa/nlu/utils/mitie_utils.py +3 -0
- rasa/nlu/utils/spacy_utils.py +3 -2
- rasa/plugin.py +8 -8
- rasa/privacy/privacy_manager.py +12 -3
- rasa/server.py +15 -3
- rasa/shared/agents/__init__.py +0 -0
- rasa/shared/agents/auth/__init__.py +0 -0
- rasa/shared/agents/auth/agent_auth_factory.py +105 -0
- rasa/shared/agents/auth/agent_auth_manager.py +92 -0
- rasa/shared/agents/auth/auth_strategy/__init__.py +19 -0
- rasa/shared/agents/auth/auth_strategy/agent_auth_strategy.py +52 -0
- rasa/shared/agents/auth/auth_strategy/api_key_auth_strategy.py +42 -0
- rasa/shared/agents/auth/auth_strategy/bearer_token_auth_strategy.py +28 -0
- rasa/shared/agents/auth/auth_strategy/oauth2_auth_strategy.py +167 -0
- rasa/shared/agents/auth/constants.py +12 -0
- rasa/shared/agents/auth/types.py +12 -0
- rasa/shared/agents/utils.py +35 -0
- rasa/shared/constants.py +8 -0
- rasa/shared/core/constants.py +16 -1
- rasa/shared/core/domain.py +0 -7
- rasa/shared/core/events.py +327 -0
- rasa/shared/core/flows/constants.py +5 -0
- rasa/shared/core/flows/flow.py +1 -1
- rasa/shared/core/flows/flows_list.py +21 -5
- rasa/shared/core/flows/flows_yaml_schema.json +119 -184
- rasa/shared/core/flows/steps/call.py +49 -5
- rasa/shared/core/flows/steps/collect.py +98 -13
- rasa/shared/core/flows/validation.py +372 -8
- rasa/shared/core/flows/yaml_flows_io.py +3 -2
- rasa/shared/core/slots.py +2 -2
- rasa/shared/core/trackers.py +5 -2
- rasa/shared/exceptions.py +16 -0
- rasa/shared/importers/rasa.py +1 -1
- rasa/shared/importers/utils.py +9 -3
- rasa/shared/providers/llm/_base_litellm_client.py +41 -9
- rasa/shared/providers/llm/litellm_router_llm_client.py +8 -4
- rasa/shared/providers/llm/llm_client.py +7 -3
- rasa/shared/providers/llm/llm_response.py +66 -0
- rasa/shared/providers/llm/self_hosted_llm_client.py +8 -4
- rasa/shared/utils/common.py +24 -0
- rasa/shared/utils/health_check/health_check.py +7 -3
- rasa/shared/utils/llm.py +39 -16
- rasa/shared/utils/mcp/__init__.py +0 -0
- rasa/shared/utils/mcp/server_connection.py +247 -0
- rasa/shared/utils/mcp/utils.py +20 -0
- rasa/shared/utils/schemas/events.py +42 -0
- rasa/shared/utils/yaml.py +3 -1
- rasa/studio/pull/pull.py +3 -2
- rasa/studio/train.py +8 -7
- rasa/studio/upload.py +3 -6
- rasa/telemetry.py +69 -5
- rasa/tracing/config.py +45 -12
- rasa/tracing/constants.py +14 -0
- rasa/tracing/instrumentation/attribute_extractors.py +142 -9
- rasa/tracing/instrumentation/instrumentation.py +626 -21
- rasa/tracing/instrumentation/intentless_policy_instrumentation.py +4 -4
- rasa/tracing/instrumentation/metrics.py +32 -0
- rasa/tracing/metric_instrument_provider.py +68 -0
- rasa/utils/common.py +92 -1
- rasa/utils/endpoints.py +11 -2
- rasa/utils/log_utils.py +96 -5
- rasa/utils/ml_utils.py +1 -1
- rasa/utils/pypred.py +38 -0
- rasa/utils/tensorflow/__init__.py +7 -0
- rasa/utils/tensorflow/callback.py +136 -101
- rasa/utils/tensorflow/crf.py +1 -1
- rasa/utils/tensorflow/data_generator.py +21 -8
- rasa/utils/tensorflow/layers.py +21 -11
- rasa/utils/tensorflow/metrics.py +7 -3
- rasa/utils/tensorflow/models.py +56 -8
- rasa/utils/tensorflow/rasa_layers.py +8 -6
- rasa/utils/tensorflow/transformer.py +2 -3
- rasa/utils/train_utils.py +54 -24
- rasa/validator.py +17 -13
- rasa/version.py +1 -1
- {rasa_pro-3.14.0a20.dist-info → rasa_pro-3.14.0a23.dist-info}/METADATA +48 -42
- {rasa_pro-3.14.0a20.dist-info → rasa_pro-3.14.0a23.dist-info}/RECORD +323 -251
- rasa/builder/scrape_rasa_docs.py +0 -97
- rasa/cli/project_templates/finance/data/general/agent_details.yml +0 -6
- rasa/cli/project_templates/finance/domain/_system/patterns/pattern_session_start.yml +0 -11
- rasa/cli/project_templates/finance/domain/general/agent_details.yml +0 -31
- rasa/core/channels/inspector/dist/assets/channel-8e08bed9.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-78c82dea.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-2b08f601.js +0 -1
- rasa/core/channels/inspector/dist/assets/index-c941dcb3.js +0 -1336
- {rasa_pro-3.14.0a20.dist-info → rasa_pro-3.14.0a23.dist-info}/NOTICE +0 -0
- {rasa_pro-3.14.0a20.dist-info → rasa_pro-3.14.0a23.dist-info}/WHEEL +0 -0
- {rasa_pro-3.14.0a20.dist-info → rasa_pro-3.14.0a23.dist-info}/entry_points.txt +0 -0
rasa/model_training.py
CHANGED
|
@@ -15,6 +15,10 @@ import rasa.shared.utils.common
|
|
|
15
15
|
import rasa.shared.utils.io
|
|
16
16
|
import rasa.utils.common
|
|
17
17
|
from rasa import telemetry
|
|
18
|
+
from rasa.core.config.configuration import (
|
|
19
|
+
Configuration,
|
|
20
|
+
MessageProcessingConfigPath,
|
|
21
|
+
)
|
|
18
22
|
from rasa.core.persistor import StorageType
|
|
19
23
|
from rasa.engine.caching import LocalTrainingCache
|
|
20
24
|
from rasa.engine.recipes.recipe import Recipe
|
|
@@ -115,58 +119,32 @@ def get_unresolved_slots(domain: Domain, stories: StoryGraph) -> List[Text]:
|
|
|
115
119
|
)
|
|
116
120
|
|
|
117
121
|
|
|
118
|
-
def _check_unresolved_slots(domain: Domain, stories: StoryGraph) -> None:
|
|
119
|
-
"""Checks if there are any unresolved slots.
|
|
120
|
-
|
|
121
|
-
Args:
|
|
122
|
-
domain: The domain.
|
|
123
|
-
stories: The story graph.
|
|
124
|
-
|
|
125
|
-
Raises:
|
|
126
|
-
`Sys exit` if there are any unresolved slots.
|
|
127
|
-
|
|
128
|
-
Returns:
|
|
129
|
-
`None` if there are no unresolved slots.
|
|
130
|
-
"""
|
|
131
|
-
unresolved_slots = get_unresolved_slots(domain, stories)
|
|
132
|
-
if unresolved_slots:
|
|
133
|
-
structlogger.error(
|
|
134
|
-
"model.training.check_unresolved_slots.not_in_domain",
|
|
135
|
-
slots=unresolved_slots,
|
|
136
|
-
event_info=(
|
|
137
|
-
f"Unresolved slots found in stories/rules🚨 \n"
|
|
138
|
-
f'Tried to set slots "{unresolved_slots}" that are not present in'
|
|
139
|
-
f"your domain.\n Check whether they need to be added to the domain or "
|
|
140
|
-
f"whether there is a spelling error."
|
|
141
|
-
),
|
|
142
|
-
)
|
|
143
|
-
rasa.shared.utils.common.display_research_study_prompt()
|
|
144
|
-
sys.exit(1)
|
|
145
|
-
|
|
146
|
-
|
|
147
122
|
async def train(
|
|
148
123
|
domain: Text,
|
|
149
124
|
config: Text,
|
|
150
125
|
training_files: Optional[Union[Text, List[Text]]],
|
|
126
|
+
endpoints: Text = rasa.shared.constants.DEFAULT_ENDPOINTS_PATH,
|
|
151
127
|
output: Text = rasa.shared.constants.DEFAULT_MODELS_PATH,
|
|
152
128
|
dry_run: bool = False,
|
|
153
129
|
force_training: bool = False,
|
|
154
|
-
fixed_model_name: Optional[
|
|
130
|
+
fixed_model_name: Optional[str] = None,
|
|
155
131
|
persist_nlu_training_data: bool = False,
|
|
156
132
|
core_additional_arguments: Optional[Dict] = None,
|
|
157
133
|
nlu_additional_arguments: Optional[Dict] = None,
|
|
158
|
-
model_to_finetune: Optional[
|
|
134
|
+
model_to_finetune: Optional[str] = None,
|
|
159
135
|
finetuning_epoch_fraction: float = 1.0,
|
|
160
136
|
remote_storage: Optional[StorageType] = None,
|
|
161
137
|
file_importer: Optional[TrainingDataImporter] = None,
|
|
162
138
|
keep_local_model_copy: bool = False,
|
|
163
139
|
remote_root_only: bool = False,
|
|
140
|
+
sub_agents: Optional[str] = None,
|
|
164
141
|
) -> TrainingResult:
|
|
165
142
|
"""Trains a Rasa model (Core and NLU).
|
|
166
143
|
|
|
167
144
|
Args:
|
|
168
145
|
domain: Path to the domain file.
|
|
169
146
|
config: Path to the config file.
|
|
147
|
+
endpoints: Path to the endpoints file.
|
|
170
148
|
training_files: List of paths to training data files.
|
|
171
149
|
output: Output directory for the trained model.
|
|
172
150
|
dry_run: If `True` then no training will be done, and the information about
|
|
@@ -190,10 +168,17 @@ async def train(
|
|
|
190
168
|
remote storage is configured.
|
|
191
169
|
remote_root_only: If `True`, the model will be stored in the root of the
|
|
192
170
|
remote model storage.
|
|
171
|
+
sub_agents: Path to sub-agents directory.
|
|
193
172
|
|
|
194
173
|
Returns:
|
|
195
174
|
An instance of `TrainingResult`.
|
|
196
175
|
"""
|
|
176
|
+
Configuration.initialise_message_processing(
|
|
177
|
+
message_processing_config_path=MessageProcessingConfigPath.validate(
|
|
178
|
+
Path(config)
|
|
179
|
+
)
|
|
180
|
+
).initialise_endpoints(endpoints_path=Path(endpoints))
|
|
181
|
+
|
|
197
182
|
if not file_importer:
|
|
198
183
|
file_importer = TrainingDataImporter.load_from_config(
|
|
199
184
|
config, domain, training_files, core_additional_arguments
|
|
@@ -278,6 +263,35 @@ async def train(
|
|
|
278
263
|
)
|
|
279
264
|
|
|
280
265
|
|
|
266
|
+
def _check_unresolved_slots(domain: Domain, stories: StoryGraph) -> None:
|
|
267
|
+
"""Checks if there are any unresolved slots.
|
|
268
|
+
|
|
269
|
+
Args:
|
|
270
|
+
domain: The domain.
|
|
271
|
+
stories: The story graph.
|
|
272
|
+
|
|
273
|
+
Raises:
|
|
274
|
+
`Sys exit` if there are any unresolved slots.
|
|
275
|
+
|
|
276
|
+
Returns:
|
|
277
|
+
`None` if there are no unresolved slots.
|
|
278
|
+
"""
|
|
279
|
+
unresolved_slots = get_unresolved_slots(domain, stories)
|
|
280
|
+
if unresolved_slots:
|
|
281
|
+
structlogger.error(
|
|
282
|
+
"model.training.check_unresolved_slots.not_in_domain",
|
|
283
|
+
slots=unresolved_slots,
|
|
284
|
+
event_info=(
|
|
285
|
+
f"Unresolved slots found in stories/rules🚨 \n"
|
|
286
|
+
f'Tried to set slots "{unresolved_slots}" that are not present in'
|
|
287
|
+
f"your domain.\n Check whether they need to be added to the domain or "
|
|
288
|
+
f"whether there is a spelling error."
|
|
289
|
+
),
|
|
290
|
+
)
|
|
291
|
+
rasa.shared.utils.common.display_research_study_prompt()
|
|
292
|
+
sys.exit(1)
|
|
293
|
+
|
|
294
|
+
|
|
281
295
|
async def _train_graph(
|
|
282
296
|
file_importer: TrainingDataImporter,
|
|
283
297
|
training_type: TrainingType,
|
|
@@ -292,24 +306,19 @@ async def _train_graph(
|
|
|
292
306
|
**kwargs: Any,
|
|
293
307
|
) -> TrainingResult:
|
|
294
308
|
if model_to_finetune:
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
"
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
),
|
|
304
|
-
)
|
|
305
|
-
rasa.shared.utils.common.display_research_study_prompt()
|
|
306
|
-
sys.exit(1)
|
|
307
|
-
|
|
308
|
-
rasa.shared.utils.common.mark_as_experimental_feature(
|
|
309
|
-
"Incremental Training feature"
|
|
309
|
+
structlogger.error(
|
|
310
|
+
"model_training.train.incremental_training_not_supported",
|
|
311
|
+
event_info=(
|
|
312
|
+
"Incremental training (--finetune) is "
|
|
313
|
+
"not supported in Rasa 3.14.0 onwards. "
|
|
314
|
+
"Please retrain your model from scratch "
|
|
315
|
+
"if you have updated your configuration. "
|
|
316
|
+
),
|
|
310
317
|
)
|
|
318
|
+
rasa.shared.utils.common.display_research_study_prompt()
|
|
319
|
+
sys.exit(1)
|
|
311
320
|
|
|
312
|
-
is_finetuning =
|
|
321
|
+
is_finetuning = False # Incremental training is not supported in Rasa 3.14.0+
|
|
313
322
|
|
|
314
323
|
config = file_importer.get_config()
|
|
315
324
|
recipe = Recipe.recipe_for_name(config.get(CONFIG_RECIPE_KEY))
|
|
@@ -573,6 +582,10 @@ async def train_nlu(
|
|
|
573
582
|
)
|
|
574
583
|
return None
|
|
575
584
|
|
|
585
|
+
Configuration.initialise_message_processing(
|
|
586
|
+
message_processing_config_path=Path(config),
|
|
587
|
+
).initialise_empty_endpoints()
|
|
588
|
+
|
|
576
589
|
return (
|
|
577
590
|
await _train_graph(
|
|
578
591
|
file_importer,
|
|
@@ -8,7 +8,13 @@ from typing import Any, Dict, List, Optional, Text, Tuple, Type, TypeVar, Union
|
|
|
8
8
|
|
|
9
9
|
import numpy as np
|
|
10
10
|
import scipy.sparse
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
from rasa.utils.tensorflow import TENSORFLOW_AVAILABLE
|
|
13
|
+
|
|
14
|
+
if TENSORFLOW_AVAILABLE:
|
|
15
|
+
import tensorflow as tf
|
|
16
|
+
else:
|
|
17
|
+
tf = None
|
|
12
18
|
|
|
13
19
|
import rasa.nlu.utils.bilou_utils as bilou_utils
|
|
14
20
|
import rasa.shared.utils.io
|
|
@@ -16,7 +22,6 @@ from rasa.engine.graph import ExecutionContext, GraphComponent
|
|
|
16
22
|
from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
17
23
|
from rasa.engine.storage.resource import Resource
|
|
18
24
|
from rasa.engine.storage.storage import ModelStorage
|
|
19
|
-
from rasa.exceptions import ModelNotFound
|
|
20
25
|
from rasa.nlu.classifiers import LABEL_RANKING_LENGTH
|
|
21
26
|
from rasa.nlu.classifiers.classifier import IntentClassifier
|
|
22
27
|
from rasa.nlu.constants import DEFAULT_TRANSFORMER_SIZE, TOKENS_NAMES
|
|
@@ -38,77 +43,155 @@ from rasa.shared.nlu.constants import (
|
|
|
38
43
|
)
|
|
39
44
|
from rasa.shared.nlu.training_data.message import Message
|
|
40
45
|
from rasa.shared.nlu.training_data.training_data import TrainingData
|
|
46
|
+
from rasa.shared.utils.io import raise_deprecation_warning
|
|
41
47
|
from rasa.utils import train_utils
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
48
|
+
|
|
49
|
+
if TENSORFLOW_AVAILABLE:
|
|
50
|
+
from rasa.utils.tensorflow import rasa_layers
|
|
51
|
+
else:
|
|
52
|
+
rasa_layers = None # type: ignore
|
|
53
|
+
if TENSORFLOW_AVAILABLE:
|
|
54
|
+
from rasa.utils.tensorflow.constants import (
|
|
55
|
+
AUTO,
|
|
56
|
+
BALANCED,
|
|
57
|
+
BATCH_SIZES,
|
|
58
|
+
BATCH_STRATEGY,
|
|
59
|
+
BILOU_FLAG,
|
|
60
|
+
CHECKPOINT_MODEL,
|
|
61
|
+
CONCAT_DIMENSION,
|
|
62
|
+
CONNECTION_DENSITY,
|
|
63
|
+
CONSTRAIN_SIMILARITIES,
|
|
64
|
+
CROSS_ENTROPY,
|
|
65
|
+
DENSE_DIMENSION,
|
|
66
|
+
DENSE_INPUT_DROPOUT,
|
|
67
|
+
DROP_RATE,
|
|
68
|
+
DROP_RATE_ATTENTION,
|
|
69
|
+
DROP_SMALL_LAST_BATCH,
|
|
70
|
+
EMBEDDING_DIMENSION,
|
|
71
|
+
ENTITY_RECOGNITION,
|
|
72
|
+
EPOCHS,
|
|
73
|
+
EVAL_NUM_EPOCHS,
|
|
74
|
+
EVAL_NUM_EXAMPLES,
|
|
75
|
+
FEATURIZERS,
|
|
76
|
+
HIDDEN_LAYERS_SIZES,
|
|
77
|
+
IDS,
|
|
78
|
+
INTENT_CLASSIFICATION,
|
|
79
|
+
KEY_RELATIVE_ATTENTION,
|
|
80
|
+
LABEL,
|
|
81
|
+
LEARNING_RATE,
|
|
82
|
+
LOSS_TYPE,
|
|
83
|
+
MASK,
|
|
84
|
+
MASKED_LM,
|
|
85
|
+
MAX_NEG_SIM,
|
|
86
|
+
MAX_POS_SIM,
|
|
87
|
+
MAX_RELATIVE_POSITION,
|
|
88
|
+
MODEL_CONFIDENCE,
|
|
89
|
+
NEGATIVE_MARGIN_SCALE,
|
|
90
|
+
NUM_HEADS,
|
|
91
|
+
NUM_NEG,
|
|
92
|
+
NUM_TRANSFORMER_LAYERS,
|
|
93
|
+
RANDOM_SEED,
|
|
94
|
+
RANKING_LENGTH,
|
|
95
|
+
REGULARIZATION_CONSTANT,
|
|
96
|
+
RENORMALIZE_CONFIDENCES,
|
|
97
|
+
RUN_EAGERLY,
|
|
98
|
+
SCALE_LOSS,
|
|
99
|
+
SENTENCE,
|
|
100
|
+
SEQUENCE,
|
|
101
|
+
SEQUENCE_LENGTH,
|
|
102
|
+
SHARE_HIDDEN_LAYERS,
|
|
103
|
+
SIMILARITY_TYPE,
|
|
104
|
+
SOFTMAX,
|
|
105
|
+
SPARSE_INPUT_DROPOUT,
|
|
106
|
+
TENSORBOARD_LOG_DIR,
|
|
107
|
+
TENSORBOARD_LOG_LEVEL,
|
|
108
|
+
TRANSFORMER_SIZE,
|
|
109
|
+
UNIDIRECTIONAL_ENCODER,
|
|
110
|
+
USE_MAX_NEG_SIM,
|
|
111
|
+
VALUE_RELATIVE_ATTENTION,
|
|
112
|
+
)
|
|
113
|
+
else:
|
|
114
|
+
# Placeholder values when TensorFlow is not available
|
|
115
|
+
AUTO = "auto"
|
|
116
|
+
BALANCED = "balanced"
|
|
117
|
+
BATCH_SIZES = "batch_sizes"
|
|
118
|
+
BATCH_STRATEGY = "batch_strategy"
|
|
119
|
+
BILOU_FLAG = "bilou_flag"
|
|
120
|
+
CHECKPOINT_MODEL = "checkpoint_model"
|
|
121
|
+
CONCAT_DIMENSION = "concat_dimension"
|
|
122
|
+
CONNECTION_DENSITY = "connection_density"
|
|
123
|
+
CONSTRAIN_SIMILARITIES = "constrain_similarities"
|
|
124
|
+
CROSS_ENTROPY = "cross_entropy"
|
|
125
|
+
DENSE_DIMENSION = "dense_dimension"
|
|
126
|
+
DENSE_INPUT_DROPOUT = "dense_input_dropout"
|
|
127
|
+
DROP_RATE = "drop_rate"
|
|
128
|
+
DROP_RATE_ATTENTION = "drop_rate_attention"
|
|
129
|
+
DROP_SMALL_LAST_BATCH = "drop_small_last_batch"
|
|
130
|
+
EMBEDDING_DIMENSION = "embedding_dimension"
|
|
131
|
+
ENTITY_RECOGNITION = "entity_recognition"
|
|
132
|
+
EPOCHS = "epochs"
|
|
133
|
+
EVAL_NUM_EPOCHS = "eval_num_epochs"
|
|
134
|
+
EVAL_NUM_EXAMPLES = "eval_num_examples"
|
|
135
|
+
FEATURIZERS = "featurizers"
|
|
136
|
+
HIDDEN_LAYERS_SIZES = "hidden_layers_sizes"
|
|
137
|
+
IDS = "ids"
|
|
138
|
+
INTENT_CLASSIFICATION = "intent_classification"
|
|
139
|
+
KEY_RELATIVE_ATTENTION = "key_relative_attention"
|
|
140
|
+
LABEL = "label"
|
|
141
|
+
LEARNING_RATE = "learning_rate"
|
|
142
|
+
LOSS_TYPE = "loss_type"
|
|
143
|
+
MASK = "mask"
|
|
144
|
+
MASKED_LM = "masked_lm"
|
|
145
|
+
MAX_NEG_SIM = "max_neg_sim"
|
|
146
|
+
MAX_POS_SIM = "max_pos_sim"
|
|
147
|
+
MAX_RELATIVE_POSITION = "max_relative_position"
|
|
148
|
+
MODEL_CONFIDENCE = "model_confidence"
|
|
149
|
+
NEGATIVE_MARGIN_SCALE = "negative_margin_scale"
|
|
150
|
+
NUM_HEADS = "num_heads"
|
|
151
|
+
NUM_NEG = "num_neg"
|
|
152
|
+
NUM_TRANSFORMER_LAYERS = "num_transformer_layers"
|
|
153
|
+
RANDOM_SEED = "random_seed"
|
|
154
|
+
RANKING_LENGTH = "ranking_length"
|
|
155
|
+
REGULARIZATION_CONSTANT = "regularization_constant"
|
|
156
|
+
RENORMALIZE_CONFIDENCES = "renormalize_confidences"
|
|
157
|
+
RUN_EAGERLY = "run_eagerly"
|
|
158
|
+
SCALE_LOSS = "scale_loss"
|
|
159
|
+
SENTENCE = "sentence"
|
|
160
|
+
SEQUENCE = "sequence"
|
|
161
|
+
SEQUENCE_LENGTH = "sequence_length"
|
|
162
|
+
SHARE_HIDDEN_LAYERS = "share_hidden_layers"
|
|
163
|
+
SIMILARITY_TYPE = "similarity_type"
|
|
164
|
+
SOFTMAX = "softmax"
|
|
165
|
+
SPARSE_INPUT_DROPOUT = "sparse_input_dropout"
|
|
166
|
+
TENSORBOARD_LOG_DIR = "tensorboard_log_dir"
|
|
167
|
+
TENSORBOARD_LOG_LEVEL = "tensorboard_log_level"
|
|
168
|
+
TRANSFORMER_SIZE = "transformer_size"
|
|
169
|
+
UNIDIRECTIONAL_ENCODER = "unidirectional_encoder"
|
|
170
|
+
USE_MAX_NEG_SIM = "use_max_neg_sim"
|
|
171
|
+
VALUE_RELATIVE_ATTENTION = "value_relative_attention"
|
|
172
|
+
if TENSORFLOW_AVAILABLE:
|
|
173
|
+
from rasa.utils.tensorflow.feature_array import (
|
|
174
|
+
FeatureArray,
|
|
175
|
+
deserialize_nested_feature_arrays,
|
|
176
|
+
serialize_nested_feature_arrays,
|
|
177
|
+
)
|
|
178
|
+
else:
|
|
179
|
+
FeatureArray = None # type: ignore
|
|
180
|
+
deserialize_nested_feature_arrays = None # type: ignore
|
|
181
|
+
serialize_nested_feature_arrays = None # type: ignore
|
|
182
|
+
if TENSORFLOW_AVAILABLE:
|
|
183
|
+
from rasa.utils.tensorflow.model_data import (
|
|
184
|
+
FeatureSignature,
|
|
185
|
+
RasaModelData,
|
|
186
|
+
)
|
|
187
|
+
else:
|
|
188
|
+
FeatureSignature = None # type: ignore
|
|
189
|
+
RasaModelData = None # type: ignore
|
|
190
|
+
if TENSORFLOW_AVAILABLE:
|
|
191
|
+
from rasa.utils.tensorflow.models import RasaModel, TransformerRasaModel
|
|
192
|
+
else:
|
|
193
|
+
RasaModel = None # type: ignore
|
|
194
|
+
TransformerRasaModel = None # type: ignore
|
|
112
195
|
|
|
113
196
|
logger = logging.getLogger(__name__)
|
|
114
197
|
|
|
@@ -306,6 +389,9 @@ class DIETClassifier(GraphComponent, IntentClassifier, EntityExtractorMixin):
|
|
|
306
389
|
sparse_feature_sizes: Optional[Dict[Text, Dict[Text, List[int]]]] = None,
|
|
307
390
|
) -> None:
|
|
308
391
|
"""Declare instance variables with default values."""
|
|
392
|
+
raise_deprecation_warning(
|
|
393
|
+
"DIETClassifier is deprecated and will be removed in a future version."
|
|
394
|
+
)
|
|
309
395
|
if EPOCHS not in config:
|
|
310
396
|
rasa.shared.utils.io.raise_warning(
|
|
311
397
|
f"Please configure the number of '{EPOCHS}' in your configuration file."
|
|
@@ -906,24 +992,16 @@ class DIETClassifier(GraphComponent, IntentClassifier, EntityExtractorMixin):
|
|
|
906
992
|
# keep one example for persisting and loading
|
|
907
993
|
self._data_example = model_data.first_data_example()
|
|
908
994
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
else:
|
|
919
|
-
if self.model is None:
|
|
920
|
-
raise ModelNotFound("Model could not be found. ")
|
|
995
|
+
# as the keras 2.15 does not allow updating a compiled model anymore,
|
|
996
|
+
# we cannot support finetune mode anymore
|
|
997
|
+
|
|
998
|
+
# Create a new instance of the model.
|
|
999
|
+
self.model = self._instantiate_model_class(model_data)
|
|
1000
|
+
self.model.compile(
|
|
1001
|
+
optimizer=tf.keras.optimizers.Adam(self.component_config[LEARNING_RATE]),
|
|
1002
|
+
run_eagerly=self.component_config[RUN_EAGERLY],
|
|
1003
|
+
)
|
|
921
1004
|
|
|
922
|
-
self.model.adjust_for_incremental_training(
|
|
923
|
-
data_example=self._data_example,
|
|
924
|
-
new_sparse_feature_sizes=model_data.get_sparse_feature_sizes(),
|
|
925
|
-
old_sparse_feature_sizes=self._sparse_feature_sizes,
|
|
926
|
-
)
|
|
927
1005
|
self._sparse_feature_sizes = model_data.get_sparse_feature_sizes()
|
|
928
1006
|
|
|
929
1007
|
data_generator, validation_data_generator = train_utils.create_data_generators(
|
|
@@ -1070,12 +1148,14 @@ class DIETClassifier(GraphComponent, IntentClassifier, EntityExtractorMixin):
|
|
|
1070
1148
|
|
|
1071
1149
|
with self._model_storage.write_to(self._resource) as model_path:
|
|
1072
1150
|
file_name = self.__class__.__name__
|
|
1073
|
-
tf_model_file = model_path / f"{file_name}.
|
|
1151
|
+
tf_model_file = model_path / f"{file_name}.weights.h5"
|
|
1074
1152
|
|
|
1075
1153
|
rasa.shared.utils.io.create_directory_for_file(tf_model_file)
|
|
1076
1154
|
|
|
1077
1155
|
if self.component_config[CHECKPOINT_MODEL] and self.tmp_checkpoint_dir:
|
|
1078
|
-
self.model.load_weights(
|
|
1156
|
+
self.model.load_weights(
|
|
1157
|
+
self.tmp_checkpoint_dir / "checkpoint.weights.h5"
|
|
1158
|
+
)
|
|
1079
1159
|
# Save an empty file to flag that this model has been
|
|
1080
1160
|
# produced using checkpointing
|
|
1081
1161
|
checkpoint_marker = model_path / f"{file_name}.from_checkpoint.pkl"
|
|
@@ -1247,7 +1327,7 @@ class DIETClassifier(GraphComponent, IntentClassifier, EntityExtractorMixin):
|
|
|
1247
1327
|
finetune_mode: bool = False,
|
|
1248
1328
|
) -> "RasaModel":
|
|
1249
1329
|
file_name = cls.__name__
|
|
1250
|
-
tf_model_file = model_path / f"{file_name}.
|
|
1330
|
+
tf_model_file = model_path / f"{file_name}.weights.h5"
|
|
1251
1331
|
|
|
1252
1332
|
label_key = LABEL_KEY if config[INTENT_CLASSIFICATION] else None
|
|
1253
1333
|
label_sub_key = LABEL_SUB_KEY if config[INTENT_CLASSIFICATION] else None
|
|
@@ -1306,7 +1386,7 @@ class DIETClassifier(GraphComponent, IntentClassifier, EntityExtractorMixin):
|
|
|
1306
1386
|
)
|
|
1307
1387
|
|
|
1308
1388
|
|
|
1309
|
-
class DIET(TransformerRasaModel):
|
|
1389
|
+
class DIET(TransformerRasaModel if TENSORFLOW_AVAILABLE else object): # type: ignore[misc]
|
|
1310
1390
|
def __init__(
|
|
1311
1391
|
self,
|
|
1312
1392
|
data_signature: Dict[Text, Dict[Text, List[FeatureSignature]]],
|
|
@@ -1314,6 +1394,8 @@ class DIET(TransformerRasaModel):
|
|
|
1314
1394
|
entity_tag_specs: Optional[List[EntityTagSpec]],
|
|
1315
1395
|
config: Dict[Text, Any],
|
|
1316
1396
|
) -> None:
|
|
1397
|
+
if not TENSORFLOW_AVAILABLE:
|
|
1398
|
+
raise RuntimeError("DIET classifier requires TensorFlow to be installed")
|
|
1317
1399
|
# create entity tag spec before calling super otherwise building the model
|
|
1318
1400
|
# will fail
|
|
1319
1401
|
super().__init__("DIET", config, data_signature, label_data)
|
|
@@ -1527,7 +1609,7 @@ class DIET(TransformerRasaModel):
|
|
|
1527
1609
|
# convert to bag-of-words by summing along the sequence dimension
|
|
1528
1610
|
x = tf.reduce_sum(x, axis=1)
|
|
1529
1611
|
|
|
1530
|
-
return self._tf_layers[f"ffnn.{name}"](x, self._training)
|
|
1612
|
+
return self._tf_layers[f"ffnn.{name}"](x, training=self._training)
|
|
1531
1613
|
|
|
1532
1614
|
def _create_all_labels(self) -> Tuple[tf.Tensor, tf.Tensor]:
|
|
1533
1615
|
all_label_ids = self.tf_label_data[LABEL_KEY][LABEL_SUB_KEY][0]
|
|
@@ -1536,9 +1618,23 @@ class DIET(TransformerRasaModel):
|
|
|
1536
1618
|
self.tf_label_data, LABEL
|
|
1537
1619
|
)
|
|
1538
1620
|
|
|
1621
|
+
# Check if SENTENCE features exist, if not use None
|
|
1622
|
+
# This is needed for compatibility with tensorFlow=2.19.1, which
|
|
1623
|
+
# has a transitive dependency on keras=3.11.3, which introduces
|
|
1624
|
+
# stricter data validation
|
|
1625
|
+
sentence_features = None
|
|
1626
|
+
if SENTENCE in self.tf_label_data[LABEL]:
|
|
1627
|
+
sentence_features = self.tf_label_data[LABEL][SENTENCE]
|
|
1628
|
+
|
|
1629
|
+
# Handle missing SEQUENCE features for Keras 3+ compatibility,
|
|
1630
|
+
# which introduces stricter data validation
|
|
1631
|
+
sequence_features = None
|
|
1632
|
+
if SEQUENCE in self.tf_label_data[LABEL]:
|
|
1633
|
+
sequence_features = self.tf_label_data[LABEL][SEQUENCE]
|
|
1634
|
+
|
|
1539
1635
|
x = self._create_bow(
|
|
1540
|
-
|
|
1541
|
-
|
|
1636
|
+
sequence_features,
|
|
1637
|
+
sentence_features,
|
|
1542
1638
|
sequence_feature_lengths,
|
|
1543
1639
|
self.label_name,
|
|
1544
1640
|
)
|
|
@@ -1797,8 +1893,12 @@ class DIET(TransformerRasaModel):
|
|
|
1797
1893
|
)
|
|
1798
1894
|
predictions = {
|
|
1799
1895
|
DIAGNOSTIC_DATA: {
|
|
1800
|
-
"attention_weights": attention_weights
|
|
1801
|
-
"
|
|
1896
|
+
"attention_weights": attention_weights.numpy()
|
|
1897
|
+
if hasattr(attention_weights, "numpy")
|
|
1898
|
+
else attention_weights,
|
|
1899
|
+
"text_transformed": text_transformed.numpy()
|
|
1900
|
+
if hasattr(text_transformed, "numpy")
|
|
1901
|
+
else text_transformed,
|
|
1802
1902
|
}
|
|
1803
1903
|
}
|
|
1804
1904
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import Any, Dict, List, Text, Tuple, Type
|
|
2
2
|
|
|
3
|
+
import skops.io as sio
|
|
3
4
|
import structlog
|
|
4
5
|
from scipy.sparse import csr_matrix, hstack, vstack
|
|
5
6
|
from sklearn.exceptions import NotFittedError
|
|
@@ -183,8 +184,6 @@ class LogisticRegressionClassifier(IntentClassifier, GraphComponent):
|
|
|
183
184
|
|
|
184
185
|
def persist(self) -> None:
|
|
185
186
|
"""Persist this model into the passed directory."""
|
|
186
|
-
import skops.io as sio
|
|
187
|
-
|
|
188
187
|
with self._model_storage.write_to(self._resource) as model_dir:
|
|
189
188
|
path = model_dir / f"{self._resource.name}.skops"
|
|
190
189
|
sio.dump(self.clf, path)
|
|
@@ -203,8 +202,6 @@ class LogisticRegressionClassifier(IntentClassifier, GraphComponent):
|
|
|
203
202
|
**kwargs: Any,
|
|
204
203
|
) -> "LogisticRegressionClassifier":
|
|
205
204
|
"""Loads trained component (see parent class for full docstring)."""
|
|
206
|
-
import skops.io as sio
|
|
207
|
-
|
|
208
205
|
try:
|
|
209
206
|
with model_storage.read_from(resource) as model_dir:
|
|
210
207
|
classifier_file = model_dir / f"{resource.name}.skops"
|
|
@@ -4,6 +4,9 @@ import logging
|
|
|
4
4
|
import typing
|
|
5
5
|
from typing import Any, Dict, List, Optional, Text, Type
|
|
6
6
|
|
|
7
|
+
# importing mitie at module level to ensure error is raised if mitie is not installed
|
|
8
|
+
import mitie
|
|
9
|
+
|
|
7
10
|
from rasa.engine.graph import ExecutionContext, GraphComponent
|
|
8
11
|
from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
9
12
|
from rasa.engine.storage.resource import Resource
|
|
@@ -6,6 +6,7 @@ import warnings
|
|
|
6
6
|
from typing import Any, Dict, List, Optional, Text, Tuple, Type
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
|
+
import skops.io as sio
|
|
9
10
|
|
|
10
11
|
import rasa.shared.utils.io
|
|
11
12
|
from rasa.engine.graph import ExecutionContext, GraphComponent
|
|
@@ -266,8 +267,6 @@ class SklearnIntentClassifier(GraphComponent, IntentClassifier):
|
|
|
266
267
|
|
|
267
268
|
def persist(self) -> None:
|
|
268
269
|
"""Persist this model into the passed directory."""
|
|
269
|
-
import skops.io as sio
|
|
270
|
-
|
|
271
270
|
with self._model_storage.write_to(self._resource) as model_dir:
|
|
272
271
|
file_name = self.__class__.__name__
|
|
273
272
|
classifier_file_name = model_dir / f"{file_name}_classifier.skops"
|
|
@@ -291,7 +290,6 @@ class SklearnIntentClassifier(GraphComponent, IntentClassifier):
|
|
|
291
290
|
**kwargs: Any,
|
|
292
291
|
) -> SklearnIntentClassifier:
|
|
293
292
|
"""Loads trained component (see parent class for full docstring)."""
|
|
294
|
-
import skops.io as sio
|
|
295
293
|
from sklearn.preprocessing import LabelEncoder
|
|
296
294
|
|
|
297
295
|
try:
|
|
@@ -10,6 +10,9 @@ from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Type
|
|
|
10
10
|
|
|
11
11
|
import numpy as np
|
|
12
12
|
|
|
13
|
+
# importing sklearn_crfsuite at module level to raise error if not installed
|
|
14
|
+
import sklearn_crfsuite
|
|
15
|
+
|
|
13
16
|
import rasa.nlu.utils.bilou_utils as bilou_utils
|
|
14
17
|
import rasa.shared.utils.io
|
|
15
18
|
import rasa.utils.train_utils
|
|
@@ -20,7 +23,6 @@ from rasa.engine.storage.storage import ModelStorage
|
|
|
20
23
|
from rasa.nlu.constants import TOKENS_NAMES
|
|
21
24
|
from rasa.nlu.extractors.extractor import EntityExtractorMixin
|
|
22
25
|
from rasa.nlu.test import determine_token_labels
|
|
23
|
-
from rasa.nlu.tokenizers.spacy_tokenizer import POS_TAG_KEY
|
|
24
26
|
from rasa.nlu.tokenizers.tokenizer import Token, Tokenizer
|
|
25
27
|
from rasa.shared.constants import DOCS_URL_COMPONENTS
|
|
26
28
|
from rasa.shared.nlu.constants import (
|
|
@@ -37,6 +39,8 @@ from rasa.shared.nlu.training_data.message import Message
|
|
|
37
39
|
from rasa.shared.nlu.training_data.training_data import TrainingData
|
|
38
40
|
from rasa.utils.tensorflow.constants import BILOU_FLAG, FEATURIZERS
|
|
39
41
|
|
|
42
|
+
POS_TAG_KEY = "pos"
|
|
43
|
+
|
|
40
44
|
logger = logging.getLogger(__name__)
|
|
41
45
|
|
|
42
46
|
if typing.TYPE_CHECKING:
|
|
@@ -445,13 +449,11 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
|
|
|
445
449
|
def _load_taggers(
|
|
446
450
|
cls, model_dir: Path, config: Dict[Text, Any]
|
|
447
451
|
) -> Dict[str, "CRF"]:
|
|
448
|
-
"""
|
|
449
|
-
Load taggers from model directory that persists trained binary
|
|
450
|
-
`model.crfsuite` files.
|
|
451
|
-
"""
|
|
452
|
+
"""Load taggers from model directory.
|
|
452
453
|
|
|
454
|
+
It persists trained binary `model.crfsuite` files.
|
|
455
|
+
"""
|
|
453
456
|
import pycrfsuite
|
|
454
|
-
import sklearn_crfsuite
|
|
455
457
|
|
|
456
458
|
# Get tagger directories
|
|
457
459
|
taggers_base = model_dir / TAGGERS_DIR
|
|
@@ -613,8 +615,7 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
|
|
|
613
615
|
|
|
614
616
|
@staticmethod
|
|
615
617
|
def _pattern_of_token(message: Message, idx: int) -> Dict[Text, bool]:
|
|
616
|
-
"""Get
|
|
617
|
-
'RegexFeaturizer'.
|
|
618
|
+
"""Get patterns of token at the given index extracted by 'RegexFeaturizer'.
|
|
618
619
|
|
|
619
620
|
The 'RegexFeaturizer' adds all patterns listed in the training data to the
|
|
620
621
|
token. The pattern name is mapped to either 'True' (pattern applies to token) or
|
|
@@ -728,8 +729,6 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
|
|
|
728
729
|
crf_order: List[str],
|
|
729
730
|
) -> OrderedDict[str, CRF]:
|
|
730
731
|
"""Train the crf tagger based on the training data."""
|
|
731
|
-
import sklearn_crfsuite
|
|
732
|
-
|
|
733
732
|
entity_taggers = OrderedDict()
|
|
734
733
|
|
|
735
734
|
for tag_name in crf_order:
|