mirror of
https://github.com/docling-project/docling-serve.git
synced 2025-12-01 09:33:18 +00:00
feat: add support for file upload and return as file in async endpoints (#152)
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional
|
||||
from typing import Optional, Union
|
||||
|
||||
from docling_serve.datamodel.requests import ConvertDocumentsRequest
|
||||
from docling_serve.datamodel.task import Task
|
||||
from fastapi import BackgroundTasks
|
||||
from fastapi.responses import FileResponse
|
||||
|
||||
from docling_serve.datamodel.convert import ConvertDocumentsOptions
|
||||
from docling_serve.datamodel.responses import ConvertDocumentResponse
|
||||
from docling_serve.datamodel.task import Task, TaskSource
|
||||
|
||||
|
||||
class OrchestratorError(Exception):
|
||||
@@ -15,7 +19,9 @@ class TaskNotFoundError(OrchestratorError):
|
||||
|
||||
class BaseOrchestrator(ABC):
|
||||
@abstractmethod
|
||||
async def enqueue(self, request: ConvertDocumentsRequest) -> Task:
|
||||
async def enqueue(
|
||||
self, sources: list[TaskSource], options: ConvertDocumentsOptions
|
||||
) -> Task:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@@ -31,9 +37,15 @@ class BaseOrchestrator(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def task_result(self, task_id: str):
|
||||
async def task_result(
|
||||
self, task_id: str, background_tasks: BackgroundTasks
|
||||
) -> Union[ConvertDocumentResponse, FileResponse, None]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def process_queue(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def warm_up_caches(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user