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

Unsupported patternProperties for json schema #617

Open
quimey opened this issue Nov 26, 2024 · 1 comment
Open

Unsupported patternProperties for json schema #617

quimey opened this issue Nov 26, 2024 · 1 comment

Comments

@quimey
Copy link

quimey commented Nov 26, 2024

Hey! I'm trying to use Gemini Flash 1.5 8b to run a prompt that includes a json schema for a structured output. This is my schema:

        "target_locations": {
            "type": "object",
            "patternProperties": {"^.*$": {"type": "number"}},
            "additionalProperties": False,
        },

The idea is to include a variable number of properties with numeric value.

This schema works well with langchain and anthropic models but when I try to use ChatGoogleGenerativeAI I get the following error:

celery-worker-1     | langchain_google_genai.chat_models.ChatGoogleGenerativeAIError: Invalid argument provided to Gemini: 400 * GenerateContentRequest.model: unexpected model name format
celery-worker-1     | * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[target_locations].properties: should be non-empty for OBJECT type
celery-worker-1     | 

Is there any workaround or a plan to support patternProperties?

I'm using python3.11 and

langchain==0.3.8
langchain-core=0.3.21
langchain-anthropic=0.3.0
langchain-google-genai=2.0.5
@Cristy94
Copy link

Cristy94 commented Jan 7, 2025

2.0 doesn't support it either, so this doesn't work (number keys):

"patternProperties": {
                "^[0-9]+$": {
                    "type": "array",
                    ...

Any way around it? I can probably write some JS to manually create the schema with the expected returned keys...

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