Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Pydantic serializer warning when following image generation example #6387

Closed
bachya opened this issue Oct 22, 2024 · 5 comments · Fixed by #6407
Closed

[Bug]: Pydantic serializer warning when following image generation example #6387

bachya opened this issue Oct 22, 2024 · 5 comments · Fixed by #6407
Labels
bug Something isn't working

Comments

@bachya
Copy link
Contributor

bachya commented Oct 22, 2024

What happened?

litellm version: 1.50.1

When running the same image generation example provided in the OpenAI-specific docs:

from litellm import image_generation
import os
os.environ['OPENAI_API_KEY'] = "MY-KEY"
response = image_generation(model='dall-e-2', prompt="cute baby otter")

I get the below (verbose) error.

Relevant log output

Request to litellm:
litellm.image_generation(prompt='A cute baby sea otter', model='dall-e-2')


SYNC kwargs[caching]: False; litellm.cache: None; kwargs.get('cache')['no-cache']: False


POST Request Sent from LiteLLM:
curl -X POST \
https://api.openai.com/v1/ \
-H 'Authorization: Bearer REDACTED' \
-d '{'model': 'dall-e-2', 'prompt': 'A cute baby sea otter'}'


RAW RESPONSE:
{"created": 1729637417, "data": [{"b64_json": null, "revised_prompt": null, "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-eKVqt5coPeguhXnGMZA3LSiY/user-64uWQ02UIoBWU4JUFEWhf6TK/img-zVGFgxKRgL9nswTwDAKysvtG.png?st=2024-10-22T21%3A50%3A17Z&se=2024-10-22T23%3A50%3A17Z&sp=r&sv=2024-08-04&sr=b&rscd=inline&rsct=image/png&skoid=d505667d-d6c1-4a0a-bac7-5c84a87759f8&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-10-22T17%3A37%3A50Z&ske=2024-10-23T17%3A37%3A50Z&sks=b&skv=2024-08-04&sig=eKQpu/vdv5OdNnJBp2Y5OBG%2BiBHvjMDNUxekM5oUJMc%3D"}]}


Logging Details LiteLLM-Success Call: Cache_hit=None
>>> /Users/bachya/Git/liminal/liminal-image-generation/.venv/lib/python3.12/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
  Expected `Image` but got `dict` with value `{'b64_json': None, 'revis...iBHvjMDNUxekM5oUJMc%3D'}` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(

Twitter / LinkedIn details

No response

@bachya bachya added the bug Something isn't working label Oct 22, 2024
@bachya
Copy link
Contributor Author

bachya commented Oct 23, 2024

@krrishdholakia Making sure you see this one (since the documentation presents something that doesn't currently work).

@krrishdholakia
Copy link
Contributor

hey @bachya

Pydantic serializer warnings

i see a warning, what was the stacktrace?

@bachya
Copy link
Contributor Author

bachya commented Oct 23, 2024

Ah, my apologies—I saw:

UserWarning: Pydantic serializer warnings:
  Expected `Image` but got `dict` with value `{'b64_json': None, 'revis...iBHvjMDNUxekM5oUJMc%3D'}` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(

...and just assumed the request failed. When I print response, I see what I want.

Should I keep this open for that Pydantic warning, or is that a non-issue?

@krrishdholakia
Copy link
Contributor

the title is still valid - i'll try to see what's raising this

@krrishdholakia krrishdholakia changed the title [Bug]: Pydantic serializer errors when following image generation example [Bug]: Pydantic serializer warning when following image generation example Oct 23, 2024
@krrishdholakia
Copy link
Contributor

This was a good issue - it caught a bug where the data field was a list of dict instead of list of image objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants