Closed rotemdan closed 4 months ago
Excellent, let's get a version number bump to 1.3
and I'll merge this.
The two Gemma models do seem to work with the system instruction passed, but I can't really know if all others will.
It's technically possible to add a check for them as well, but I don't know if it matters, since probably most people using the API are using it for the larger models (except for testing maybe).
I guess the script may need to be edited further in the future for those kind of things.
I think you're right, this should cover probably 90% of most people's usage. Thanks! 🙏
Now I realized gemma-7b-it
and gemma2-9b-it
actually originated from the Groq API, not Gemini. This change doesn't apply to them at all.
I got confused there due to Gemma models appearing on Google AI Studio. The Gemini API currently only provides Gemini models, not any Gemma models.
So, this change does currently apply to 100% of use cases. No need for any other check until a newer version number of Gemini is released.
I also ported this enhancement to the Functions version: https://openwebui.com/f/justinrahb/google_genai
The current code in
google_manifold_pipeline
adds a "system"-like prompt by prepending the request with a message containing the system prompt:On Gemini 1.5 models, Google added support for native system instructions. In the Python API it is passed as an argument for the constructor:
The equivalent in the REST API is documented here:
In my patch I added support for it when the string
gemini-1.5
is part of the model id:Gemini 1.0 and Gemma models don't support system instructions, so they will fall back to the other approach. Note: after trying to use
system_instruction
with Gemini 1.0 I got an error from the server, but both Gemma models (gemma2-9b-it
andgemma-7b-it
) did accept the instruction without error and showed knowledge of it. Officially they don't support system instructions, so it could be a workaround prompt on the server.Future models, say, like
gemini-2.0
will need to be added manually when they become available on the API, otherwise they will fall back to the other approach.The information returned by the API unfortunately doesn't indicate if the model supports system instructions. Here is for example, the information for Gemini 1.5 pro (returned via
https://generativelanguage.googleapis.com/v1beta/models
):