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).
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | gemini_provider-3588223-2.patch | 1.06 KB | stijnstroobants |
Issue fork gemini_provider-3588223
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
Comment #2
stijnstroobantsComment #3
stijnstroobantsComment #4
stijnstroobantsComment #7
ishani patel commentedHello,
I've created an MR from the patch.
Thank you!
Comment #8
ishani patel commented