rasa-pro 3.13.1a18__py3-none-any.whl → 3.13.1a20__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 +8 -0
- rasa/builder/auth.py +71 -0
- rasa/builder/config.py +16 -0
- rasa/builder/copilot/constants.py +15 -0
- rasa/builder/copilot/copilot.py +342 -0
- rasa/builder/copilot/copilot_response_handler.py +471 -0
- rasa/builder/copilot/exceptions.py +20 -0
- rasa/builder/copilot/models.py +344 -0
- rasa/builder/copilot/prompts/copilot_system_prompt.jinja2 +495 -0
- rasa/builder/copilot/telemetry.py +195 -0
- rasa/builder/document_retrieval/__init__.py +0 -0
- rasa/builder/document_retrieval/constants.py +16 -0
- rasa/builder/{inkeep_document_retrieval.py → document_retrieval/inkeep_document_retrieval.py} +53 -44
- rasa/builder/document_retrieval/models.py +62 -0
- rasa/builder/download.py +140 -0
- rasa/builder/guardrails/__init__.py +1 -0
- rasa/builder/guardrails/constants.py +4 -0
- rasa/builder/guardrails/exceptions.py +4 -0
- rasa/builder/guardrails/lakera.py +188 -0
- rasa/builder/guardrails/models.py +199 -0
- rasa/builder/guardrails/utils.py +305 -0
- rasa/builder/job_manager.py +87 -0
- rasa/builder/jobs.py +232 -0
- rasa/builder/llm_service.py +89 -173
- rasa/builder/logging_utils.py +162 -4
- rasa/builder/main.py +29 -16
- rasa/builder/models.py +93 -121
- rasa/builder/project_generator.py +91 -7
- rasa/builder/scrape_rasa_docs.py +1 -1
- rasa/builder/service.py +650 -452
- rasa/builder/shared/tracker_context.py +212 -0
- rasa/builder/validation_service.py +4 -4
- rasa/cli/data.py +8 -3
- rasa/cli/project_templates/basic/actions/action_api.py +15 -0
- rasa/cli/project_templates/basic/actions/action_human_handoff.py +44 -0
- rasa/cli/project_templates/basic/config.yml +23 -0
- rasa/cli/project_templates/{plain → basic}/credentials.yml +8 -7
- rasa/cli/project_templates/basic/data/general/feedback.yml +20 -0
- rasa/cli/project_templates/basic/data/general/goodbye.yml +6 -0
- rasa/cli/project_templates/basic/data/general/hello.yml +7 -0
- rasa/cli/project_templates/basic/data/general/help.yml +6 -0
- rasa/cli/project_templates/basic/data/general/human_handoff.yml +16 -0
- rasa/cli/project_templates/basic/data/general/welcome.yml +9 -0
- rasa/cli/project_templates/{finance/data/patterns → basic/data/system}/pattern_completed.yml +2 -1
- rasa/cli/project_templates/basic/data/system/pattern_correction.yml +7 -0
- rasa/cli/project_templates/basic/data/system/pattern_search.yml +8 -0
- rasa/cli/project_templates/basic/data/system/pattern_session_start.yml +8 -0
- rasa/cli/project_templates/basic/docs/rasa_assistant_qa.txt +65 -0
- rasa/cli/project_templates/basic/docs/template.txt +7 -0
- rasa/cli/project_templates/basic/domain/general/assistant_details.yml +12 -0
- rasa/cli/project_templates/basic/domain/general/bot_identity.yml +5 -0
- rasa/cli/project_templates/basic/domain/general/cannot_handle.yml +5 -0
- rasa/cli/project_templates/basic/domain/general/feedback.yml +28 -0
- rasa/cli/project_templates/basic/domain/general/goodbye.yml +7 -0
- rasa/cli/project_templates/basic/domain/general/help.yml +5 -0
- rasa/cli/project_templates/basic/domain/general/human_handoff_domain.yml +35 -0
- rasa/cli/project_templates/{finance/domain/default_actions.yml → basic/domain/general/utils.yml} +0 -3
- rasa/cli/project_templates/basic/domain/general/welcome.yml +7 -0
- rasa/cli/project_templates/{plain → basic}/endpoints.yml +42 -27
- rasa/cli/project_templates/basic/prompts/rephraser_demo_personality_prompt.jinja2 +19 -0
- rasa/cli/project_templates/defaults.py +25 -3
- rasa/cli/project_templates/finance/actions/__init__.py +46 -0
- rasa/cli/project_templates/finance/actions/accounts/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/{action_ask_account.py → accounts/action_ask_account.py} +6 -9
- rasa/cli/project_templates/finance/actions/{action_check_balance.py → accounts/action_check_balance.py} +4 -4
- rasa/cli/project_templates/finance/actions/action_session_start.py +11 -6
- rasa/cli/project_templates/finance/actions/cards/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/{action_ask_card.py → cards/action_ask_card.py} +4 -3
- rasa/cli/project_templates/finance/actions/{action_check_card_existence.py → cards/action_check_card_existence.py} +4 -3
- rasa/cli/project_templates/finance/actions/{action_update_card_status.py → cards/action_update_card_status.py} +18 -9
- rasa/cli/project_templates/finance/actions/database.py +1 -0
- rasa/cli/project_templates/finance/actions/transfers/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/{action_add_payee.py → transfers/action_add_payee.py} +8 -3
- rasa/cli/project_templates/finance/actions/{action_ask_account_from.py → transfers/action_ask_account_from.py} +5 -4
- rasa/cli/project_templates/finance/actions/{action_check_payee_existence.py → transfers/action_check_payee_existence.py} +3 -3
- rasa/cli/project_templates/finance/actions/{action_check_sufficient_funds.py → transfers/action_check_sufficient_funds.py} +3 -4
- rasa/cli/project_templates/finance/actions/{action_list_payees.py → transfers/action_list_payees.py} +4 -3
- rasa/cli/project_templates/finance/actions/{action_remove_payee.py → transfers/action_remove_payee.py} +4 -4
- rasa/cli/project_templates/finance/config.yml +8 -19
- rasa/cli/project_templates/finance/credentials.yml +6 -7
- rasa/cli/project_templates/finance/csvs/cards.csv +10 -10
- rasa/cli/project_templates/finance/csvs/payees.csv +10 -9
- rasa/cli/project_templates/finance/data/{flows → accounts}/check_balance.yml +2 -1
- rasa/cli/project_templates/finance/data/general/bot_identity.yml +6 -0
- rasa/cli/project_templates/finance/data/general/feedback.yml +20 -0
- rasa/cli/project_templates/finance/data/general/goodbye.yml +6 -0
- rasa/cli/project_templates/finance/data/general/hello.yml +7 -0
- rasa/cli/project_templates/finance/data/{flows/welcome.yml → general/help.yml} +2 -7
- rasa/cli/project_templates/finance/data/general/human_handoff.yml +16 -0
- rasa/cli/project_templates/finance/data/general/welcome.yml +9 -0
- rasa/cli/project_templates/finance/data/{patterns → system/patterns}/pattern_chitchat.yml +0 -2
- rasa/cli/project_templates/finance/data/system/patterns/pattern_completed.yml +7 -0
- rasa/cli/project_templates/finance/data/system/patterns/pattern_correction.yml +7 -0
- rasa/cli/project_templates/finance/data/system/patterns/pattern_search.yml +8 -0
- rasa/cli/project_templates/finance/data/{patterns → system/patterns}/pattern_session_start.yml +0 -1
- rasa/cli/project_templates/finance/domain/{check_balance.yml → accounts/check_balance.yml} +2 -0
- rasa/cli/project_templates/finance/domain/general/assistant_details.yml +12 -0
- rasa/cli/project_templates/finance/domain/general/bot_identity.yml +5 -0
- rasa/cli/project_templates/finance/domain/general/cannot_handle.yml +5 -0
- rasa/cli/project_templates/finance/domain/general/defaults.yml +24 -0
- rasa/cli/project_templates/finance/domain/general/feedback.yml +28 -0
- rasa/cli/project_templates/finance/domain/general/goodbye.yml +7 -0
- rasa/cli/project_templates/finance/domain/general/help.yml +5 -0
- rasa/cli/project_templates/finance/domain/general/human_handoff.yml +30 -0
- rasa/cli/project_templates/finance/domain/general/utils.yml +13 -0
- rasa/cli/project_templates/finance/domain/general/welcome.yml +8 -0
- rasa/cli/project_templates/finance/endpoints.yml +1 -0
- rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +3 -3
- rasa/cli/project_templates/telco/actions/actions_billing.py +24 -17
- rasa/cli/project_templates/telco/actions/actions_get_data_from_db.py +6 -1
- rasa/cli/project_templates/telco/actions/actions_run_diagnostics.py +6 -1
- rasa/cli/project_templates/telco/actions/actions_session_start.py +6 -1
- rasa/cli/project_templates/tutorial/config.yml +2 -1
- rasa/cli/scaffold.py +27 -2
- rasa/cli/train.py +8 -0
- rasa/cli/utils.py +31 -15
- rasa/core/actions/action.py +28 -41
- rasa/core/actions/action_run_slot_rejections.py +1 -1
- rasa/core/channels/development_inspector.py +47 -14
- rasa/core/channels/inspector/dist/assets/{arc-371401b1.js → arc-1ddec37b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-3f126156.js → blockDiagram-38ab4fdb-18af387c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-12f22eb7.js → c4Diagram-3d4e48cf-250127a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-59f6d54b.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-03b1d386.js → classDiagram-70f12bd4-c3388b34.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-84f69d63.js → classDiagram-v2-f2320105-9c893a82.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-26177ddb.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-ca47fd38.js → createText-2e5e7dd3-c111213b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-f837ca8a.js → edges-e0da2a9e-812a729d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-8717ac54.js → erDiagram-9861fffd-fd5051bc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-94f38b83.js → flowDb-956e92f1-3287ac02.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-b616f9fb.js → flowDiagram-66a62f08-692fb0b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-29c03f5a.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-f5d24bb8.js → flowchart-elk-definition-4a651766-008376f1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-b43ba8d9.js → ganttDiagram-c361ad54-df330a69.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-c3aafaa5.js → gitGraphDiagram-72cf32ee-e03676fb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-0d0a2c10.js → graph-46fad2ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-58ea0305.js → index-3862675e-a484ac55.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-cce6f8a1.js → index-a003633f.js} +179 -179
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b8f60461.js → infoDiagram-f8f76790-3f9e6ec2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-95be5545.js → journeyDiagram-49397b02-79f72383.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-da885b9b.js → layout-aad098e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-f1c817d3.js → line-219ab7ae.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-d42801e6.js → linear-2cddbe62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-a38923a6.js → mindmap-definition-fc14e90a-1d41ed99.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-ca6e71e9.js → pieDiagram-8a3498a8-cc496ee8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b290dae9.js → quadrantDiagram-120e2f19-84d32884.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-03f02ceb.js → requirementDiagram-deff3bca-c0deb984.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-c49eee40.js → sankeyDiagram-04a897e0-b9d7fd62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-b2cd6a3d.js → sequenceDiagram-704730f1-7d517565.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-e53a2028.js → stateDiagram-587899a1-98ef9b27.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-e1982a03.js → stateDiagram-v2-d93cdb3a-cee70748.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-d0226ca5.js → styles-6aaf32cf-3f9d1c96.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-0e21dc00.js → styles-9a916d00-67471923.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-9588494e.js → styles-c10674c1-bd093fb7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-be478d4f.js → svgDrawCommon-08f97a94-675794e8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-74631749.js → timeline-definition-85554ec2-0ac67617.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-a043552f.js → xychartDiagram-e933f94c-c018dc37.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +2 -2
- rasa/core/channels/inspector/index.html +1 -1
- rasa/core/channels/inspector/package.json +4 -3
- rasa/core/channels/inspector/src/App.tsx +53 -7
- rasa/core/channels/inspector/src/components/Chat.tsx +3 -2
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +1 -1
- rasa/core/channels/inspector/src/components/LatencyDisplay.tsx +268 -0
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +6 -2
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +8 -3
- rasa/core/channels/inspector/src/types.ts +8 -0
- rasa/core/channels/inspector/yarn.lock +12 -12
- rasa/core/channels/studio_chat.py +119 -34
- rasa/core/channels/voice_ready/twilio_voice.py +1 -1
- rasa/core/channels/voice_stream/asr/asr_engine.py +5 -1
- rasa/core/channels/voice_stream/asr/deepgram.py +5 -0
- rasa/core/channels/voice_stream/audiocodes.py +16 -8
- rasa/core/channels/voice_stream/browser_audio.py +39 -4
- rasa/core/channels/voice_stream/call_state.py +13 -2
- rasa/core/channels/voice_stream/genesys.py +16 -13
- rasa/core/channels/voice_stream/jambonz.py +14 -12
- rasa/core/channels/voice_stream/twilio_media_streams.py +14 -13
- rasa/core/channels/voice_stream/util.py +11 -1
- rasa/core/channels/voice_stream/voice_channel.py +108 -29
- rasa/core/nlg/callback.py +1 -1
- rasa/core/nlg/contextual_response_rephraser.py +19 -9
- rasa/core/nlg/generator.py +21 -5
- rasa/core/nlg/response.py +43 -6
- rasa/core/nlg/translate.py +8 -0
- rasa/core/policies/enterprise_search_policy.py +16 -21
- rasa/dialogue_understanding/commands/correct_slots_command.py +38 -10
- rasa/dialogue_understanding/generator/command_generator.py +5 -5
- rasa/dialogue_understanding/generator/command_parser.py +9 -13
- rasa/dialogue_understanding/processor/command_processor.py +149 -55
- rasa/dialogue_understanding/stack/utils.py +13 -3
- rasa/dialogue_understanding_test/du_test_schema.yml +3 -3
- rasa/dialogue_understanding_test/validation.py +9 -10
- rasa/e2e_test/e2e_config.py +18 -11
- rasa/e2e_test/e2e_test_schema.yml +3 -3
- rasa/e2e_test/utils/validation.py +17 -19
- rasa/engine/validation.py +86 -91
- rasa/exceptions.py +26 -1
- rasa/model_manager/model_api.py +2 -2
- rasa/model_manager/socket_bridge.py +8 -2
- rasa/shared/providers/_configs/default_litellm_client_config.py +3 -7
- rasa/shared/utils/cli.py +2 -0
- rasa/shared/utils/common.py +2 -1
- rasa/shared/utils/health_check/health_check.py +10 -14
- rasa/studio/upload.py +6 -2
- rasa/studio/utils.py +33 -22
- rasa/telemetry.py +95 -22
- rasa/utils/licensing.py +21 -10
- rasa/utils/log_utils.py +1 -1
- rasa/utils/tensorflow/transformer.py +3 -3
- rasa/validator.py +7 -5
- rasa/version.py +1 -1
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/METADATA +7 -7
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/RECORD +242 -203
- rasa/builder/create_openai_vector_store.py +0 -228
- rasa/builder/llm-helper-schema.json +0 -69
- rasa/builder/llm_context.py +0 -81
- rasa/builder/llm_helper_prompt.jinja2 +0 -245
- rasa/cli/project_templates/finance/data/nlu.yml +0 -29
- rasa/cli/project_templates/finance/data/patterns/pattern_search.yml +0 -5
- rasa/cli/project_templates/finance/domain/default_flows.yml +0 -33
- rasa/cli/project_templates/finance/prompts/command-generator.jinja2 +0 -57
- rasa/cli/project_templates/finance/tests/conversation_repair/cancellations.yml +0 -12
- rasa/cli/project_templates/finance/tests/conversation_repair/cannot_handle.yml +0 -7
- rasa/cli/project_templates/finance/tests/conversation_repair/chitchat.yml +0 -7
- rasa/cli/project_templates/finance/tests/conversation_repair/clarification.yml +0 -9
- rasa/cli/project_templates/finance/tests/conversation_repair/completion.yml +0 -18
- rasa/cli/project_templates/finance/tests/conversation_repair/corrections.yml +0 -17
- rasa/cli/project_templates/finance/tests/conversation_repair/digressions.yml +0 -32
- rasa/cli/project_templates/finance/tests/conversation_repair/human_handoff.yml +0 -21
- rasa/cli/project_templates/finance/tests/conversation_repair/skipping_collect_steps.yml +0 -16
- rasa/cli/project_templates/finance/tests/demo_scripts/main.yml +0 -16
- rasa/cli/project_templates/finance/tests/happy_paths/balance_verification.yml +0 -15
- rasa/cli/project_templates/finance/tests/happy_paths/banking_questions.yml +0 -12
- rasa/cli/project_templates/finance/tests/happy_paths/card_blocking.yml +0 -52
- rasa/cli/project_templates/finance/tests/happy_paths/money_transfer.yml +0 -136
- rasa/cli/project_templates/finance/tests/happy_paths/payee_management.yml +0 -27
- rasa/cli/project_templates/finance/tests/happy_paths/user_greeted.yml +0 -5
- rasa/cli/project_templates/plain/config.yml +0 -17
- rasa/cli/project_templates/plain/data/patterns/pattern_session_start.yml +0 -7
- rasa/cli/project_templates/plain/domain.yml +0 -5
- rasa/core/channels/inspector/dist/assets/channel-f1efda17.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-fdf164e2.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-7d7a1629.js +0 -1
- rasa/shared/importers/static.py +0 -63
- /rasa/{cli/project_templates/plain/actions → builder/copilot}/__init__.py +0 -0
- /rasa/builder/{inkeep-rag-response-schema.json → document_retrieval/inkeep-rag-response-schema.json} +0 -0
- /rasa/cli/project_templates/finance/actions/{action_process_immediate_payment.py → transfers/action_process_immediate_payment.py} +0 -0
- /rasa/cli/project_templates/finance/actions/{action_schedule_payment.py → transfers/action_schedule_payment.py} +0 -0
- /rasa/cli/project_templates/finance/actions/{action_validate_payment_date.py → transfers/action_validate_payment_date.py} +0 -0
- /rasa/cli/project_templates/finance/data/{flows → cards}/block_card.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → cards}/select_card.yml +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/accounts.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/advisors.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/appointments.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/branches.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/cards.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/payees.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/transactions.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/users.json +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/add_payee.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/list_payees.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/remove_payee.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/transfer_money.yml +0 -0
- /rasa/cli/project_templates/finance/domain/{block_card.yml → cards/block_card.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{select_card.yml → cards/select_card.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{add_payee.yml → transfers/add_payee.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{list_payees.yml → transfers/list_payees.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{remove_payee.yml → transfers/remove_payee.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{transfer_money.yml → transfers/transfer_money.yml} +0 -0
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any, Dict, List, Literal, Optional, Union
|
|
5
|
+
|
|
6
|
+
import structlog
|
|
7
|
+
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk
|
|
8
|
+
from pydantic import BaseModel, Field, model_validator
|
|
9
|
+
|
|
10
|
+
from rasa.builder.copilot.constants import ROLE_ASSISTANT, ROLE_COPILOT, ROLE_USER
|
|
11
|
+
from rasa.builder.models import ServerSentEvent
|
|
12
|
+
from rasa.builder.shared.tracker_context import TrackerContext
|
|
13
|
+
|
|
14
|
+
structlogger = structlog.get_logger()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ResponseCompleteness(Enum):
|
|
18
|
+
"""Enum for response completeness levels."""
|
|
19
|
+
|
|
20
|
+
TOKEN = "token" # Streaming token/chunk
|
|
21
|
+
COMPLETE = "complete" # Complete response (e.g., templated responses)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ResponseCategory(Enum):
|
|
25
|
+
"""Enum for different categories of responses."""
|
|
26
|
+
|
|
27
|
+
COPILOT = "copilot"
|
|
28
|
+
ROLEPLAY_DETECTION = "roleplay_detection"
|
|
29
|
+
OUT_OF_SCOPE_DETECTION = "out_of_scope_detection"
|
|
30
|
+
GUARDRAILS_POLICY_VIOLATION = "guardrails_policy_violation"
|
|
31
|
+
REFERENCE = "reference"
|
|
32
|
+
REFERENCE_ENTRY = "reference_entry"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class BaseContent(BaseModel):
|
|
36
|
+
type: str
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class TextContent(BaseContent):
|
|
40
|
+
type: Literal["text"]
|
|
41
|
+
text: str
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class CodeContent(BaseContent):
|
|
45
|
+
type: Literal["code"]
|
|
46
|
+
text: str
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class FileContent(BaseContent):
|
|
50
|
+
type: Literal["file"]
|
|
51
|
+
file_path: str
|
|
52
|
+
file_content: str
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class EventContent(BaseModel):
|
|
56
|
+
type: Literal["event"]
|
|
57
|
+
event: str = Field(..., description="The event's type_name")
|
|
58
|
+
|
|
59
|
+
event_data: Dict[str, Any] = Field(
|
|
60
|
+
default_factory=dict, description="Contains event-specific data fields."
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
@model_validator(mode="before")
|
|
64
|
+
@classmethod
|
|
65
|
+
def _collect_event_data(cls, data: Dict[str, Any]) -> Dict[str, Any]:
|
|
66
|
+
generic = {"type", "event"}
|
|
67
|
+
data["event_data"] = {
|
|
68
|
+
key: data.pop(key) for key in list(data.keys()) if key not in generic
|
|
69
|
+
}
|
|
70
|
+
return data
|
|
71
|
+
|
|
72
|
+
class Config:
|
|
73
|
+
extra = "forbid"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class CopilotChatMessage(BaseModel):
|
|
77
|
+
"""Model for a single chat messages between the user and the copilot."""
|
|
78
|
+
|
|
79
|
+
role: str = Field(..., pattern=f"^({ROLE_USER}|{ROLE_COPILOT})$")
|
|
80
|
+
content: List[Union[TextContent, CodeContent, FileContent, EventContent]] = Field(
|
|
81
|
+
...,
|
|
82
|
+
description=(
|
|
83
|
+
"The content of the message. "
|
|
84
|
+
"The content is expected to be a list of content blocks. "
|
|
85
|
+
"The content blocks are expected to be one of the following types: "
|
|
86
|
+
"text, link, code, or file."
|
|
87
|
+
),
|
|
88
|
+
)
|
|
89
|
+
response_category: Optional[ResponseCategory] = Field(
|
|
90
|
+
None,
|
|
91
|
+
description=(
|
|
92
|
+
"The category/source of this message. For user role messages, only `None` "
|
|
93
|
+
"or `GUARDRAILS_POLICY_VIOLATION` are allowed. For copilot role messages, "
|
|
94
|
+
"any category is permitted."
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
@model_validator(mode="after")
|
|
99
|
+
def validate_response_category_for_role(self) -> "CopilotChatMessage":
|
|
100
|
+
"""Validate value of response_category for the role of the message.
|
|
101
|
+
|
|
102
|
+
For user role messages, only None or GUARDRAILS_POLICY_VIOLATION are allowed.
|
|
103
|
+
For copilot role messages, any category is permitted.
|
|
104
|
+
"""
|
|
105
|
+
if (
|
|
106
|
+
self.role == ROLE_USER
|
|
107
|
+
and self.response_category is not None
|
|
108
|
+
and self.response_category != ResponseCategory.GUARDRAILS_POLICY_VIOLATION
|
|
109
|
+
):
|
|
110
|
+
message = (
|
|
111
|
+
f"User role messages can only have response_category of `None` or "
|
|
112
|
+
f"`{ResponseCategory.GUARDRAILS_POLICY_VIOLATION}`, "
|
|
113
|
+
f"got `{self.response_category}`."
|
|
114
|
+
)
|
|
115
|
+
structlogger.error(
|
|
116
|
+
"copilot_chat_message.validate_response_category_for_role"
|
|
117
|
+
".invalid_response_category",
|
|
118
|
+
event_info=message,
|
|
119
|
+
response_category=self.response_category,
|
|
120
|
+
role=self.role,
|
|
121
|
+
)
|
|
122
|
+
raise ValueError(message)
|
|
123
|
+
|
|
124
|
+
return self
|
|
125
|
+
|
|
126
|
+
def get_text_content(self) -> str:
|
|
127
|
+
"""Concatenate all 'text' content blocks into a single string."""
|
|
128
|
+
return "\n".join(
|
|
129
|
+
content_block.text
|
|
130
|
+
for content_block in self.content
|
|
131
|
+
if isinstance(content_block, TextContent)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
def to_openai_format(self) -> Dict[str, Any]:
|
|
135
|
+
"""Convert to OpenAI message format for API calls."""
|
|
136
|
+
role = self._map_role_to_openai()
|
|
137
|
+
|
|
138
|
+
if role == ROLE_USER:
|
|
139
|
+
content = self.get_text_content()
|
|
140
|
+
else:
|
|
141
|
+
content_blocks = [block.model_dump() for block in self.content]
|
|
142
|
+
content = json.dumps(content_blocks)
|
|
143
|
+
|
|
144
|
+
return {"role": role, "content": content}
|
|
145
|
+
|
|
146
|
+
def _map_role_to_openai(self) -> str:
|
|
147
|
+
"""Map internal roles to OpenAI-compatible roles."""
|
|
148
|
+
role_mapping = {
|
|
149
|
+
ROLE_USER: ROLE_USER,
|
|
150
|
+
ROLE_COPILOT: ROLE_ASSISTANT,
|
|
151
|
+
}
|
|
152
|
+
if self.role not in [ROLE_USER, ROLE_COPILOT]:
|
|
153
|
+
structlogger.error(
|
|
154
|
+
"copilot_chat_message.to_openai_format.invalid_role",
|
|
155
|
+
event_info=(
|
|
156
|
+
f"Invalid role: `{self.role}`. "
|
|
157
|
+
"Only `user` and `copilot` roles are supported."
|
|
158
|
+
),
|
|
159
|
+
role=self.role,
|
|
160
|
+
)
|
|
161
|
+
raise ValueError(f"Invalid role: {self.role}")
|
|
162
|
+
|
|
163
|
+
return role_mapping[self.role]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class CopilotRequest(BaseModel):
|
|
167
|
+
"""Request model for the copilot endpoint."""
|
|
168
|
+
|
|
169
|
+
copilot_chat_history: List[CopilotChatMessage] = Field(
|
|
170
|
+
...,
|
|
171
|
+
description=(
|
|
172
|
+
"The chat history between the user and the copilot. "
|
|
173
|
+
"Used to generate a new response based on the previous conversation."
|
|
174
|
+
),
|
|
175
|
+
)
|
|
176
|
+
session_id: str = Field(
|
|
177
|
+
...,
|
|
178
|
+
description=(
|
|
179
|
+
"The session ID of chat session with the assistant. "
|
|
180
|
+
"Used to fetch the conversation from the tracker."
|
|
181
|
+
),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def last_message(self) -> Optional[CopilotChatMessage]:
|
|
186
|
+
"""Get the last message from the copilot chat history."""
|
|
187
|
+
if not self.copilot_chat_history:
|
|
188
|
+
return None
|
|
189
|
+
return self.copilot_chat_history[-1]
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class CopilotOutput(BaseModel, ABC):
|
|
193
|
+
"""Base class for response events."""
|
|
194
|
+
|
|
195
|
+
response_completeness: ResponseCompleteness = Field(
|
|
196
|
+
description=(
|
|
197
|
+
"Indicates whether this is a streaming token (TOKEN) or a complete "
|
|
198
|
+
"response (COMPLETE)"
|
|
199
|
+
),
|
|
200
|
+
)
|
|
201
|
+
response_category: ResponseCategory = Field(
|
|
202
|
+
description=(
|
|
203
|
+
"The category/source of this response. Each response type has a fixed "
|
|
204
|
+
"category that cannot be changed. "
|
|
205
|
+
),
|
|
206
|
+
frozen=True,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
@abstractmethod
|
|
210
|
+
def to_sse_event(self) -> ServerSentEvent:
|
|
211
|
+
"""Convert to SSE event format."""
|
|
212
|
+
pass
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class GeneratedContent(CopilotOutput):
|
|
216
|
+
"""Represents generated content from the LLM to be streamed."""
|
|
217
|
+
|
|
218
|
+
content: str
|
|
219
|
+
response_category: ResponseCategory = Field(frozen=True)
|
|
220
|
+
response_completeness: ResponseCompleteness = ResponseCompleteness.TOKEN
|
|
221
|
+
|
|
222
|
+
def to_sse_event(self) -> ServerSentEvent:
|
|
223
|
+
"""Convert to SSE event format."""
|
|
224
|
+
return ServerSentEvent(
|
|
225
|
+
event="copilot_response",
|
|
226
|
+
data={
|
|
227
|
+
"content": self.content,
|
|
228
|
+
"response_category": self.response_category.value,
|
|
229
|
+
"completeness": self.response_completeness.value,
|
|
230
|
+
},
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class ReferenceEntry(CopilotOutput):
|
|
235
|
+
"""Represents a reference entry with title and url."""
|
|
236
|
+
|
|
237
|
+
index: int
|
|
238
|
+
title: str
|
|
239
|
+
url: str
|
|
240
|
+
response_category: ResponseCategory = Field(
|
|
241
|
+
default=ResponseCategory.REFERENCE_ENTRY,
|
|
242
|
+
frozen=True,
|
|
243
|
+
)
|
|
244
|
+
response_completeness: ResponseCompleteness = ResponseCompleteness.COMPLETE
|
|
245
|
+
|
|
246
|
+
@model_validator(mode="after")
|
|
247
|
+
def validate_response_category(self) -> "ReferenceEntry":
|
|
248
|
+
"""Validate that response_category has the correct default value."""
|
|
249
|
+
if self.response_category != ResponseCategory.REFERENCE_ENTRY:
|
|
250
|
+
raise ValueError(
|
|
251
|
+
f"ReferenceEntry response_category must be "
|
|
252
|
+
f"{ResponseCategory.REFERENCE_ENTRY}, got `{self.response_category}`."
|
|
253
|
+
)
|
|
254
|
+
return self
|
|
255
|
+
|
|
256
|
+
def to_sse_event(self) -> ServerSentEvent:
|
|
257
|
+
"""Convert to SSE event format."""
|
|
258
|
+
return ServerSentEvent(
|
|
259
|
+
event="copilot_response",
|
|
260
|
+
data={
|
|
261
|
+
"index": self.index,
|
|
262
|
+
"title": self.title,
|
|
263
|
+
"url": self.url,
|
|
264
|
+
"response_category": self.response_category.value,
|
|
265
|
+
"completeness": self.response_completeness.value,
|
|
266
|
+
},
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class ReferenceSection(CopilotOutput):
|
|
271
|
+
"""Represents a reference section with documentation links."""
|
|
272
|
+
|
|
273
|
+
references: list[ReferenceEntry]
|
|
274
|
+
response_category: ResponseCategory = Field(
|
|
275
|
+
default=ResponseCategory.REFERENCE,
|
|
276
|
+
frozen=True,
|
|
277
|
+
)
|
|
278
|
+
response_completeness: ResponseCompleteness = ResponseCompleteness.COMPLETE
|
|
279
|
+
|
|
280
|
+
@model_validator(mode="after")
|
|
281
|
+
def validate_response_category(self) -> "ReferenceSection":
|
|
282
|
+
"""Validate that response_category has the correct default value."""
|
|
283
|
+
if self.response_category != ResponseCategory.REFERENCE:
|
|
284
|
+
raise ValueError(
|
|
285
|
+
f"ReferenceSection response_category must be "
|
|
286
|
+
f"{ResponseCategory.REFERENCE}, got `{self.response_category}`."
|
|
287
|
+
)
|
|
288
|
+
return self
|
|
289
|
+
|
|
290
|
+
def to_sse_event(self) -> ServerSentEvent:
|
|
291
|
+
"""Convert to SSE event format."""
|
|
292
|
+
return ServerSentEvent(
|
|
293
|
+
event="copilot_response",
|
|
294
|
+
data={
|
|
295
|
+
"references": [
|
|
296
|
+
reference.model_dump(include={"index", "title", "url"})
|
|
297
|
+
for reference in self.references
|
|
298
|
+
],
|
|
299
|
+
"response_category": self.response_category.value,
|
|
300
|
+
"completeness": self.response_completeness.value,
|
|
301
|
+
},
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
class CopilotContext(BaseModel):
|
|
306
|
+
"""Model containing the context used by the copilot to generate a response."""
|
|
307
|
+
|
|
308
|
+
assistant_logs: str = Field("")
|
|
309
|
+
assistant_files: Dict[str, str] = Field({})
|
|
310
|
+
copilot_chat_history: List["CopilotChatMessage"] = Field([])
|
|
311
|
+
tracker_context: Optional[TrackerContext] = Field(None)
|
|
312
|
+
|
|
313
|
+
class Config:
|
|
314
|
+
"""Config for LLMBuilderContext."""
|
|
315
|
+
|
|
316
|
+
arbitrary_types_allowed = True
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
class UsageStatistics(BaseModel):
|
|
320
|
+
prompt_tokens: Optional[int] = None
|
|
321
|
+
completion_tokens: Optional[int] = None
|
|
322
|
+
total_tokens: Optional[int] = None
|
|
323
|
+
model: Optional[str] = None
|
|
324
|
+
|
|
325
|
+
def reset(self) -> None:
|
|
326
|
+
"""Reset usage statistics to their default values."""
|
|
327
|
+
self.prompt_tokens = None
|
|
328
|
+
self.completion_tokens = None
|
|
329
|
+
self.total_tokens = None
|
|
330
|
+
self.model = None
|
|
331
|
+
|
|
332
|
+
def update_from_stream_chunk(self, chunk: ChatCompletionChunk) -> None:
|
|
333
|
+
"""Update usage statistics from an OpenAI stream chunk.
|
|
334
|
+
|
|
335
|
+
Args:
|
|
336
|
+
chunk: The OpenAI stream chunk containing usage statistics.
|
|
337
|
+
"""
|
|
338
|
+
if not (usage := getattr(chunk, "usage", None)):
|
|
339
|
+
return
|
|
340
|
+
|
|
341
|
+
self.prompt_tokens = usage.prompt_tokens
|
|
342
|
+
self.completion_tokens = usage.completion_tokens
|
|
343
|
+
self.total_tokens = usage.total_tokens
|
|
344
|
+
self.model = getattr(chunk, "model", None)
|