Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-2541 [FIX] Enabled platform key support in text extractor adapter configuration edit (#1423)

Athul8f196ce36fb1
diff --git a/backend/adapter_processor_v2/views.py b/backend/adapter_processor_v2/views.py
index b9bebd969..8a34daaef 100644
--- a/backend/adapter_processor_v2/views.py
+++ b/backend/adapter_processor_v2/views.py
@@ -289,6 +289,26 @@ class AdapterInstanceViewSet(ModelViewSet):
def partial_update(
self, request: Request, *args: tuple[Any], **kwargs: dict[str, Any]
) -> Response:
+ # Check if adapter metadata is being updated and contains the platform key flag
+ use_platform_unstract_key = False
+ adapter_metadata = request.data.get(AdapterKeys.ADAPTER_METADATA)
+
+ if adapter_metadata and adapter_metadata.get(
+ AdapterKeys.PLATFORM_PROVIDED_UNSTRACT_KEY, False
+ ):
+ use_platform_unstract_key = True
+
+ # Get the adapter instance and check if it's an X2TEXT adapter
+ adapter = self.get_object()
+ if adapter.adapter_type == AdapterKeys.X2TEXT and use_platform_unstract_key:
+ # If adapter_metadata_b is in the request data, update it with the Unstract key
+ if AdapterKeys.ADAPTER_METADATA_B in request.data:
+ adapter_metadata_b = request.data.get(AdapterKeys.ADAPTER_METADATA_B)
+ updated_metadata_b = AdapterProcessor.update_adapter_metadata(
+ adapter_metadata_b, is_paid_subscription=True
+ )
+ request.data[AdapterKeys.ADAPTER_METADATA_B] = updated_metadata_b
+
if AdapterKeys.SHARED_USERS in request.data:
# find the deleted users
adapter = self.get_object()