Skip to content
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

Supporting structured JSON output for Google AI #210

Open
vkryukov opened this issue Dec 9, 2024 · 4 comments
Open

Supporting structured JSON output for Google AI #210

vkryukov opened this issue Dec 9, 2024 · 4 comments

Comments

@vkryukov
Copy link
Contributor

vkryukov commented Dec 9, 2024

Looks like Google supports structured JSON output by supplying a schema through model configuration:

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
    "contents": [{
      "parts":[
        {"text": "List 5 popular cookie recipes"}
        ]
    }],
    "generationConfig": {
        "response_mime_type": "application/json",
        "response_schema": {
          "type": "ARRAY",
          "items": {
            "type": "OBJECT",
            "properties": {
              "recipe_name": {"type":"STRING"},
            }
          }
        }
    }
}' 2> /dev/null | head

Would you be interested in a PR that adds this ability, similar to ChatOpenAI implementation (which btw should be documented?)

@brainlid
Copy link
Owner

Hi @vkryukov! Yes, I'd love help implementing and supporting Google Gemini support for structured output with a schema declaration. 😄

@vkryukov
Copy link
Contributor Author

Sounds good, I will try develop a PR to start as a discussion point.

Google's models are improving fast (both gemini-2.0-flash-exp and gemini-exp-1206 are pretty impressive), and they offer massive context windows - so I want to keep testing them. So we need to have a first-class support by LangChain.

@brainlid
Copy link
Owner

That's cool. I've been so underwhelmed and disappointed by Google's past models that I wrote them off for personal use. Glad to hear they are improving!

@vkryukov
Copy link
Contributor Author

Yeah, I can relate to that. I plan to post a comparison (eventually); for my use case (code generation), gemini-exp-1206 is not bad! But of course, Sonnet 3.5 New still seems to be the SOTA.

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

No branches or pull requests

2 participants