feat: api to trigger offloading the models (#188)

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
Michele Dolfi
2025-05-14 15:02:18 +02:00
committed by GitHub
parent 3ff1b2f983
commit 00be428490
2 changed files with 15 additions and 0 deletions

View File

@@ -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