Publish 2.0.0 - #26
Conversation
…eadme test(llm-tool): add complex structured tool test
Co-Authored-By: greg@fireflies.ai <greg.teixeira123@gmail.com>
Add support for inferring JSON Schema properties from class-validator decorators: - ArrayMaxSize -> maxItems - ArrayMinSize -> minItems - Max -> maximum (for numbers) - Min -> minimum (for numbers) - IsInt -> type: integer - MinLength -> minLength (for strings) - MaxLength -> maxLength (for strings) - IsUrl -> format: uri - IsPositive -> minimum: 1 Also adds support for manually specifying these properties via ToolProp options. Co-Authored-By: greg@fireflies.ai <greg.teixeira123@gmail.com>
- Add assertion that format is undefined in structured output test - Rename test 11 to 'ToolProp validation constraint options' for clarity - Fix class-validator integration to not override explicit ToolProp options - Fix getTargetValidationMetadatas call to pass empty string instead of undefined - Bump version from 1.0.3 to 1.1.0 Co-Authored-By: greg@fireflies.ai <greg.teixeira123@gmail.com>
Co-Authored-By: greg@fireflies.ai <greg.teixeira123@gmail.com>
- Add Class-Validator Integration section to README - Document supported decorators and their JSON Schema mappings - Add examples for using class-validator with ToolProp - Bump version to 2.0.0 Co-Authored-By: greg@fireflies.ai <greg.teixeira123@gmail.com>
- ArrayUnique -> uniqueItems: true - ArrayNotEmpty -> minItems: 1 - IsEmail -> format: 'email' Updated README with new decorators documentation. Co-Authored-By: greg@fireflies.ai <greg.teixeira123@gmail.com>
…e-support-with-string-format-date
Co-Authored-By: greg@fireflies.ai <greg.teixeira123@gmail.com>
…og-md-for-schema-forge-v2-0-0
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
Comment |
🔍 PR Complexity Assessment🟡 Risk Score: 4/10
📝 SummaryThis PR publishes version 2.0.0 of the @firefliesai/schema-forge library, adding Date type support with date-time format, class-validator decorator integration for automatic JSON Schema constraint inference, and new validation constraint options in the ToolProp decorator. 📊 Lines Analysis
💡 RecommendationReview the class-validator integration logic in class-validator-integration.ts and ensure the decorator property inference precedence (explicit ToolProp options over class-validator inferred values) works correctly. Verify the Date type handling doesn't break existing consumers. The changes are well-tested but given the major version bump, consider impact on downstream services. This assessment is automated and should be used as a guide. Please use your judgment when reviewing. |
There was a problem hiding this comment.
🟡 prepareForOpenAIStructuredOutput doesn't strip constraints for 'integer' type
When a property has type: 'integer' (set via @IsInt() class-validator decorator or explicit type: 'integer' in @ToolProp), the minimum, maximum, and multipleOf properties won't be stripped when converting to OpenAI structured output format.
Click to expand
Issue Details
The prepareForOpenAIStructuredOutput function in utils.ts only checks for type === 'number' when deciding whether to strip unsupported numeric constraints:
} else if (
newObj.type === 'number' ||
(Array.isArray(newObj.type) && newObj.type.includes('number'))
) {
// Remove unsupported number properties
['minimum', 'maximum', 'multipleOf'].forEach((prop) => {
if (prop in newObj) delete newObj[prop];
});
}However, the PR introduces support for type: 'integer' via:
@IsInt()class-validator decorator (class-validator-integration.ts:152)- Explicit
type: 'integer'in@ToolPropoptions (types.ts:40)
Impact
When using OpenAI structured output with integer types that have constraints, the schema will contain minimum/maximum properties that OpenAI's structured output mode doesn't support, potentially causing API errors or unexpected behavior.
Expected vs Actual
- Expected:
minimum,maximum,multipleOfshould be stripped for bothnumberandintegertypes whenforStructuredOutput: true - Actual: These constraints are only stripped for
numbertype, notinteger
(Refers to lines 93-100)
Recommendation: Add a check for 'integer' type alongside 'number':
} else if (
newObj.type === 'number' ||
newObj.type === 'integer' ||
(Array.isArray(newObj.type) && (newObj.type.includes('number') || newObj.type.includes('integer')))
) {Was this helpful? React with 👍 or 👎 to provide feedback.
What does this PR do?