convert tests/integration/inference/test_vision_inference.py from deprecated inference to openai-compat

This commit is contained in:
Matthew Farrellee 2025-01-09 04:05:06 -05:00
parent 605d6985b7
commit 7bfbded5de
2 changed files with 220 additions and 0 deletions

View file

@ -192,6 +192,14 @@ async def localize_image_content(uri: str) -> tuple[bytes, str] | None:
format = "png"
return content, format
elif uri.startswith("data"):
# data:image/{format};base64,{data}
match = re.match(r"data:image/(\w+);base64,(.+)", uri)
if not match:
raise ValueError(f"Invalid data URL format, {uri[:40]}...")
fmt, image_data = match.groups()
content = base64.b64decode(image_data)
return content, fmt
else:
return None