-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
Describe the bug
Structured responses are failing (at least when using OpenAIResponses provider) with schemas that have nested objects
{
"error": {
"message": "Invalid schema for response_format 'ProductGenerationSchema': In context=('properties', 'model_attributes'), 'required' is required to be supplied and to be an array including every key in properties. Missing 'package_weight_minor'.",
"type": "invalid_request_error",
"param": "text.format.schema",
"code": "invalid_json_schema"
}
}
The Neuron AI version you are using:
- Version 2.3.4
Additional context
Main Schema Object
<?php
namespace App\Domain\AI\Neuron\Schemas\Products;
use NeuronAI\StructuredOutput\SchemaProperty;
use NeuronAI\StructuredOutput\Validation\Rules\Length;
class ProductGenerationSchema
{
#[SchemaProperty(description: 'Product name', required: true)]
#[Length(min: 5, max: 200)]
public string $name;
#[SchemaProperty(description: 'The materials used in the product', required: false)]
#[Length(min: 3, max: 200)]
public ?string $materials;
#[SchemaProperty(description: 'Detailed description of the product suitable for marketplace listings', required: true)]
#[Length(min: 200, max: 500)]
public string $description;
#[SchemaProperty(description: 'Core attributes and specifications of the product model', required: true)]
public ProductModelAttributesSchema $model_attributes;
}
Nested Schema Object
<?php
namespace App\Domain\AI\Neuron\Schemas\Products;
use NeuronAI\StructuredOutput\SchemaProperty;
use NeuronAI\StructuredOutput\Validation\Rules\GreaterThanEqual;
use NeuronAI\StructuredOutput\Validation\Rules\NotBlank;
class ProductModelAttributesSchema
{
#[SchemaProperty(description: 'Marketplace-specific optimized titles', required: true)]
public MarketplaceTitlesSchema $marketplace_titles;
#[SchemaProperty(description: 'Fixed selling price for the product (it should be a a number in the format of 1.00, two decimal places even if zero)', required: true)]
#[NotBlank(allowNull: false)]
public float $fixed_price;
#[SchemaProperty(description: 'Buy it now price for auction listings', required: true)]
public float $buy_it_now_price;
#[SchemaProperty(description: 'Starting price for auction-style listings', required: true)]
public ?float $start_price;
#[SchemaProperty(description: 'Manufacturer suggested retail price', required: true)]
public float $msrp;
#[SchemaProperty(description: 'Major weight value of the packaged product in whole numbers (not the product itself)', required: false)]
public ?float $package_weight_value;
#[SchemaProperty(description: 'Minor weight value of the packaged product in whole numbers (not the product itself)', required: false)]
public ?float $package_weight_minor;
#[SchemaProperty(description: 'Length of the product package (not the product itself)', required: false)]
public ?float $package_length;
#[SchemaProperty(description: 'Width of the product package (not the product itself)', required: false)]
public ?float $package_width;
#[SchemaProperty(description: 'Height of the product package (not the product itself)', required: false)]
public ?float $package_height;
#[SchemaProperty(description: 'Unit of measurement for package weight (default: lb)', required: false)]
public ?string $package_weight_unit;
#[SchemaProperty(description: 'Unit of measurement for package dimensions (default: in)', required: false)]
public ?string $package_dimensions_unit;
#[SchemaProperty(description: 'Whether the product listing should be private (default: false)', required: false)]
public ?bool $private;
#[SchemaProperty(description: 'Available quantity for sale (default: 1)', required: true)]
#[GreaterThanEqual(reference: 1)]
public ?int $quantity;
#[SchemaProperty(description: 'Currency code for pricing (default: USD)', required: false)]
public ?string $currency;
#[SchemaProperty(description: 'Country code for the product location (default: US)', required: false)]
public ?string $country;
#[SchemaProperty(description: 'Number of items in a lot (default: 1)', required: false)]
public ?int $lot_size;
#[SchemaProperty(description: 'Product manufacturer or brand name', required: false)]
public ?string $manufacturer;
#[SchemaProperty(description: 'Manufacturer model number', required: false)]
public ?string $model_number;
}
Generated JSON schema
[
"type" => "json_schema"
"strict" => true
"name" => "ProductGenerationSchema"
"schema" => array:4 [
"type" => "object"
"properties" => array:4 [
"name" => array:2 [
"description" => "Product name"
"type" => "string"
]
"materials" => array:2 [
"description" => "The materials used in the product"
"type" => array:2 [
0 => "string"
1 => "null"
]
]
"description" => array:2 [
"description" => "Detailed description of the product suitable for marketplace listings"
"type" => "string"
]
"model_attributes" => array:5 [
"description" => "Core attributes and specifications of the product model"
"type" => "object"
"properties" => array:19 [
"marketplace_titles" => array:5 [
"description" => "Marketplace-specific optimized titles"
"type" => "object"
"properties" => array:1 [
"eBay" => array:2 [
"description" => "Optimized title for eBay (max 80 characters)"
"type" => "string"
]
]
"additionalProperties" => false
"required" => array:1 [
0 => "eBay"
]
]
"fixed_price" => array:2 [
"description" => "Fixed selling price for the product (it should be a a number in the format of 1.00, two decimal places even if zero)"
"type" => "number"
]
"buy_it_now_price" => array:2 [
"description" => "Buy it now price for auction listings"
"type" => "number"
]
"start_price" => array:2 [
"description" => "Starting price for auction-style listings"
"type" => array:2 [
0 => "number"
1 => "null"
]
]
"msrp" => array:2 [
"description" => "Manufacturer suggested retail price"
"type" => "number"
]
"package_weight_value" => array:2 [
"description" => "Major weight value of the packaged product in whole numbers (not the product itself)"
"type" => array:2 [
0 => "number"
1 => "null"
]
]
"package_weight_minor" => array:2 [
"description" => "Minor weight value of the packaged product in whole numbers (not the product itself)"
"type" => array:2 [
0 => "number"
1 => "null"
]
]
"package_length" => array:2 [
"description" => "Length of the product package (not the product itself)"
"type" => array:2 [
0 => "number"
1 => "null"
]
]
"package_width" => array:2 [
"description" => "Width of the product package (not the product itself)"
"type" => array:2 [
0 => "number"
1 => "null"
]
]
"package_height" => array:2 [
"description" => "Height of the product package (not the product itself)"
"type" => array:2 [
0 => "number"
1 => "null"
]
]
"package_weight_unit" => array:2 [
"description" => "Unit of measurement for package weight (default: lb)"
"type" => array:2 [
0 => "string"
1 => "null"
]
]
"package_dimensions_unit" => array:2 [
"description" => "Unit of measurement for package dimensions (default: in)"
"type" => array:2 [
0 => "string"
1 => "null"
]
]
"private" => array:2 [
"description" => "Whether the product listing should be private (default: false)"
"type" => array:2 [
0 => "boolean"
1 => "null"
]
]
"quantity" => array:2 [
"description" => "Available quantity for sale (default: 1)"
"type" => array:2 [
0 => "integer"
1 => "null"
]
]
"currency" => array:2 [
"description" => "Currency code for pricing (default: USD)"
"type" => array:2 [
0 => "string"
1 => "null"
]
]
"country" => array:2 [
"description" => "Country code for the product location (default: US)"
"type" => array:2 [
0 => "string"
1 => "null"
]
]
"lot_size" => array:2 [
"description" => "Number of items in a lot (default: 1)"
"type" => array:2 [
0 => "integer"
1 => "null"
]
]
"manufacturer" => array:2 [
"description" => "Product manufacturer or brand name"
"type" => array:2 [
0 => "string"
1 => "null"
]
]
"model_number" => array:2 [
"description" => "Manufacturer model number"
"type" => array:2 [
0 => "string"
1 => "null"
]
]
]
"additionalProperties" => false
"required" => array:7 [
0 => "marketplace_titles"
1 => "fixed_price"
2 => "buy_it_now_price"
3 => "start_price"
4 => "msrp"
5 => "package_weight_value"
6 => "quantity"
]
]
]
"additionalProperties" => false
"required" => array:3 [
0 => "name"
1 => "description"
2 => "model_attributes"
]
]
]
]
Metadata
Metadata
Assignees
Labels
No labels