vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
8.49k stars 1.19k forks source link

Google Gemini System instructions #1983

Open tomasmcm opened 1 week ago

tomasmcm commented 1 week ago

Feature Description

Google Gemini models now support a "system instructions" parameter that works like the "system messate" in OpenAI. https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/send-chat-prompts-gemini

Can you update the google gemini provider to use the new paramter instead of prepending the system prompt as a user message?

Use Case

Prepending the system prompt as a user message makes it have less importance and users can steer the model away from the intended use case. In order to build role playing assistants, defining the output format, or others as stated here https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/send-chat-prompts-gemini#system-instructions it's better to use the new system instructions.

Additional context

No response

BleedingDev commented 1 week ago

Would love to work on this, I already cloned the repo, so I'll take a look. :)

tomasmcm commented 1 week ago

On closer inspection, it seems the Vertex AI integration already supports system instructions. So it’s a matter to replicating a similar behaviour.