google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.59k stars 319 forks source link

Invalid operation: The `response.parts` #526

Closed Pratik-Kumar-Cse closed 2 months ago

Pratik-Kumar-Cse commented 2 months ago

Description of the bug:

Invalid operation: The response.parts quick accessor requires a single candidate, but none were returned. Please check the response.prompt_feedback to determine if the prompt was blocked.

Actual vs expected behavior:

I am calling the llm using image and video like this

response = model.generate_content( [prompt, video_file], request_options={"timeout": 600}, safety_settings=safety_settings, )

Any other information you'd like to share?

No response

MarkDaoust commented 2 months ago

There are some improved error messages in: https://github.com/google-gemini/generative-ai-python/pull/527

What was in response.prompt_feedback? Was it empty?

MarkDaoust commented 2 months ago

Unless there's something new, let's call this a duplicate of #170, with https://github.com/google-gemini/generative-ai-python/pull/527 as a fix.

Pratik-Kumar-Cse commented 2 months ago

when I try to access the response.text then this error message will come but I am able to access token used