propertyOrdering is missing from Schema
Description of the bug:
According to the docs, the JSON schema supports propertyOrdering but it's not present in the Schema object.
https://ai.google.dev/gemini-api/docs/structured-output?lang=go#property-ordering
Actual vs expected behavior:
No response
Any other information you'd like to share?
No response
I tried to edit Schema in code but it says that the file is autogenerated and I'm not sure what is the source.
Thanks for bringing this issue up. Do you have a reproducible code snippet that can be used for further triaging?
genai.Schema{PropertyOrdering: []string{"a", "b"}} 👀
Same here, it seems to fill-in the fields in alphabetical order as specified by the docs. This leads to poor behavior for this simple toy example since the "punchline" is filled before the "setup".
model.ResponseMIMEType = "application/json"
model.ResponseSchema = &genai.Schema{
Type: genai.TypeObject,
Description: "Jokes are formatted as JSON objects with setup and punchline fields.",
Nullable: false,
Required: []string{"setup", "punchline"},
Properties: map[string]*genai.Schema{
"setup": &genai.Schema{
Type: genai.TypeString,
Description: "The setup of the joke.",
Nullable: false,
},
"punchline": &genai.Schema{
Type: genai.TypeString,
Description: "The punchline of the joke.",
Nullable: false,
},
},
}
resp, err := model.GenerateContent(ctx, genai.Text(`Tell me a joke about tariffs.`))
I am able to force the order by renaming the fields to a_setup and b_punchline.
Also, by looking at the struct in genai.Schema, I am also confused on other schema properties like anyOf, maxItems, minItems, minimum, maximum as referenced by the Schema documentation here: https://ai.google.dev/api/caching#Schema
This is solved in this SDK: https://github.com/googleapis/go-genai/tree/v0.7.0 I am not sure why there are two competing go SDKs for Google GenAI...