allow only localhost traffic

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
Michele Dolfi 2025-02-06 13:58:06 +01:00
parent 8ac000e35e
commit 15e18f5903

View File

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