Skip to content

Add an exception for GoogleGemini and GoogleVertexAI when using the OutputFixingParser #1016

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

carlows
Copy link

@carlows carlows commented Jul 16, 2025

Connected to #1015

As described in the README, the google APIs have a different format for their LLMs:

messages = [
  { role: "system", content: "You are a helpful assistant." },
  { role: "user", content: "What's the weather like today?" }
  # Google Gemini and Google VertexAI expect messages in a different format:
  # { role: "user", parts: [{ text: "why is the sky blue?" }]}
]
response = llm.chat(messages: messages)
chat_completion = response.chat_completion

And the OutputFixingParser class doesn't work with Gemini 2.5-flash, as it throws the following error:

{"error"=>{"code"=>400, "message"=>"Invalid JSON payload received. Unknown name "content" at 'contents[0]': 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."}]}]}}

The goal of this PR is to use the correct format instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant