fix(factory.py): handle escape characters in image url
prevents mimetype errors in vertex ai calls
This commit is contained in:
parent
b9d4d67357
commit
30d6c1d171
@ -709,6 +709,7 @@ def convert_to_anthropic_image_obj(openai_image_url: str) -> GenericImageParsing
|
||||
openai_image_url = convert_url_to_base64(url=openai_image_url)
|
||||
# Extract the media type and base64 data
|
||||
media_type, base64_data = openai_image_url.split("data:")[1].split(";base64,")
|
||||
media_type = media_type.replace("\\/", "/")
|
||||
|
||||
return GenericImageParsingChunk(
|
||||
type="base64",
|
||||
|
||||
@ -212,6 +212,7 @@ def test_convert_url_to_img():
|
||||
[
|
||||
("data:image/jpeg;base64,1234", "image/jpeg"),
|
||||
("data:application/pdf;base64,1234", "application/pdf"),
|
||||
("data:image\/jpeg;base64,1234", "image/jpeg"),
|
||||
],
|
||||
)
|
||||
def test_base64_image_input(url, expected_media_type):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user