promptfoo: Google provider fails when using gemini 1.5 flash
Describe the bug
Using the gemini-1.5-flash model fails with an error that is not intuitive to understand.
The error is
API did not return any candidate responses: {"error":{"code":400,"message":"Invalid JSON payload received. Unknown name \"content\" at 'contents[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"content\" at 'contents[1]': Cannot find field.","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"contents[0]","description":"Invalid JSON payload received. Unknown name \"content\" at 'contents[0]': Cannot find field."},{"field":"contents[1]","description":"Invalid JSON payload received. Unknown name \"content\" at 'contents[1]': Cannot find field."}]}]}}
In addition to the following log
Using unknown Google chat model: gemini-1.5-flash-latest
To Reproduce
Try and use the model in providers: e.g
- id: google:gemini-1.5-flash-latest
config:
temperature: 0
max_tokens: 4096
Expected behavior The model is used to evaluate the prompts.
Screenshots N/A
System information (please complete the following information):
- Promptfoo version:
0.92.3
Additional context Looks similar to #1393 although that particular issue is specific to using gemini as a grader?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 19 (10 by maintainers)
It looks like the API request we use is out of date
https://github.com/promptfoo/promptfoo/blob/207469a6a54b3a4123c2f8418d51affe9b04d40d/src/providers/palm.ts#L103-L112
vs the structure used in REST examples here: https://ai.google.dev/gemini-api/docs/text-generation?lang=rest
Note that there is also a node API client for AI studio: https://github.com/google-gemini/generative-ai-js
@hyusetiawan Promptfoo is using
v1notv1betaso that might be why. I’ve opened a PR that lets you override the API version #2529This is working for me now on
0.94.0- thank you!Hi @aaronstillwell and @danpe,
We’ve made some updates to address the Gemini formatting issue in the latest release. Could you please try updating to version 0.94.0 and see if it resolves the problem? The fix is included in #1947.
If the issue persists, feel free to book some time on my calendar here: https://cal.com/michael-dangelo/15min, and we can troubleshoot it together.
Thanks again for your patience and feedback!
@aaronstillwell I get the same:
@mldangelo there’s some differences between my config and yours:
and prompts.yaml
The OpenAI provider is working fine with this setup. Gemini returns: