mirror of
https://github.com/docling-project/docling-serve.git
synced 2025-11-29 08:33:50 +00:00
feat: api to trigger offloading the models (#188)
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
@@ -39,6 +39,7 @@ from docling_serve.datamodel.requests import (
|
||||
ConvertDocumentsRequest,
|
||||
)
|
||||
from docling_serve.datamodel.responses import (
|
||||
ClearResponse,
|
||||
ConvertDocumentResponse,
|
||||
HealthCheckResponse,
|
||||
MessageKind,
|
||||
@@ -46,6 +47,7 @@ from docling_serve.datamodel.responses import (
|
||||
WebsocketMessage,
|
||||
)
|
||||
from docling_serve.datamodel.task import Task, TaskSource
|
||||
from docling_serve.docling_conversion import _get_converter_from_hash
|
||||
from docling_serve.engines.async_orchestrator import (
|
||||
BaseAsyncOrchestrator,
|
||||
ProgressInvalid,
|
||||
@@ -544,4 +546,13 @@ def create_app(): # noqa: C901
|
||||
status_code=400, detail=f"Invalid progress payload: {err}"
|
||||
)
|
||||
|
||||
# Offload models
|
||||
@app.get(
|
||||
"/v1alpha/clear/converters",
|
||||
response_model=ClearResponse,
|
||||
)
|
||||
async def clear_converters():
|
||||
_get_converter_from_hash.cache_clear()
|
||||
return ClearResponse()
|
||||
|
||||
return app
|
||||
|
||||
@@ -15,6 +15,10 @@ class HealthCheckResponse(BaseModel):
|
||||
status: str = "ok"
|
||||
|
||||
|
||||
class ClearResponse(BaseModel):
|
||||
status: str = "ok"
|
||||
|
||||
|
||||
class DocumentResponse(BaseModel):
|
||||
filename: str
|
||||
md_content: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user