TypeError Could not create `Blob`, expected `Blob`, `dict` or an `Image` type(`PIL.Image.Image` or `IPython.display.Image`)
petrgazarov opened this issue · comments
Petr Gazarov commented
Description of the bug:
Getting this error sometimes. What does it mean? If I rerun the script, it is not raised every time, but only sometimes.
REQUEST_TIMEOUT = 90
# model is `gemini-1.5-flash`
client = genai.GenerativeModel(model, system_instruction=system_instruction)
google_completion = await asyncio.wait_for(
client.generate_content_async(
messages,
safety_settings={
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
},
),
REQUEST_TIMEOUT,
)
Actual vs expected behavior:
Actual:
TypeError Could not create `Blob`, expected `Blob`, `dict` or an `Image` type(`PIL.Image.Image` or `IPython.display.Image`).
Got a: <class 'NoneType'>
Value: None
Expected there to be no error
Any other information you'd like to share?
No response
Mark Daoust commented
Right, that's not the best error.
This is at the step where it's trying to convert your input into the classes the api actually uses.
And you have a None
in your list of contents
or one of their lists of parts
.
I should make these errors clearer. You need to track down where that None
is coming from.