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/__main__.py
CHANGED
|
@@ -34,6 +34,7 @@ from rasa.cli.utils import (
|
|
|
34
34
|
warn_if_rasa_plus_package_installed,
|
|
35
35
|
)
|
|
36
36
|
from rasa.constants import MINIMUM_COMPATIBLE_VERSION
|
|
37
|
+
from rasa.exceptions import DetailedRasaException
|
|
37
38
|
from rasa.plugin import plugin_manager
|
|
38
39
|
from rasa.shared.exceptions import RasaException
|
|
39
40
|
from rasa.utils.common import configure_logging_and_warnings
|
|
@@ -152,6 +153,13 @@ def main(raw_arguments: Optional[List[str]] = None) -> None:
|
|
|
152
153
|
structlogger.error("cli.no_command", event_info="No command specified.")
|
|
153
154
|
arg_parser.print_help()
|
|
154
155
|
sys.exit(1)
|
|
156
|
+
except DetailedRasaException as exc:
|
|
157
|
+
structlogger.error(
|
|
158
|
+
exc.code,
|
|
159
|
+
event_info=exc.info,
|
|
160
|
+
**exc.ctx,
|
|
161
|
+
)
|
|
162
|
+
sys.exit(1)
|
|
155
163
|
except RasaException as exc:
|
|
156
164
|
# these are exceptions we expect to happen (e.g. invalid training data format)
|
|
157
165
|
# it doesn't make sense to print a stacktrace for these if we are not in
|
rasa/builder/auth.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Authentication utilities for bot builder service."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Optional
|
|
4
|
+
|
|
5
|
+
import jwt
|
|
6
|
+
from jwt import PyJWKClient
|
|
7
|
+
from pydantic import BaseModel
|
|
8
|
+
|
|
9
|
+
from rasa.builder.config import AUTH0_CLIENT_ID, AUTH0_ISSUER, JWKS_URL
|
|
10
|
+
|
|
11
|
+
HEADER_USER_ID = "X-User-Id"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def verify_auth0_token(token: str) -> Dict[str, Any]:
|
|
15
|
+
"""Verify JWT token from Auth0.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
token: JWT token string
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
Dict containing the token payload
|
|
22
|
+
|
|
23
|
+
Raises:
|
|
24
|
+
Exception: If token verification fails
|
|
25
|
+
"""
|
|
26
|
+
jwk_client = PyJWKClient(JWKS_URL)
|
|
27
|
+
signing_key = jwk_client.get_signing_key_from_jwt(token)
|
|
28
|
+
|
|
29
|
+
payload = jwt.decode(
|
|
30
|
+
token,
|
|
31
|
+
signing_key.key,
|
|
32
|
+
algorithms=["RS256"],
|
|
33
|
+
audience=AUTH0_CLIENT_ID,
|
|
34
|
+
issuer=AUTH0_ISSUER,
|
|
35
|
+
)
|
|
36
|
+
return payload
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class Auth0TokenVerificationResult(BaseModel):
|
|
40
|
+
payload: Optional[Dict[str, Any]]
|
|
41
|
+
error_message: Optional[str]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def extract_and_verify_auth0_token(
|
|
45
|
+
auth_header: str,
|
|
46
|
+
) -> Auth0TokenVerificationResult:
|
|
47
|
+
"""Extract and verify JWT token from Authorization header.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
auth_header: Authorization header value
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Auth0TokenVerificationResult: Contains payload and error_message.
|
|
54
|
+
"""
|
|
55
|
+
# Check Authorization header format
|
|
56
|
+
if not auth_header.startswith("Bearer "):
|
|
57
|
+
return Auth0TokenVerificationResult(
|
|
58
|
+
payload=None, error_message="Missing or invalid Authorization header"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Extract token
|
|
62
|
+
token = auth_header.split(" ")[1]
|
|
63
|
+
|
|
64
|
+
# Verify token
|
|
65
|
+
try:
|
|
66
|
+
payload = verify_auth0_token(token)
|
|
67
|
+
return Auth0TokenVerificationResult(payload=payload, error_message=None)
|
|
68
|
+
except Exception as e:
|
|
69
|
+
return Auth0TokenVerificationResult(
|
|
70
|
+
payload=None, error_message=f"Invalid token: {e!s}"
|
|
71
|
+
)
|
rasa/builder/config.py
CHANGED
|
@@ -22,6 +22,7 @@ BUILDER_SERVER_HOST = os.getenv("SERVER_HOST", "0.0.0.0")
|
|
|
22
22
|
BUILDER_SERVER_PORT = int(os.getenv("SERVER_PORT", "5050"))
|
|
23
23
|
MAX_RETRIES = int(os.getenv("MAX_RETRIES", "5"))
|
|
24
24
|
MAX_LOG_ENTRIES = int(os.getenv("MAX_LOG_ENTRIES", "30"))
|
|
25
|
+
HELLO_RASA_PROJECT_ID = os.getenv("HELLO_RASA_PROJECT_ID")
|
|
25
26
|
|
|
26
27
|
# CORS Configuration
|
|
27
28
|
_cors_origins_env = os.getenv("CORS_ORIGINS", "*")
|
|
@@ -33,6 +34,21 @@ VALIDATION_FAIL_ON_WARNINGS = (
|
|
|
33
34
|
)
|
|
34
35
|
VALIDATION_MAX_HISTORY = None # Could be configured if needed
|
|
35
36
|
|
|
37
|
+
# Copilot Response Handler Configuration
|
|
38
|
+
COPILOT_CONTROLLED_RESPONSE_MAX_TOKENS = 20
|
|
39
|
+
COPILOT_HANDLER_ROLLING_BUFFER_SIZE = 20
|
|
40
|
+
COPILOT_ASSISTANT_TRACKER_MAX_TURNS = 10
|
|
41
|
+
|
|
42
|
+
# Guardrail Configuration
|
|
43
|
+
ASSISTANT_HISTORY_GUARDRAIL_PROJECT_ID = "project-5442154580"
|
|
44
|
+
COPILOT_HISTORY_GUARDRAIL_PROJECT_ID = "project-4637497223"
|
|
45
|
+
|
|
46
|
+
# Auth0 configuration
|
|
47
|
+
AUTH0_DOMAIN = "login.hello.rasa.ai"
|
|
48
|
+
AUTH0_CLIENT_ID = "Gq5RdRwp174OFIfTz6Re9TZUseYDXUYE"
|
|
49
|
+
AUTH0_ISSUER = f"https://{AUTH0_DOMAIN}/"
|
|
50
|
+
JWKS_URL = f"{AUTH0_ISSUER}.well-known/jwks.json"
|
|
51
|
+
|
|
36
52
|
|
|
37
53
|
def get_default_config(assistant_id: str) -> Dict[str, Any]:
|
|
38
54
|
"""Get default Rasa configuration."""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# A dot-path for importlib to the copilot prompt
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
COPILOT_PROMPTS_DIR = "builder.copilot.prompts"
|
|
5
|
+
COPILOT_PROMPTS_FILE = "copilot_system_prompt.jinja2"
|
|
6
|
+
|
|
7
|
+
# Roles copilot utilizes - Use literal types to avoid type errors with OpenAI
|
|
8
|
+
ROLE_USER: Literal["user"] = "user"
|
|
9
|
+
ROLE_SYSTEM: Literal["system"] = "system"
|
|
10
|
+
ROLE_ASSISTANT: Literal["assistant"] = "assistant"
|
|
11
|
+
# Rasa Copilot role - Added to avoid confusion with the assistant role on the frontend.
|
|
12
|
+
ROLE_COPILOT: Literal["copilot"] = "copilot"
|
|
13
|
+
|
|
14
|
+
# Copilot Telemetry
|
|
15
|
+
COPILOT_SEGMENT_WRITE_KEY_ENV_VAR = "COPILOT_SEGMENT_WRITE_KEY"
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import importlib
|
|
3
|
+
import json
|
|
4
|
+
from contextlib import asynccontextmanager
|
|
5
|
+
from typing import Any, Dict, List, Optional
|
|
6
|
+
|
|
7
|
+
import openai
|
|
8
|
+
import structlog
|
|
9
|
+
from jinja2 import Template
|
|
10
|
+
from typing_extensions import AsyncGenerator
|
|
11
|
+
|
|
12
|
+
from rasa.builder import config
|
|
13
|
+
from rasa.builder.copilot.constants import (
|
|
14
|
+
COPILOT_PROMPTS_DIR,
|
|
15
|
+
COPILOT_PROMPTS_FILE,
|
|
16
|
+
ROLE_SYSTEM,
|
|
17
|
+
ROLE_USER,
|
|
18
|
+
)
|
|
19
|
+
from rasa.builder.copilot.exceptions import CopilotStreamError
|
|
20
|
+
from rasa.builder.copilot.models import (
|
|
21
|
+
CopilotContext,
|
|
22
|
+
ResponseCategory,
|
|
23
|
+
UsageStatistics,
|
|
24
|
+
)
|
|
25
|
+
from rasa.builder.document_retrieval.inkeep_document_retrieval import (
|
|
26
|
+
InKeepDocumentRetrieval,
|
|
27
|
+
)
|
|
28
|
+
from rasa.builder.document_retrieval.models import Document
|
|
29
|
+
from rasa.builder.exceptions import (
|
|
30
|
+
DocumentRetrievalError,
|
|
31
|
+
)
|
|
32
|
+
from rasa.builder.shared.tracker_context import TrackerContext
|
|
33
|
+
from rasa.shared.constants import PACKAGE_NAME
|
|
34
|
+
|
|
35
|
+
structlogger = structlog.get_logger()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Copilot:
|
|
39
|
+
def __init__(self) -> None:
|
|
40
|
+
self._inkeep_document_retrieval = InKeepDocumentRetrieval()
|
|
41
|
+
|
|
42
|
+
# Load both prompt templates up-front
|
|
43
|
+
self._system_message_prompt_template = Template(
|
|
44
|
+
importlib.resources.read_text(
|
|
45
|
+
f"{PACKAGE_NAME}.{COPILOT_PROMPTS_DIR}",
|
|
46
|
+
COPILOT_PROMPTS_FILE,
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# The final stream chunk includes usage statistics.
|
|
51
|
+
self.usage_statistics = UsageStatistics()
|
|
52
|
+
|
|
53
|
+
@asynccontextmanager
|
|
54
|
+
async def _get_client(self) -> AsyncGenerator[openai.AsyncOpenAI, None]:
|
|
55
|
+
"""Create a fresh OpenAI client, yield it, and always close it."""
|
|
56
|
+
client = openai.AsyncOpenAI(timeout=config.OPENAI_TIMEOUT)
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
yield client
|
|
60
|
+
except Exception as e:
|
|
61
|
+
structlogger.error("copilot.llm_client_error", error=str(e))
|
|
62
|
+
raise
|
|
63
|
+
finally:
|
|
64
|
+
try:
|
|
65
|
+
await client.close()
|
|
66
|
+
except Exception as exc:
|
|
67
|
+
# Closing should not break request processing, but we log it
|
|
68
|
+
structlogger.warning(
|
|
69
|
+
"copilot.llm_client_close_error",
|
|
70
|
+
event_info="Failed to close OpenAI client cleanly.",
|
|
71
|
+
error=str(exc),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
async def search_rasa_documentation(
|
|
75
|
+
self,
|
|
76
|
+
context: CopilotContext,
|
|
77
|
+
) -> List[Document]:
|
|
78
|
+
"""Search Rasa documentation for relevant information.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
context: The context of the copilot.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
A list of Document objects. Empty list is returned if the search fails.
|
|
85
|
+
"""
|
|
86
|
+
try:
|
|
87
|
+
query = self._create_documentation_search_query(context)
|
|
88
|
+
return await self._inkeep_document_retrieval.retrieve_documents(query)
|
|
89
|
+
except DocumentRetrievalError as e:
|
|
90
|
+
structlogger.error(
|
|
91
|
+
"copilot.search_rasa_documentation.error",
|
|
92
|
+
event_info=(
|
|
93
|
+
f"Copilot: Searching Rasa documentation for query '{query}' "
|
|
94
|
+
f"failed with the following error: {e}. Returning empty list."
|
|
95
|
+
),
|
|
96
|
+
query=query,
|
|
97
|
+
error=str(e),
|
|
98
|
+
)
|
|
99
|
+
return []
|
|
100
|
+
|
|
101
|
+
async def generate_response(
|
|
102
|
+
self,
|
|
103
|
+
context: CopilotContext,
|
|
104
|
+
) -> tuple[AsyncGenerator[str, None], list[Document]]:
|
|
105
|
+
"""Generate a response from the copilot.
|
|
106
|
+
|
|
107
|
+
This method performs document retrieval and response generation as a single
|
|
108
|
+
atomic operation. The returned documents are the supporting evidence used
|
|
109
|
+
to generate the response, ensuring consistency between the response content
|
|
110
|
+
and its sources.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
context: The context of the copilot.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
A tuple containing the async response stream and the relevant documents
|
|
117
|
+
used as supporting evidence for the generated response.
|
|
118
|
+
|
|
119
|
+
Raises:
|
|
120
|
+
CopilotStreamError: If the stream fails.
|
|
121
|
+
Exception: If an unexpected error occurs.
|
|
122
|
+
"""
|
|
123
|
+
relevant_documents = await self.search_rasa_documentation(context)
|
|
124
|
+
system_message = await self._create_system_message(context, relevant_documents)
|
|
125
|
+
chat_history = self._create_chat_history_messages(context)
|
|
126
|
+
messages = [system_message, *chat_history]
|
|
127
|
+
|
|
128
|
+
return self._stream_response(messages), relevant_documents
|
|
129
|
+
|
|
130
|
+
async def _stream_response(
|
|
131
|
+
self, messages: List[Dict[str, Any]]
|
|
132
|
+
) -> AsyncGenerator[str, None]:
|
|
133
|
+
"""Stream markdown chunks one by one."""
|
|
134
|
+
self.usage_statistics.reset()
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
async with self._get_client() as client:
|
|
138
|
+
stream = await client.chat.completions.create(
|
|
139
|
+
model=config.OPENAI_MODEL,
|
|
140
|
+
messages=messages, # type: ignore
|
|
141
|
+
temperature=config.OPENAI_TEMPERATURE,
|
|
142
|
+
stream=True,
|
|
143
|
+
stream_options={"include_usage": True},
|
|
144
|
+
)
|
|
145
|
+
async for chunk in stream:
|
|
146
|
+
# The final chunk, which contains the usage statistics,
|
|
147
|
+
# arrives with an empty `choices` list.
|
|
148
|
+
if not chunk.choices:
|
|
149
|
+
self.usage_statistics.update_from_stream_chunk(chunk)
|
|
150
|
+
# Nothing to yield – continue to the next chunk.
|
|
151
|
+
continue
|
|
152
|
+
|
|
153
|
+
delta = chunk.choices[0].delta
|
|
154
|
+
if delta and delta.content:
|
|
155
|
+
yield delta.content
|
|
156
|
+
except openai.OpenAIError as e:
|
|
157
|
+
structlogger.exception("copilot.stream_response.api_error", error=str(e))
|
|
158
|
+
raise CopilotStreamError(
|
|
159
|
+
"Failed to stream response from OpenAI API."
|
|
160
|
+
) from e
|
|
161
|
+
except asyncio.TimeoutError as e:
|
|
162
|
+
structlogger.exception(
|
|
163
|
+
"copilot.stream_response.timeout_error", error=str(e)
|
|
164
|
+
)
|
|
165
|
+
raise CopilotStreamError("Request to OpenAI API timed out.") from e
|
|
166
|
+
except Exception as e:
|
|
167
|
+
structlogger.exception(
|
|
168
|
+
"copilot.stream_response.unexpected_error", error=str(e)
|
|
169
|
+
)
|
|
170
|
+
raise
|
|
171
|
+
|
|
172
|
+
async def _create_system_message(
|
|
173
|
+
self,
|
|
174
|
+
context: CopilotContext,
|
|
175
|
+
relevant_documents: List[Document],
|
|
176
|
+
) -> Dict[str, Any]:
|
|
177
|
+
"""Render the correct Jinja template based on desired output_type."""
|
|
178
|
+
# Format relevant documentation
|
|
179
|
+
documents = [doc.model_dump() for doc in relevant_documents]
|
|
180
|
+
|
|
181
|
+
# Format conversation history
|
|
182
|
+
conversation = self._format_conversation_history(context.tracker_context)
|
|
183
|
+
|
|
184
|
+
# Format current state
|
|
185
|
+
current_state = self._format_current_state(context.tracker_context)
|
|
186
|
+
|
|
187
|
+
# Render template
|
|
188
|
+
rendered_prompt = self._system_message_prompt_template.render(
|
|
189
|
+
current_conversation=conversation,
|
|
190
|
+
current_state=current_state,
|
|
191
|
+
assistant_logs=context.assistant_logs,
|
|
192
|
+
assistant_files=context.assistant_files,
|
|
193
|
+
documentation_results=documents,
|
|
194
|
+
)
|
|
195
|
+
return {"role": ROLE_SYSTEM, "content": rendered_prompt}
|
|
196
|
+
|
|
197
|
+
def _create_chat_history_messages(
|
|
198
|
+
self,
|
|
199
|
+
context: CopilotContext,
|
|
200
|
+
) -> List[Dict[str, Any]]:
|
|
201
|
+
"""Create the chat history messages for the copilot.
|
|
202
|
+
|
|
203
|
+
Filter out messages with response_category of GUARDRAILS_POLICY_VIOLATION.
|
|
204
|
+
This will filter out all the user messages that were flagged by guardrails, but
|
|
205
|
+
also the copilot messages that were produced by guardrails.
|
|
206
|
+
"""
|
|
207
|
+
return [
|
|
208
|
+
message.to_openai_format()
|
|
209
|
+
for message in context.copilot_chat_history
|
|
210
|
+
if message.response_category != ResponseCategory.GUARDRAILS_POLICY_VIOLATION
|
|
211
|
+
]
|
|
212
|
+
|
|
213
|
+
@staticmethod
|
|
214
|
+
def _create_documentation_search_query(context: CopilotContext) -> str:
|
|
215
|
+
"""Format chat messages between user and copilot for documentation search."""
|
|
216
|
+
result = ""
|
|
217
|
+
user_prefix = "User"
|
|
218
|
+
assistant_prefix = "Assistant"
|
|
219
|
+
for message in context.copilot_chat_history:
|
|
220
|
+
text = message.get_text_content().strip()
|
|
221
|
+
if not text:
|
|
222
|
+
continue
|
|
223
|
+
if message.role == ROLE_USER:
|
|
224
|
+
result += f"{user_prefix}: {text}\n"
|
|
225
|
+
else:
|
|
226
|
+
result += f"{assistant_prefix}: {text}\n"
|
|
227
|
+
return result
|
|
228
|
+
|
|
229
|
+
@staticmethod
|
|
230
|
+
def _format_documents(results: List[Document]) -> Optional[str]:
|
|
231
|
+
"""Format documentation search results as JSON dump to be used in the prompt."""
|
|
232
|
+
if not results:
|
|
233
|
+
return None
|
|
234
|
+
|
|
235
|
+
formatted_results = {
|
|
236
|
+
"sources": [
|
|
237
|
+
{
|
|
238
|
+
# Start the reference from 1, not 0.
|
|
239
|
+
"idx": idx + 1,
|
|
240
|
+
"title": result.title,
|
|
241
|
+
"url": result.url,
|
|
242
|
+
"content": result.content,
|
|
243
|
+
}
|
|
244
|
+
for idx, result in enumerate(results)
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
return json.dumps(formatted_results, ensure_ascii=False, indent=2)
|
|
248
|
+
|
|
249
|
+
@staticmethod
|
|
250
|
+
def _format_conversation_history(tracker_context: Optional[TrackerContext]) -> str:
|
|
251
|
+
"""Format conversation history from TrackerContext using nested turn structure.
|
|
252
|
+
|
|
253
|
+
Args:
|
|
254
|
+
tracker_context: The TrackerContext containing conversation data.
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
A JSON string with turns containing user_input, assistant_response,
|
|
258
|
+
and context.
|
|
259
|
+
|
|
260
|
+
Example:
|
|
261
|
+
```json
|
|
262
|
+
{
|
|
263
|
+
"conversation_history": [
|
|
264
|
+
{
|
|
265
|
+
"turn_id": 1,
|
|
266
|
+
"USER": {
|
|
267
|
+
"text": "I want to transfer money",
|
|
268
|
+
"predicted_commands": ["start flow", "set slot", ...]
|
|
269
|
+
},
|
|
270
|
+
"BOT": [
|
|
271
|
+
{"text": "How much would you like to transfer?"}
|
|
272
|
+
],
|
|
273
|
+
"other_tracker_events": [
|
|
274
|
+
{
|
|
275
|
+
"event": "action_executed",
|
|
276
|
+
"data": {"action_name": "action_ask_amount"}
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"event": "slot_set",
|
|
280
|
+
"data": {
|
|
281
|
+
"slot_name": "amount_of_money",
|
|
282
|
+
"slot_value": 100,
|
|
283
|
+
},
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
"""
|
|
291
|
+
conversation_history: Dict[str, Any] = {
|
|
292
|
+
"conversation_history": [],
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if not tracker_context or not tracker_context.conversation_turns:
|
|
296
|
+
return json.dumps(conversation_history, ensure_ascii=False, indent=2)
|
|
297
|
+
|
|
298
|
+
conversation_turns: List[Dict[str, Any]] = []
|
|
299
|
+
user_prefix = "USER"
|
|
300
|
+
assistant_prefix = "BOT"
|
|
301
|
+
|
|
302
|
+
for turn_idx, turn in enumerate(tracker_context.conversation_turns, 1):
|
|
303
|
+
turn_data: Dict[str, Any] = {"turn_id": turn_idx}
|
|
304
|
+
|
|
305
|
+
# Add user if present
|
|
306
|
+
if turn.user_message:
|
|
307
|
+
turn_data[user_prefix] = {
|
|
308
|
+
"text": turn.user_message.text,
|
|
309
|
+
"predicted_commands": turn.user_message.predicted_commands,
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
# Add assistant messages if present
|
|
313
|
+
if turn.assistant_messages:
|
|
314
|
+
turn_data[assistant_prefix] = [
|
|
315
|
+
{"text": assistant_message.text}
|
|
316
|
+
for assistant_message in turn.assistant_messages
|
|
317
|
+
]
|
|
318
|
+
|
|
319
|
+
# Add other tracker events
|
|
320
|
+
if turn.context_events:
|
|
321
|
+
other_events = [event.model_dump() for event in turn.context_events]
|
|
322
|
+
turn_data["other_tracker_events"] = other_events
|
|
323
|
+
|
|
324
|
+
conversation_turns.append(turn_data)
|
|
325
|
+
|
|
326
|
+
conversation_history["conversation_history"] = conversation_turns
|
|
327
|
+
return json.dumps(conversation_history, ensure_ascii=False, indent=2)
|
|
328
|
+
|
|
329
|
+
@staticmethod
|
|
330
|
+
def _format_current_state(tracker_context: Optional[TrackerContext]) -> str:
|
|
331
|
+
"""Format current state from TrackerContext for LLM consumption.
|
|
332
|
+
|
|
333
|
+
Args:
|
|
334
|
+
tracker_context: The TrackerContext containing current state data.
|
|
335
|
+
|
|
336
|
+
Returns:
|
|
337
|
+
A JSON string containing the current state information.
|
|
338
|
+
"""
|
|
339
|
+
if not tracker_context or not tracker_context.current_state:
|
|
340
|
+
return json.dumps({}, ensure_ascii=False, indent=2)
|
|
341
|
+
current_state = tracker_context.current_state.model_dump()
|
|
342
|
+
return json.dumps(current_state, ensure_ascii=False, indent=2)
|