From 15e18f5903dc2d033328489dece010c3ad45c5fd Mon Sep 17 00:00:00 2001 From: Michele Dolfi Date: Thu, 6 Feb 2025 13:58:06 +0100 Subject: [PATCH] allow only localhost traffic Signed-off-by: Michele Dolfi --- docling/models/pic_description_api_model.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docling/models/pic_description_api_model.py b/docling/models/pic_description_api_model.py index a68b2b4e..85fc55eb 100644 --- a/docling/models/pic_description_api_model.py +++ b/docling/models/pic_description_api_model.py @@ -53,6 +53,12 @@ class PictureDescriptionApiModel(PictureDescriptionBaseModel): super().__init__(enabled=enabled, options=options) self.options: PicDescApiOptions + if self.enabled: + if options.url.host != "localhost": + raise NotImplementedError( + "The options try to connect to remote APIs which are not yet allowed." + ) + def _annotate_images(self, images: Iterable[Image.Image]) -> Iterable[str]: # Note: technically we could make a batch request here, # but not all APIs will allow for it. For example, vllm won't allow more than 1.