OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
chore: fix main (#1613)
Edwin Josee7fb3244ca52
diff --git a/src/services/docling_service.py b/src/services/docling_service.pyindex 98ffbf627..7c1b2db7e 100644--- a/src/services/docling_service.py+++ b/src/services/docling_service.py@@ -1,8 +1,8 @@import asyncioimport json-from dataclasses import dataclass-from enum import Enumimport platform+from dataclasses import dataclass+from enum import StrEnumfrom pathlib import Pathfrom typing import Any@@ -29,12 +29,11 @@ class DoclingConfig(BaseModel):picture_description_local: dict | None = None-class DoclingServeError(Exception):"""Raised when docling-serve conversion fails."""-class DoclingTaskState(str, Enum):+class DoclingTaskState(StrEnum):"""Result of a single status check against Docling Serve."""PENDING = "pending"@@ -49,8 +48,8 @@ class DoclingStatusSnapshot:"""Single-point-in-time view of a Docling task's state."""state: DoclingTaskState- detail: Optional[str] = None- raw: Optional[dict] = None+ detail: str | None = None+ raw: dict | None = Nonedef get_docling_preset_configs(@@ -78,7 +77,7 @@ class DoclingService:_default_client: httpx.AsyncClient | None = Nonedef __init__(- self, docling_url: Optional[str] = None, httpx_client: Optional[httpx.AsyncClient] = None+ self, docling_url: str | None = None, httpx_client: httpx.AsyncClient | None = None):"""Initialize the DoclingService.@@ -268,7 +267,7 @@ class DoclingService:return DoclingStatusSnapshot(state=DoclingTaskState.PROCESSING, raw=payload)return DoclingStatusSnapshot(state=DoclingTaskState.PENDING, raw=payload)- async def fetch_task_result(self, task_id: str) -> Dict[str, Any]:+ async def fetch_task_result(self, task_id: str) -> dict[str, Any]:"""Fetch the converted document for a Docling task that is already SUCCESS.diff --git a/src/services/langflow_file_service.py b/src/services/langflow_file_service.pyindex d56c76dec..c2ca4ae01 100644--- a/src/services/langflow_file_service.py+++ b/src/services/langflow_file_service.py@@ -71,7 +71,7 @@ class LangflowFileService:return final_tweaks- async def upload_user_file(self, file_tuple, jwt_token: Optional[str] = None) -> Dict[str, Any]:+ async def upload_user_file(self, file_tuple, jwt_token: str | None = None) -> dict[str, Any]:"""Upload a file using Langflow Files API v2: POST /api/v2/files.Returns JSON with keys: id, name, path, size, provider."""@@ -515,8 +515,13 @@ class LangflowFileService:raise last_errorraise RuntimeError("Unable to validate/import URL ingest flow")- async def submit_to_docling(self, filename: str, content: bytes, jwt_token: Optional[str] = None,- owner: Optional[str] = None,) -> str:+ async def submit_to_docling(+ self,+ filename: str,+ content: bytes,+ jwt_token: str | None = None,+ owner: str | None = None,+ ) -> str:"""Upload a file to Docling Serve and return the task_id immediately.Phase 1 of the two-phase ingestion model. The caller is responsible@@ -531,6 +536,7 @@ class LangflowFileService:try:task_id = await self.docling_service.upload_to_docling_direct_async(filename, content, user_id=owner, auth_header=jwt_token+ )logger.debug("[LF] Docling submission accepted",extra={"task_id": task_id, "filename": filename},@@ -541,22 +547,22 @@ class LangflowFileService:"[LF] Docling submission failed",extra={"error": str(e), "filename": filename},)- raise Exception(f"Docling upload failed: {str(e)}")+ raise Exception(f"Docling upload failed: {str(e)}") from easync def upload_and_ingest_file(self,file_tuple,- session_id: Optional[str] = None,- tweaks: Optional[Dict[str, Any]] = None,- settings: Optional[Dict[str, Any]] = None,- jwt_token: Optional[str] = None,- owner: Optional[str] = None,- owner_name: Optional[str] = None,- owner_email: Optional[str] = None,- connector_type: Optional[str] = None,- docling_polling_service: Optional[Any] = None,- file_task: Optional[Any] = None,- ) -> Dict[str, Any]:+ session_id: str | None = None,+ tweaks: dict[str, Any] | None = None,+ settings: dict[str, Any] | None = None,+ jwt_token: str | None = None,+ owner: str | None = None,+ owner_name: str | None = None,+ owner_email: str | None = None,+ connector_type: str | None = None,+ docling_polling_service: Any | None = None,+ file_task: Any | None = None,+ ) -> dict[str, Any]:"""Two-phase Docling upload + Langflow ingest operation.@@ -591,7 +597,7 @@ class LangflowFileService:file_task.phase = IngestionPhase.DOCLINGfile_task.docling_status = DoclingPhaseStatus.PENDING- task_id = await self.submit_to_docling(filename, content,user_id=owner, auth_header=jwt_token)+ task_id = await self.submit_to_docling(filename, content, owner=owner, jwt_token=jwt_token)if file_task is not None:file_task.docling_task_id = task_id