LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
[MISC] Fixed notification plugin loading related issue (#1657)
Chandrasekharan M9cc47bdab32d
diff --git a/backend/adapter_processor_v2/views.py b/backend/adapter_processor_v2/views.pyindex 046f80bd4..3e59d1259 100644--- a/backend/adapter_processor_v2/views.py+++ b/backend/adapter_processor_v2/views.py@@ -12,6 +12,7 @@ from permissions.permission import (IsOwner,IsOwnerOrSharedUserOrSharedToOrg,)+from plugins import get_pluginfrom rest_framework import statusfrom rest_framework.decorators import actionfrom rest_framework.request import Request@@ -44,6 +45,10 @@ from adapter_processor_v2.serializers import (from .constants import AdapterKeys as constantfrom .models import AdapterInstance, UserDefaultAdapter+notification_plugin = get_plugin("notification")+if notification_plugin:+ from plugins.notification.constants import ResourceType+logger = logging.getLogger(__name__)@@ -342,40 +347,34 @@ class AdapterInstanceViewSet(ModelViewSet):# Send email notifications to newly shared usersif response.status_code == 200 and AdapterKeys.SHARED_USERS in request.data:try:- from plugins import get_plugin-- notification_plugin = get_plugin("notification")- if notification_plugin:- from plugins.notification.constants import ResourceType-- adapter.refresh_from_db()- new_shared_users = set(adapter.shared_users.all())- newly_shared_users = new_shared_users - current_shared_users-- if newly_shared_users:- # Map adapter type to specific resource type- adapter_type_to_resource = {- "LLM": ResourceType.LLM.value,- "EMBEDDING": ResourceType.EMBEDDING.value,- "VECTOR_DB": ResourceType.VECTOR_DB.value,- "X2TEXT": ResourceType.X2TEXT.value,- }-- resource_type = adapter_type_to_resource.get(- adapter.adapter_type, ResourceType.LLM.value- )+ adapter.refresh_from_db()+ new_shared_users = set(adapter.shared_users.all())+ newly_shared_users = new_shared_users - current_shared_users++ if newly_shared_users:+ # Map adapter type to specific resource type+ adapter_type_to_resource = {+ "LLM": ResourceType.LLM.value,+ "EMBEDDING": ResourceType.EMBEDDING.value,+ "VECTOR_DB": ResourceType.VECTOR_DB.value,+ "X2TEXT": ResourceType.X2TEXT.value,+ }++ resource_type = adapter_type_to_resource.get(+ adapter.adapter_type, ResourceType.LLM.value+ )- # Get notification service from plugin- service_class = notification_plugin["service_class"]- notification_service = service_class()- notification_service.send_sharing_notification(- resource_type=resource_type,- resource_name=adapter.adapter_name,- resource_id=str(adapter.id),- shared_by=request.user,- shared_to=list(newly_shared_users),- resource_instance=adapter,- )+ # Get notification service from plugin+ service_class = notification_plugin["service_class"]+ notification_service = service_class()+ notification_service.send_sharing_notification(+ resource_type=resource_type,+ resource_name=adapter.adapter_name,+ resource_id=str(adapter.id),+ shared_by=request.user,+ shared_to=list(newly_shared_users),+ resource_instance=adapter,+ )except Exception as e:logger.exception(f"Failed to send sharing notification: {e}")diff --git a/backend/api_v2/api_deployment_views.py b/backend/api_v2/api_deployment_views.pyindex 7174547e0..a7aeeb701 100644--- a/backend/api_v2/api_deployment_views.py+++ b/backend/api_v2/api_deployment_views.py@@ -34,10 +34,7 @@ from api_v2.serializers import (SharedUserListSerializer,)-# Check if notification plugin is availablenotification_plugin = get_plugin("notification")--# Import constants from notification plugin if availableif notification_plugin:from plugins.notification.constants import ResourceTypediff --git a/backend/connector_v2/views.py b/backend/connector_v2/views.pyindex 1641b8536..b03035ad1 100644--- a/backend/connector_v2/views.py+++ b/backend/connector_v2/views.py@@ -9,6 +9,7 @@ from connector_processor.exceptions import OAuthTimeOutfrom django.db import IntegrityErrorfrom django.db.models import ProtectedError, QuerySetfrom permissions.permission import IsOwner, IsOwnerOrSharedUserOrSharedToOrg+from plugins import get_pluginfrom rest_framework import status, viewsetsfrom rest_framework.request import Requestfrom rest_framework.response import Response@@ -24,16 +25,11 @@ from .exceptions import DeleteConnectorInUseErrorfrom .models import ConnectorInstancefrom .serializers import ConnectorInstanceSerializer-try:+notification_plugin = get_plugin("notification")+if notification_plugin:from plugins.notification.constants import ResourceTypefrom plugins.notification.sharing_notification import SharingNotificationService- NOTIFICATION_PLUGIN_AVAILABLE = True- sharing_notification_service = SharingNotificationService()-except ImportError:- NOTIFICATION_PLUGIN_AVAILABLE = False- sharing_notification_service = None-logger = logging.getLogger(__name__)@@ -214,7 +210,7 @@ class ConnectorInstanceViewSet(viewsets.ModelViewSet):if (response.status_code == 200and "shared_users" in request.data- and NOTIFICATION_PLUGIN_AVAILABLE+ and bool(notification_plugin)):try:instance.refresh_from_db()@@ -223,7 +219,7 @@ class ConnectorInstanceViewSet(viewsets.ModelViewSet):if newly_shared_users:# Only send notifications if there are newly shared users- sharing_notification_service.send_sharing_notification(+ SharingNotificationService().send_sharing_notification(resource_type=ResourceType.CONNECTOR.value,resource_name=instance.connector_name,resource_id=str(instance.id),diff --git a/backend/pipeline_v2/views.py b/backend/pipeline_v2/views.pyindex 02625a52f..64b6a8b26 100644--- a/backend/pipeline_v2/views.py+++ b/backend/pipeline_v2/views.py@@ -33,12 +33,8 @@ from pipeline_v2.serializers.execute import ()from pipeline_v2.serializers.sharing import SharedUserListSerializer-# Check if notification plugin is availablenotification_plugin = get_plugin("notification")-NOTIFICATION_PLUGIN_AVAILABLE = notification_plugin is not None--# Import constants from notification plugin if available-if NOTIFICATION_PLUGIN_AVAILABLE:+if notification_plugin:from plugins.notification.constants import ResourceTypelogger = logging.getLogger(__name__)@@ -135,7 +131,7 @@ class PipelineViewSet(viewsets.ModelViewSet):if (response.status_code == 200and "shared_users" in request.data- and NOTIFICATION_PLUGIN_AVAILABLE+ and notification_plugin):try:instance.refresh_from_db()diff --git a/backend/workflow_manager/workflow_v2/views.py b/backend/workflow_manager/workflow_v2/views.pyindex aa4f869a9..e2d8e21ac 100644--- a/backend/workflow_manager/workflow_v2/views.py+++ b/backend/workflow_manager/workflow_v2/views.py@@ -58,12 +58,8 @@ from workflow_manager.workflow_v2.workflow_helper import (WorkflowSchemaHelper,)-# Check if notification plugin is availablenotification_plugin = get_plugin("notification")-NOTIFICATION_PLUGIN_AVAILABLE = notification_plugin is not None--# Import constants from notification plugin if available-if NOTIFICATION_PLUGIN_AVAILABLE:+if notification_plugin:from plugins.notification.constants import ResourceTypelogger = logging.getLogger(__name__)@@ -156,7 +152,7 @@ class WorkflowViewSet(viewsets.ModelViewSet):if (response.status_code == 200and "shared_users" in request.data- and NOTIFICATION_PLUGIN_AVAILABLE+ and bool(notification_plugin)):try:# Get updated workflow to compare shared users