rasa-pro 3.22.0.dev3__py3-none-any.whl → 3.22.0.dev4__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.
- rasa/api/__init__.py +8 -0
- rasa/api/brokers/__init__.py +6 -0
- rasa/api/brokers/_conversation_key.py +29 -0
- rasa/api/brokers/_factory.py +173 -0
- rasa/api/brokers/_sql.py +36 -0
- rasa/api/brokers/v1/__init__.py +28 -0
- rasa/api/brokers/v1/base.py +56 -0
- rasa/api/brokers/v1/file.py +70 -0
- rasa/{core/brokers → api/brokers/v1}/http.py +59 -42
- rasa/api/brokers/v1/kafka.py +578 -0
- rasa/api/brokers/v1/pika.py +436 -0
- rasa/api/brokers/v1/sql.py +98 -0
- rasa/api/brokers/v1/types.py +49 -0
- rasa/api/channels/__init__.py +6 -0
- rasa/api/channels/_auth.py +105 -0
- rasa/api/channels/_collector.py +11 -0
- rasa/api/channels/_credentials.py +39 -0
- rasa/api/channels/_factory.py +237 -0
- rasa/api/channels/_response.py +188 -0
- rasa/api/channels/_runtime.py +113 -0
- rasa/api/channels/v1/__init__.py +33 -0
- rasa/api/channels/v1/base.py +320 -0
- rasa/api/channels/v1/botframework.py +348 -0
- rasa/api/channels/v1/collector.py +99 -0
- rasa/api/channels/v1/facebook.py +441 -0
- rasa/api/channels/v1/hangouts.py +336 -0
- rasa/api/channels/v1/mattermost.py +240 -0
- rasa/api/channels/v1/rocketchat.py +187 -0
- rasa/api/channels/v1/slack.py +714 -0
- rasa/api/channels/v1/socketio.py +579 -0
- rasa/api/channels/v1/telegram.py +375 -0
- rasa/api/channels/v1/twilio.py +225 -0
- rasa/api/channels/v1/twilio_utils.py +29 -0
- rasa/api/channels/v1/types.py +100 -0
- rasa/api/channels/v1/vier_cvg.py +419 -0
- rasa/api/channels/v1/voice_ready/__init__.py +1 -0
- rasa/api/channels/v1/voice_ready/audiocodes.py +457 -0
- rasa/api/channels/v1/voice_ready/jambonz.py +144 -0
- rasa/api/channels/v1/voice_ready/twilio_voice.py +494 -0
- rasa/api/channels/v1/voice_stream/__init__.py +1 -0
- rasa/api/channels/v1/voice_stream/audiocodes.py +397 -0
- rasa/api/channels/v1/voice_stream/chirp.py +334 -0
- rasa/api/channels/v1/voice_stream/genesys.py +475 -0
- rasa/api/channels/v1/voice_stream/jambonz.py +283 -0
- rasa/api/channels/v1/voice_stream/signalwire.py +504 -0
- rasa/api/channels/v1/voice_stream/twilio_media_streams.py +381 -0
- rasa/api/channels/v1/voice_stream/voice_channel.py +2515 -0
- rasa/api/channels/v1/voice_stream/vonage.py +440 -0
- rasa/api/channels/v1/webexteams.py +146 -0
- rasa/api/endpoints/__init__.py +7 -0
- rasa/api/endpoints/v1/__init__.py +14 -0
- rasa/api/knowledge/__init__.py +6 -0
- rasa/api/knowledge/_factory.py +111 -0
- rasa/api/knowledge/v1/__init__.py +40 -0
- rasa/api/knowledge/v1/base.py +33 -0
- rasa/api/knowledge/v1/embeddings.py +24 -0
- rasa/api/knowledge/v1/exceptions.py +16 -0
- rasa/api/knowledge/v1/faiss/__init__.py +49 -0
- rasa/api/knowledge/v1/faiss/constants.py +32 -0
- rasa/api/knowledge/v1/faiss/exceptions.py +25 -0
- rasa/api/knowledge/v1/faiss/knowledge.py +423 -0
- rasa/api/knowledge/v1/milvus/__init__.py +32 -0
- rasa/api/knowledge/v1/milvus/constants.py +15 -0
- rasa/api/knowledge/v1/milvus/knowledge.py +173 -0
- rasa/api/knowledge/v1/qdrant/__init__.py +35 -0
- rasa/api/knowledge/v1/qdrant/constants.py +11 -0
- rasa/api/knowledge/v1/qdrant/exceptions.py +13 -0
- rasa/api/knowledge/v1/qdrant/knowledge.py +118 -0
- rasa/api/knowledge/v1/types.py +74 -0
- rasa/api/locks/__init__.py +6 -0
- rasa/api/locks/_factory.py +114 -0
- rasa/api/locks/_ticket_lock.py +183 -0
- rasa/api/locks/v1/__init__.py +35 -0
- rasa/api/locks/v1/base.py +57 -0
- rasa/api/locks/v1/concurrent.py +303 -0
- rasa/api/locks/v1/exceptions.py +12 -0
- rasa/api/locks/v1/in_memory.py +34 -0
- rasa/api/locks/v1/redis.py +206 -0
- rasa/api/locks/v1/types.py +123 -0
- rasa/api/timers/__init__.py +6 -0
- rasa/api/timers/_factory.py +120 -0
- rasa/api/timers/v1/__init__.py +27 -0
- rasa/api/timers/v1/_helpers.py +33 -0
- rasa/api/timers/v1/base.py +63 -0
- rasa/api/timers/v1/in_memory.py +74 -0
- rasa/api/timers/v1/redis.py +353 -0
- rasa/api/timers/v1/types.py +68 -0
- rasa/api/tracker/__init__.py +6 -0
- rasa/api/tracker/_exceptions.py +12 -0
- rasa/api/tracker/_factory.py +213 -0
- rasa/api/tracker/_lifecycle.py +416 -0
- rasa/api/tracker/_serialisation.py +147 -0
- rasa/api/tracker/_storage_context.py +87 -0
- rasa/api/tracker/v1/__init__.py +57 -0
- rasa/api/tracker/v1/base.py +58 -0
- rasa/api/tracker/v1/dynamo.py +702 -0
- rasa/api/tracker/v1/exceptions.py +7 -0
- rasa/api/tracker/v1/in_memory.py +126 -0
- rasa/api/tracker/v1/mongo.py +467 -0
- rasa/api/tracker/v1/redis.py +579 -0
- rasa/api/tracker/v1/sql.py +1718 -0
- rasa/api/tracker/v1/types.py +21 -0
- rasa/api/versioning/__init__.py +45 -0
- rasa/api/versioning/discover.py +176 -0
- rasa/api/versioning/exceptions.py +25 -0
- rasa/api/versioning/resolve.py +152 -0
- rasa/api/voice/__init__.py +6 -0
- rasa/api/voice/_speech_api_key.py +113 -0
- rasa/api/voice/asr/__init__.py +6 -0
- rasa/api/voice/asr/_builtins.py +46 -0
- rasa/api/voice/asr/_factory.py +35 -0
- rasa/api/voice/asr/v1/__init__.py +66 -0
- rasa/api/voice/asr/v1/azure/__init__.py +21 -0
- rasa/api/voice/asr/v1/azure/config.py +43 -0
- rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/azure/engine.py +7 -7
- rasa/api/voice/asr/v1/base.py +469 -0
- rasa/api/voice/asr/v1/deepgram/__init__.py +39 -0
- rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/base.py +23 -7
- rasa/api/voice/asr/v1/deepgram/config.py +60 -0
- rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/constants.py +2 -1
- rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/flux.py +5 -5
- rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/nova.py +3 -3
- rasa/api/voice/asr/v1/deepgram_flux.py +17 -0
- rasa/api/voice/asr/v1/elevenlabs.py +246 -0
- rasa/api/voice/asr/v1/events.py +23 -0
- rasa/api/voice/asr/v1/speechmatics.py +311 -0
- rasa/api/voice/tts/__init__.py +6 -0
- rasa/api/voice/tts/_builtins.py +53 -0
- rasa/api/voice/tts/_factory.py +35 -0
- rasa/api/voice/tts/v1/__init__.py +65 -0
- rasa/api/voice/tts/v1/azure.py +565 -0
- rasa/api/voice/tts/v1/base.py +844 -0
- rasa/api/voice/tts/v1/cartesia.py +279 -0
- rasa/api/voice/tts/v1/config.py +12 -0
- rasa/api/voice/tts/v1/deepgram.py +242 -0
- rasa/api/voice/tts/v1/deepgram_flux.py +301 -0
- rasa/api/voice/tts/v1/elevenlabs.py +502 -0
- rasa/api/voice/tts/v1/rime.py +406 -0
- rasa/api/voice/v1/__init__.py +31 -0
- rasa/api/voice/v1/audio.py +120 -0
- rasa/builder/agent_skills.py +42 -16
- rasa/builder/branches.py +278 -16
- rasa/builder/config.py +1 -1
- rasa/builder/copilot/constants.py +3 -0
- rasa/builder/copilot/file_operations.py +295 -0
- rasa/builder/copilot/mcp_server/models.py +8 -0
- rasa/builder/copilot/mcp_server/tools/event_ledger.py +54 -10
- rasa/builder/copilot/mcp_server/tools/llm_judge_models.py +1 -1
- rasa/builder/copilot/modes/AGENTS.md +1 -1
- rasa/builder/copilot/modes/eval/AGENTS.md +15 -0
- rasa/builder/copilot/modes/eval/__init__.py +0 -0
- rasa/builder/copilot/modes/eval/actions.py +169 -0
- rasa/builder/copilot/modes/eval/capability.py +44 -0
- rasa/builder/copilot/modes/eval/cards.py +161 -0
- rasa/builder/copilot/modes/eval/job.py +232 -0
- rasa/builder/copilot/modes/eval/models.py +5 -0
- rasa/builder/copilot/modes/eval/sessions.py +36 -0
- rasa/builder/copilot/modes/plan/AGENTS.md +1 -1
- rasa/builder/copilot/modes/plan/build_job.py +109 -109
- rasa/builder/copilot/modes/plan/build_steps.py +12 -1
- rasa/builder/copilot/modes/plan/capability.py +14 -4
- rasa/builder/copilot/modes/registry.py +9 -2
- rasa/builder/copilot/prompts/evaluation_criteria_judge_prompt.jinja2 +2 -1
- rasa/builder/copilot/pydantic_ai/agent.py +10 -41
- rasa/builder/copilot/pydantic_ai/branch_tool.py +3 -3
- rasa/builder/copilot/pydantic_ai/config.py +1 -1
- rasa/builder/copilot/pydantic_ai/file_tools.py +87 -1
- rasa/builder/copilot/pydantic_ai/mcp_calls.py +53 -0
- rasa/builder/copilot/pydantic_ai/model_registry.py +86 -78
- rasa/builder/copilot/pydantic_ai/prompt_loader.py +36 -27
- rasa/builder/copilot/skill_catalog.py +15 -0
- rasa/builder/copilot/skills/mantle/building-from-conversations/SKILL.md +5 -3
- rasa/builder/copilot/skills/mantle/building-skills/SKILL.md +24 -9
- rasa/builder/copilot/skills/mantle/building-skills/references/control-levers.md +2 -2
- rasa/builder/copilot/skills/mantle/building-skills/references/responses.md +2 -2
- rasa/builder/copilot/skills/mantle/building-skills/references/tools.md +6 -2
- rasa/builder/copilot/skills/mantle/configuring-agent/SKILL.md +7 -5
- rasa/builder/copilot/skills/mantle/configuring-agent/references/agent-yml.md +1 -1
- rasa/builder/copilot/skills/mantle/configuring-agent/references/integrations-yml.md +9 -5
- rasa/builder/copilot/skills/mantle/migrating-from-calm/SKILL.md +6 -5
- rasa/builder/copilot/skills/mantle/simulating-evaluating/SKILL.md +8 -7
- rasa/builder/copilot/skills/mantle/simulating-evaluating/references/assertions.md +1 -1
- rasa/builder/copilot/subagents/AGENTS.md +4 -1
- rasa/builder/copilot/subagents/base.py +5 -0
- rasa/builder/copilot/subagents/builder/agent.py +15 -97
- rasa/builder/copilot/subagents/evaluation.py +40 -0
- rasa/builder/copilot/subagents/evaluator/__init__.py +0 -0
- rasa/builder/copilot/subagents/evaluator/agent.py +289 -0
- rasa/builder/copilot/subagents/model_choice.py +2 -2
- rasa/builder/copilot/subagents/planner/agent.py +40 -4
- rasa/builder/copilot/subagents/project_validation.py +110 -0
- rasa/builder/copilot/subagents/registry.py +6 -1
- rasa/builder/document_retrieval/local/data/docs_vectors.parquet +0 -0
- rasa/builder/document_retrieval/local/data/mantle_docs_vectors.parquet +0 -0
- rasa/builder/exceptions.py +10 -2
- rasa/builder/job_runner.py +31 -1
- rasa/builder/models.py +36 -4
- rasa/builder/project_generator/project_generator.py +2 -2
- rasa/builder/service.py +69 -1
- rasa/builder/validation_service.py +32 -2
- rasa/cli/export.py +41 -9
- rasa/cli/project_templates/mantle/AGENTS.md +16 -0
- rasa/cli/project_templates/mantle/skills/view_transactions/skill.md +4 -4
- rasa/cli/run.py +1 -1
- rasa/cli/scaffold.py +1 -1
- rasa/cli/tools/skills_data/mantle/mantle-building-from-conversations/SKILL.md +8 -1
- rasa/cli/tools/skills_data/mantle/mantle-building-skills/SKILL.md +35 -11
- rasa/cli/tools/skills_data/mantle/mantle-configuring-agent/SKILL.md +18 -10
- rasa/cli/tools/skills_data/mantle/mantle-simulating-evaluating/SKILL.md +6 -5
- rasa/cli/tools/skills_data/mantle/mantle-testing-debugging/SKILL.md +2 -1
- rasa/cli/train.py +1 -1
- rasa/core/a2a_server/rasa_a2a_agent_executor.py +11 -5
- rasa/core/agent.py +88 -28
- rasa/core/brokers/broker.py +45 -16
- rasa/core/brokers/broker_only_metadata.py +38 -0
- rasa/core/brokers/file.py +11 -34
- rasa/core/brokers/kafka.py +59 -543
- rasa/core/brokers/pika.py +34 -351
- rasa/core/brokers/sql.py +19 -62
- rasa/core/channels/__init__.py +181 -120
- rasa/core/channels/botframework.py +11 -330
- rasa/core/channels/callback.py +8 -6
- rasa/core/channels/channel.py +89 -1066
- rasa/core/channels/console.py +6 -3
- rasa/core/channels/development_inspector.py +10 -8
- rasa/core/channels/facebook.py +11 -421
- rasa/core/channels/hangouts.py +11 -323
- rasa/core/channels/inspector-nextgen/dist/assets/{index--9qSkQVO.js → index-B9poI8Mv.js} +66 -66
- rasa/core/channels/inspector-nextgen/dist/index.html +1 -1
- rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/card_disambiguation/skill.md +1 -1
- rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/card_replace/skill.md +13 -13
- rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/card_replace/tools.py +5 -5
- rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/close_savings_account/tools.py +1 -1
- rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/travel_notice/skill.md +2 -2
- rasa/core/channels/inspector-nextgen/src/Icon/index.ts +2 -0
- rasa/core/channels/inspector-nextgen/src/assets/images/index.ts +1 -3
- rasa/core/channels/inspector-nextgen/src/components/EventInfo/BargeInEventInfo.test.tsx +4 -5
- rasa/core/channels/inspector-nextgen/src/components/EventInfo/BargeInEventInfo.tsx +7 -22
- rasa/core/channels/inspector-nextgen/src/components/EventInfo/LlmCallEventInfo.test.tsx +3 -3
- rasa/core/channels/inspector-nextgen/src/components/EventInfo/OrderedBlockEventInfo.test.tsx +1 -0
- rasa/core/channels/inspector-nextgen/src/components/EventInfo/SkillEventInfo.test.tsx +20 -1
- rasa/core/channels/inspector-nextgen/src/components/EventInfo/SkillEventInfo.tsx +21 -13
- rasa/core/channels/inspector-nextgen/src/hooks/useBotConnection.test.ts +1 -0
- rasa/core/channels/inspector-nextgen/src/store/selectors.test.ts +2 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/BargeInEvent.test.tsx +50 -8
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/BargeInEvent.tsx +3 -13
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/FlowEvent.test.tsx +1 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/OrderedBlockEvent.test.tsx +1 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/SkillEvent.test.tsx +1 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Message/MessageMarkup.test.tsx +12 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Message/MessageMarkup.tsx +3 -2
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/groupEventsByToolCall.test.ts +61 -17
- rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/groupEventsByToolCall.ts +24 -17
- rasa/core/channels/inspector-nextgen/src/try-assistant/MiddlePane.test.tsx +1 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/SkillMemoryDetails.test.tsx +1 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/ReferenceTag.tsx +5 -1
- rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/SkillSection.test.tsx +30 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/SkillSection.tsx +10 -2
- rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/deriveSkillStateAt.test.ts +1 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/references.test.ts +1 -0
- rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/references.ts +5 -2
- rasa/core/channels/inspector-nextgen/src/try-assistant/deriveLlmCallView.test.ts +4 -4
- rasa/core/channels/inspector-nextgen/src/types/conversation.ts +1 -0
- rasa/core/channels/inspector-nextgen/src/types/skill.test.ts +23 -0
- rasa/core/channels/inspector-nextgen/src/types/skill.ts +3 -0
- rasa/core/channels/inspector-nextgen/src/utils/barge-in.ts +12 -12
- rasa/core/channels/inspector.py +20 -5
- rasa/core/channels/mattermost.py +11 -221
- rasa/core/channels/rasa_chat.py +6 -9
- rasa/core/channels/rest.py +63 -146
- rasa/core/channels/rocketchat.py +11 -167
- rasa/core/channels/slack.py +11 -690
- rasa/core/channels/socketio.py +14 -564
- rasa/core/channels/telegram.py +11 -335
- rasa/core/channels/twilio.py +11 -210
- rasa/core/channels/twilio_utils.py +8 -27
- rasa/core/channels/vier_cvg.py +11 -401
- rasa/core/channels/voice_ready/audiocodes.py +11 -439
- rasa/core/channels/voice_ready/jambonz.py +13 -132
- rasa/core/channels/voice_ready/twilio_voice.py +13 -482
- rasa/core/channels/voice_stream/asr/__init__.py +11 -42
- rasa/core/channels/voice_stream/asr/asr_engine.py +17 -466
- rasa/core/channels/voice_stream/asr/asr_event.py +14 -23
- rasa/core/channels/voice_stream/asr/azure/__init__.py +8 -21
- rasa/core/channels/voice_stream/asr/azure/config.py +3 -41
- rasa/core/channels/voice_stream/asr/deepgram/__init__.py +46 -36
- rasa/core/channels/voice_stream/asr/deepgram/config.py +12 -58
- rasa/core/channels/voice_stream/asr/deepgram_flux.py +11 -7
- rasa/core/channels/voice_stream/asr/elevenlabs.py +10 -242
- rasa/core/channels/voice_stream/asr/speechmatics.py +13 -307
- rasa/core/channels/voice_stream/audio_bytes.py +32 -120
- rasa/core/channels/voice_stream/audiocodes.py +13 -388
- rasa/core/channels/voice_stream/browser_audio.py +17 -14
- rasa/core/channels/voice_stream/chirp.py +11 -325
- rasa/core/channels/voice_stream/genesys.py +11 -466
- rasa/core/channels/voice_stream/jambonz.py +13 -271
- rasa/core/channels/voice_stream/json_audio.py +15 -12
- rasa/core/channels/voice_stream/marker_scheduler.py +121 -48
- rasa/core/channels/voice_stream/signalwire.py +13 -470
- rasa/core/channels/voice_stream/speech_api_key.py +8 -113
- rasa/core/channels/voice_stream/speech_model/README.md +51 -0
- rasa/core/channels/voice_stream/speech_model/__init__.py +8 -0
- rasa/core/channels/voice_stream/speech_model/constants.py +13 -0
- rasa/core/channels/voice_stream/speech_model/engine.py +452 -0
- rasa/core/channels/voice_stream/speech_model/factory.py +89 -0
- rasa/core/channels/voice_stream/speech_model/openai.py +53 -0
- rasa/core/channels/voice_stream/speech_model/openai_live.py +482 -0
- rasa/core/channels/voice_stream/speech_model/output_channel.py +150 -0
- rasa/core/channels/voice_stream/speech_model/polyai.py +95 -0
- rasa/core/channels/voice_stream/speech_model/rime_prism.py +402 -0
- rasa/core/channels/voice_stream/tts/__init__.py +31 -55
- rasa/core/channels/voice_stream/tts/azure.py +10 -562
- rasa/core/channels/voice_stream/tts/cartesia.py +5 -276
- rasa/core/channels/voice_stream/tts/config.py +4 -11
- rasa/core/channels/voice_stream/tts/deepgram.py +5 -239
- rasa/core/channels/voice_stream/tts/deepgram_flux.py +5 -298
- rasa/core/channels/voice_stream/tts/elevenlabs.py +16 -472
- rasa/core/channels/voice_stream/tts/rime.py +5 -403
- rasa/core/channels/voice_stream/tts/tts_engine.py +27 -839
- rasa/core/channels/voice_stream/twilio_media_streams.py +15 -372
- rasa/core/channels/voice_stream/util.py +2 -0
- rasa/core/channels/voice_stream/voice_channel.py +29 -2196
- rasa/core/channels/voice_stream/vonage.py +10 -416
- rasa/core/channels/voice_stream/websockets.py +17 -14
- rasa/core/channels/webexteams.py +11 -125
- rasa/core/concurrent_lock_store.py +28 -308
- rasa/core/constants.py +32 -21
- rasa/core/exporter.py +1 -1
- rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +17 -326
- rasa/core/iam_credentials_providers/credentials_provider_protocol.py +19 -92
- rasa/core/information_retrieval/_results.py +25 -0
- rasa/core/information_retrieval/faiss.py +50 -448
- rasa/core/information_retrieval/milvus.py +24 -157
- rasa/core/information_retrieval/qdrant.py +28 -98
- rasa/core/lock.py +3 -136
- rasa/core/lock_store.py +26 -412
- rasa/core/nlg/contextual_response_rephraser.py +12 -15
- rasa/core/policies/enterprise_search_policy.py +11 -14
- rasa/core/processor.py +3 -3
- rasa/core/redis_connection_factory.py +19 -472
- rasa/core/run.py +45 -4
- rasa/core/timer_managers/persistent_timer_manager.py +372 -0
- rasa/core/timer_managers/redis_timer_manager.py +19 -337
- rasa/core/timer_managers/timer_manager.py +22 -8
- rasa/core/timer_stores/in_memory_timer_store.py +7 -66
- rasa/core/timer_stores/redis_timer_store.py +20 -326
- rasa/core/timer_stores/timer_store.py +22 -171
- rasa/core/tracker_stores/auth_retry_tracker_store.py +126 -46
- rasa/core/tracker_stores/dynamo_tracker_store.py +23 -656
- rasa/core/tracker_stores/mongo_tracker_store.py +24 -377
- rasa/core/tracker_stores/redis_tracker_store.py +36 -510
- rasa/core/tracker_stores/sql_tracker_store.py +46 -1635
- rasa/core/tracker_stores/tracker_store.py +203 -802
- rasa/core/voice/event_composition/events/composite_events.py +1 -0
- rasa/core/voice/event_composition/events/constants.py +0 -3
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/__init__.py +5 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/__init__.py +5 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/constants.py +54 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/deberta.py +65 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/deberta_hypothesis.jinja2 +1 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/deberta_premise.jinja2 +5 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/loader.py +116 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/nli_model.py +104 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/protocol.py +18 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/detector.py +103 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel/runtime.py +75 -0
- rasa/core/voice/event_composition/handlers/barge_in/barge_in_handler.py +10 -5
- rasa/core/voice/event_composition/handlers/playback_tracking_handler.py +0 -21
- rasa/core/voice/interruptions.py +4 -2
- rasa/dialogue_understanding/stack/frames/mantle_stack_frames.py +21 -1
- rasa/dialogue_understanding/utils.py +34 -8
- rasa/{api.py → entrypoint.py} +2 -6
- rasa/mantle/config/_tracker_auth_retry.py +214 -0
- rasa/mantle/config/agent_spec.py +3 -1
- rasa/mantle/config/builtin_tool_constraints.py +2 -2
- rasa/mantle/config/channels.py +1 -1
- rasa/mantle/config/integrations.py +23 -10
- rasa/mantle/config/runtime_endpoints.py +240 -48
- rasa/mantle/config/validation.py +4 -4
- rasa/mantle/content/responses.py +44 -7
- rasa/mantle/content/static_buttons.py +3 -3
- rasa/mantle/content/validation.py +23 -2
- rasa/mantle/decorator_contract.py +492 -0
- rasa/mantle/inspector.py +26 -1
- rasa/mantle/llm/client.py +5 -4
- rasa/mantle/llm/tool_schemas.py +238 -78
- rasa/mantle/memory/coercion.py +90 -0
- rasa/mantle/memory/field.py +2 -2
- rasa/mantle/memory/validation.py +2 -2
- rasa/mantle/model_archive/training_telemetry.py +13 -4
- rasa/mantle/orchestration/collect_ask_state.py +16 -9
- rasa/mantle/orchestration/contracts.py +0 -6
- rasa/mantle/orchestration/correction/coercion.py +2 -29
- rasa/mantle/orchestration/correction/executor.py +4 -1
- rasa/mantle/orchestration/hybrid_link.py +161 -0
- rasa/mantle/orchestration/memory_validation_tools.py +2 -2
- rasa/mantle/orchestration/orchestrator.py +207 -367
- rasa/mantle/orchestration/pending_hold.py +225 -0
- rasa/mantle/orchestration/precondition_stack.py +95 -37
- rasa/mantle/orchestration/set_memory_button.py +1 -1
- rasa/mantle/orchestration/settable_write.py +81 -3
- rasa/mantle/orchestration/skill_digression.py +0 -18
- rasa/mantle/orchestration/skill_executor.py +1185 -439
- rasa/mantle/orchestration/skill_utils.py +72 -1
- rasa/mantle/orchestration/stated_fields.py +416 -0
- rasa/mantle/orchestration/tool_call_batch.py +77 -0
- rasa/mantle/orchestration/turn_context.py +15 -13
- rasa/mantle/prompts/constructor.py +9 -17
- rasa/mantle/prompts/messages.py +1 -1
- rasa/mantle/prompts/renderer.py +22 -0
- rasa/mantle/prompts/state.py +70 -17
- rasa/mantle/prompts/system_prompt.py +34 -23
- rasa/mantle/prompts/templates/__init__.py +0 -4
- rasa/mantle/prompts/templates/active_skill.jinja2 +18 -11
- rasa/mantle/prompts/templates/knowledge_answering.jinja2 +5 -0
- rasa/mantle/prompts/templates/lifecycle_tools.jinja2 +17 -16
- rasa/mantle/prompts/templates/pending_tool_confirmation.jinja2 +32 -7
- rasa/mantle/prompts/templates/routing_catalog.jinja2 +1 -2
- rasa/mantle/skills/catalog.py +61 -9
- rasa/mantle/skills/prose_scoping.py +29 -19
- rasa/mantle/skills/steps.py +3 -3
- rasa/mantle/state/tracker_handle.py +4 -4
- rasa/mantle/tools/constants.py +9 -0
- rasa/mantle/tools/decorator.py +8 -3
- rasa/mantle/tools/inventory.py +6 -4
- rasa/mantle/tools/loader.py +11 -11
- rasa/mantle/tools/mcp_import_spec.py +34 -19
- rasa/mantle/tools/validation.py +11 -1
- rasa/privacy/event_broker_utils.py +24 -3
- rasa/privacy/privacy_filter.py +282 -77
- rasa/privacy/privacy_manager.py +25 -7
- rasa/server.py +25 -7
- rasa/shared/constants.py +2 -0
- rasa/shared/core/playback_marker.py +50 -16
- rasa/shared/infrastructure/__init__.py +1 -0
- rasa/shared/infrastructure/constants.py +22 -0
- rasa/shared/infrastructure/iam/__init__.py +1 -0
- rasa/shared/infrastructure/iam/aws_iam_credentials_providers.py +328 -0
- rasa/shared/infrastructure/iam/credentials_provider_protocol.py +92 -0
- rasa/shared/infrastructure/redis_connection_factory.py +474 -0
- rasa/shared/nlu/constants.py +2 -0
- rasa/shared/utils/llm.py +17 -21
- rasa/studio/train.py +1 -1
- rasa/tracing/engine_token_usage.py +0 -1
- rasa/version.py +1 -1
- {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/METADATA +8 -8
- {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/RECORD +452 -272
- rasa/core/channels/inspector-nextgen/src/assets/images/tya-bot.png +0 -0
- rasa/core/channels/inspector-nextgen/src/assets/images/tya-user.png +0 -0
- rasa/core/voice/event_composition/handlers/barge_in/backchannel.py +0 -245
- rasa/mantle/prompts/templates/set_fields_fill_instruction.jinja2 +0 -2
- rasa/mantle/prompts/templates/set_fields_fill_task.jinja2 +0 -11
- /rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/azure/constants.py +0 -0
- /rasa/{core/channels/voice_stream/tts → api/voice/tts/v1}/_client_session.py +0 -0
- {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/WHEEL +0 -0
- {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/entry_points.txt +0 -0
- {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/licenses/NOTICE +0 -0
rasa/api/__init__.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Conversation field selection for brokers that key events by conversation.
|
|
2
|
+
|
|
3
|
+
Kafka and SQL need to know whether an event identifies its conversation as
|
|
4
|
+
``sender_id`` or ``conversation_id``. That choice follows the loaded engine
|
|
5
|
+
and is not part of the published ``EventBroker`` port. A later broker version
|
|
6
|
+
can reuse this mixin without copying it onto the storage contract.
|
|
7
|
+
|
|
8
|
+
This module does not import a published version.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from rasa.shared.engine_version import DEFAULT_ENGINE_VERSION, MANTLE_ENGINE_VERSION
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ConversationKeyMixin:
|
|
17
|
+
"""Select the event field that identifies a conversation.
|
|
18
|
+
|
|
19
|
+
``engine_version`` is set from the loaded model. Until then the default
|
|
20
|
+
engine version selects ``sender_id``.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
engine_version: str = DEFAULT_ENGINE_VERSION
|
|
24
|
+
|
|
25
|
+
def conversation_key_name(self) -> str:
|
|
26
|
+
"""Return the event field that identifies the conversation."""
|
|
27
|
+
if self.engine_version == MANTLE_ENGINE_VERSION:
|
|
28
|
+
return "conversation_id"
|
|
29
|
+
return "sender_id"
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""Create Mantle event brokers from a type key or import path.
|
|
2
|
+
|
|
3
|
+
The leading underscore marks this module as private. Customers subclass
|
|
4
|
+
``EventBroker`` from the published brokers API package. Rasa loads brokers
|
|
5
|
+
through this module.
|
|
6
|
+
|
|
7
|
+
Short names resolve to the builtins of the current published version. A custom
|
|
8
|
+
class may subclass the current or previous version; ``prepare_instance`` wraps
|
|
9
|
+
a previous version so callers receive the current interface.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import importlib
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
import structlog
|
|
18
|
+
|
|
19
|
+
from rasa.api.versioning import (
|
|
20
|
+
AmbiguousApiVersionError,
|
|
21
|
+
UnknownApiVersionError,
|
|
22
|
+
current_version,
|
|
23
|
+
prepare_instance,
|
|
24
|
+
resolve_version,
|
|
25
|
+
)
|
|
26
|
+
from rasa.shared.exceptions import ConnectionException, RasaException
|
|
27
|
+
|
|
28
|
+
structlogger = structlog.get_logger()
|
|
29
|
+
|
|
30
|
+
_BUILTIN_SPECS = {
|
|
31
|
+
"pika": ("pika", "PikaEventBroker"),
|
|
32
|
+
"sql": ("sql", "SQLEventBroker"),
|
|
33
|
+
"file": ("file", "FileEventBroker"),
|
|
34
|
+
"kafka": ("kafka", "KafkaEventBroker"),
|
|
35
|
+
"concurrent_kafka": ("kafka", "ConcurrentKafkaEventBroker"),
|
|
36
|
+
"http": ("http", "HttpEventBroker"),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _version_base(version: str | None = None) -> Any:
|
|
41
|
+
resolved = version or current_version("brokers")
|
|
42
|
+
return importlib.import_module(f"rasa.api.brokers.{resolved}.base")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _version_submodule(version: str, name: str) -> Any:
|
|
46
|
+
return importlib.import_module(f"rasa.api.brokers.{version}.{name}")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def builtin_types(version: str | None = None) -> dict[str, type]:
|
|
50
|
+
"""Map builtin short names to event broker classes for ``version``."""
|
|
51
|
+
resolved = version or current_version("brokers")
|
|
52
|
+
return {
|
|
53
|
+
name: getattr(_version_submodule(resolved, module_name), class_name)
|
|
54
|
+
for name, (module_name, class_name) in _BUILTIN_SPECS.items()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def create_event_broker(
|
|
59
|
+
config_type: str | None,
|
|
60
|
+
settings: Any,
|
|
61
|
+
) -> Any:
|
|
62
|
+
"""Instantiate a Mantle event broker and normalize it to the current API.
|
|
63
|
+
|
|
64
|
+
``config_type`` is a builtin short name (``pika``, ``sql``, ``file``,
|
|
65
|
+
``kafka``, ``concurrent_kafka``, ``http``), a ``module.path.ClassName``
|
|
66
|
+
import path, or omitted for the Pika default when a broker section is
|
|
67
|
+
present.
|
|
68
|
+
|
|
69
|
+
``connect`` is awaited after preparation so this never returns an
|
|
70
|
+
unconfigured builtin.
|
|
71
|
+
|
|
72
|
+
Omitting the ``event_broker`` section entirely is handled by the Mantle
|
|
73
|
+
loader and yields ``None`` — this factory always builds a broker.
|
|
74
|
+
"""
|
|
75
|
+
resolved_type = config_type or "pika"
|
|
76
|
+
structlogger.debug(
|
|
77
|
+
"rasa.api.brokers.create_event_broker", config_type=resolved_type
|
|
78
|
+
)
|
|
79
|
+
base = _version_base()
|
|
80
|
+
broker_cls = resolve_event_broker_class(resolved_type)
|
|
81
|
+
_validate_event_broker_class(broker_cls, resolved_type)
|
|
82
|
+
try:
|
|
83
|
+
broker = broker_cls()
|
|
84
|
+
except TypeError as error:
|
|
85
|
+
raise RasaException(
|
|
86
|
+
f"{resolved_type} must be constructible without arguments."
|
|
87
|
+
) from error
|
|
88
|
+
prepared = prepare_instance(broker, "brokers")
|
|
89
|
+
if not isinstance(prepared, base.EventBroker):
|
|
90
|
+
raise RasaException(
|
|
91
|
+
f"Prepared event broker must implement EventBroker, got {type(prepared)!r}."
|
|
92
|
+
)
|
|
93
|
+
try:
|
|
94
|
+
await prepared.connect(settings)
|
|
95
|
+
except _connection_errors() as error:
|
|
96
|
+
raise ConnectionException("Cannot connect to event broker.") from error
|
|
97
|
+
return prepared
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def resolve_event_broker_class(config_type: str) -> type:
|
|
101
|
+
"""Resolve a builtin name or import path to an event broker class."""
|
|
102
|
+
builtin_spec = _BUILTIN_SPECS.get(config_type.lower())
|
|
103
|
+
if builtin_spec is not None and "." not in config_type:
|
|
104
|
+
module_name, class_name = builtin_spec
|
|
105
|
+
return getattr(
|
|
106
|
+
_version_submodule(current_version("brokers"), module_name), class_name
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
module_name, class_name = config_type.rsplit(".", 1)
|
|
111
|
+
module = importlib.import_module(module_name)
|
|
112
|
+
except ValueError as error:
|
|
113
|
+
raise RasaException(
|
|
114
|
+
f"Invalid event broker type '{config_type}'. "
|
|
115
|
+
f"Expected a builtin name ({', '.join(sorted(_BUILTIN_SPECS))}) "
|
|
116
|
+
f"or module.path.ClassName."
|
|
117
|
+
) from error
|
|
118
|
+
except ModuleNotFoundError as error:
|
|
119
|
+
raise RasaException(
|
|
120
|
+
f"Cannot retrieve class from path {config_type}."
|
|
121
|
+
) from error
|
|
122
|
+
|
|
123
|
+
external_class = getattr(module, class_name, None)
|
|
124
|
+
if not isinstance(external_class, type):
|
|
125
|
+
raise RasaException(f"{config_type} did not resolve to a class.")
|
|
126
|
+
_validate_event_broker_class(external_class, config_type)
|
|
127
|
+
return external_class
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _validate_event_broker_class(broker_cls: type, config_type: str) -> None:
|
|
131
|
+
"""Validate a broker contract before running customer construction code."""
|
|
132
|
+
try:
|
|
133
|
+
resolved = resolve_version(broker_cls, "brokers")
|
|
134
|
+
except (UnknownApiVersionError, AmbiguousApiVersionError) as error:
|
|
135
|
+
raise RasaException(
|
|
136
|
+
f"{config_type} must be a subclass of EventBroker."
|
|
137
|
+
) from error
|
|
138
|
+
|
|
139
|
+
broker_base = _version_base(resolved.version).EventBroker
|
|
140
|
+
if not issubclass(broker_cls, broker_base):
|
|
141
|
+
raise RasaException(f"{config_type} must be a subclass of EventBroker.")
|
|
142
|
+
|
|
143
|
+
matched_base_index = broker_cls.__mro__.index(resolved.matched_base)
|
|
144
|
+
compatibility_bases = [
|
|
145
|
+
base
|
|
146
|
+
for base in broker_cls.__mro__[:matched_base_index]
|
|
147
|
+
if base.__module__.startswith("rasa.core.")
|
|
148
|
+
]
|
|
149
|
+
if compatibility_bases:
|
|
150
|
+
raise RasaException(
|
|
151
|
+
f"{config_type} must subclass the published "
|
|
152
|
+
f"rasa.api.brokers.{resolved.version} EventBroker contract, "
|
|
153
|
+
"not an internal compatibility class."
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
if getattr(broker_cls, "connect", None) is broker_base.connect:
|
|
157
|
+
raise RasaException(f"{config_type} must implement connect().")
|
|
158
|
+
if getattr(broker_cls, "publish", None) is broker_base.publish:
|
|
159
|
+
raise RasaException(f"{config_type} must implement publish().")
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def _connection_errors() -> tuple[type[BaseException], ...]:
|
|
163
|
+
"""Return backend connection failures normalized by both runtime paths."""
|
|
164
|
+
import aio_pika.exceptions
|
|
165
|
+
import aiormq.exceptions
|
|
166
|
+
import sqlalchemy.exc
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
sqlalchemy.exc.OperationalError,
|
|
170
|
+
aio_pika.exceptions.AMQPConnectionError,
|
|
171
|
+
aiormq.exceptions.ChannelNotFoundEntity,
|
|
172
|
+
*aio_pika.exceptions.CONNECTION_EXCEPTIONS,
|
|
173
|
+
)
|
rasa/api/brokers/_sql.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Private SQL helpers shared by published broker implementations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
from urllib import parse
|
|
7
|
+
|
|
8
|
+
from sqlalchemy.engine import URL
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def build_db_url(
|
|
12
|
+
dialect: str = "sqlite",
|
|
13
|
+
host: str | None = None,
|
|
14
|
+
port: int | None = None,
|
|
15
|
+
db: str = "events.db",
|
|
16
|
+
username: str | None = None,
|
|
17
|
+
password: str | None = None,
|
|
18
|
+
query: dict[str, Any] | None = None,
|
|
19
|
+
) -> str | URL:
|
|
20
|
+
"""Build an SQLAlchemy URL without depending on a CALM tracker store."""
|
|
21
|
+
if host and "://" in host:
|
|
22
|
+
return host
|
|
23
|
+
if host:
|
|
24
|
+
parsed = parse.urlsplit(f"scheme://{host}")
|
|
25
|
+
port = parsed.port or port
|
|
26
|
+
host = parsed.hostname or host
|
|
27
|
+
|
|
28
|
+
return URL.create(
|
|
29
|
+
dialect,
|
|
30
|
+
username=username,
|
|
31
|
+
password=password,
|
|
32
|
+
host=host,
|
|
33
|
+
port=port,
|
|
34
|
+
database=db,
|
|
35
|
+
query=query or {},
|
|
36
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Mantle event broker contract — version 1.
|
|
2
|
+
|
|
3
|
+
Public surface for custom event brokers.
|
|
4
|
+
|
|
5
|
+
Publishing this package under ``rasa.api.brokers.v1`` is enough for the
|
|
6
|
+
versioning framework to discover it — no registration call is required.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from rasa.api.brokers.v1.base import EventBroker
|
|
12
|
+
from rasa.api.brokers.v1.file import FileEventBroker
|
|
13
|
+
from rasa.api.brokers.v1.http import HttpEventBroker
|
|
14
|
+
from rasa.api.brokers.v1.kafka import ConcurrentKafkaEventBroker, KafkaEventBroker
|
|
15
|
+
from rasa.api.brokers.v1.pika import PikaEventBroker
|
|
16
|
+
from rasa.api.brokers.v1.sql import SQLEventBroker
|
|
17
|
+
from rasa.api.brokers.v1.types import EventBrokerSettings
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"ConcurrentKafkaEventBroker",
|
|
21
|
+
"EventBroker",
|
|
22
|
+
"EventBrokerSettings",
|
|
23
|
+
"FileEventBroker",
|
|
24
|
+
"HttpEventBroker",
|
|
25
|
+
"KafkaEventBroker",
|
|
26
|
+
"PikaEventBroker",
|
|
27
|
+
"SQLEventBroker",
|
|
28
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Mantle ``EventBroker`` abstract base (``rasa.api.brokers.v1``)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from typing import Any, Optional
|
|
7
|
+
|
|
8
|
+
from rasa.api.brokers.v1.types import EventBrokerSettings
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EventBroker(ABC):
|
|
12
|
+
"""Published Mantle contract for event broker backends.
|
|
13
|
+
|
|
14
|
+
Customers subclass this base, or a builtin from the same module, and import
|
|
15
|
+
it from ``rasa.api.brokers.v1``. YAML names the class only; the import names
|
|
16
|
+
the version.
|
|
17
|
+
|
|
18
|
+
A backend implements ``connect``, ``publish``, and may override ``is_ready``
|
|
19
|
+
and ``close``.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self) -> None:
|
|
23
|
+
"""Create an unconnected event broker."""
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
async def connect(self, settings: EventBrokerSettings) -> None:
|
|
27
|
+
"""Connect or configure the broker using Mantle settings."""
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def publish(self, event: dict[str, Any]) -> None:
|
|
31
|
+
"""Publish a JSON-formatted Rasa event."""
|
|
32
|
+
|
|
33
|
+
def publish_batch(self, events: list[dict[str, Any]]) -> None:
|
|
34
|
+
"""Publish the new events of one conversation, in order.
|
|
35
|
+
|
|
36
|
+
A transport that pays a per-request cost overrides this to send them
|
|
37
|
+
together. Publishing them one at a time is what the caller would do
|
|
38
|
+
otherwise, so a broker that has no use for the batch inherits exactly
|
|
39
|
+
the behaviour it had before.
|
|
40
|
+
"""
|
|
41
|
+
for event in events:
|
|
42
|
+
self.publish(event)
|
|
43
|
+
|
|
44
|
+
def raise_if_engine_unsupported(self, engine_version: Optional[str]) -> None:
|
|
45
|
+
"""Refuse a model whose events this broker cannot carry.
|
|
46
|
+
|
|
47
|
+
Brokers carry every engine by default. Engine-specific transports can
|
|
48
|
+
override this hook to reject an incompatible model before it is loaded.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def is_ready(self) -> bool:
|
|
52
|
+
"""Return whether the broker is ready to publish."""
|
|
53
|
+
return True
|
|
54
|
+
|
|
55
|
+
async def close(self) -> None:
|
|
56
|
+
"""Close the connection to the event broker."""
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""File Mantle event broker builtin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any, Optional
|
|
8
|
+
|
|
9
|
+
from rasa.api.brokers.v1.base import EventBroker
|
|
10
|
+
from rasa.api.brokers.v1.types import EventBrokerSettings
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FileEventBroker(EventBroker):
|
|
16
|
+
"""Log events to a file in json format.
|
|
17
|
+
|
|
18
|
+
There will be one event per line and each event is stored as json.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
DEFAULT_LOG_FILE_NAME = "rasa_event.log"
|
|
22
|
+
|
|
23
|
+
def __init__(self) -> None:
|
|
24
|
+
"""Create an unconnected file event broker."""
|
|
25
|
+
super().__init__()
|
|
26
|
+
self.path: str = self.DEFAULT_LOG_FILE_NAME
|
|
27
|
+
self.event_logger: logging.Logger | None = None
|
|
28
|
+
|
|
29
|
+
async def connect(self, settings: EventBrokerSettings) -> None:
|
|
30
|
+
"""Configure the log file from Mantle settings."""
|
|
31
|
+
params = dict(settings.params)
|
|
32
|
+
self._configure(path=params.get("path"))
|
|
33
|
+
|
|
34
|
+
def publish(self, event: dict[str, Any]) -> None:
|
|
35
|
+
"""Write event to file."""
|
|
36
|
+
if self.event_logger is None:
|
|
37
|
+
raise RuntimeError("FileEventBroker.connect must be called before publish.")
|
|
38
|
+
self.event_logger.info(json.dumps(event))
|
|
39
|
+
self.event_logger.handlers[0].flush()
|
|
40
|
+
|
|
41
|
+
async def close(self) -> None:
|
|
42
|
+
"""Close this broker's file handlers."""
|
|
43
|
+
if self.event_logger is None:
|
|
44
|
+
return
|
|
45
|
+
for handler in list(self.event_logger.handlers):
|
|
46
|
+
self.event_logger.removeHandler(handler)
|
|
47
|
+
handler.close()
|
|
48
|
+
logging.Logger.manager.loggerDict.pop(self.event_logger.name, None)
|
|
49
|
+
self.event_logger = None
|
|
50
|
+
|
|
51
|
+
def _configure(self, path: Optional[str] = None) -> None:
|
|
52
|
+
self.path = path or self.DEFAULT_LOG_FILE_NAME
|
|
53
|
+
self.event_logger = self._event_logger()
|
|
54
|
+
|
|
55
|
+
def _event_logger(self) -> logging.Logger:
|
|
56
|
+
"""Instantiate the file logger."""
|
|
57
|
+
logger_file = self.path
|
|
58
|
+
query_logger = logging.getLogger(f"event-logger.{id(self)}")
|
|
59
|
+
query_logger.setLevel(logging.INFO)
|
|
60
|
+
for existing_handler in list(query_logger.handlers):
|
|
61
|
+
query_logger.removeHandler(existing_handler)
|
|
62
|
+
existing_handler.close()
|
|
63
|
+
handler = logging.FileHandler(logger_file)
|
|
64
|
+
handler.setFormatter(logging.Formatter("%(message)s"))
|
|
65
|
+
query_logger.propagate = False
|
|
66
|
+
query_logger.addHandler(handler)
|
|
67
|
+
|
|
68
|
+
logger.info(f"Logging events to '{logger_file}'.")
|
|
69
|
+
|
|
70
|
+
return query_logger
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"""HTTP Mantle event broker builtin (Studio ingestion)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
1
5
|
import asyncio
|
|
2
6
|
import random
|
|
3
7
|
import re
|
|
@@ -10,7 +14,8 @@ import aiohttp
|
|
|
10
14
|
import structlog
|
|
11
15
|
from pydantic import BaseModel, ConfigDict, ValidationError
|
|
12
16
|
|
|
13
|
-
from rasa.
|
|
17
|
+
from rasa.api.brokers.v1.base import EventBroker
|
|
18
|
+
from rasa.api.brokers.v1.types import EventBrokerSettings
|
|
14
19
|
from rasa.shared.engine_version import (
|
|
15
20
|
DEFAULT_ENGINE_VERSION,
|
|
16
21
|
MANTLE_ENGINE_VERSION,
|
|
@@ -93,7 +98,41 @@ class HttpEventBroker(EventBroker):
|
|
|
93
98
|
on any other engine the events have no representation in the contract.
|
|
94
99
|
"""
|
|
95
100
|
|
|
96
|
-
def __init__(
|
|
101
|
+
def __init__(self) -> None:
|
|
102
|
+
"""Create an unconnected HTTP event broker."""
|
|
103
|
+
super().__init__()
|
|
104
|
+
self.url: Optional[Text] = None
|
|
105
|
+
self.timeout = DEFAULT_TIMEOUT_IN_SECONDS
|
|
106
|
+
self.retries = DEFAULT_RETRIES
|
|
107
|
+
self.retry_delay_in_seconds = DEFAULT_RETRY_DELAY_IN_SECONDS
|
|
108
|
+
self.max_retry_delay_in_seconds = DEFAULT_MAX_RETRY_DELAY_IN_SECONDS
|
|
109
|
+
self.max_in_flight_requests = DEFAULT_MAX_IN_FLIGHT_REQUESTS
|
|
110
|
+
self.endpoint: Optional[EndpointConfig] = None
|
|
111
|
+
self.stream_pii = True
|
|
112
|
+
self._ssl_context: Any = None
|
|
113
|
+
self._engine_version: Text = DEFAULT_ENGINE_VERSION
|
|
114
|
+
self._engine_refused = False
|
|
115
|
+
self._engine_refusal_logged = False
|
|
116
|
+
self._session: Optional[aiohttp.ClientSession] = None
|
|
117
|
+
self._session_loop: Optional[AbstractEventLoop] = None
|
|
118
|
+
# Maps each in-flight task to the number of events it carries, so a
|
|
119
|
+
# batch abandoned at shutdown can say what it cost.
|
|
120
|
+
self._in_flight: Dict[asyncio.Task, int] = {}
|
|
121
|
+
self._closing = asyncio.Event()
|
|
122
|
+
self._closed = False
|
|
123
|
+
self._shut_down = False
|
|
124
|
+
|
|
125
|
+
async def connect(self, settings: EventBrokerSettings) -> None:
|
|
126
|
+
"""Configure the HTTP client from Mantle settings."""
|
|
127
|
+
params = dict(settings.params)
|
|
128
|
+
url = params.pop("url", None)
|
|
129
|
+
# Rebuild EndpointConfig so headers, auth, token and TLS settings land
|
|
130
|
+
# on the same object the send path already reads. Named HTTP tuning
|
|
131
|
+
# keys (timeout, retries, …) ride along in ``kwargs``.
|
|
132
|
+
endpoint = EndpointConfig(url=url, **params)
|
|
133
|
+
self._configure(url=url, endpoint=endpoint, **endpoint.kwargs)
|
|
134
|
+
|
|
135
|
+
def _configure(
|
|
97
136
|
self,
|
|
98
137
|
url: Optional[Text] = None,
|
|
99
138
|
timeout: float = DEFAULT_TIMEOUT_IN_SECONDS,
|
|
@@ -104,7 +143,7 @@ class HttpEventBroker(EventBroker):
|
|
|
104
143
|
endpoint: Optional[EndpointConfig] = None,
|
|
105
144
|
**kwargs: Any,
|
|
106
145
|
) -> None:
|
|
107
|
-
"""
|
|
146
|
+
"""Apply connection settings for Studio's ingestion endpoint.
|
|
108
147
|
|
|
109
148
|
Args:
|
|
110
149
|
url: Studio's ingestion endpoint, for example
|
|
@@ -116,9 +155,8 @@ class HttpEventBroker(EventBroker):
|
|
|
116
155
|
max_retry_delay_in_seconds: Ceiling for the doubling delay.
|
|
117
156
|
max_in_flight_requests: Requests allowed in flight before further
|
|
118
157
|
batches are dropped rather than queued without limit.
|
|
119
|
-
endpoint: Pre-built endpoint configuration.
|
|
120
|
-
|
|
121
|
-
settings the user configured.
|
|
158
|
+
endpoint: Pre-built endpoint configuration. Carries the headers,
|
|
159
|
+
auth and SSL settings the user configured.
|
|
122
160
|
kwargs: Remaining endpoint configuration, ignored.
|
|
123
161
|
|
|
124
162
|
Raises:
|
|
@@ -200,37 +238,6 @@ class HttpEventBroker(EventBroker):
|
|
|
200
238
|
# to repeat on every request.
|
|
201
239
|
self._ssl_context = self.endpoint.create_ssl_context()
|
|
202
240
|
|
|
203
|
-
# The base class declares this as a plain `str`, so the default
|
|
204
|
-
# stands in until a model loads. It is never read before then.
|
|
205
|
-
self._engine_version: Text = DEFAULT_ENGINE_VERSION
|
|
206
|
-
self._engine_refused = False
|
|
207
|
-
self._engine_refusal_logged = False
|
|
208
|
-
|
|
209
|
-
self._session: Optional[aiohttp.ClientSession] = None
|
|
210
|
-
self._session_loop: Optional[AbstractEventLoop] = None
|
|
211
|
-
# Maps each in-flight task to the number of events it carries, so a
|
|
212
|
-
# batch abandoned at shutdown can say what it cost.
|
|
213
|
-
self._in_flight: Dict[asyncio.Task, int] = {}
|
|
214
|
-
self._closing = asyncio.Event()
|
|
215
|
-
self._closed = False
|
|
216
|
-
self._shut_down = False
|
|
217
|
-
|
|
218
|
-
@classmethod
|
|
219
|
-
async def from_endpoint_config(
|
|
220
|
-
cls,
|
|
221
|
-
broker_config: Optional[EndpointConfig],
|
|
222
|
-
event_loop: Optional[AbstractEventLoop] = None,
|
|
223
|
-
) -> Optional["HttpEventBroker"]:
|
|
224
|
-
"""Creates broker. See the parent class for more information."""
|
|
225
|
-
if broker_config is None:
|
|
226
|
-
return None
|
|
227
|
-
|
|
228
|
-
return cls(
|
|
229
|
-
url=broker_config.url,
|
|
230
|
-
endpoint=broker_config,
|
|
231
|
-
**broker_config.kwargs,
|
|
232
|
-
)
|
|
233
|
-
|
|
234
241
|
@property
|
|
235
242
|
def _loggable_url(self) -> Text:
|
|
236
243
|
"""The configured url without the credentials it may embed.
|
|
@@ -239,8 +246,16 @@ class HttpEventBroker(EventBroker):
|
|
|
239
246
|
both work, so the url as configured never goes into a log or an error
|
|
240
247
|
message. Derived on each read so it follows `url` if that changes.
|
|
241
248
|
"""
|
|
249
|
+
if not self.url:
|
|
250
|
+
return ""
|
|
242
251
|
return strip_url_credentials(self.url)
|
|
243
252
|
|
|
253
|
+
def _require_endpoint(self) -> EndpointConfig:
|
|
254
|
+
"""Return the configured endpoint, or fail if connect was skipped."""
|
|
255
|
+
if self.endpoint is None or not self.url:
|
|
256
|
+
raise RuntimeError("HttpEventBroker.connect must be called before use.")
|
|
257
|
+
return self.endpoint
|
|
258
|
+
|
|
244
259
|
def _batches(
|
|
245
260
|
self, events: List[Dict[Text, Any]]
|
|
246
261
|
) -> Iterator[List[Dict[Text, Any]]]:
|
|
@@ -594,15 +609,16 @@ class HttpEventBroker(EventBroker):
|
|
|
594
609
|
)
|
|
595
610
|
raise PermanentDeliveryError("The event broker has been closed.")
|
|
596
611
|
|
|
612
|
+
endpoint = self._require_endpoint()
|
|
597
613
|
auth = None
|
|
598
|
-
if
|
|
614
|
+
if endpoint.basic_auth:
|
|
599
615
|
auth = aiohttp.BasicAuth(
|
|
600
|
-
|
|
601
|
-
|
|
616
|
+
endpoint.basic_auth["username"],
|
|
617
|
+
endpoint.basic_auth["password"],
|
|
602
618
|
)
|
|
603
619
|
|
|
604
620
|
self._session = aiohttp.ClientSession(
|
|
605
|
-
headers=
|
|
621
|
+
headers=endpoint.headers,
|
|
606
622
|
auth=auth,
|
|
607
623
|
timeout=aiohttp.ClientTimeout(total=self.timeout),
|
|
608
624
|
connector=aiohttp.TCPConnector(
|
|
@@ -647,13 +663,14 @@ class HttpEventBroker(EventBroker):
|
|
|
647
663
|
Studio refused the request itself, or the broker is closed.
|
|
648
664
|
"""
|
|
649
665
|
payload = self._payload(events)
|
|
666
|
+
endpoint = self._require_endpoint()
|
|
650
667
|
session = self._client_session()
|
|
651
668
|
|
|
652
669
|
try:
|
|
653
670
|
async with session.post(
|
|
654
671
|
self.url,
|
|
655
672
|
json=payload,
|
|
656
|
-
params=
|
|
673
|
+
params=endpoint.combine_parameters(),
|
|
657
674
|
# Correlates this attempt with the receiving end's own logs.
|
|
658
675
|
headers={"X-Request-ID": request_id},
|
|
659
676
|
# A 307 or 308 would re-post the whole batch, user text and
|