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,471 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
import re
|
|
3
|
+
from collections import deque
|
|
4
|
+
from typing import AsyncGenerator, Deque, List, Optional, Set
|
|
5
|
+
|
|
6
|
+
import structlog
|
|
7
|
+
|
|
8
|
+
from rasa.builder.copilot.exceptions import (
|
|
9
|
+
CopilotFinalBufferReached,
|
|
10
|
+
CopilotStreamEndedEarly,
|
|
11
|
+
)
|
|
12
|
+
from rasa.builder.copilot.models import (
|
|
13
|
+
CopilotOutput,
|
|
14
|
+
GeneratedContent,
|
|
15
|
+
ReferenceEntry,
|
|
16
|
+
ReferenceSection,
|
|
17
|
+
ResponseCategory,
|
|
18
|
+
ResponseCompleteness,
|
|
19
|
+
)
|
|
20
|
+
from rasa.builder.document_retrieval.models import Document
|
|
21
|
+
|
|
22
|
+
structlogger = structlog.get_logger()
|
|
23
|
+
|
|
24
|
+
# Controlled prediction markers for detecting roleplay and out-of-scope requests
|
|
25
|
+
ROLEPLAY_PREDICTION = "[ROLEPLAY_REQUEST_DETECTED]"
|
|
26
|
+
OUT_OF_SCOPE_PREDICTION = "[OUT_OF_SCOPE_REQUEST_DETECTED]"
|
|
27
|
+
|
|
28
|
+
# Predefined responses for controlled predictions
|
|
29
|
+
ROLEPLAY_RESPONSE = """I'm here to help you build and develop your Rasa chatbot, not to
|
|
30
|
+
roleplay as the assistant you're creating.
|
|
31
|
+
|
|
32
|
+
If you'd like to test how your bot would respond, you can:
|
|
33
|
+
- Share your bot's configuration files and I can help you understand its behavior
|
|
34
|
+
- Ask me to help you modify responses or flows
|
|
35
|
+
- Get guidance on how to improve your bot's conversation flow
|
|
36
|
+
|
|
37
|
+
What would you like to work on with your Rasa chatbot today?"""
|
|
38
|
+
|
|
39
|
+
OUT_OF_SCOPE_RESPONSE = """I'm specifically designed to help with Rasa chatbot
|
|
40
|
+
development and customization.
|
|
41
|
+
|
|
42
|
+
If you have questions about Rasa development or need help with your chatbot, I'm here to
|
|
43
|
+
help! What would you like to work on?"""
|
|
44
|
+
|
|
45
|
+
# Response for guardrail policy violations
|
|
46
|
+
GUARDRAIL_POLICY_VIOLATION_RESPONSE = """I'm here to help you with Rasa chatbot
|
|
47
|
+
development in a safe and respectful environment. I cannot assist with requests that
|
|
48
|
+
involve harmful content, inappropriate material, or attempts to manipulate my responses.
|
|
49
|
+
|
|
50
|
+
Please note that continued attempts to use inappropriate content or manipulate
|
|
51
|
+
responses will result in project termination and account blocking.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
# Redacted message for copilot responses to guardrail policy violations.
|
|
55
|
+
COPILOT_REDACTED_MESSAGE = "[Copilot response redacted for guardrails check.]"
|
|
56
|
+
|
|
57
|
+
# Common LLM response prefixes and suffixes before the actual content. These are removed
|
|
58
|
+
# from the content.
|
|
59
|
+
LLM_PREFIXES_TO_SUFFIX_REMOVE = {
|
|
60
|
+
"```": "```",
|
|
61
|
+
"```markdown": "```",
|
|
62
|
+
'"""': '"""',
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Regex pattern to match inline citations in the generated markdown.
|
|
66
|
+
INLINE_CITATION_PATTERN = r"\[([^\]]+)\]\(([^)]+)\)"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class CopilotResponseHandler:
|
|
70
|
+
"""Handles the controlled responses from Copilot.
|
|
71
|
+
|
|
72
|
+
This handler manages two types of data:
|
|
73
|
+
- llm_stream_buffer: A list of tokens streamed from the LLM during processing.
|
|
74
|
+
- generated_responses: A list of cleaned responses.
|
|
75
|
+
|
|
76
|
+
Parameters:
|
|
77
|
+
rolling_buffer_size: Size of the rolling buffer for prefix/suffix handling.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
def __init__(
|
|
81
|
+
self,
|
|
82
|
+
rolling_buffer_size: int = 20,
|
|
83
|
+
):
|
|
84
|
+
self._rolling_buffer_size = rolling_buffer_size
|
|
85
|
+
|
|
86
|
+
# Rolling buffer for handling special tokens and prefix/suffix removal.
|
|
87
|
+
self._rolling_buffer: Deque[str] = deque(maxlen=self._rolling_buffer_size)
|
|
88
|
+
|
|
89
|
+
# A list of tokens streamed from the LLM during processing. Tokens are added
|
|
90
|
+
# to the buffer when the rolling buffer is full.
|
|
91
|
+
self._llm_stream_buffer: List[str] = []
|
|
92
|
+
|
|
93
|
+
# A list of cleaned and generated responses.
|
|
94
|
+
self._generated_responses: List[GeneratedContent] = []
|
|
95
|
+
|
|
96
|
+
# Flag for checking if the stream has ended (raised by the async generator).
|
|
97
|
+
self._stream_ended: bool = False
|
|
98
|
+
# Flag for checking if the stream ended before the max expected special response
|
|
99
|
+
# tokens were reached.
|
|
100
|
+
self._stream_ended_early: bool = False
|
|
101
|
+
|
|
102
|
+
# Maximum number of tokens to check for special responses (e.g. roleplay,
|
|
103
|
+
# out-of-scope, etc.).
|
|
104
|
+
self._max_expected_special_response_tokens: int = 20
|
|
105
|
+
|
|
106
|
+
# Prefix/suffix tracking
|
|
107
|
+
self._stream_started_with_prefix: bool = False
|
|
108
|
+
self._prefix_found: Optional[str] = None
|
|
109
|
+
self._suffix_found: Optional[str] = None
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def llm_stream_buffer(self) -> List[str]:
|
|
113
|
+
return copy.deepcopy(self._llm_stream_buffer)
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def generated_responses(self) -> List[GeneratedContent]:
|
|
117
|
+
return copy.deepcopy(self._generated_responses)
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def llm_stream_buffer_content(self) -> str:
|
|
121
|
+
return "".join(self._llm_stream_buffer)
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def token_count(self) -> int:
|
|
125
|
+
return len(self._llm_stream_buffer)
|
|
126
|
+
|
|
127
|
+
def clear_buffers(self) -> None:
|
|
128
|
+
"""Clear all buffers and reset the handler."""
|
|
129
|
+
self._rolling_buffer.clear()
|
|
130
|
+
self._llm_stream_buffer.clear()
|
|
131
|
+
self._generated_responses.clear()
|
|
132
|
+
self._stream_started_with_prefix = False
|
|
133
|
+
self._prefix_found = None
|
|
134
|
+
self._suffix_found = None
|
|
135
|
+
self._stream_ended = False
|
|
136
|
+
|
|
137
|
+
async def _buffer_stream(
|
|
138
|
+
self, response_stream: AsyncGenerator[str, None]
|
|
139
|
+
) -> AsyncGenerator[str, None]:
|
|
140
|
+
"""Wrapper that performs rolling buffer handling and automatically saves chunks.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
response_stream: The original streaming response from the LLM.
|
|
144
|
+
|
|
145
|
+
Yields:
|
|
146
|
+
The same chunks from the original stream, but persisted in the buffer.
|
|
147
|
+
|
|
148
|
+
Raises:
|
|
149
|
+
StopAsyncIteration: If the stream has ended.
|
|
150
|
+
"""
|
|
151
|
+
try:
|
|
152
|
+
while True:
|
|
153
|
+
# Get the next chunk from LLM stream and add it to the rolling buffer
|
|
154
|
+
# and the LLM stream buffer.
|
|
155
|
+
chunk = await response_stream.__anext__()
|
|
156
|
+
self._rolling_buffer.append(chunk)
|
|
157
|
+
|
|
158
|
+
# Only yield when buffer is full to maintain the rolling buffer
|
|
159
|
+
# behavior
|
|
160
|
+
if len(self._rolling_buffer) == self._rolling_buffer_size:
|
|
161
|
+
# Yield the oldest element.
|
|
162
|
+
oldest_element = self._rolling_buffer.popleft()
|
|
163
|
+
self._llm_stream_buffer.append(oldest_element)
|
|
164
|
+
yield oldest_element
|
|
165
|
+
|
|
166
|
+
except StopAsyncIteration:
|
|
167
|
+
self._llm_stream_buffer.extend(self._rolling_buffer)
|
|
168
|
+
self._stream_ended = True
|
|
169
|
+
# Need to raise a new instance of StopAsyncIteration to avoid the
|
|
170
|
+
# RuntimeError: generator raised StopIteration
|
|
171
|
+
raise CopilotFinalBufferReached()
|
|
172
|
+
|
|
173
|
+
except Exception as e:
|
|
174
|
+
structlogger.exception(
|
|
175
|
+
"copilot_response_handler._buffer_stream.unexpected_error",
|
|
176
|
+
)
|
|
177
|
+
raise e
|
|
178
|
+
|
|
179
|
+
async def handle_response(
|
|
180
|
+
self, response_stream: AsyncGenerator[str, None]
|
|
181
|
+
) -> AsyncGenerator[CopilotOutput, None]:
|
|
182
|
+
"""Intercept a streaming response and handle special responses from the Copilot.
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
response_stream: The original streaming response from the LLM.
|
|
186
|
+
|
|
187
|
+
Yields:
|
|
188
|
+
ResponseEvent objects representing either generated tokens, default
|
|
189
|
+
responses, or reference sections.
|
|
190
|
+
"""
|
|
191
|
+
# Clear the stream buffer and reference buffer at the start
|
|
192
|
+
self.clear_buffers()
|
|
193
|
+
|
|
194
|
+
try:
|
|
195
|
+
# Exhaust the buffer early to check for controlled predictions and prefix
|
|
196
|
+
# detection.
|
|
197
|
+
await self._exhaust_buffer_for_early_detection(response_stream)
|
|
198
|
+
|
|
199
|
+
# Check for controlled predictions in the collected tokens
|
|
200
|
+
controlled_response = self._check_for_controlled_predictions(
|
|
201
|
+
self.llm_stream_buffer_content,
|
|
202
|
+
)
|
|
203
|
+
if controlled_response is not None:
|
|
204
|
+
self._generated_responses.append(controlled_response)
|
|
205
|
+
yield controlled_response
|
|
206
|
+
return
|
|
207
|
+
|
|
208
|
+
# At this point, no controlled predictions were found. Check if the stream
|
|
209
|
+
# started with a prefix and if present, remove it. Yield the clean content.
|
|
210
|
+
initial_content = self._remove_prexif(self.llm_stream_buffer_content)
|
|
211
|
+
if initial_content:
|
|
212
|
+
generated_content = GeneratedContent(
|
|
213
|
+
content=initial_content,
|
|
214
|
+
response_category=ResponseCategory.COPILOT,
|
|
215
|
+
response_completeness=ResponseCompleteness.TOKEN,
|
|
216
|
+
)
|
|
217
|
+
self._generated_responses.append(generated_content)
|
|
218
|
+
yield generated_content
|
|
219
|
+
|
|
220
|
+
# Continue streaming remaining chunks with rolling buffer handling
|
|
221
|
+
async for chunk in self._buffer_stream(response_stream):
|
|
222
|
+
generated_content = GeneratedContent(
|
|
223
|
+
content=chunk,
|
|
224
|
+
response_category=ResponseCategory.COPILOT,
|
|
225
|
+
response_completeness=ResponseCompleteness.TOKEN,
|
|
226
|
+
)
|
|
227
|
+
self._generated_responses.append(generated_content)
|
|
228
|
+
yield generated_content
|
|
229
|
+
|
|
230
|
+
# Stream ended early
|
|
231
|
+
except CopilotStreamEndedEarly:
|
|
232
|
+
# Check for controlled predictions in the collected tokens
|
|
233
|
+
controlled_response = self._check_for_controlled_predictions(
|
|
234
|
+
self.llm_stream_buffer_content,
|
|
235
|
+
)
|
|
236
|
+
if controlled_response is not None:
|
|
237
|
+
self._generated_responses.append(controlled_response)
|
|
238
|
+
yield controlled_response
|
|
239
|
+
return
|
|
240
|
+
|
|
241
|
+
# At this point, no controlled predictions were found. Clean the content
|
|
242
|
+
# from the prefix and suffix if present.
|
|
243
|
+
final_content = self._remove_prefix_and_suffix(
|
|
244
|
+
self.llm_stream_buffer_content,
|
|
245
|
+
)
|
|
246
|
+
if final_content:
|
|
247
|
+
generated_content = GeneratedContent(
|
|
248
|
+
content=final_content,
|
|
249
|
+
response_category=ResponseCategory.COPILOT,
|
|
250
|
+
response_completeness=ResponseCompleteness.COMPLETE,
|
|
251
|
+
)
|
|
252
|
+
self._generated_responses.append(generated_content)
|
|
253
|
+
yield generated_content
|
|
254
|
+
|
|
255
|
+
# Stream has ended, process the final rolling buffer. Remove the suffix if
|
|
256
|
+
# present.
|
|
257
|
+
except CopilotFinalBufferReached:
|
|
258
|
+
final_content = self._remove_suffix(self.llm_stream_buffer_content)
|
|
259
|
+
if final_content:
|
|
260
|
+
generated_content = GeneratedContent(
|
|
261
|
+
content=final_content,
|
|
262
|
+
response_category=ResponseCategory.COPILOT,
|
|
263
|
+
response_completeness=ResponseCompleteness.COMPLETE,
|
|
264
|
+
)
|
|
265
|
+
self._generated_responses.append(generated_content)
|
|
266
|
+
yield generated_content
|
|
267
|
+
|
|
268
|
+
# Unexpected error occurred.
|
|
269
|
+
except Exception as e:
|
|
270
|
+
structlogger.exception(
|
|
271
|
+
"copilot_response_handler.handle_response.unexpected_error",
|
|
272
|
+
)
|
|
273
|
+
raise e
|
|
274
|
+
|
|
275
|
+
async def _exhaust_buffer_for_early_detection(
|
|
276
|
+
self, response_stream: AsyncGenerator[str, None]
|
|
277
|
+
) -> None:
|
|
278
|
+
"""Exhaust the buffer for early detection.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
response_stream: The original streaming response from the LLM.
|
|
282
|
+
"""
|
|
283
|
+
try:
|
|
284
|
+
async for _ in self._buffer_stream(response_stream):
|
|
285
|
+
if self.token_count >= self._max_expected_special_response_tokens:
|
|
286
|
+
break
|
|
287
|
+
except CopilotFinalBufferReached:
|
|
288
|
+
# The stream ended before the max expected special response tokens
|
|
289
|
+
# were reached.
|
|
290
|
+
raise CopilotStreamEndedEarly()
|
|
291
|
+
|
|
292
|
+
def _check_for_controlled_predictions(
|
|
293
|
+
self, content: str
|
|
294
|
+
) -> Optional[CopilotOutput]:
|
|
295
|
+
"""Check for controlled predictions in the collected tokens.
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
Controlled response if found, None otherwise.
|
|
299
|
+
"""
|
|
300
|
+
# If the Copilot detected a roleplay request, return the default response.
|
|
301
|
+
if ROLEPLAY_PREDICTION in content:
|
|
302
|
+
structlogger.info("response_interceptor.roleplay_request_detected")
|
|
303
|
+
return GeneratedContent(
|
|
304
|
+
response_category=ResponseCategory.ROLEPLAY_DETECTION,
|
|
305
|
+
content=ROLEPLAY_RESPONSE,
|
|
306
|
+
response_completeness=ResponseCompleteness.COMPLETE,
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
# If the Copilot detected an out-of-scope request, return the default response.
|
|
310
|
+
elif OUT_OF_SCOPE_PREDICTION in content:
|
|
311
|
+
structlogger.info("response_interceptor.out_of_scope_request_detected")
|
|
312
|
+
return GeneratedContent(
|
|
313
|
+
response_category=ResponseCategory.OUT_OF_SCOPE_DETECTION,
|
|
314
|
+
content=OUT_OF_SCOPE_RESPONSE,
|
|
315
|
+
response_completeness=ResponseCompleteness.COMPLETE,
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
return None
|
|
319
|
+
|
|
320
|
+
def _remove_prexif(self, content: str) -> str:
|
|
321
|
+
"""Process the initial content from the buffer, handling prefix removal.
|
|
322
|
+
|
|
323
|
+
Returns:
|
|
324
|
+
Processed content with prefix removed if applicable.
|
|
325
|
+
"""
|
|
326
|
+
# Check if content starts with any of the known prefixes
|
|
327
|
+
for prefix in LLM_PREFIXES_TO_SUFFIX_REMOVE.keys():
|
|
328
|
+
if content.startswith(prefix):
|
|
329
|
+
self._stream_started_with_prefix = True
|
|
330
|
+
self._prefix_found = prefix
|
|
331
|
+
self._code_block_depth = 1
|
|
332
|
+
structlogger.debug(
|
|
333
|
+
"copilot_response_handler.handle_response.prefix_detected",
|
|
334
|
+
prefix=prefix,
|
|
335
|
+
content_length=len(content),
|
|
336
|
+
)
|
|
337
|
+
return content[len(prefix) :]
|
|
338
|
+
|
|
339
|
+
return content
|
|
340
|
+
|
|
341
|
+
def _remove_suffix(self, content: str) -> str:
|
|
342
|
+
"""Process the rolling buffer content, handling suffix removal.
|
|
343
|
+
|
|
344
|
+
Returns:
|
|
345
|
+
Processed content with suffix removed if applicable.
|
|
346
|
+
"""
|
|
347
|
+
# Check if content ends with any of the known suffixes
|
|
348
|
+
for suffix in LLM_PREFIXES_TO_SUFFIX_REMOVE.values():
|
|
349
|
+
if content.endswith(suffix):
|
|
350
|
+
self._stream_ended_with_suffix = True
|
|
351
|
+
self._suffix_found = suffix
|
|
352
|
+
structlogger.debug(
|
|
353
|
+
"copilot_response_handler.handle_response.suffix_detected",
|
|
354
|
+
suffix=suffix,
|
|
355
|
+
content_length=len(content),
|
|
356
|
+
)
|
|
357
|
+
return content[: -len(suffix)]
|
|
358
|
+
|
|
359
|
+
return content
|
|
360
|
+
|
|
361
|
+
def _remove_prefix_and_suffix(self, content: str) -> str:
|
|
362
|
+
"""Remove the prefix and suffix from the content.
|
|
363
|
+
|
|
364
|
+
Returns:
|
|
365
|
+
Processed content with prefix and suffix removed if applicable.
|
|
366
|
+
"""
|
|
367
|
+
content = self._remove_prexif(content)
|
|
368
|
+
content = self._remove_suffix(content)
|
|
369
|
+
return content
|
|
370
|
+
|
|
371
|
+
@staticmethod
|
|
372
|
+
def respond_to_guardrail_policy_violations() -> GeneratedContent:
|
|
373
|
+
"""Respond to guardrail policy violations.
|
|
374
|
+
|
|
375
|
+
Returns:
|
|
376
|
+
CopilotOutput object with the response.
|
|
377
|
+
"""
|
|
378
|
+
return GeneratedContent(
|
|
379
|
+
response_category=ResponseCategory.GUARDRAILS_POLICY_VIOLATION,
|
|
380
|
+
content=GUARDRAIL_POLICY_VIOLATION_RESPONSE,
|
|
381
|
+
response_completeness=ResponseCompleteness.COMPLETE,
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
@staticmethod
|
|
385
|
+
def get_copilot_redacted_message() -> str:
|
|
386
|
+
"""Get the redacted message for copilot responses.
|
|
387
|
+
|
|
388
|
+
Returns:
|
|
389
|
+
Redacted message for copilot responses.
|
|
390
|
+
"""
|
|
391
|
+
return COPILOT_REDACTED_MESSAGE
|
|
392
|
+
|
|
393
|
+
def extract_references(self, documents: List[Document]) -> ReferenceSection:
|
|
394
|
+
"""Extract references from the LLM stream buffer content.
|
|
395
|
+
|
|
396
|
+
This method performs regex matching to find markdown links in the format:
|
|
397
|
+
[text](url).
|
|
398
|
+
|
|
399
|
+
The matched links are validated against the provided documents, and a
|
|
400
|
+
ReferenceSection is returned with valid references.
|
|
401
|
+
|
|
402
|
+
Note:
|
|
403
|
+
This method can only be called after `handle_response` has been called,
|
|
404
|
+
as it relies on the LLM stream buffer content that gets populated
|
|
405
|
+
during the response handling process.
|
|
406
|
+
|
|
407
|
+
Args:
|
|
408
|
+
documents: List of Document objects to match URLs against
|
|
409
|
+
|
|
410
|
+
Returns:
|
|
411
|
+
ReferenceSection containing valid reference entries.
|
|
412
|
+
|
|
413
|
+
Raises:
|
|
414
|
+
RuntimeError: If called before `handle_response` has populated the buffer.
|
|
415
|
+
"""
|
|
416
|
+
if not self.llm_stream_buffer_content:
|
|
417
|
+
message = (
|
|
418
|
+
"`extract_references` can only be called after `handle_response` "
|
|
419
|
+
"has been called to populate the LLM stream buffer."
|
|
420
|
+
)
|
|
421
|
+
structlogger.error(
|
|
422
|
+
"copilot_response_handler.extract_references.buffer_not_populated",
|
|
423
|
+
event_info=message,
|
|
424
|
+
llm_stream_buffer_content=self.llm_stream_buffer_content,
|
|
425
|
+
)
|
|
426
|
+
raise RuntimeError(message)
|
|
427
|
+
|
|
428
|
+
# Find all matches in the buffered content
|
|
429
|
+
matches = re.findall(INLINE_CITATION_PATTERN, self.llm_stream_buffer_content)
|
|
430
|
+
|
|
431
|
+
valid_references: List[ReferenceEntry] = []
|
|
432
|
+
document_urls: Set[str] = {
|
|
433
|
+
document.url for document in documents if document.url
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
for reference_text, reference_url in matches:
|
|
437
|
+
# Check if link_text is a number
|
|
438
|
+
if not reference_text.isdigit():
|
|
439
|
+
structlogger.warning(
|
|
440
|
+
"copilot_response_handler.extract_references"
|
|
441
|
+
".link_text_not_a_number",
|
|
442
|
+
event_info="Link text is not a number.",
|
|
443
|
+
link_text=reference_text,
|
|
444
|
+
link_url=reference_url,
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
# Check if URL exists in the documents
|
|
448
|
+
if reference_url not in document_urls:
|
|
449
|
+
structlogger.warning(
|
|
450
|
+
"copilot_response_handler.extract_references.url_not_found",
|
|
451
|
+
event_info=(
|
|
452
|
+
"URL not found in provided documents. Omitted from reference "
|
|
453
|
+
"section.",
|
|
454
|
+
),
|
|
455
|
+
link_url=reference_url,
|
|
456
|
+
document_urls=document_urls,
|
|
457
|
+
)
|
|
458
|
+
continue
|
|
459
|
+
|
|
460
|
+
# Find the corresponding document for this URL and get its index in the list
|
|
461
|
+
for document_index, document in enumerate(documents, start=1):
|
|
462
|
+
if document.url == reference_url:
|
|
463
|
+
reference_entry = ReferenceEntry(
|
|
464
|
+
index=document_index,
|
|
465
|
+
title=document.title or f"Reference {document_index}",
|
|
466
|
+
url=reference_url,
|
|
467
|
+
)
|
|
468
|
+
valid_references.append(reference_entry)
|
|
469
|
+
break
|
|
470
|
+
|
|
471
|
+
return ReferenceSection(references=valid_references)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class CopilotFinalBufferReached(Exception):
|
|
2
|
+
"""Raised when the rolling buffer ends."""
|
|
3
|
+
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CopilotStreamEndedEarly(Exception):
|
|
8
|
+
"""Raised when the stream ended early.
|
|
9
|
+
|
|
10
|
+
This happens when the stream ended before the max expected special response
|
|
11
|
+
tokens were reached.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CopilotStreamError(Exception):
|
|
18
|
+
"""Raised when the stream fails."""
|
|
19
|
+
|
|
20
|
+
pass
|