When Gemini blocks a prompt, it returns zero candidates, and calling $response->parts() throws a ValueError.
I think the fix is to guard against empty candidates in GeminiProvider.php.

Error:
ValueError: The `GenerateContentResponse::parts()` quick accessor only works for a single candidate,but
none were returned. Check the `GenerateContentResponse::$promptFeedback` to see if the prompt was blocked. in
Gemini\Responses\GenerativeModel\GenerateContentResponse->parts() (regel 47 van
/dev/vendor/google-gemini-php/client/src/Responses/GenerativeModel/GenerateContentResponse.php).

CommentFileSizeAuthor
#3 gemini_provider-3588223-2.patch1.06 KBstijnstroobants
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

stijnstroobants created an issue. See original summary.

stijnstroobants’s picture

Issue summary: View changes
stijnstroobants’s picture

StatusFileSize
new1.06 KB
stijnstroobants’s picture

Status: Active » Needs review

ishani patel made their first commit to this issue’s fork.

ishani patel’s picture

Assigned: Unassigned » ishani patel

Hello,
I've created an MR from the patch.

Thank you!

ishani patel’s picture

Assigned: ishani patel » Unassigned