Thanks for the reply @GUNAND_MAYANGLAMBAM !
So I have pursued this route and am enforcing a dictionary output with a list of key and a list of values. I am now running into issues with the formatting of the response_schema
arg in GenerationConfig
.
If I pass it as:
generation_config = GenerationConfig(
temperature=float(config["temperature"]),
response_mime_type="application/json",
response_schema=ResponseSchema.schema()
)
I get an error:
google.protobuf.json_format.ParseError: Message type "google.cloud.aiplatform.v1beta1.Schema" has no field named "$defs" at "Schema".
Available Fields(except extensions): "['type', 'format', 'title', 'description', 'nullable', 'default', 'items', 'minItems', 'maxItems', 'enum', 'properties', 'propertyOrdering', 'required', 'minProperties', 'maxProperties', 'minimum', 'maximum', 'minLength', 'maxLength', 'pattern', 'example', 'anyOf']"
and if i define it as:
response_schema=ResponseSchema,
then I get another error:
TypeError: argument of type 'ModelMetaclass' is not iterable
and if i define it as:
response_schema=list[ResponseSchema]
then I get this error:
if items_schema := schema_dict.get("items"):
^^^^^^^^^^^^^^^
AttributeError: type object 'list' has no attribute 'get'
Based on this post: Is it possible to have a schema with no $ref references ? · Issue #889 · pydantic/pydantic · GitHub
My nested pydantic classes pose an issue as they introduce these $refs
keys. Is there a proper way to pass in a nested pydantic schema?