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/logging_utils.py
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
"""Logging utilities for the
|
|
1
|
+
"""Logging and Sentry utilities for the builder service."""
|
|
2
2
|
|
|
3
3
|
import collections
|
|
4
4
|
import logging
|
|
5
5
|
import threading
|
|
6
|
-
|
|
6
|
+
import time
|
|
7
|
+
import uuid
|
|
8
|
+
from typing import Any, Deque, Dict, Mapping, MutableMapping, Optional
|
|
9
|
+
|
|
10
|
+
import sentry_sdk
|
|
11
|
+
import structlog
|
|
12
|
+
from sanic import Request
|
|
7
13
|
|
|
8
14
|
from rasa.builder import config
|
|
15
|
+
from rasa.builder.auth import HEADER_USER_ID
|
|
16
|
+
|
|
17
|
+
structlogger = structlog.get_logger()
|
|
9
18
|
|
|
10
19
|
# Thread-safe deque for collecting recent logs
|
|
11
20
|
_recent_logs: Deque[str] = collections.deque(maxlen=config.MAX_LOG_ENTRIES)
|
|
@@ -13,8 +22,8 @@ _logs_lock = threading.RLock()
|
|
|
13
22
|
|
|
14
23
|
|
|
15
24
|
def collecting_logs_processor(
|
|
16
|
-
logger: Any, log_level: str, event_dict:
|
|
17
|
-
) ->
|
|
25
|
+
logger: Any, log_level: str, event_dict: MutableMapping[str, Any]
|
|
26
|
+
) -> MutableMapping[str, Any]:
|
|
18
27
|
"""Structlog processor that collects recent log entries.
|
|
19
28
|
|
|
20
29
|
This processor is thread-safe and maintains a rolling buffer of recent logs.
|
|
@@ -29,6 +38,22 @@ def collecting_logs_processor(
|
|
|
29
38
|
return event_dict
|
|
30
39
|
|
|
31
40
|
|
|
41
|
+
def attach_request_id_processor(
|
|
42
|
+
logger: Any, log_level: str, event_dict: MutableMapping[str, Any]
|
|
43
|
+
) -> MutableMapping[str, Any]:
|
|
44
|
+
"""Structlog processor that attaches the request id to the event dict.
|
|
45
|
+
|
|
46
|
+
This processor is thread-safe and maintains a rolling buffer of recent logs.
|
|
47
|
+
"""
|
|
48
|
+
try:
|
|
49
|
+
request = Request.get_current()
|
|
50
|
+
event_dict["correlation_id"] = request.ctx.correlation_id
|
|
51
|
+
return event_dict
|
|
52
|
+
except Exception:
|
|
53
|
+
# there is no request context, so we don't attach the request id
|
|
54
|
+
return event_dict
|
|
55
|
+
|
|
56
|
+
|
|
32
57
|
def get_recent_logs() -> str:
|
|
33
58
|
"""Get recent log entries as a formatted string.
|
|
34
59
|
|
|
@@ -49,3 +74,136 @@ def get_log_count() -> int:
|
|
|
49
74
|
"""Get the current number of log entries."""
|
|
50
75
|
with _logs_lock:
|
|
51
76
|
return len(_recent_logs)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _sanitize_headers(headers: Mapping[str, str]) -> Dict[str, Any]:
|
|
80
|
+
"""Remove or redact sensitive headers for safe logging and Sentry context."""
|
|
81
|
+
lowered = {k.lower(): v for k, v in headers.items()}
|
|
82
|
+
result: Dict[str, Any] = {}
|
|
83
|
+
# Safe keepers
|
|
84
|
+
if "user-agent" in lowered:
|
|
85
|
+
result["user-agent"] = lowered["user-agent"]
|
|
86
|
+
if HEADER_USER_ID in lowered:
|
|
87
|
+
result[HEADER_USER_ID] = lowered[HEADER_USER_ID]
|
|
88
|
+
# Redact auth info
|
|
89
|
+
if "authorization" in lowered:
|
|
90
|
+
auth_val = lowered["authorization"]
|
|
91
|
+
# Keep only the scheme if present
|
|
92
|
+
scheme = auth_val.split(" ")[0] if auth_val else ""
|
|
93
|
+
result["authorization"] = f"{scheme} <redacted>" if scheme else "present"
|
|
94
|
+
return result
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def ensure_correlation_id_on_request(request: Any) -> str:
|
|
98
|
+
"""Ensure a correlation id exists on the request and return it."""
|
|
99
|
+
if not hasattr(request.ctx, "correlation_id") or not request.ctx.correlation_id:
|
|
100
|
+
request.ctx.correlation_id = uuid.uuid4().hex
|
|
101
|
+
return request.ctx.correlation_id
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def extract_request_context() -> Dict[str, Any]:
|
|
105
|
+
"""Extract safe request context for logging / Sentry."""
|
|
106
|
+
try:
|
|
107
|
+
request = Request.get_current()
|
|
108
|
+
headers = getattr(request, "headers", {}) or {}
|
|
109
|
+
args = getattr(request, "args", {}) or {}
|
|
110
|
+
json_body = getattr(request, "json", None)
|
|
111
|
+
content_length = getattr(request, "content_length", None)
|
|
112
|
+
ctx: Dict[str, Any] = {
|
|
113
|
+
"method": getattr(request, "method", None),
|
|
114
|
+
"path": getattr(request, "path", None),
|
|
115
|
+
"query_args": dict(args) if hasattr(args, "items") else args,
|
|
116
|
+
"remote_addr": getattr(request, "remote_addr", None),
|
|
117
|
+
"content_length": content_length,
|
|
118
|
+
"has_json": json_body is not None,
|
|
119
|
+
"headers": _sanitize_headers(dict(headers)),
|
|
120
|
+
}
|
|
121
|
+
if hasattr(request, "ctx"):
|
|
122
|
+
ctx["correlation_id"] = ensure_correlation_id_on_request(request)
|
|
123
|
+
# Common custom fields if present
|
|
124
|
+
ctx["user_id"] = request.headers.get(HEADER_USER_ID)
|
|
125
|
+
return ctx
|
|
126
|
+
except Exception:
|
|
127
|
+
return {}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def capture_exception_with_context(
|
|
131
|
+
exc: BaseException,
|
|
132
|
+
event_id: str,
|
|
133
|
+
extra: Optional[Dict[str, Any]] = None,
|
|
134
|
+
tags: Optional[Dict[str, str]] = None,
|
|
135
|
+
) -> None:
|
|
136
|
+
"""Capture exception in Sentry and log it with rich context.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
request: Sanic request
|
|
140
|
+
exc: exception instance
|
|
141
|
+
event_id: structlog event id
|
|
142
|
+
extra: additional context to include
|
|
143
|
+
tags: sentry tags to attach
|
|
144
|
+
"""
|
|
145
|
+
request_ctx = extract_request_context()
|
|
146
|
+
if extra is None:
|
|
147
|
+
extra = {}
|
|
148
|
+
# Sentry scope
|
|
149
|
+
try:
|
|
150
|
+
with sentry_sdk.configure_scope() as scope:
|
|
151
|
+
scope.set_tag("service", "bot-builder")
|
|
152
|
+
if tags:
|
|
153
|
+
for k, v in tags.items():
|
|
154
|
+
scope.set_tag(k, v)
|
|
155
|
+
# Flatten some useful fields as tags
|
|
156
|
+
if request_ctx.get("path"):
|
|
157
|
+
scope.set_tag("route", request_ctx["path"])
|
|
158
|
+
if request_ctx.get("method"):
|
|
159
|
+
scope.set_tag("method", request_ctx["method"])
|
|
160
|
+
if request_ctx.get("correlation_id"):
|
|
161
|
+
scope.set_tag("correlation_id", request_ctx["correlation_id"])
|
|
162
|
+
user_id = request_ctx.get("user_id")
|
|
163
|
+
if user_id and hasattr(scope, "set_user"):
|
|
164
|
+
scope.set_user({"id": str(user_id)})
|
|
165
|
+
# Context blocks
|
|
166
|
+
scope.set_context("request", request_ctx)
|
|
167
|
+
if extra:
|
|
168
|
+
scope.set_context("extra", extra)
|
|
169
|
+
sentry_sdk.capture_exception(exc)
|
|
170
|
+
except Exception:
|
|
171
|
+
# Never fail the app because Sentry failed
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
# Structlog error with merged context (avoid dumping huge payloads)
|
|
175
|
+
structlogger.error(
|
|
176
|
+
event_id,
|
|
177
|
+
error=str(exc),
|
|
178
|
+
**{k: v for k, v in {**request_ctx, **extra}.items() if k not in {"headers"}},
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def log_request_start(request: Any) -> float:
|
|
183
|
+
"""Log request start and return start time."""
|
|
184
|
+
start = time.perf_counter()
|
|
185
|
+
cid = ensure_correlation_id_on_request(request)
|
|
186
|
+
ctx = extract_request_context()
|
|
187
|
+
structlogger.info(
|
|
188
|
+
"request.received",
|
|
189
|
+
method=ctx.get("method"),
|
|
190
|
+
path=ctx.get("path"),
|
|
191
|
+
remote_addr=ctx.get("remote_addr") or "unknown",
|
|
192
|
+
correlation_id=cid,
|
|
193
|
+
user_id=ctx.get("user_id"),
|
|
194
|
+
)
|
|
195
|
+
return start
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def log_request_end(request: Any, response: Any, start: float) -> None:
|
|
199
|
+
"""Log request completion with latency and correlation id."""
|
|
200
|
+
latency_ms = int((time.perf_counter() - start) * 1000)
|
|
201
|
+
cid = ensure_correlation_id_on_request(request)
|
|
202
|
+
structlogger.info(
|
|
203
|
+
"request.completed",
|
|
204
|
+
method=getattr(request, "method", None),
|
|
205
|
+
path=getattr(request, "path", None),
|
|
206
|
+
status=getattr(response, "status", None),
|
|
207
|
+
latency_ms=latency_ms,
|
|
208
|
+
correlation_id=cid,
|
|
209
|
+
)
|
rasa/builder/main.py
CHANGED
|
@@ -11,8 +11,14 @@ from sanic.request import Request
|
|
|
11
11
|
from sanic_openapi import openapi3_blueprint
|
|
12
12
|
|
|
13
13
|
import rasa.core.utils
|
|
14
|
+
import rasa.telemetry
|
|
14
15
|
from rasa.builder import config
|
|
15
|
-
from rasa.builder.logging_utils import
|
|
16
|
+
from rasa.builder.logging_utils import (
|
|
17
|
+
attach_request_id_processor,
|
|
18
|
+
collecting_logs_processor,
|
|
19
|
+
log_request_end,
|
|
20
|
+
log_request_start,
|
|
21
|
+
)
|
|
16
22
|
from rasa.builder.service import bp, setup_project_generator
|
|
17
23
|
from rasa.core.channels.studio_chat import StudioChatInput
|
|
18
24
|
from rasa.server import configure_cors
|
|
@@ -37,7 +43,7 @@ def setup_logging() -> None:
|
|
|
37
43
|
configure_structlog(
|
|
38
44
|
log_level,
|
|
39
45
|
include_time=True,
|
|
40
|
-
additional_processors=[collecting_logs_processor],
|
|
46
|
+
additional_processors=[attach_request_id_processor, collecting_logs_processor],
|
|
41
47
|
)
|
|
42
48
|
|
|
43
49
|
|
|
@@ -52,23 +58,26 @@ def setup_input_channel() -> StudioChatInput:
|
|
|
52
58
|
def setup_middleware(app: Sanic) -> None:
|
|
53
59
|
"""Setup middleware for request/response processing."""
|
|
54
60
|
|
|
55
|
-
@app.middleware("request")
|
|
61
|
+
@app.middleware("request") # type: ignore[misc,no-untyped-call]
|
|
56
62
|
async def log_request(request: Request) -> None:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
method=request.method,
|
|
60
|
-
path=request.path,
|
|
61
|
-
remote_addr=request.remote_addr or "unknown",
|
|
62
|
-
)
|
|
63
|
+
# store start time on request ctx for later latency calculation
|
|
64
|
+
request.ctx._start_time = log_request_start(request)
|
|
63
65
|
|
|
64
|
-
@app.middleware("response")
|
|
66
|
+
@app.middleware("response") # type: ignore[misc,no-untyped-call]
|
|
65
67
|
async def log_response(request: Request, response: HTTPResponse) -> None:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
try:
|
|
69
|
+
start = getattr(request.ctx, "_start_time", None)
|
|
70
|
+
if start is None:
|
|
71
|
+
# If for some reason the request middleware didn't run
|
|
72
|
+
start = log_request_start(request)
|
|
73
|
+
# propagate correlation id for clients
|
|
74
|
+
correlation_id = getattr(request.ctx, "correlation_id", None)
|
|
75
|
+
if correlation_id:
|
|
76
|
+
response.headers["X-Correlation-Id"] = correlation_id
|
|
77
|
+
log_request_end(request, response, start)
|
|
78
|
+
except Exception:
|
|
79
|
+
# avoid breaking response path
|
|
80
|
+
pass
|
|
72
81
|
|
|
73
82
|
|
|
74
83
|
def create_app(project_folder: Optional[str] = None) -> Sanic:
|
|
@@ -116,6 +125,10 @@ def main(project_folder: Optional[str] = None) -> None:
|
|
|
116
125
|
# Setup logging
|
|
117
126
|
setup_logging()
|
|
118
127
|
|
|
128
|
+
# Setup telemetry
|
|
129
|
+
rasa.telemetry.initialize_telemetry()
|
|
130
|
+
rasa.telemetry.initialize_error_reporting(private_mode=False)
|
|
131
|
+
|
|
119
132
|
# Create and configure app
|
|
120
133
|
app = create_app(project_folder)
|
|
121
134
|
register_custom_sanic_error_handler(app)
|
rasa/builder/models.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"""Pydantic models for request/response validation."""
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import json
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from typing import Any, Dict, List, Literal, Optional
|
|
4
6
|
|
|
7
|
+
import structlog
|
|
5
8
|
from pydantic import BaseModel, Field, validator
|
|
6
9
|
|
|
7
10
|
from rasa.cli.scaffold import ProjectTemplateName
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
structlogger = structlog.get_logger()
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
class PromptRequest(BaseModel):
|
|
@@ -14,9 +18,6 @@ class PromptRequest(BaseModel):
|
|
|
14
18
|
prompt: str = Field(
|
|
15
19
|
..., min_length=1, max_length=10000, description="The skill description prompt"
|
|
16
20
|
)
|
|
17
|
-
client_id: Optional[str] = Field(
|
|
18
|
-
None, max_length=255, description="Optional client identifier"
|
|
19
|
-
)
|
|
20
21
|
|
|
21
22
|
@validator("prompt")
|
|
22
23
|
def validate_prompt(cls, v: str) -> str:
|
|
@@ -34,9 +35,6 @@ class TemplateRequest(BaseModel):
|
|
|
34
35
|
f"The template name to use ({ProjectTemplateName.supported_values()})"
|
|
35
36
|
),
|
|
36
37
|
)
|
|
37
|
-
client_id: Optional[str] = Field(
|
|
38
|
-
None, max_length=255, description="Optional client identifier"
|
|
39
|
-
)
|
|
40
38
|
|
|
41
39
|
@validator("template_name")
|
|
42
40
|
def validate_template_name(cls, v: Any) -> Any:
|
|
@@ -47,33 +45,6 @@ class TemplateRequest(BaseModel):
|
|
|
47
45
|
return v
|
|
48
46
|
|
|
49
47
|
|
|
50
|
-
class ChatMessage(BaseModel):
|
|
51
|
-
"""Model for chat messages."""
|
|
52
|
-
|
|
53
|
-
type: str = Field(..., pattern="^(user|assistant)$")
|
|
54
|
-
content: Union[str, List[Dict[str, Any]]] = Field(...)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class LLMBuilderRequest(BaseModel):
|
|
58
|
-
"""Request model for LLM builder endpoint."""
|
|
59
|
-
|
|
60
|
-
messages: List[ChatMessage] = Field(..., min_items=1, max_items=50)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class LLMBuilderContext(BaseModel):
|
|
64
|
-
"""Context model for LLM builder endpoint."""
|
|
65
|
-
|
|
66
|
-
tracker: Optional[DialogueStateTracker] = Field(None)
|
|
67
|
-
bot_logs: str = Field("")
|
|
68
|
-
chat_bot_files: Dict[str, str] = Field({})
|
|
69
|
-
chat_history: List[ChatMessage] = Field([])
|
|
70
|
-
|
|
71
|
-
class Config:
|
|
72
|
-
"""Config for LLMBuilderContext."""
|
|
73
|
-
|
|
74
|
-
arbitrary_types_allowed = True
|
|
75
|
-
|
|
76
|
-
|
|
77
48
|
class BotDataUpdateRequest(BaseModel):
|
|
78
49
|
"""Request model for bot data updates."""
|
|
79
50
|
|
|
@@ -87,67 +58,101 @@ class BotDataUpdateRequest(BaseModel):
|
|
|
87
58
|
allow_population_by_field_name = True
|
|
88
59
|
|
|
89
60
|
|
|
90
|
-
class
|
|
91
|
-
"""
|
|
61
|
+
class BotData(BaseModel):
|
|
62
|
+
"""Data of a running assistant."""
|
|
92
63
|
|
|
93
|
-
|
|
64
|
+
domain: Dict[str, Any] = Field(..., description="The domain of the assistant.")
|
|
65
|
+
flows: Dict[str, Any] = Field(..., description="The flows of the assistant.")
|
|
94
66
|
|
|
95
67
|
|
|
96
|
-
class
|
|
97
|
-
"""
|
|
68
|
+
class AssistantInfo(BaseModel):
|
|
69
|
+
"""Basic information about the loaded assistant."""
|
|
98
70
|
|
|
99
|
-
|
|
100
|
-
|
|
71
|
+
assistant_id: Optional[str] = Field(
|
|
72
|
+
None,
|
|
73
|
+
description=(
|
|
74
|
+
"Assistant identifier coming from `assistant_id` in the model "
|
|
75
|
+
"metadata (config.yml)."
|
|
76
|
+
),
|
|
77
|
+
)
|
|
101
78
|
|
|
102
79
|
|
|
103
|
-
class
|
|
104
|
-
"""
|
|
80
|
+
class ApiErrorResponse(BaseModel):
|
|
81
|
+
"""API error response model."""
|
|
105
82
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
83
|
+
status: Literal["error"] = "error"
|
|
84
|
+
error: str = Field(...)
|
|
85
|
+
details: Optional[Dict[str, Any]] = Field(None)
|
|
109
86
|
|
|
110
87
|
|
|
111
|
-
class
|
|
112
|
-
|
|
88
|
+
class ServerSentEventType(str, Enum):
|
|
89
|
+
progress = "progress"
|
|
90
|
+
error = "error"
|
|
91
|
+
_EOF = "_EOF"
|
|
113
92
|
|
|
114
|
-
type: Literal["file"] = "file"
|
|
115
|
-
file: str = Field(...)
|
|
116
|
-
content: str = Field(...)
|
|
117
93
|
|
|
94
|
+
class ServerSentEvent(BaseModel):
|
|
95
|
+
"""Generic Server-Sent Event payload."""
|
|
118
96
|
|
|
119
|
-
|
|
120
|
-
|
|
97
|
+
event: str = Field(..., description="SSE event name / type")
|
|
98
|
+
data: Dict[str, Any] = Field(
|
|
99
|
+
default_factory=dict,
|
|
100
|
+
description="Arbitrary JSON-serializable payload",
|
|
101
|
+
)
|
|
121
102
|
|
|
122
|
-
|
|
123
|
-
|
|
103
|
+
@classmethod
|
|
104
|
+
def build(cls, event: str, data: Any) -> "ServerSentEvent":
|
|
105
|
+
"""General-purpose constructor.
|
|
124
106
|
|
|
107
|
+
Args:
|
|
108
|
+
event: The event name (e.g. "progress", "error").
|
|
109
|
+
data: Arbitrary key-value pairs to include in the payload.
|
|
125
110
|
|
|
126
|
-
|
|
127
|
-
|
|
111
|
+
Returns:
|
|
112
|
+
A ServerSentEvent instance with the specified event and data.
|
|
113
|
+
"""
|
|
114
|
+
return cls(event=event, data=data)
|
|
128
115
|
|
|
129
|
-
|
|
116
|
+
@classmethod
|
|
117
|
+
def eof(cls) -> "ServerSentEvent":
|
|
118
|
+
"""Helper that returns the special end-of-stream marker."""
|
|
119
|
+
return cls(event=ServerSentEventType._EOF.value, data={})
|
|
130
120
|
|
|
121
|
+
def format(self) -> str:
|
|
122
|
+
"""Return the text representation used by SSE protocols."""
|
|
123
|
+
return (
|
|
124
|
+
f"event: {self.event}\n"
|
|
125
|
+
f"data: {json.dumps(self.data, separators=(', ', ': '))}\n\n"
|
|
126
|
+
)
|
|
131
127
|
|
|
132
|
-
class ApiErrorResponse(BaseModel):
|
|
133
|
-
"""API error response model."""
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
details: Optional[Dict[str, Any]] = Field(None)
|
|
129
|
+
class JobStatusEvent(ServerSentEvent):
|
|
130
|
+
"""Job status event with special handling for progress and error states."""
|
|
138
131
|
|
|
132
|
+
@classmethod
|
|
133
|
+
def from_status(
|
|
134
|
+
cls,
|
|
135
|
+
status: str,
|
|
136
|
+
message: Optional[str] = None,
|
|
137
|
+
) -> "JobStatusEvent":
|
|
138
|
+
"""Factory for job-status events.
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
Args:
|
|
141
|
+
status: The job status (e.g. "training", "train_success").
|
|
142
|
+
message: Optional error message for error events.
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
Returns:
|
|
145
|
+
A JobStatusEvent instance with the appropriate event type and data.
|
|
146
|
+
"""
|
|
147
|
+
event_type = (
|
|
148
|
+
ServerSentEventType.error if message else ServerSentEventType.progress
|
|
149
|
+
)
|
|
145
150
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
payload: Dict[str, Any] = {"status": status}
|
|
152
|
+
if message:
|
|
153
|
+
payload["message"] = message
|
|
149
154
|
|
|
150
|
-
return
|
|
155
|
+
return cls(event=event_type.value, data=payload)
|
|
151
156
|
|
|
152
157
|
|
|
153
158
|
class ValidationResult(BaseModel):
|
|
@@ -169,57 +174,24 @@ class TrainingResult(BaseModel):
|
|
|
169
174
|
BotFiles = Dict[str, Optional[str]]
|
|
170
175
|
|
|
171
176
|
|
|
172
|
-
class
|
|
173
|
-
|
|
177
|
+
class JobStatus(str, Enum):
|
|
178
|
+
received = "received"
|
|
179
|
+
done = "done"
|
|
180
|
+
error = "error"
|
|
174
181
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
metadata: Optional[Dict[str, Any]] = Field(None)
|
|
182
|
+
generating = "generating"
|
|
183
|
+
generation_success = "generation_success"
|
|
184
|
+
generation_error = "generation_error"
|
|
179
185
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
training = "training"
|
|
187
|
+
train_success = "train_success"
|
|
188
|
+
train_error = "train_error"
|
|
183
189
|
|
|
184
|
-
|
|
185
|
-
|
|
190
|
+
validating = "validating"
|
|
191
|
+
validation_success = "validation_success"
|
|
192
|
+
validation_error = "validation_error"
|
|
186
193
|
|
|
187
|
-
Returns:
|
|
188
|
-
Document object with extracted content and metadata
|
|
189
|
-
"""
|
|
190
|
-
source = rag_item.get("source", {})
|
|
191
|
-
text_content = cls._extract_text_from_source(source)
|
|
192
|
-
|
|
193
|
-
return cls(
|
|
194
|
-
content=text_content.strip() if text_content else "",
|
|
195
|
-
url=rag_item.get("url"),
|
|
196
|
-
title=rag_item.get("title"),
|
|
197
|
-
metadata={
|
|
198
|
-
"type": rag_item.get("type"),
|
|
199
|
-
"record_type": rag_item.get("record_type"),
|
|
200
|
-
"context": rag_item.get("context"),
|
|
201
|
-
"media_type": source.get("media_type"),
|
|
202
|
-
},
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
@staticmethod
|
|
206
|
-
def _extract_text_from_source(source: Dict[str, Any]) -> str:
|
|
207
|
-
"""Extract text content from InKeep source object.
|
|
208
|
-
|
|
209
|
-
Args:
|
|
210
|
-
source: Source object from InKeep RAG response
|
|
211
194
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
# Try to extract from content array first
|
|
216
|
-
if "content" in source:
|
|
217
|
-
text_parts = []
|
|
218
|
-
for content_item in source["content"]:
|
|
219
|
-
if content_item.get("type") == "text" and content_item.get("text"):
|
|
220
|
-
text_parts.append(content_item["text"])
|
|
221
|
-
if text_parts:
|
|
222
|
-
return "\n".join(text_parts)
|
|
223
|
-
|
|
224
|
-
# Fallback to source data
|
|
225
|
-
return source.get("data", "")
|
|
195
|
+
class JobCreateResponse(BaseModel):
|
|
196
|
+
job_id: str = Field(...)
|
|
197
|
+
status: JobStatus = JobStatus.received
|