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
rasa/builder/jobs.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
3
|
+
import structlog
|
|
4
|
+
from sanic import Sanic
|
|
5
|
+
|
|
6
|
+
from rasa.builder.exceptions import (
|
|
7
|
+
LLMGenerationError,
|
|
8
|
+
ProjectGenerationError,
|
|
9
|
+
TrainingError,
|
|
10
|
+
ValidationError,
|
|
11
|
+
)
|
|
12
|
+
from rasa.builder.job_manager import JobInfo, job_manager
|
|
13
|
+
from rasa.builder.models import (
|
|
14
|
+
JobStatus,
|
|
15
|
+
JobStatusEvent,
|
|
16
|
+
)
|
|
17
|
+
from rasa.builder.training_service import train_and_load_agent
|
|
18
|
+
from rasa.builder.validation_service import validate_project
|
|
19
|
+
from rasa.cli.scaffold import ProjectTemplateName
|
|
20
|
+
|
|
21
|
+
structlogger = structlog.get_logger()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def push_job_status_event(
|
|
25
|
+
job: JobInfo, status: JobStatus, message: Optional[str] = None
|
|
26
|
+
) -> None:
|
|
27
|
+
event = JobStatusEvent.from_status(status=status.value, message=message)
|
|
28
|
+
job.status = status.value
|
|
29
|
+
await job.put(event)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
async def run_prompt_to_bot_job(
|
|
33
|
+
app: Any,
|
|
34
|
+
job: JobInfo,
|
|
35
|
+
prompt: str,
|
|
36
|
+
) -> None:
|
|
37
|
+
"""Run the prompt-to-bot job in the background.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
app: The Sanic application instance.
|
|
41
|
+
job: The job information instance.
|
|
42
|
+
prompt: The natural language prompt for bot generation.
|
|
43
|
+
"""
|
|
44
|
+
project_generator = app.ctx.project_generator
|
|
45
|
+
input_channel = app.ctx.input_channel
|
|
46
|
+
await push_job_status_event(job, JobStatus.received)
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
# 1. Generating
|
|
50
|
+
await push_job_status_event(job, JobStatus.generating)
|
|
51
|
+
bot_files = await project_generator.generate_project_with_retries(
|
|
52
|
+
prompt,
|
|
53
|
+
template=ProjectTemplateName.BASIC,
|
|
54
|
+
)
|
|
55
|
+
await push_job_status_event(job, JobStatus.generation_success)
|
|
56
|
+
|
|
57
|
+
# 2. Training
|
|
58
|
+
await push_job_status_event(job, JobStatus.training)
|
|
59
|
+
importer = project_generator._create_importer()
|
|
60
|
+
app.ctx.agent = await train_and_load_agent(importer)
|
|
61
|
+
input_channel.agent = app.ctx.agent
|
|
62
|
+
await push_job_status_event(job, JobStatus.train_success)
|
|
63
|
+
|
|
64
|
+
structlogger.info(
|
|
65
|
+
"bot_builder_service.prompt_to_bot.success",
|
|
66
|
+
files_generated=list(bot_files.keys()),
|
|
67
|
+
)
|
|
68
|
+
await push_job_status_event(job, JobStatus.done)
|
|
69
|
+
job_manager.mark_done(job)
|
|
70
|
+
|
|
71
|
+
except TrainingError as exc:
|
|
72
|
+
structlogger.debug(
|
|
73
|
+
"prompt_to_bot_job.training_error", job_id=job.id, error=str(exc)
|
|
74
|
+
)
|
|
75
|
+
await push_job_status_event(job, JobStatus.train_error, message=str(exc))
|
|
76
|
+
job_manager.mark_done(job, error=str(exc))
|
|
77
|
+
|
|
78
|
+
except ValidationError as exc:
|
|
79
|
+
structlogger.debug(
|
|
80
|
+
"prompt_to_bot_job.validation_error", job_id=job.id, error=str(exc)
|
|
81
|
+
)
|
|
82
|
+
await push_job_status_event(job, JobStatus.validation_error, message=str(exc))
|
|
83
|
+
job_manager.mark_done(job, error=str(exc))
|
|
84
|
+
|
|
85
|
+
except (ProjectGenerationError, LLMGenerationError) as exc:
|
|
86
|
+
structlogger.debug(
|
|
87
|
+
"prompt_to_bot_job.generation_error", job_id=job.id, error=str(exc)
|
|
88
|
+
)
|
|
89
|
+
await push_job_status_event(job, JobStatus.generation_error, message=str(exc))
|
|
90
|
+
job_manager.mark_done(job, error=str(exc))
|
|
91
|
+
|
|
92
|
+
except Exception as exc:
|
|
93
|
+
# Capture full traceback
|
|
94
|
+
structlogger.exception(
|
|
95
|
+
"prompt_to_bot_job.unexpected_error", job_id=job.id, error=str(exc)
|
|
96
|
+
)
|
|
97
|
+
await push_job_status_event(job, JobStatus.error, message=str(exc))
|
|
98
|
+
job_manager.mark_done(job, error=str(exc))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
async def run_template_to_bot_job(
|
|
102
|
+
app: "Sanic",
|
|
103
|
+
job: JobInfo,
|
|
104
|
+
template_name: ProjectTemplateName,
|
|
105
|
+
) -> None:
|
|
106
|
+
"""Run the template-to-bot job in the background.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
app: The Sanic application instance.
|
|
110
|
+
job: The job information instance.
|
|
111
|
+
template_name: The name of the template to use for bot generation.
|
|
112
|
+
"""
|
|
113
|
+
project_generator = app.ctx.project_generator
|
|
114
|
+
input_channel = app.ctx.input_channel
|
|
115
|
+
await push_job_status_event(job, JobStatus.received)
|
|
116
|
+
|
|
117
|
+
try:
|
|
118
|
+
# 1) Generating
|
|
119
|
+
await push_job_status_event(job, JobStatus.generating)
|
|
120
|
+
await project_generator.init_from_template(template_name)
|
|
121
|
+
bot_files = project_generator.get_bot_files()
|
|
122
|
+
await push_job_status_event(job, JobStatus.generation_success)
|
|
123
|
+
|
|
124
|
+
# 2) Training
|
|
125
|
+
await push_job_status_event(job, JobStatus.training)
|
|
126
|
+
importer = project_generator._create_importer()
|
|
127
|
+
app.ctx.agent = await train_and_load_agent(importer)
|
|
128
|
+
input_channel.agent = app.ctx.agent
|
|
129
|
+
await push_job_status_event(job, JobStatus.train_success)
|
|
130
|
+
|
|
131
|
+
# 3) Done
|
|
132
|
+
structlogger.info(
|
|
133
|
+
"bot_builder_service.template_to_bot.success",
|
|
134
|
+
files_generated=list(bot_files.keys()),
|
|
135
|
+
)
|
|
136
|
+
await push_job_status_event(job, JobStatus.done)
|
|
137
|
+
job_manager.mark_done(job)
|
|
138
|
+
|
|
139
|
+
except TrainingError as exc:
|
|
140
|
+
structlogger.debug(
|
|
141
|
+
"template_to_bot_job.training_error",
|
|
142
|
+
job_id=job.id,
|
|
143
|
+
error=str(exc),
|
|
144
|
+
)
|
|
145
|
+
await push_job_status_event(job, JobStatus.train_error, message=str(exc))
|
|
146
|
+
job_manager.mark_done(job, error=str(exc))
|
|
147
|
+
|
|
148
|
+
except ValidationError as exc:
|
|
149
|
+
structlogger.debug(
|
|
150
|
+
"template_to_bot_job.validation_error",
|
|
151
|
+
job_id=job.id,
|
|
152
|
+
error=str(exc),
|
|
153
|
+
)
|
|
154
|
+
await push_job_status_event(job, JobStatus.validation_error, message=str(exc))
|
|
155
|
+
job_manager.mark_done(job, error=str(exc))
|
|
156
|
+
|
|
157
|
+
except ProjectGenerationError as exc:
|
|
158
|
+
structlogger.debug(
|
|
159
|
+
"template_to_bot_job.generation_error",
|
|
160
|
+
job_id=job.id,
|
|
161
|
+
error=str(exc),
|
|
162
|
+
)
|
|
163
|
+
await push_job_status_event(job, JobStatus.generation_error, message=str(exc))
|
|
164
|
+
job_manager.mark_done(job, error=str(exc))
|
|
165
|
+
|
|
166
|
+
except Exception as exc:
|
|
167
|
+
# Capture full traceback
|
|
168
|
+
structlogger.exception(
|
|
169
|
+
"template_to_bot_job.unexpected_error",
|
|
170
|
+
job_id=job.id,
|
|
171
|
+
error=str(exc),
|
|
172
|
+
)
|
|
173
|
+
await push_job_status_event(job, JobStatus.error, message=str(exc))
|
|
174
|
+
job_manager.mark_done(job, error=str(exc))
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
async def run_update_files_job(
|
|
178
|
+
app: "Sanic",
|
|
179
|
+
job: JobInfo,
|
|
180
|
+
bot_files: dict,
|
|
181
|
+
) -> None:
|
|
182
|
+
project_generator = app.ctx.project_generator
|
|
183
|
+
input_channel = app.ctx.input_channel
|
|
184
|
+
await push_job_status_event(job, JobStatus.received)
|
|
185
|
+
|
|
186
|
+
try:
|
|
187
|
+
project_generator.update_bot_files(bot_files)
|
|
188
|
+
|
|
189
|
+
# 1. Validating
|
|
190
|
+
await push_job_status_event(job, JobStatus.validating)
|
|
191
|
+
importer = project_generator._create_importer()
|
|
192
|
+
validation_error = await validate_project(importer)
|
|
193
|
+
if validation_error:
|
|
194
|
+
raise ValidationError(validation_error)
|
|
195
|
+
await push_job_status_event(job, JobStatus.validation_success)
|
|
196
|
+
|
|
197
|
+
# 2. Training
|
|
198
|
+
await push_job_status_event(job, JobStatus.training)
|
|
199
|
+
app.ctx.agent = await train_and_load_agent(importer)
|
|
200
|
+
input_channel.agent = app.ctx.agent
|
|
201
|
+
await push_job_status_event(job, JobStatus.train_success)
|
|
202
|
+
|
|
203
|
+
await push_job_status_event(job, JobStatus.done)
|
|
204
|
+
job_manager.mark_done(job)
|
|
205
|
+
|
|
206
|
+
except ValidationError as exc:
|
|
207
|
+
structlogger.debug(
|
|
208
|
+
"update_files_job.validation_error",
|
|
209
|
+
job_id=job.id,
|
|
210
|
+
error=str(exc),
|
|
211
|
+
)
|
|
212
|
+
await push_job_status_event(job, JobStatus.validation_error, message=str(exc))
|
|
213
|
+
job_manager.mark_done(job, error=str(exc))
|
|
214
|
+
|
|
215
|
+
except TrainingError as exc:
|
|
216
|
+
structlogger.debug(
|
|
217
|
+
"update_files_job.train_error",
|
|
218
|
+
job_id=job.id,
|
|
219
|
+
error=str(exc),
|
|
220
|
+
)
|
|
221
|
+
await push_job_status_event(job, JobStatus.train_error, message=str(exc))
|
|
222
|
+
job_manager.mark_done(job, error=str(exc))
|
|
223
|
+
|
|
224
|
+
except Exception as exc:
|
|
225
|
+
# Capture full traceback for anything truly unexpected
|
|
226
|
+
structlogger.exception(
|
|
227
|
+
"update_files_job.unexpected_error",
|
|
228
|
+
job_id=job.id,
|
|
229
|
+
error=str(exc),
|
|
230
|
+
)
|
|
231
|
+
await push_job_status_event(job, JobStatus.error, message=str(exc))
|
|
232
|
+
job_manager.mark_done(job, error=str(exc))
|
rasa/builder/llm_service.py
CHANGED
|
@@ -11,13 +11,12 @@ import importlib_resources
|
|
|
11
11
|
import openai
|
|
12
12
|
import structlog
|
|
13
13
|
from jinja2 import Template
|
|
14
|
-
from pydantic import ValidationError
|
|
15
14
|
|
|
16
15
|
from rasa.builder import config
|
|
16
|
+
from rasa.builder.copilot.copilot import Copilot
|
|
17
|
+
from rasa.builder.copilot.copilot_response_handler import CopilotResponseHandler
|
|
17
18
|
from rasa.builder.exceptions import LLMGenerationError
|
|
18
|
-
from rasa.builder.
|
|
19
|
-
from rasa.builder.llm_context import tracker_as_llm_context
|
|
20
|
-
from rasa.builder.models import Document, LLMBuilderContext, LLMHelperResponse
|
|
19
|
+
from rasa.builder.guardrails.lakera import LakeraAIGuardrails
|
|
21
20
|
from rasa.constants import PACKAGE_NAME
|
|
22
21
|
from rasa.shared.constants import DOMAIN_SCHEMA_FILE, RESPONSES_SCHEMA_FILE
|
|
23
22
|
from rasa.shared.core.flows.yaml_flows_io import FLOWS_SCHEMA_FILE
|
|
@@ -34,7 +33,71 @@ class LLMService:
|
|
|
34
33
|
self._client: Optional[openai.AsyncOpenAI] = None
|
|
35
34
|
self._domain_schema: Optional[Dict[str, Any]] = None
|
|
36
35
|
self._flows_schema: Optional[Dict[str, Any]] = None
|
|
37
|
-
self.
|
|
36
|
+
self._copilot: Optional[Copilot] = None
|
|
37
|
+
self._guardrails: Optional[LakeraAIGuardrails] = None
|
|
38
|
+
self._copilot_response_handler: Optional[CopilotResponseHandler] = None
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def copilot(self) -> Copilot:
|
|
42
|
+
"""Get or lazy create copilot instance."""
|
|
43
|
+
if self._copilot is None:
|
|
44
|
+
self._copilot = Copilot()
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
return self._copilot
|
|
48
|
+
except Exception as e:
|
|
49
|
+
structlogger.error(
|
|
50
|
+
"llm_service.copilot.error",
|
|
51
|
+
event_info="LLM Service: Error getting copilot instance.",
|
|
52
|
+
error=str(e),
|
|
53
|
+
)
|
|
54
|
+
raise
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def copilot_response_handler(self) -> CopilotResponseHandler:
|
|
58
|
+
"""Get or lazy create copilot response handler instance."""
|
|
59
|
+
if self._copilot_response_handler is None:
|
|
60
|
+
self._copilot_response_handler = CopilotResponseHandler(
|
|
61
|
+
rolling_buffer_size=config.COPILOT_HANDLER_ROLLING_BUFFER_SIZE,
|
|
62
|
+
)
|
|
63
|
+
try:
|
|
64
|
+
return self._copilot_response_handler
|
|
65
|
+
except Exception as e:
|
|
66
|
+
structlogger.error(
|
|
67
|
+
"llm_service.copilot_response_handler.error",
|
|
68
|
+
event_info=(
|
|
69
|
+
"LLM Service: Error getting copilot response handler instance."
|
|
70
|
+
),
|
|
71
|
+
error=str(e),
|
|
72
|
+
)
|
|
73
|
+
raise
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def guardrails(self) -> LakeraAIGuardrails:
|
|
77
|
+
"""Get or lazy create guardrails instance."""
|
|
78
|
+
if self._guardrails is None:
|
|
79
|
+
self._guardrails = LakeraAIGuardrails()
|
|
80
|
+
try:
|
|
81
|
+
return self._guardrails
|
|
82
|
+
except Exception as e:
|
|
83
|
+
structlogger.error(
|
|
84
|
+
"llm_service.guardrails.error",
|
|
85
|
+
event_info="LLM Service: Error getting guardrails instance.",
|
|
86
|
+
error=str(e),
|
|
87
|
+
)
|
|
88
|
+
raise
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def instantiate_copilot() -> Copilot:
|
|
92
|
+
"""Instantiate a new Copilot instance."""
|
|
93
|
+
return Copilot()
|
|
94
|
+
|
|
95
|
+
@staticmethod
|
|
96
|
+
def instantiate_handler(rolling_buffer_size: int) -> CopilotResponseHandler:
|
|
97
|
+
"""Instantiate a new CopilotResponseHandler instance."""
|
|
98
|
+
return CopilotResponseHandler(
|
|
99
|
+
rolling_buffer_size=rolling_buffer_size,
|
|
100
|
+
)
|
|
38
101
|
|
|
39
102
|
@asynccontextmanager
|
|
40
103
|
async def _get_client(self) -> AsyncGenerator[openai.AsyncOpenAI, None]:
|
|
@@ -56,9 +119,6 @@ class LLMService:
|
|
|
56
119
|
if self._flows_schema is None:
|
|
57
120
|
self._flows_schema = _prepare_flows_schema()
|
|
58
121
|
|
|
59
|
-
if self._helper_schema is None:
|
|
60
|
-
self._helper_schema = _load_helper_schema()
|
|
61
|
-
|
|
62
122
|
async def generate_rasa_project(
|
|
63
123
|
self, messages: List[Dict[str, Any]]
|
|
64
124
|
) -> Dict[str, Any]:
|
|
@@ -67,24 +127,25 @@ class LLMService:
|
|
|
67
127
|
|
|
68
128
|
try:
|
|
69
129
|
async with self._get_client() as client:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"type": "object",
|
|
80
|
-
"properties": {
|
|
81
|
-
"domain": self._domain_schema,
|
|
82
|
-
"flows": self._flows_schema,
|
|
83
|
-
},
|
|
84
|
-
"required": ["domain", "flows"],
|
|
130
|
+
response_format = {
|
|
131
|
+
"type": "json_schema",
|
|
132
|
+
"json_schema": {
|
|
133
|
+
"name": "rasa_project",
|
|
134
|
+
"schema": {
|
|
135
|
+
"type": "object",
|
|
136
|
+
"properties": {
|
|
137
|
+
"domain": self._domain_schema,
|
|
138
|
+
"flows": self._flows_schema,
|
|
85
139
|
},
|
|
140
|
+
"required": ["domain", "flows"],
|
|
86
141
|
},
|
|
87
142
|
},
|
|
143
|
+
}
|
|
144
|
+
response = await client.chat.completions.create( # type: ignore
|
|
145
|
+
model=config.OPENAI_MODEL,
|
|
146
|
+
messages=messages,
|
|
147
|
+
temperature=config.OPENAI_TEMPERATURE,
|
|
148
|
+
response_format=response_format,
|
|
88
149
|
)
|
|
89
150
|
|
|
90
151
|
content = response.choices[0].message.content
|
|
@@ -101,119 +162,6 @@ class LLMService:
|
|
|
101
162
|
except asyncio.TimeoutError:
|
|
102
163
|
raise LLMGenerationError("LLM request timed out")
|
|
103
164
|
|
|
104
|
-
async def create_helper_messages(
|
|
105
|
-
self, llm_builder_context: LLMBuilderContext
|
|
106
|
-
) -> List[Dict[str, Any]]:
|
|
107
|
-
"""Create helper messages for LLM builder."""
|
|
108
|
-
# Format chat history for documentation search
|
|
109
|
-
chat_dump = self._format_chat_dump(llm_builder_context.chat_history)
|
|
110
|
-
|
|
111
|
-
# Search documentation
|
|
112
|
-
documentation_results = await self.search_documentation(chat_dump)
|
|
113
|
-
formatted_docs = self._format_documentation_results(documentation_results)
|
|
114
|
-
|
|
115
|
-
current_conversation = tracker_as_llm_context(llm_builder_context.tracker)
|
|
116
|
-
|
|
117
|
-
# Prepare LLM messages
|
|
118
|
-
system_messages = get_helper_messages(
|
|
119
|
-
current_conversation,
|
|
120
|
-
llm_builder_context.bot_logs,
|
|
121
|
-
llm_builder_context.chat_bot_files,
|
|
122
|
-
formatted_docs,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
# Add user messages
|
|
126
|
-
messages = system_messages.copy()
|
|
127
|
-
for msg in llm_builder_context.chat_history:
|
|
128
|
-
messages.append(
|
|
129
|
-
{
|
|
130
|
-
"role": "user" if msg.type == "user" else "assistant",
|
|
131
|
-
"content": json.dumps(msg.content)
|
|
132
|
-
if isinstance(msg.content, list)
|
|
133
|
-
else msg.content,
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
return messages
|
|
137
|
-
|
|
138
|
-
async def generate_helper_response(
|
|
139
|
-
self, messages: List[Dict[str, Any]]
|
|
140
|
-
) -> LLMHelperResponse:
|
|
141
|
-
"""Generate helper response using OpenAI."""
|
|
142
|
-
self._prepare_schemas()
|
|
143
|
-
|
|
144
|
-
try:
|
|
145
|
-
async with self._get_client() as client:
|
|
146
|
-
response = await client.chat.completions.create(
|
|
147
|
-
model=config.OPENAI_MODEL,
|
|
148
|
-
messages=messages,
|
|
149
|
-
response_format={
|
|
150
|
-
"type": "json_schema",
|
|
151
|
-
"json_schema": {
|
|
152
|
-
"name": "llm_helper",
|
|
153
|
-
"schema": self._helper_schema,
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
content = response.choices[0].message.content
|
|
159
|
-
if not content:
|
|
160
|
-
raise LLMGenerationError("Empty response from LLM helper")
|
|
161
|
-
|
|
162
|
-
try:
|
|
163
|
-
return LLMHelperResponse.model_validate_json(json.loads(content))
|
|
164
|
-
except json.JSONDecodeError as e:
|
|
165
|
-
raise LLMGenerationError(f"Invalid JSON from LLM helper: {e}")
|
|
166
|
-
except ValidationError as e:
|
|
167
|
-
raise LLMGenerationError(f"Invalid JSON from LLM helper: {e}")
|
|
168
|
-
|
|
169
|
-
except openai.OpenAIError as e:
|
|
170
|
-
raise LLMGenerationError(f"OpenAI API error in helper: {e}")
|
|
171
|
-
except asyncio.TimeoutError:
|
|
172
|
-
raise LLMGenerationError("LLM helper request timed out")
|
|
173
|
-
|
|
174
|
-
async def search_documentation(
|
|
175
|
-
self, query: str, max_results: Optional[int] = None
|
|
176
|
-
) -> List[Document]:
|
|
177
|
-
"""Search documentation using OpenAI vector store."""
|
|
178
|
-
inkeep_document_retrieval = InKeepDocumentRetrieval()
|
|
179
|
-
documents = await inkeep_document_retrieval.retrieve_documents(query)
|
|
180
|
-
return documents
|
|
181
|
-
|
|
182
|
-
@staticmethod
|
|
183
|
-
def _format_chat_dump(messages: List[Dict[str, Any]]) -> str:
|
|
184
|
-
"""Format chat messages for documentation search."""
|
|
185
|
-
result = ""
|
|
186
|
-
for message in messages:
|
|
187
|
-
if message.type == "user":
|
|
188
|
-
content = (
|
|
189
|
-
message.content
|
|
190
|
-
if isinstance(message.content, str)
|
|
191
|
-
else str(message.content)
|
|
192
|
-
)
|
|
193
|
-
result += f"User: {content}\n"
|
|
194
|
-
else:
|
|
195
|
-
if isinstance(message.content, list):
|
|
196
|
-
for part in message.content:
|
|
197
|
-
if part.get("type") == "text":
|
|
198
|
-
result += f"Assistant: {part.get('text')}\n"
|
|
199
|
-
else:
|
|
200
|
-
result += f"Assistant: {message.content}\n"
|
|
201
|
-
return result
|
|
202
|
-
|
|
203
|
-
@staticmethod
|
|
204
|
-
def _format_documentation_results(results: List[Document]) -> str:
|
|
205
|
-
"""Format documentation search results."""
|
|
206
|
-
if not results:
|
|
207
|
-
return "<sources>No relevant documentation found.</sources>"
|
|
208
|
-
|
|
209
|
-
formatted_results = ""
|
|
210
|
-
for result in results:
|
|
211
|
-
formatted_result = f"<result url='{result.url}'>"
|
|
212
|
-
formatted_result += f"<content>{result.content}</content>"
|
|
213
|
-
formatted_results += formatted_result + "</result>"
|
|
214
|
-
|
|
215
|
-
return f"<sources>{formatted_results}</sources>"
|
|
216
|
-
|
|
217
165
|
|
|
218
166
|
# Schema preparation functions (stateless)
|
|
219
167
|
def _prepare_domain_schema() -> Dict[str, Any]:
|
|
@@ -237,9 +185,11 @@ def _prepare_domain_schema() -> Dict[str, Any]:
|
|
|
237
185
|
slot_mapping.pop("validation", None)
|
|
238
186
|
|
|
239
187
|
# Add responses schema
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
188
|
+
responses_schema = read_schema_file(RESPONSES_SCHEMA_FILE, PACKAGE_NAME, False)
|
|
189
|
+
if isinstance(responses_schema, dict):
|
|
190
|
+
domain_schema["mapping"]["responses"] = responses_schema["schema;responses"]
|
|
191
|
+
else:
|
|
192
|
+
raise ValueError("Expected responses schema to be a dictionary.")
|
|
243
193
|
|
|
244
194
|
return domain_schema
|
|
245
195
|
|
|
@@ -254,15 +204,6 @@ def _prepare_flows_schema() -> Dict[str, Any]:
|
|
|
254
204
|
return flows_schema
|
|
255
205
|
|
|
256
206
|
|
|
257
|
-
def _load_helper_schema() -> Dict[str, Any]:
|
|
258
|
-
"""Load helper schema."""
|
|
259
|
-
return read_json_file(
|
|
260
|
-
importlib_resources.files(PACKAGE_NAME).joinpath(
|
|
261
|
-
"builder/llm-helper-schema.json"
|
|
262
|
-
)
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
|
|
266
207
|
# Template functions (stateless with caching)
|
|
267
208
|
_skill_template: Optional[Template] = None
|
|
268
209
|
_helper_template: Optional[Template] = None
|
|
@@ -288,30 +229,5 @@ def get_skill_generation_messages(
|
|
|
288
229
|
return [{"role": "system", "content": system_prompt}]
|
|
289
230
|
|
|
290
231
|
|
|
291
|
-
def get_helper_messages(
|
|
292
|
-
current_conversation: str,
|
|
293
|
-
bot_logs: str,
|
|
294
|
-
chat_bot_files: Dict[str, str],
|
|
295
|
-
documentation_results: str,
|
|
296
|
-
) -> List[Dict[str, Any]]:
|
|
297
|
-
"""Get messages for helper response."""
|
|
298
|
-
global _helper_template
|
|
299
|
-
|
|
300
|
-
if _helper_template is None:
|
|
301
|
-
template_content = importlib.resources.read_text(
|
|
302
|
-
"rasa.builder",
|
|
303
|
-
"llm_helper_prompt.jinja2",
|
|
304
|
-
)
|
|
305
|
-
_helper_template = Template(template_content)
|
|
306
|
-
|
|
307
|
-
system_prompt = _helper_template.render(
|
|
308
|
-
current_conversation=current_conversation,
|
|
309
|
-
bot_logs=bot_logs,
|
|
310
|
-
chat_bot_files=chat_bot_files,
|
|
311
|
-
documentation_results=documentation_results,
|
|
312
|
-
)
|
|
313
|
-
return [{"role": "system", "content": system_prompt}]
|
|
314
|
-
|
|
315
|
-
|
|
316
232
|
# Global service instance
|
|
317
233
|
llm_service = LLMService()
|