-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON mode to Gemini (Vertex AI) #2964
Add JSON mode to Gemini (Vertex AI) #2964
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
You can tell JSON mode is working, because if you remove
|
For some odd reason, |
Oh, and
|
LGTM - will take care of fixing any issues that show up during ci/cd |
@krrishdholakia Hmm, did you do any testing after 77d6b88? JSON mode doesn't seem to work anymore after I merged in v1.35.2. |
hey @Manouchehri I added a check if the sdk supports 'response_mime_type' - reason: it was failing ci/cd since the vertex version didn't have 'response_mime_type' as a supported init param |
Oh. That won't work, since no version of the Vertex AI Python SDK has I reverted 77d6b88 and it works as expected; could we find a another solution? :) This is what you should see when it's working: {
"id": "chatcmpl-84b126f1-01ab-42a3-a600-fe56856b041b",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "{\n \"joke\": \"Why did the V8 engine stall at 11:06:41? Because it ran out of juice!\"\n}\n",
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1712938040,
"model": "gemini-1.5-pro-preview-0409",
"object": "chat.completion",
"system_fingerprint": null,
"usage": {
"completion_tokens": 34,
"prompt_tokens": 30,
"total_tokens": 64
}
} And this is what you should see when it's not working (see the Markdown wrapped output): {
"id": "chatcmpl-e7c447a7-f047-42ac-a039-becb982b48fb",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "```json\n{\n \"joke\": \"Why did the V8 engine laugh at 11:07:37? Because it was past its bedtime, silly! V8s need their rest to keep running smoothly.\"\n}\n``` \n",
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1712938061,
"model": "gemini-1.5-pro-preview-0409",
"object": "chat.completion",
"system_fingerprint": null,
"usage": {
"completion_tokens": 53,
"prompt_tokens": 30,
"total_tokens": 83
}
} |
@Manouchehri open to suggestions how're you able to make the call without response_mime_type being supported? it failed during testing for us - https://app.circleci.com/pipelines/github/BerriAI/litellm/8432/workflows/e75a83e3-7ffe-431c-861e-1da736d0b857/jobs/17175/steps |
Not sure to be honest, but it's definitely working. 😅 That's odd, it looks like only the sync version is failing, while the async one is fine? |
Okay, we can wait until googleapis/python-aiplatform#3639 is merged soon and I'll just make a PR to revert this once it's updated. :) |
Fixes #2962.
Example code:
Output: