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

with_structured_output returns this 400 BAD Request must be specified when not using one_of #686

Open
jeffmorris1993 opened this issue Jan 9, 2025 · 0 comments

Comments

@jeffmorris1993
Copy link

Hi all,

I am using ChatGoogleGenerativeAI within the latest version of the package (2.0.8). with_structured_output results in me getting this full issue:
google.api_core.exceptions.BadRequest: 400 POST https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent?%24alt=json%3Benum-encoding%3Dint: * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[overlap_classification].type: must be specified when not using one_of
2025-01-09T03:39:45.455541804Z * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[similiar_requirements].items.properties[reuse_classification].type: must be specified when not using one_of

And here is the Pydantic model that is used as the schema:

class OverlapEnum(str, Enum):
    no_overlap = "No-Overlap"
    clear_overlap = "Overlap"
    some_overlap = "Some-Overlap"


class SimiliarRequirementExplanationModel(BaseModel):
    id: str = Field(..., description="ID of the similar requirement")
    description: str = Field(..., description="The text description of the similar requirement")
    reuse_classification: OverlapEnum = Field(..., description="Classification of the similar requirement")
    explanation: str = Field(..., description="Explanation of the reuse determination")


class InternalReuseModel(BaseModel):
    overlap_classification: OverlapEnum = Field(
        ..., description="Overall classification of the requirement's overlap across the comparision groups"
    )
    similiar_requirements: list[SimiliarRequirementExplanationModel] = Field(
        ..., description="List of similar requirements and their reuse classification"
    )

Can anyone help me understand this error and what I need to fix in my code?

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

1 participant