django-cfg 1.3.11__py3-none-any.whl → 1.4.0__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.
- django_cfg/__init__.py +1 -1
- django_cfg/apps/accounts/admin/inlines.py +11 -5
- django_cfg/apps/accounts/admin/user_admin.py +39 -16
- django_cfg/apps/accounts/serializers/profile.py +1 -1
- django_cfg/apps/accounts/services/otp_service.py +18 -11
- django_cfg/apps/accounts/signals.py +15 -24
- django_cfg/apps/accounts/utils/notifications.py +217 -358
- django_cfg/apps/accounts/views/otp.py +2 -2
- django_cfg/apps/accounts/views/webhook.py +1 -1
- django_cfg/apps/agents/core/django_agent.py +1 -1
- django_cfg/apps/api/commands/views.py +66 -83
- django_cfg/apps/api/health/drf_views.py +269 -0
- django_cfg/apps/api/health/serializers.py +45 -0
- django_cfg/apps/api/health/urls.py +6 -1
- django_cfg/apps/knowbase/admin/actions/__init__.py +13 -0
- django_cfg/apps/knowbase/admin/actions/visibility_actions.py +56 -0
- django_cfg/apps/knowbase/admin/document_admin.py +136 -270
- django_cfg/apps/knowbase/admin/helpers/__init__.py +17 -0
- django_cfg/apps/knowbase/admin/helpers/configs.py +72 -0
- django_cfg/apps/knowbase/admin/helpers/display_helpers.py +156 -0
- django_cfg/apps/knowbase/admin/helpers/statistics.py +108 -0
- django_cfg/apps/knowbase/config/constance_fields.py +1 -1
- django_cfg/apps/knowbase/config/settings.py +2 -2
- django_cfg/apps/knowbase/mixins/__init__.py +19 -2
- django_cfg/apps/knowbase/mixins/config/__init__.py +14 -0
- django_cfg/apps/knowbase/mixins/config/defaults.py +75 -0
- django_cfg/apps/knowbase/mixins/config/meta_config.py +120 -0
- django_cfg/apps/knowbase/mixins/creator.py +10 -10
- django_cfg/apps/knowbase/mixins/external_data_mixin.py +105 -403
- django_cfg/apps/knowbase/mixins/generators/__init__.py +16 -0
- django_cfg/apps/knowbase/mixins/generators/content_generator.py +218 -0
- django_cfg/apps/knowbase/mixins/generators/field_analyzer.py +76 -0
- django_cfg/apps/knowbase/mixins/generators/metadata_generator.py +124 -0
- django_cfg/apps/knowbase/mixins/service.py +2 -2
- django_cfg/apps/knowbase/services/archive/__init__.py +1 -0
- django_cfg/apps/knowbase/services/archive/analyzers/__init__.py +17 -0
- django_cfg/apps/knowbase/services/archive/analyzers/complexity_analyzer.py +33 -0
- django_cfg/apps/knowbase/services/archive/analyzers/purpose_detector.py +36 -0
- django_cfg/apps/knowbase/services/archive/analyzers/quality_analyzer.py +39 -0
- django_cfg/apps/knowbase/services/archive/analyzers/tag_generator.py +103 -0
- django_cfg/apps/knowbase/services/archive/chunking/__init__.py +19 -0
- django_cfg/apps/knowbase/services/archive/chunking/base.py +81 -0
- django_cfg/apps/knowbase/services/archive/chunking/json_chunker.py +62 -0
- django_cfg/apps/knowbase/services/archive/chunking/markdown_chunker.py +107 -0
- django_cfg/apps/knowbase/services/archive/chunking/python_chunker.py +248 -0
- django_cfg/apps/knowbase/services/archive/chunking/text_chunker.py +70 -0
- django_cfg/apps/knowbase/services/archive/chunking_service.py +110 -729
- django_cfg/apps/knowbase/services/archive/context/__init__.py +14 -0
- django_cfg/apps/knowbase/services/archive/context/builders.py +220 -0
- django_cfg/apps/knowbase/services/archive/context/models.py +38 -0
- django_cfg/apps/knowbase/services/embedding/models.py +18 -14
- django_cfg/apps/knowbase/services/embedding/processors.py +6 -3
- django_cfg/apps/knowbase/tasks/document_processing.py +11 -3
- django_cfg/apps/leads/tests.py +1 -1
- django_cfg/apps/payments/admin/api_keys_admin.py +1 -1
- django_cfg/apps/payments/admin/balance_admin.py +1 -1
- django_cfg/apps/payments/admin/currencies_admin.py +1 -1
- django_cfg/apps/payments/admin/payments_admin.py +1 -1
- django_cfg/apps/payments/admin/subscriptions_admin.py +1 -1
- django_cfg/apps/payments/admin_interface/templates/payments/base.html +59 -126
- django_cfg/apps/payments/admin_interface/views/api/payments.py +1 -1
- django_cfg/apps/payments/admin_interface/views/api/stats.py +1 -1
- django_cfg/apps/payments/admin_interface/views/api/users.py +1 -1
- django_cfg/apps/payments/admin_interface/views/api/webhook_admin.py +1 -1
- django_cfg/apps/payments/admin_interface/views/api/webhook_public.py +1 -1
- django_cfg/apps/payments/admin_interface/views/base.py +29 -2
- django_cfg/apps/payments/apps.py +1 -1
- django_cfg/apps/payments/config/django_cfg_integration.py +2 -2
- django_cfg/apps/payments/config/helpers.py +3 -2
- django_cfg/apps/payments/management/commands/cleanup_expired_data.py +1 -1
- django_cfg/apps/payments/management/commands/currency_stats.py +1 -1
- django_cfg/apps/payments/management/commands/manage_currencies.py +1 -1
- django_cfg/apps/payments/management/commands/manage_providers.py +1 -1
- django_cfg/apps/payments/management/commands/process_pending_payments.py +1 -1
- django_cfg/apps/payments/management/commands/test_providers.py +1 -1
- django_cfg/apps/payments/middleware/api_access.py +1 -1
- django_cfg/apps/payments/middleware/rate_limiting.py +1 -1
- django_cfg/apps/payments/middleware/usage_tracking.py +1 -1
- django_cfg/apps/payments/models/balance.py +2 -2
- django_cfg/apps/payments/models/managers/api_key_managers.py +1 -1
- django_cfg/apps/payments/models/managers/balance_managers.py +1 -1
- django_cfg/apps/payments/models/managers/currency_managers.py +1 -1
- django_cfg/apps/payments/models/managers/payment_managers.py +1 -1
- django_cfg/apps/payments/models/managers/subscription_managers.py +1 -1
- django_cfg/apps/payments/models/payments.py +2 -2
- django_cfg/apps/payments/services/cache_service/__init__.py +1 -1
- django_cfg/apps/payments/services/cache_service/simple_cache.py +10 -5
- django_cfg/apps/payments/services/core/base.py +1 -1
- django_cfg/apps/payments/services/core/currency/__init__.py +13 -0
- django_cfg/apps/payments/services/core/currency/currency_converter.py +57 -0
- django_cfg/apps/payments/services/core/currency/currency_validator.py +61 -0
- django_cfg/apps/payments/services/core/operations/__init__.py +15 -0
- django_cfg/apps/payments/services/core/operations/payment_canceller.py +100 -0
- django_cfg/apps/payments/services/core/operations/payment_creator.py +196 -0
- django_cfg/apps/payments/services/core/operations/status_checker.py +100 -0
- django_cfg/apps/payments/services/core/payment_service.py +124 -612
- django_cfg/apps/payments/services/core/providers/__init__.py +13 -0
- django_cfg/apps/payments/services/core/providers/provider_client.py +132 -0
- django_cfg/apps/payments/services/core/providers/status_mapper.py +89 -0
- django_cfg/apps/payments/services/core/utils/__init__.py +13 -0
- django_cfg/apps/payments/services/core/utils/data_converter.py +48 -0
- django_cfg/apps/payments/services/core/utils/statistics_calculator.py +69 -0
- django_cfg/apps/payments/services/providers/base.py +1 -1
- django_cfg/apps/payments/services/providers/nowpayments/__init__.py +3 -3
- django_cfg/apps/payments/services/providers/nowpayments/parsers/__init__.py +9 -0
- django_cfg/apps/payments/services/providers/nowpayments/parsers/data/__init__.py +23 -0
- django_cfg/apps/payments/services/providers/nowpayments/parsers/data/constants.py +23 -0
- django_cfg/apps/payments/services/providers/nowpayments/parsers/data/currency_names.py +244 -0
- django_cfg/apps/payments/services/providers/nowpayments/parsers/data/patterns.py +511 -0
- django_cfg/apps/payments/services/providers/nowpayments/parsers/parser.py +168 -0
- django_cfg/apps/payments/services/providers/nowpayments/provider.py +1 -1
- django_cfg/apps/payments/services/providers/nowpayments/sync.py +1 -1
- django_cfg/apps/payments/services/providers/registry.py +1 -1
- django_cfg/apps/payments/services/providers/sync_service.py +1 -1
- django_cfg/apps/payments/signals/__init__.py +1 -1
- django_cfg/apps/payments/signals/api_key_signals.py +1 -1
- django_cfg/apps/payments/signals/balance_signals.py +1 -1
- django_cfg/apps/payments/signals/payment_signals.py +1 -1
- django_cfg/apps/payments/signals/subscription_signals.py +1 -1
- django_cfg/apps/payments/views/api/api_keys.py +1 -1
- django_cfg/apps/payments/views/api/balances.py +1 -1
- django_cfg/apps/payments/views/api/base.py +1 -1
- django_cfg/apps/payments/views/api/currencies.py +1 -1
- django_cfg/apps/payments/views/api/payments.py +1 -1
- django_cfg/apps/payments/views/api/subscriptions.py +1 -1
- django_cfg/apps/payments/views/api/webhooks.py +1 -1
- django_cfg/apps/payments/views/serializers/api_keys.py +1 -1
- django_cfg/apps/payments/views/serializers/balances.py +1 -1
- django_cfg/apps/payments/views/serializers/currencies.py +1 -1
- django_cfg/apps/payments/views/serializers/payments.py +1 -1
- django_cfg/apps/payments/views/serializers/subscriptions.py +1 -1
- django_cfg/apps/payments/views/serializers/webhooks.py +1 -1
- django_cfg/apps/support/admin/support_admin.py +21 -13
- django_cfg/apps/support/templates/support/chat/access_denied.html +21 -27
- django_cfg/apps/support/templates/support/chat/ticket_chat.html +183 -254
- django_cfg/apps/support/utils/support_email_service.py +1 -1
- django_cfg/apps/tasks/templates/tasks/layout/base.html +20 -115
- django_cfg/apps/tasks/utils/simulator.py +1 -1
- django_cfg/apps/tasks/views/dashboard.py +33 -3
- django_cfg/apps/urls.py +5 -1
- django_cfg/cli/README.md +57 -471
- django_cfg/cli/commands/create_project.py +140 -529
- django_cfg/cli/main.py +13 -10
- django_cfg/core/__init__.py +63 -6
- django_cfg/core/base/__init__.py +5 -0
- django_cfg/core/base/config_model.py +652 -0
- django_cfg/core/builders/__init__.py +11 -0
- django_cfg/core/builders/apps_builder.py +258 -0
- django_cfg/core/builders/middleware_builder.py +115 -0
- django_cfg/core/builders/security_builder.py +96 -0
- django_cfg/core/config.py +20 -892
- django_cfg/core/constants.py +69 -0
- django_cfg/core/environment/__init__.py +9 -0
- django_cfg/core/exceptions.py +45 -298
- django_cfg/core/generation/__init__.py +51 -0
- django_cfg/core/generation/core_generators/__init__.py +0 -0
- django_cfg/core/generation/core_generators/settings.py +90 -0
- django_cfg/core/generation/core_generators/static.py +82 -0
- django_cfg/core/generation/core_generators/templates.py +141 -0
- django_cfg/core/generation/data_generators/__init__.py +15 -0
- django_cfg/core/generation/data_generators/cache.py +132 -0
- django_cfg/core/generation/data_generators/database.py +117 -0
- django_cfg/core/generation/generation.py +92 -0
- django_cfg/core/generation/integration_generators/__init__.py +21 -0
- django_cfg/core/generation/integration_generators/api.py +237 -0
- django_cfg/core/generation/integration_generators/sessions.py +65 -0
- django_cfg/core/generation/integration_generators/tailwind.py +54 -0
- django_cfg/core/generation/integration_generators/tasks.py +92 -0
- django_cfg/core/generation/integration_generators/third_party.py +144 -0
- django_cfg/core/generation/orchestrator.py +285 -0
- django_cfg/core/generation/protocols.py +30 -0
- django_cfg/core/generation/security_generators/__init__.py +0 -0
- django_cfg/core/generation/utility_generators/__init__.py +24 -0
- django_cfg/core/generation/utility_generators/email.py +58 -0
- django_cfg/core/generation/utility_generators/i18n.py +66 -0
- django_cfg/core/generation/utility_generators/limits.py +58 -0
- django_cfg/core/generation/utility_generators/logging.py +66 -0
- django_cfg/core/generation/utility_generators/security.py +101 -0
- django_cfg/core/generation/utils/__init__.py +0 -0
- django_cfg/core/generation/utils/helpers.py +32 -0
- django_cfg/core/integration/__init__.py +18 -25
- django_cfg/core/integration/display/startup.py +146 -133
- django_cfg/core/integration/url_integration.py +13 -2
- django_cfg/core/services/__init__.py +5 -0
- django_cfg/core/services/config_service.py +121 -0
- django_cfg/core/state/__init__.py +9 -0
- django_cfg/core/state/registry.py +84 -0
- django_cfg/core/types/__init__.py +15 -0
- django_cfg/core/types/aliases.py +15 -0
- django_cfg/core/types/enums.py +49 -0
- django_cfg/dashboard/DEBUG_README.md +105 -0
- django_cfg/dashboard/REFACTORING_SUMMARY.md +237 -0
- django_cfg/dashboard/__init__.py +24 -0
- django_cfg/dashboard/components.py +308 -0
- django_cfg/dashboard/debug.py +176 -0
- django_cfg/dashboard/management/__init__.py +0 -0
- django_cfg/dashboard/management/commands/__init__.py +0 -0
- django_cfg/dashboard/management/commands/debug_dashboard.py +109 -0
- django_cfg/dashboard/sections/__init__.py +1 -0
- django_cfg/dashboard/sections/base.py +128 -0
- django_cfg/dashboard/sections/commands.py +32 -0
- django_cfg/dashboard/sections/overview.py +394 -0
- django_cfg/dashboard/sections/stats.py +48 -0
- django_cfg/dashboard/sections/system.py +73 -0
- django_cfg/management/commands/check_settings.py +6 -2
- django_cfg/management/commands/clear_constance.py +6 -1
- django_cfg/management/commands/create_token.py +5 -4
- django_cfg/management/commands/generate.py +5 -0
- django_cfg/management/commands/list_urls.py +7 -2
- django_cfg/management/commands/migrate_all.py +6 -2
- django_cfg/management/commands/migrator.py +6 -1
- django_cfg/management/commands/rundramatiq.py +6 -1
- django_cfg/management/commands/rundramatiq_simulator.py +11 -4
- django_cfg/management/commands/runserver_ngrok.py +9 -7
- django_cfg/management/commands/script.py +25 -21
- django_cfg/management/commands/show_config.py +6 -1
- django_cfg/management/commands/show_urls.py +8 -3
- django_cfg/management/commands/superuser.py +5 -4
- django_cfg/management/commands/task_clear.py +8 -3
- django_cfg/management/commands/task_status.py +8 -3
- django_cfg/management/commands/test_email.py +6 -1
- django_cfg/management/commands/test_telegram.py +6 -1
- django_cfg/management/commands/test_twilio.py +6 -1
- django_cfg/management/commands/tree.py +7 -4
- django_cfg/models/__init__.py +88 -3
- django_cfg/models/api/__init__.py +27 -0
- django_cfg/models/{api.py → api/config.py} +1 -1
- django_cfg/models/api/drf/__init__.py +21 -0
- django_cfg/models/api/drf/config.py +101 -0
- django_cfg/models/api/drf/redoc.py +31 -0
- django_cfg/models/api/drf/spectacular.py +129 -0
- django_cfg/models/api/drf/swagger.py +59 -0
- django_cfg/models/{api_keys.py → api/keys.py} +16 -6
- django_cfg/models/{limits.py → api/limits.py} +0 -1
- django_cfg/models/base/__init__.py +14 -0
- django_cfg/models/django/__init__.py +16 -0
- django_cfg/models/{constance.py → django/constance.py} +1 -1
- django_cfg/models/{environment.py → django/environment.py} +1 -1
- django_cfg/models/infrastructure/__init__.py +17 -0
- django_cfg/models/{cache.py → infrastructure/cache.py} +3 -2
- django_cfg/models/infrastructure/database/__init__.py +22 -0
- django_cfg/models/infrastructure/database/config.py +265 -0
- django_cfg/models/infrastructure/database/converters.py +91 -0
- django_cfg/models/infrastructure/database/parsers.py +96 -0
- django_cfg/models/infrastructure/database/routing.py +85 -0
- django_cfg/models/infrastructure/database/validators.py +170 -0
- django_cfg/models/{logging.py → infrastructure/logging.py} +1 -1
- django_cfg/models/{security.py → infrastructure/security.py} +2 -2
- django_cfg/models/ngrok/__init__.py +11 -0
- django_cfg/models/ngrok/auth.py +37 -0
- django_cfg/models/ngrok/config.py +77 -0
- django_cfg/models/ngrok/tunnel.py +35 -0
- django_cfg/models/payments/__init__.py +20 -0
- django_cfg/models/payments/api_keys.py +57 -0
- django_cfg/models/{payments.py → payments/config.py} +56 -154
- django_cfg/models/payments/providers/__init__.py +15 -0
- django_cfg/models/payments/providers/base.py +25 -0
- django_cfg/models/payments/providers/nowpayments.py +48 -0
- django_cfg/models/services/__init__.py +18 -0
- django_cfg/models/services/base.py +65 -0
- django_cfg/models/{email.py → services/email.py} +1 -1
- django_cfg/models/services/telegram.py +172 -0
- django_cfg/models/tasks/__init__.py +51 -0
- django_cfg/models/tasks/backends.py +250 -0
- django_cfg/models/tasks/config.py +314 -0
- django_cfg/models/tasks/utils.py +174 -0
- django_cfg/modules/base.py +18 -3
- django_cfg/modules/django_admin/decorators/actions.py +1 -1
- django_cfg/modules/django_admin/decorators/display.py +1 -1
- django_cfg/modules/django_admin/mixins/standalone_actions_mixin.py +1 -1
- django_cfg/modules/django_cfg_rpc_client/README.md +346 -0
- django_cfg/modules/django_cfg_rpc_client/__init__.py +51 -0
- django_cfg/modules/django_cfg_rpc_client/client.py +540 -0
- django_cfg/modules/django_cfg_rpc_client/config.py +207 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/README.md +517 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/UNFOLD_INTEGRATION.md +439 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/__init__.py +11 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/apps.py +22 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/monitor.py +435 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/static/django_cfg_rpc_dashboard/js/dashboard.js +373 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/templates/django_cfg_rpc_dashboard/base.html +76 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/templates/django_cfg_rpc_dashboard/dashboard.html +200 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/urls.py +22 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/urls_admin.py +9 -0
- django_cfg/modules/django_cfg_rpc_client/dashboard/views.py +251 -0
- django_cfg/modules/django_cfg_rpc_client/exceptions.py +201 -0
- django_cfg/modules/django_drf_theme/CHANGELOG.md +210 -0
- django_cfg/modules/django_drf_theme/EXAMPLE.md +465 -0
- django_cfg/modules/django_drf_theme/IMPLEMENTATION.md +232 -0
- django_cfg/modules/django_drf_theme/README.md +207 -0
- django_cfg/modules/django_drf_theme/TAILWIND_CDN_GUIDE.md +274 -0
- django_cfg/modules/django_drf_theme/__init__.py +23 -0
- django_cfg/modules/django_drf_theme/apps.py +15 -0
- django_cfg/modules/django_drf_theme/renderers.py +58 -0
- django_cfg/modules/django_drf_theme/templates/rest_framework/tailwind/api.html +375 -0
- django_cfg/modules/django_drf_theme/templates/rest_framework/tailwind/base.html +938 -0
- django_cfg/modules/django_drf_theme/templates/rest_framework/tailwind/forms/filter_form.html +132 -0
- django_cfg/modules/django_drf_theme/templates/rest_framework/tailwind/forms/raw_data_form.html +123 -0
- django_cfg/modules/django_drf_theme/templatetags/__init__.py +1 -0
- django_cfg/modules/django_drf_theme/templatetags/tailwind_tags.py +57 -0
- django_cfg/modules/django_email/__init__.py +14 -0
- django_cfg/modules/{django_email.py → django_email/service.py} +78 -113
- django_cfg/modules/django_email/utils.py +40 -0
- django_cfg/modules/django_health/__init__.py +9 -0
- django_cfg/modules/{django_health.py → django_health/service.py} +23 -21
- django_cfg/modules/django_llm/llm/client.py +155 -550
- django_cfg/modules/django_llm/llm/embeddings/__init__.py +13 -0
- django_cfg/modules/django_llm/llm/embeddings/mock_embedder.py +106 -0
- django_cfg/modules/django_llm/llm/embeddings/openai_embedder.py +79 -0
- django_cfg/modules/django_llm/llm/models_api/__init__.py +9 -0
- django_cfg/modules/django_llm/llm/models_api/models_query.py +163 -0
- django_cfg/modules/django_llm/llm/providers/__init__.py +15 -0
- django_cfg/modules/django_llm/llm/providers/config_builder.py +103 -0
- django_cfg/modules/django_llm/llm/providers/provider_manager.py +148 -0
- django_cfg/modules/django_llm/llm/providers/provider_selector.py +60 -0
- django_cfg/modules/django_llm/llm/requests/__init__.py +15 -0
- django_cfg/modules/django_llm/llm/requests/cache_manager.py +170 -0
- django_cfg/modules/django_llm/llm/requests/chat_handler.py +199 -0
- django_cfg/modules/django_llm/llm/requests/embedding_handler.py +113 -0
- django_cfg/modules/django_llm/llm/responses/__init__.py +9 -0
- django_cfg/modules/django_llm/llm/responses/response_builder.py +131 -0
- django_cfg/modules/django_llm/llm/stats/__init__.py +9 -0
- django_cfg/modules/django_llm/llm/stats/stats_manager.py +107 -0
- django_cfg/modules/django_llm/translator/detectors/__init__.py +13 -0
- django_cfg/modules/django_llm/translator/detectors/language_detector.py +90 -0
- django_cfg/modules/django_llm/translator/detectors/script_detector.py +153 -0
- django_cfg/modules/django_llm/translator/stats/__init__.py +11 -0
- django_cfg/modules/django_llm/translator/stats/stats_tracker.py +85 -0
- django_cfg/modules/django_llm/translator/translator.py +150 -603
- django_cfg/modules/django_llm/translator/translators/__init__.py +15 -0
- django_cfg/modules/django_llm/translator/translators/json_translator.py +316 -0
- django_cfg/modules/django_llm/translator/translators/text_translator.py +139 -0
- django_cfg/modules/django_llm/translator/utils/__init__.py +13 -0
- django_cfg/modules/django_llm/translator/utils/prompt_builder.py +110 -0
- django_cfg/modules/django_llm/translator/utils/text_utils.py +114 -0
- django_cfg/modules/django_logging/FIXES_SUMMARY.md +276 -0
- django_cfg/modules/django_logging/LOGGING_GUIDE.md +504 -0
- django_cfg/modules/django_logging/__init__.py +14 -0
- django_cfg/modules/{django_logger.py → django_logging/django_logger.py} +13 -13
- django_cfg/modules/{logger.py → django_logging/logger.py} +14 -4
- django_cfg/modules/django_ngrok/__init__.py +39 -0
- django_cfg/modules/{django_ngrok.py → django_ngrok/service.py} +14 -42
- django_cfg/modules/django_rpc_old/POETRY.md +344 -0
- django_cfg/modules/django_rpc_old/README.md +397 -0
- django_cfg/modules/django_rpc_old/TESTING.md +358 -0
- django_cfg/modules/django_rpc_old/__init__.py +39 -0
- django_cfg/modules/django_rpc_old/client.py +531 -0
- django_cfg/modules/django_rpc_old/config.py +279 -0
- django_cfg/modules/django_rpc_old/exceptions.py +172 -0
- django_cfg/modules/django_tailwind/README.md +478 -0
- django_cfg/modules/django_tailwind/__init__.py +7 -0
- django_cfg/modules/django_tailwind/apps.py +10 -0
- django_cfg/modules/django_tailwind/templates/django_tailwind/app.html +5 -0
- django_cfg/modules/django_tailwind/templates/django_tailwind/base.html +117 -0
- django_cfg/modules/django_tailwind/templates/django_tailwind/components/navbar.html +124 -0
- django_cfg/modules/django_tailwind/templates/django_tailwind/components/theme_toggle.html +54 -0
- django_cfg/modules/django_tailwind/templates/django_tailwind/components/user_menu.html +116 -0
- django_cfg/modules/django_tailwind/templates/django_tailwind/simple.html +46 -0
- django_cfg/modules/django_tailwind/templatetags/__init__.py +1 -0
- django_cfg/modules/django_tailwind/templatetags/tailwind_info.py +185 -0
- django_cfg/modules/django_tasks/__init__.py +29 -0
- django_cfg/modules/django_tasks/factory.py +127 -0
- django_cfg/modules/{django_tasks.py → django_tasks/service.py} +45 -274
- django_cfg/modules/django_tasks/settings.py +107 -0
- django_cfg/modules/django_telegram/__init__.py +29 -0
- django_cfg/modules/{django_telegram.py → django_telegram/service.py} +45 -113
- django_cfg/modules/django_telegram/utils.py +62 -0
- django_cfg/modules/django_twilio/__init__.py +54 -107
- django_cfg/modules/django_twilio/_imports.py +30 -0
- django_cfg/modules/django_twilio/base.py +192 -0
- django_cfg/modules/django_twilio/email_otp.py +227 -0
- django_cfg/modules/django_twilio/sendgrid_service.py +1 -1
- django_cfg/modules/django_twilio/simple_service.py +1 -2
- django_cfg/modules/django_twilio/sms.py +94 -0
- django_cfg/modules/django_twilio/twilio_service.py +2 -3
- django_cfg/modules/django_twilio/unified.py +310 -0
- django_cfg/modules/django_twilio/utils.py +190 -0
- django_cfg/modules/django_twilio/whatsapp.py +137 -0
- django_cfg/modules/django_unfold/callbacks/base.py +198 -7
- django_cfg/modules/django_unfold/callbacks/main.py +102 -10
- django_cfg/modules/django_unfold/dashboard.py +65 -43
- django_cfg/modules/django_unfold/models/config.py +13 -12
- django_cfg/modules/django_unfold/models/navigation.py +8 -3
- django_cfg/modules/django_unfold/models/tabs.py +2 -2
- django_cfg/modules/django_unfold/templates/unfold/helpers/app_list.html +102 -0
- django_cfg/registry/core.py +24 -26
- django_cfg/registry/modules.py +5 -2
- django_cfg/registry/services.py +20 -3
- django_cfg/registry/third_party.py +8 -8
- django_cfg/static/admin/css/dashboard.css +260 -0
- django_cfg/static/admin/js/commands.js +171 -0
- django_cfg/static/admin/js/dashboard.js +126 -0
- django_cfg/templates/admin/components/management_commands.js +375 -0
- django_cfg/templates/admin/components/progress_bar.html +18 -23
- django_cfg/templates/admin/index.html +48 -20
- django_cfg/templates/admin/index_new.html +106 -0
- django_cfg/templates/admin/layouts/base_dashboard.html +60 -0
- django_cfg/templates/admin/layouts/dashboard_with_tabs.html +1 -20
- django_cfg/templates/admin/sections/commands_section.html +626 -0
- django_cfg/templates/admin/sections/overview_section.html +112 -0
- django_cfg/templates/admin/sections/stats_section.html +35 -0
- django_cfg/templates/admin/sections/system_section.html +99 -0
- django_cfg/templates/admin/snippets/components/CHARTS_GUIDE.md +322 -0
- django_cfg/templates/admin/snippets/components/activity_tracker.html +85 -47
- django_cfg/templates/admin/snippets/components/charts_section.html +154 -64
- django_cfg/templates/admin/snippets/components/django_commands.html +3 -3
- django_cfg/templates/admin/snippets/components/recent_activity_improved.html +25 -0
- django_cfg/templates/admin/snippets/components/recent_users_table.html +1 -1
- django_cfg/templates/admin/snippets/components/system_metrics.html +179 -93
- django_cfg/templates/admin/snippets/zones/zones_table.html +2 -2
- django_cfg/templatetags/django_cfg.py +7 -1
- django_cfg/utils/smart_defaults.py +4 -4
- django_cfg-1.4.0.dist-info/METADATA +920 -0
- {django_cfg-1.3.11.dist-info → django_cfg-1.4.0.dist-info}/RECORD +425 -196
- django_cfg/apps/accounts/utils/auth_email_service.py +0 -84
- django_cfg/apps/payments/services/providers/nowpayments/parsers.py +0 -879
- django_cfg/core/generation.py +0 -621
- django_cfg/management/commands/validate_config.py +0 -189
- django_cfg/models/database.py +0 -480
- django_cfg/models/drf.py +0 -272
- django_cfg/models/ngrok.py +0 -122
- django_cfg/models/services.py +0 -440
- django_cfg/models/tasks.py +0 -550
- django_cfg/modules/django_twilio/service.py +0 -942
- django_cfg/template_archive/django_sample.zip +0 -0
- django_cfg/templates/rest_framework/api.html +0 -12
- django_cfg/utils/toolkit.py +0 -703
- django_cfg-1.3.11.dist-info/METADATA +0 -1029
- /django_cfg/apps/accounts/management/commands/{test_otp.py → otp_test.py} +0 -0
- /django_cfg/core/{environment.py → environment/detector.py} +0 -0
- /django_cfg/models/{cors.py → api/cors.py} +0 -0
- /django_cfg/models/{jwt.py → api/jwt.py} +0 -0
- /django_cfg/models/{base.py → base/config.py} +0 -0
- /django_cfg/models/{cfg.py → base/module.py} +0 -0
- /django_cfg/models/{revolution.py → django/revolution.py} +0 -0
- /django_cfg/modules/{dramatiq_setup.py → django_tasks/dramatiq_setup.py} +0 -0
- {django_cfg-1.3.11.dist-info → django_cfg-1.4.0.dist-info}/WHEEL +0 -0
- {django_cfg-1.3.11.dist-info → django_cfg-1.4.0.dist-info}/entry_points.txt +0 -0
- {django_cfg-1.3.11.dist-info → django_cfg-1.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
"""
|
2
|
+
Tag generation for chunks.
|
3
|
+
|
4
|
+
Generates semantic tags for code and document chunks.
|
5
|
+
"""
|
6
|
+
|
7
|
+
import re
|
8
|
+
from typing import List, Dict, Any
|
9
|
+
|
10
|
+
|
11
|
+
class TagGenerator:
|
12
|
+
"""Generate tags for different content types."""
|
13
|
+
|
14
|
+
@staticmethod
|
15
|
+
def generate_code_tags(content: str, code_info: Dict[str, Any]) -> List[str]:
|
16
|
+
"""
|
17
|
+
Generate technical tags for code content.
|
18
|
+
|
19
|
+
Args:
|
20
|
+
content: Code content
|
21
|
+
code_info: Code analysis info (element_name, element_type, etc.)
|
22
|
+
|
23
|
+
Returns:
|
24
|
+
List of technical tags
|
25
|
+
"""
|
26
|
+
tags = []
|
27
|
+
|
28
|
+
# Element type tags
|
29
|
+
if code_info.get('element_type'):
|
30
|
+
tags.append(f"contains:{code_info['element_type']}")
|
31
|
+
|
32
|
+
# Async tag
|
33
|
+
if code_info.get('is_async'):
|
34
|
+
tags.append('async')
|
35
|
+
|
36
|
+
# Pattern detection
|
37
|
+
if 'import ' in content or 'from ' in content:
|
38
|
+
tags.append('contains:imports')
|
39
|
+
|
40
|
+
if 'class ' in content:
|
41
|
+
tags.append('contains:class_definition')
|
42
|
+
|
43
|
+
if 'def ' in content:
|
44
|
+
tags.append('contains:function_definition')
|
45
|
+
|
46
|
+
if 'test' in code_info.get('element_name', '').lower():
|
47
|
+
tags.append('purpose:testing')
|
48
|
+
|
49
|
+
return tags
|
50
|
+
|
51
|
+
@staticmethod
|
52
|
+
def generate_document_tags(content: str) -> List[str]:
|
53
|
+
"""
|
54
|
+
Generate topic tags for document content.
|
55
|
+
|
56
|
+
Args:
|
57
|
+
content: Document content
|
58
|
+
|
59
|
+
Returns:
|
60
|
+
List of topic tags
|
61
|
+
"""
|
62
|
+
tags = []
|
63
|
+
|
64
|
+
# Detect headings
|
65
|
+
if content.strip().startswith('#'):
|
66
|
+
tags.append('contains:heading')
|
67
|
+
|
68
|
+
# Detect lists
|
69
|
+
if re.search(r'^\s*[-*+]\s', content, re.MULTILINE):
|
70
|
+
tags.append('contains:list')
|
71
|
+
|
72
|
+
# Detect code blocks
|
73
|
+
if '```' in content or ' ' in content:
|
74
|
+
tags.append('contains:code_block')
|
75
|
+
|
76
|
+
return tags
|
77
|
+
|
78
|
+
@staticmethod
|
79
|
+
def detect_code_purpose(element_name: str, content: str) -> str:
|
80
|
+
"""
|
81
|
+
Detect purpose of code element.
|
82
|
+
|
83
|
+
Args:
|
84
|
+
element_name: Name of code element
|
85
|
+
content: Code content
|
86
|
+
|
87
|
+
Returns:
|
88
|
+
Purpose string (test, configuration, initialization, etc.)
|
89
|
+
"""
|
90
|
+
name_lower = element_name.lower()
|
91
|
+
|
92
|
+
if name_lower.startswith('test_'):
|
93
|
+
return 'test'
|
94
|
+
elif name_lower.startswith('_'):
|
95
|
+
return 'private_method'
|
96
|
+
elif 'config' in name_lower:
|
97
|
+
return 'configuration'
|
98
|
+
elif 'init' in name_lower:
|
99
|
+
return 'initialization'
|
100
|
+
elif 'main' in name_lower:
|
101
|
+
return 'main_function'
|
102
|
+
else:
|
103
|
+
return 'implementation'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"""
|
2
|
+
Chunking strategies for different content types.
|
3
|
+
|
4
|
+
Language-specific and content-aware chunking implementations.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from .base import BaseChunker
|
8
|
+
from .text_chunker import TextChunker
|
9
|
+
from .python_chunker import PythonChunker
|
10
|
+
from .markdown_chunker import MarkdownChunker
|
11
|
+
from .json_chunker import JsonChunker
|
12
|
+
|
13
|
+
__all__ = [
|
14
|
+
'BaseChunker',
|
15
|
+
'TextChunker',
|
16
|
+
'PythonChunker',
|
17
|
+
'MarkdownChunker',
|
18
|
+
'JsonChunker',
|
19
|
+
]
|
@@ -0,0 +1,81 @@
|
|
1
|
+
"""
|
2
|
+
Base chunker interface.
|
3
|
+
|
4
|
+
Abstract base class for content-specific chunking strategies.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from abc import ABC, abstractmethod
|
8
|
+
from typing import List
|
9
|
+
from ....models.archive import ArchiveItem
|
10
|
+
from ..context.models import ChunkData
|
11
|
+
|
12
|
+
|
13
|
+
class BaseChunker(ABC):
|
14
|
+
"""
|
15
|
+
Base class for content chunkers.
|
16
|
+
|
17
|
+
Provides common interface and utilities for chunking strategies.
|
18
|
+
"""
|
19
|
+
|
20
|
+
def __init__(self, chunk_size: int = 1000, overlap: int = 200):
|
21
|
+
"""
|
22
|
+
Initialize chunker.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
chunk_size: Default chunk size in characters
|
26
|
+
overlap: Overlap between chunks in characters
|
27
|
+
"""
|
28
|
+
self.chunk_size = chunk_size
|
29
|
+
self.overlap = overlap
|
30
|
+
|
31
|
+
@abstractmethod
|
32
|
+
def can_handle(self, item: ArchiveItem) -> bool:
|
33
|
+
"""
|
34
|
+
Check if this chunker can handle the item.
|
35
|
+
|
36
|
+
Args:
|
37
|
+
item: Archive item to check
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
True if this chunker can process the item
|
41
|
+
"""
|
42
|
+
pass
|
43
|
+
|
44
|
+
@abstractmethod
|
45
|
+
def chunk(self, item: ArchiveItem) -> List[ChunkData]:
|
46
|
+
"""
|
47
|
+
Create chunks from item content.
|
48
|
+
|
49
|
+
Args:
|
50
|
+
item: Archive item to chunk
|
51
|
+
|
52
|
+
Returns:
|
53
|
+
List of ChunkData objects
|
54
|
+
"""
|
55
|
+
pass
|
56
|
+
|
57
|
+
def _find_good_break_point(self, content: str, start: int, end: int) -> int:
|
58
|
+
"""
|
59
|
+
Find good break point for text chunking.
|
60
|
+
|
61
|
+
Tries to break at sentence endings or word boundaries.
|
62
|
+
|
63
|
+
Args:
|
64
|
+
content: Content being chunked
|
65
|
+
start: Start position
|
66
|
+
end: Desired end position
|
67
|
+
|
68
|
+
Returns:
|
69
|
+
Actual break point position
|
70
|
+
"""
|
71
|
+
# Look for sentence endings
|
72
|
+
for i in range(end - 1, start, -1):
|
73
|
+
if content[i] in '.!?\n':
|
74
|
+
return i + 1
|
75
|
+
|
76
|
+
# Look for word boundaries
|
77
|
+
for i in range(end - 1, start, -1):
|
78
|
+
if content[i].isspace():
|
79
|
+
return i
|
80
|
+
|
81
|
+
return end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"""
|
2
|
+
JSON data chunker.
|
3
|
+
|
4
|
+
Chunks JSON by object structure.
|
5
|
+
"""
|
6
|
+
|
7
|
+
import json
|
8
|
+
from typing import List
|
9
|
+
from .base import BaseChunker
|
10
|
+
from ..context.models import ChunkData
|
11
|
+
from ..context.builders import ChunkContextBuilder
|
12
|
+
from ....models.archive import ArchiveItem, ChunkType
|
13
|
+
|
14
|
+
|
15
|
+
class JsonChunker(BaseChunker):
|
16
|
+
"""
|
17
|
+
Chunk JSON by object structure.
|
18
|
+
|
19
|
+
Splits JSON documents by top-level keys.
|
20
|
+
"""
|
21
|
+
|
22
|
+
def can_handle(self, item: ArchiveItem) -> bool:
|
23
|
+
"""Can handle JSON files."""
|
24
|
+
return item.language == 'json'
|
25
|
+
|
26
|
+
def chunk(self, item: ArchiveItem) -> List[ChunkData]:
|
27
|
+
"""
|
28
|
+
Chunk JSON by object structure.
|
29
|
+
|
30
|
+
Args:
|
31
|
+
item: Archive item to chunk
|
32
|
+
|
33
|
+
Returns:
|
34
|
+
List of ChunkData objects
|
35
|
+
"""
|
36
|
+
try:
|
37
|
+
data = json.loads(item.raw_content)
|
38
|
+
chunks = []
|
39
|
+
|
40
|
+
if isinstance(data, dict):
|
41
|
+
# Chunk by top-level keys
|
42
|
+
for key, value in data.items():
|
43
|
+
chunk_content = json.dumps({key: value}, indent=2)
|
44
|
+
|
45
|
+
context = ChunkContextBuilder.build_data_context(
|
46
|
+
item, len(chunks), chunk_content, 'json_object', key
|
47
|
+
)
|
48
|
+
|
49
|
+
chunks.append(ChunkData(
|
50
|
+
content=chunk_content,
|
51
|
+
chunk_index=len(chunks),
|
52
|
+
chunk_type=ChunkType.METADATA,
|
53
|
+
context_metadata=context
|
54
|
+
))
|
55
|
+
|
56
|
+
return chunks
|
57
|
+
|
58
|
+
except json.JSONDecodeError:
|
59
|
+
# Fallback to text chunking on parse errors
|
60
|
+
from .text_chunker import TextChunker
|
61
|
+
text_chunker = TextChunker(self.chunk_size, self.overlap)
|
62
|
+
return text_chunker.chunk(item)
|
@@ -0,0 +1,107 @@
|
|
1
|
+
"""
|
2
|
+
Markdown document chunker.
|
3
|
+
|
4
|
+
Chunks markdown by headings and sections.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from typing import List, Dict, Any
|
8
|
+
from .base import BaseChunker
|
9
|
+
from ..context.models import ChunkData
|
10
|
+
from ..context.builders import ChunkContextBuilder
|
11
|
+
from ....models.archive import ArchiveItem, ChunkType
|
12
|
+
|
13
|
+
|
14
|
+
class MarkdownChunker(BaseChunker):
|
15
|
+
"""
|
16
|
+
Chunk markdown by headings and sections.
|
17
|
+
|
18
|
+
Splits markdown documents into logical sections based on heading structure.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def can_handle(self, item: ArchiveItem) -> bool:
|
22
|
+
"""Can handle markdown files."""
|
23
|
+
return item.language == 'markdown'
|
24
|
+
|
25
|
+
def chunk(self, item: ArchiveItem) -> List[ChunkData]:
|
26
|
+
"""
|
27
|
+
Chunk markdown by headings and sections.
|
28
|
+
|
29
|
+
Args:
|
30
|
+
item: Archive item to chunk
|
31
|
+
|
32
|
+
Returns:
|
33
|
+
List of ChunkData objects
|
34
|
+
"""
|
35
|
+
content = item.raw_content
|
36
|
+
lines = content.split('\n')
|
37
|
+
chunks = []
|
38
|
+
|
39
|
+
current_section = {'title': '', 'level': 0, 'start_line': 0}
|
40
|
+
|
41
|
+
for i, line in enumerate(lines):
|
42
|
+
if line.startswith('#'):
|
43
|
+
# New section found
|
44
|
+
if current_section['start_line'] < i:
|
45
|
+
# Create chunk for previous section
|
46
|
+
chunk = self._create_section_chunk(
|
47
|
+
lines[current_section['start_line']:i],
|
48
|
+
current_section,
|
49
|
+
item,
|
50
|
+
len(chunks)
|
51
|
+
)
|
52
|
+
chunks.append(chunk)
|
53
|
+
|
54
|
+
# Start new section
|
55
|
+
level = len(line) - len(line.lstrip('#'))
|
56
|
+
current_section = {
|
57
|
+
'title': line.lstrip('# ').strip(),
|
58
|
+
'level': level,
|
59
|
+
'start_line': i
|
60
|
+
}
|
61
|
+
|
62
|
+
# Handle last section
|
63
|
+
if current_section['start_line'] < len(lines):
|
64
|
+
chunk = self._create_section_chunk(
|
65
|
+
lines[current_section['start_line']:],
|
66
|
+
current_section,
|
67
|
+
item,
|
68
|
+
len(chunks)
|
69
|
+
)
|
70
|
+
chunks.append(chunk)
|
71
|
+
|
72
|
+
return chunks
|
73
|
+
|
74
|
+
def _create_section_chunk(
|
75
|
+
self,
|
76
|
+
section_lines: List[str],
|
77
|
+
section_info: Dict[str, Any],
|
78
|
+
item: ArchiveItem,
|
79
|
+
chunk_index: int
|
80
|
+
) -> ChunkData:
|
81
|
+
"""
|
82
|
+
Create chunk for markdown section.
|
83
|
+
|
84
|
+
Args:
|
85
|
+
section_lines: Lines of the section
|
86
|
+
section_info: Section metadata (title, level)
|
87
|
+
item: Archive item
|
88
|
+
chunk_index: Index of this chunk
|
89
|
+
|
90
|
+
Returns:
|
91
|
+
ChunkData for the section
|
92
|
+
"""
|
93
|
+
content = '\n'.join(section_lines)
|
94
|
+
|
95
|
+
# Build context metadata
|
96
|
+
context = ChunkContextBuilder.build_document_context(
|
97
|
+
item, chunk_index, content, section_info
|
98
|
+
)
|
99
|
+
|
100
|
+
chunk_type = ChunkType.HEADING if section_info['title'] else ChunkType.TEXT
|
101
|
+
|
102
|
+
return ChunkData(
|
103
|
+
content=content,
|
104
|
+
chunk_index=chunk_index,
|
105
|
+
chunk_type=chunk_type,
|
106
|
+
context_metadata=context
|
107
|
+
)
|
@@ -0,0 +1,248 @@
|
|
1
|
+
"""
|
2
|
+
Python code chunker using AST parsing.
|
3
|
+
|
4
|
+
Chunks Python code by logical boundaries (classes, functions, imports).
|
5
|
+
"""
|
6
|
+
|
7
|
+
import ast
|
8
|
+
from typing import List, Optional, Dict, Any
|
9
|
+
from .base import BaseChunker
|
10
|
+
from ..context.models import ChunkData
|
11
|
+
from ..context.builders import ChunkContextBuilder
|
12
|
+
from ....models.archive import ArchiveItem, ChunkType
|
13
|
+
|
14
|
+
|
15
|
+
class PythonChunker(BaseChunker):
|
16
|
+
"""
|
17
|
+
Chunk Python code by logical boundaries using AST.
|
18
|
+
|
19
|
+
Extracts:
|
20
|
+
- Import statements
|
21
|
+
- Class definitions
|
22
|
+
- Function definitions
|
23
|
+
- Module-level code
|
24
|
+
"""
|
25
|
+
|
26
|
+
def can_handle(self, item: ArchiveItem) -> bool:
|
27
|
+
"""Can handle Python code files."""
|
28
|
+
return item.language == 'python'
|
29
|
+
|
30
|
+
def chunk(self, item: ArchiveItem) -> List[ChunkData]:
|
31
|
+
"""
|
32
|
+
Chunk Python code by classes and functions.
|
33
|
+
|
34
|
+
Args:
|
35
|
+
item: Archive item to chunk
|
36
|
+
|
37
|
+
Returns:
|
38
|
+
List of ChunkData objects
|
39
|
+
"""
|
40
|
+
content = item.raw_content
|
41
|
+
lines = content.split('\n')
|
42
|
+
chunks = []
|
43
|
+
|
44
|
+
try:
|
45
|
+
tree = ast.parse(content)
|
46
|
+
|
47
|
+
# Extract imports first
|
48
|
+
imports_chunk = self._extract_imports(tree, lines, item, 0)
|
49
|
+
if imports_chunk:
|
50
|
+
chunks.append(imports_chunk)
|
51
|
+
|
52
|
+
# Extract classes and functions
|
53
|
+
for node in ast.walk(tree):
|
54
|
+
if isinstance(node, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)):
|
55
|
+
chunk = self._create_element_chunk(
|
56
|
+
node, lines, item, len(chunks)
|
57
|
+
)
|
58
|
+
chunks.append(chunk)
|
59
|
+
|
60
|
+
# Handle module-level code
|
61
|
+
remaining_chunk = self._extract_remaining_code(
|
62
|
+
tree, lines, item, len(chunks)
|
63
|
+
)
|
64
|
+
if remaining_chunk:
|
65
|
+
chunks.append(remaining_chunk)
|
66
|
+
|
67
|
+
except SyntaxError:
|
68
|
+
# Fallback to text chunking on syntax errors
|
69
|
+
from .text_chunker import TextChunker
|
70
|
+
text_chunker = TextChunker(self.chunk_size, self.overlap)
|
71
|
+
return text_chunker.chunk(item)
|
72
|
+
|
73
|
+
return chunks
|
74
|
+
|
75
|
+
def _create_element_chunk(
|
76
|
+
self,
|
77
|
+
node: ast.AST,
|
78
|
+
lines: List[str],
|
79
|
+
item: ArchiveItem,
|
80
|
+
chunk_index: int
|
81
|
+
) -> ChunkData:
|
82
|
+
"""
|
83
|
+
Create chunk for Python code element.
|
84
|
+
|
85
|
+
Args:
|
86
|
+
node: AST node (ClassDef, FunctionDef, etc.)
|
87
|
+
lines: File lines
|
88
|
+
item: Archive item
|
89
|
+
chunk_index: Index of this chunk
|
90
|
+
|
91
|
+
Returns:
|
92
|
+
ChunkData for the element
|
93
|
+
"""
|
94
|
+
start_line = node.lineno - 1
|
95
|
+
end_line = self._find_block_end(node, lines)
|
96
|
+
|
97
|
+
content = '\n'.join(lines[start_line:end_line])
|
98
|
+
|
99
|
+
# Analyze code structure
|
100
|
+
from ..analyzers import ComplexityAnalyzer, QualityAnalyzer, PurposeDetector
|
101
|
+
code_info = self._analyze_structure(
|
102
|
+
node, content,
|
103
|
+
ComplexityAnalyzer, QualityAnalyzer, PurposeDetector
|
104
|
+
)
|
105
|
+
|
106
|
+
# Build context metadata
|
107
|
+
context = ChunkContextBuilder.build_code_context(
|
108
|
+
item, chunk_index, content, start_line, end_line, code_info
|
109
|
+
)
|
110
|
+
|
111
|
+
return ChunkData(
|
112
|
+
content=content,
|
113
|
+
chunk_index=chunk_index,
|
114
|
+
chunk_type=ChunkType.CODE,
|
115
|
+
context_metadata=context
|
116
|
+
)
|
117
|
+
|
118
|
+
def _analyze_structure(
|
119
|
+
self,
|
120
|
+
node: ast.AST,
|
121
|
+
content: str,
|
122
|
+
complexity_analyzer,
|
123
|
+
quality_analyzer,
|
124
|
+
purpose_detector
|
125
|
+
) -> Dict[str, Any]:
|
126
|
+
"""
|
127
|
+
Analyze Python code structure for context.
|
128
|
+
|
129
|
+
Args:
|
130
|
+
node: AST node
|
131
|
+
content: Code content
|
132
|
+
complexity_analyzer: Analyzer for complexity
|
133
|
+
quality_analyzer: Analyzer for quality
|
134
|
+
purpose_detector: Detector for purpose
|
135
|
+
|
136
|
+
Returns:
|
137
|
+
Dictionary with code analysis info
|
138
|
+
"""
|
139
|
+
info = {
|
140
|
+
'element_name': node.name,
|
141
|
+
'element_type': 'class' if isinstance(node, ast.ClassDef) else 'function',
|
142
|
+
'is_async': isinstance(node, ast.AsyncFunctionDef),
|
143
|
+
'docstring': ast.get_docstring(node),
|
144
|
+
'decorators': [d.id for d in getattr(node, 'decorator_list', []) if hasattr(d, 'id')],
|
145
|
+
'complexity_score': complexity_analyzer.calculate_code_complexity(content),
|
146
|
+
'quality_score': quality_analyzer.assess_code_quality(content),
|
147
|
+
'purpose': purpose_detector.detect_code_purpose(node.name, content),
|
148
|
+
}
|
149
|
+
|
150
|
+
# Extract function/method arguments
|
151
|
+
if hasattr(node, 'args'):
|
152
|
+
info['arguments'] = [arg.arg for arg in node.args.args]
|
153
|
+
|
154
|
+
# Extract class bases
|
155
|
+
if isinstance(node, ast.ClassDef):
|
156
|
+
info['base_classes'] = [base.id for base in node.bases if hasattr(base, 'id')]
|
157
|
+
|
158
|
+
return info
|
159
|
+
|
160
|
+
def _find_block_end(self, node: ast.AST, lines: List[str]) -> int:
|
161
|
+
"""
|
162
|
+
Find end line of Python code block.
|
163
|
+
|
164
|
+
Args:
|
165
|
+
node: AST node
|
166
|
+
lines: File lines
|
167
|
+
|
168
|
+
Returns:
|
169
|
+
End line number
|
170
|
+
"""
|
171
|
+
# Start from the node's end line
|
172
|
+
start_line = getattr(node, 'end_lineno', node.lineno) or node.lineno
|
173
|
+
|
174
|
+
# Look for the actual end by checking indentation
|
175
|
+
for i in range(start_line, len(lines)):
|
176
|
+
line = lines[i]
|
177
|
+
if line.strip() and not line.startswith(' ') and not line.startswith('\t'):
|
178
|
+
return i
|
179
|
+
|
180
|
+
return len(lines)
|
181
|
+
|
182
|
+
def _extract_imports(
|
183
|
+
self,
|
184
|
+
tree: ast.AST,
|
185
|
+
lines: List[str],
|
186
|
+
item: ArchiveItem,
|
187
|
+
chunk_index: int
|
188
|
+
) -> Optional[ChunkData]:
|
189
|
+
"""
|
190
|
+
Extract imports as separate chunk.
|
191
|
+
|
192
|
+
Args:
|
193
|
+
tree: Parsed AST
|
194
|
+
lines: File lines
|
195
|
+
item: Archive item
|
196
|
+
chunk_index: Chunk index
|
197
|
+
|
198
|
+
Returns:
|
199
|
+
ChunkData for imports or None
|
200
|
+
"""
|
201
|
+
import_lines = []
|
202
|
+
|
203
|
+
for node in ast.walk(tree):
|
204
|
+
if isinstance(node, (ast.Import, ast.ImportFrom)):
|
205
|
+
import_lines.append(node.lineno - 1)
|
206
|
+
|
207
|
+
if not import_lines:
|
208
|
+
return None
|
209
|
+
|
210
|
+
# Get all import lines
|
211
|
+
import_content = '\n'.join(lines[min(import_lines):max(import_lines) + 1])
|
212
|
+
|
213
|
+
context = ChunkContextBuilder.build_code_context(
|
214
|
+
item, chunk_index, import_content,
|
215
|
+
min(import_lines), max(import_lines) + 1,
|
216
|
+
{'element_name': 'imports', 'element_type': 'imports', 'purpose': 'imports'}
|
217
|
+
)
|
218
|
+
|
219
|
+
return ChunkData(
|
220
|
+
content=import_content,
|
221
|
+
chunk_index=chunk_index,
|
222
|
+
chunk_type=ChunkType.METADATA,
|
223
|
+
context_metadata=context
|
224
|
+
)
|
225
|
+
|
226
|
+
def _extract_remaining_code(
|
227
|
+
self,
|
228
|
+
tree: ast.AST,
|
229
|
+
lines: List[str],
|
230
|
+
item: ArchiveItem,
|
231
|
+
chunk_index: int
|
232
|
+
) -> Optional[ChunkData]:
|
233
|
+
"""
|
234
|
+
Extract remaining module-level code.
|
235
|
+
|
236
|
+
Args:
|
237
|
+
tree: Parsed AST
|
238
|
+
lines: File lines
|
239
|
+
item: Archive item
|
240
|
+
chunk_index: Chunk index
|
241
|
+
|
242
|
+
Returns:
|
243
|
+
ChunkData for module-level code or None
|
244
|
+
"""
|
245
|
+
# Simplified implementation - skip module-level code for now
|
246
|
+
# Could be enhanced to identify module-level statements
|
247
|
+
# that aren't part of classes or functions
|
248
|
+
return None
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"""
|
2
|
+
Generic text chunker.
|
3
|
+
|
4
|
+
Simple text chunking with fixed size and overlap.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from typing import List
|
8
|
+
from .base import BaseChunker
|
9
|
+
from ..context.models import ChunkData
|
10
|
+
from ..context.builders import ChunkContextBuilder
|
11
|
+
from ....models.archive import ArchiveItem, ChunkType
|
12
|
+
|
13
|
+
|
14
|
+
class TextChunker(BaseChunker):
|
15
|
+
"""
|
16
|
+
Generic text chunker with overlap.
|
17
|
+
|
18
|
+
Uses fixed-size chunking with overlap and smart break points.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def can_handle(self, item: ArchiveItem) -> bool:
|
22
|
+
"""Can handle any content as fallback."""
|
23
|
+
return True
|
24
|
+
|
25
|
+
def chunk(self, item: ArchiveItem) -> List[ChunkData]:
|
26
|
+
"""
|
27
|
+
Chunk text with fixed size and overlap.
|
28
|
+
|
29
|
+
Args:
|
30
|
+
item: Archive item to chunk
|
31
|
+
|
32
|
+
Returns:
|
33
|
+
List of ChunkData objects
|
34
|
+
"""
|
35
|
+
content = item.raw_content
|
36
|
+
chunks = []
|
37
|
+
|
38
|
+
# Simple text splitting with overlap
|
39
|
+
start = 0
|
40
|
+
chunk_index = 0
|
41
|
+
|
42
|
+
while start < len(content):
|
43
|
+
end = start + self.chunk_size
|
44
|
+
|
45
|
+
# Try to break at word boundary
|
46
|
+
if end < len(content):
|
47
|
+
break_point = self._find_good_break_point(content, start, end)
|
48
|
+
if break_point > start:
|
49
|
+
end = break_point
|
50
|
+
|
51
|
+
chunk_content = content[start:end].strip()
|
52
|
+
|
53
|
+
if chunk_content:
|
54
|
+
context = ChunkContextBuilder.build_generic_context(
|
55
|
+
item, chunk_index, chunk_content, start, end
|
56
|
+
)
|
57
|
+
|
58
|
+
chunks.append(ChunkData(
|
59
|
+
content=chunk_content,
|
60
|
+
chunk_index=chunk_index,
|
61
|
+
chunk_type=ChunkType.TEXT,
|
62
|
+
context_metadata=context
|
63
|
+
))
|
64
|
+
|
65
|
+
chunk_index += 1
|
66
|
+
|
67
|
+
# Move start position with overlap
|
68
|
+
start = max(start + self.chunk_size - self.overlap, end)
|
69
|
+
|
70
|
+
return chunks
|