GoogleCloudPlatform / vertex-ai-samples

Notebooks, code samples, sample apps, and other resources that demonstrate how to use, develop and manage machine learning and generative AI workflows using Google Cloud Vertex AI.
https://cloud.google.com/vertex-ai
Apache License 2.0
104 stars 25 forks source link

501 Unable to submit request because one or more response schemas specified unsupported field min_length #3618

Closed mihalaches closed 1 month ago

mihalaches commented 1 month ago

Expected Behavior

Until this morning this worked. I have this schema and I'm using : vertexai = "^1.69.0" google-cloud-aiplatform = "^1.69.0" And for some reason I receive this error:

501 Unable to submit request because one or more response schemas specified unsupported field min_length. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output
Request Method: | GET -- | -- http://localhost:8651/test 5.0.3 MethodNotImplemented 501 Unable to submit request because one or more response schemas specified unsupported field min_length. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output This is the schema: INVOICE_PRODUCTS_SCHEMA = { "type": "array", "items": { "type": "object", "properties": { "product_code": { "type": "string", "minLength": 1, "maxLength": 50, "pattern": "^[a-zA-Z0-9-_.]+$", "description": "A unique identifier for the product. This may include letters, numbers, and specific symbols (hyphen, underscore, period)." }, "product_description": { "type": "string", "minLength": 5, "maxLength": 500, "pattern": "^[\\w\\s,.-]+$", "description": "A detailed description of the product, typically including its name, type, and key features." }, "external_product_code": { "type": "string", "minLength": 0, "maxLength": 50, "pattern": "^[\\w\\s-_.]*$", "description": "An optional external code used to identify the product in systems outside your organization." }, "unit_and_quantity_detected": { "type": "string", "minLength": 1, "maxLength": 100, "pattern": "^[\\w\\s,()]+(\\s\\d+)?$", "description": "The detected unit and quantity of the product, which may include text descriptions (e.g., 'boxes', 'packs') and quantities." }, "customer_unit_and_quantity_detected": { "type": "string", "minLength": 1, "maxLength": 100, "pattern": "^[\\w\\s,()]+(\\s\\d+)?$", "description": "The customer-specific unit and quantity detected, similar to the previous field but tailored to the customer's terminology.", "example": ['20 for 40 Stuck', 'pro 10 stk', '20uz', 'Dis a 50 Stk', '60 Stuck/Dispenser', '20 Stuck/Dispenser', '30 Stuck', 'a 50 ST', 'Pack a 10 Stk', 'only a integer'] }, "product_quantity": { "type": "integer", "minimum": 1, "description": "The actual quantity of the product being purchased, which must be a positive integer." }, "unit_price": { "type": "number", "minimum": 0.01, "description": "The price per unit of the product, expressed in the appropriate currency format with two decimal places." } }, "required": ["product_code","product_description","external_product_code","unit_and_quantity_detected","customer_unit_and_quantity_detected","product_quantity","unit_price"], }, }

This was working until 2 hrs ago or something like that, And in the documentation I can see that we can use this schema: https://cloud.google.com/vertex-ai/docs/reference/rest/v1/Schema

Specifications

gericdong commented 1 month ago

@mihalaches: can you please check if it's still happening to you? Thanks.

RPripAvenir commented 1 month ago

@gericdong There is a similar issue happening right now (since 30 min ago) on the "pattern" field of the response schema, with error: 'Arguments: (InvalidArgument('Unable to submit request because one or more response schemas specified unsupported field pattern. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output'),)'

However, this was all working perfectly fine and now it seems to crash it. VertexAI works if I remove the 'pattern' field, but can you please double-check and see what the cause behind this is? Thanks

response_schema = { "type": "object", "properties": { value_researched : { "type": "object", "properties": { "value": { "type": "string", "description": "Value we are looking for. Nothing should be invented : values should be found in the provided documents, infered from provided documents.", "default": "" }, "sourceQuote": { "type": "string", "description": "Grounded text, extracted from the source document you took the value from. \ It should be as much as possible an exact extract from the document, used to determine the value. \ The source should be self sufficient and not require any additional context. \ Nothing should be invented, if the source can not be found, that should be stated clearly.", "default": "" }, "document": { "type": "string", "description": "Exact file name (or file names, if multiple ones where used) of the file(s) you extracted the information from.", "default": "AI was not able to identify a document." } }, "required": ["value", "sourceQuote"] } }, "required": [value_researched] }

md2eoseo commented 1 month ago

I'm getting similar error when I send response_schema as document written.

I'm using python, so I'm not sure document that I linked here is right for me. If I'm wrong please guide me with right document. Thank you.

Error messages: google-cloud-aiplatform==1.60.0

{"utils": {"error": "Protocol message Schema has no \"minLength\" field."}}}

google-cloud-aiplatform==1.70.0

{"utils": {"error": "400 Unable to submit request because one or more response schemas specified unsupported field min_length. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output"}}}
gericdong commented 1 month ago

Thanks for reporting this issue. It's a duplicate of https://github.com/googleapis/python-aiplatform/issues/4510. I am closing this issue here.