-
-
Notifications
You must be signed in to change notification settings - Fork 258
Fix Gemini schema conversion #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
result[:format] = schema[:format] if schema[:format] | ||
result[:nullable] = schema[:nullable] if schema.key?(:nullable) | ||
result | ||
when 'number' | ||
result = { type: 'NUMBER' } | ||
result[:description] = schema[:description] if schema[:description] | ||
result[:format] = schema[:format] if schema[:format] | ||
result[:nullable] = schema[:nullable] if schema.key?(:nullable) | ||
result | ||
when 'integer' | ||
result = { type: 'INTEGER' } | ||
result[:description] = schema[:description] if schema[:description] | ||
result[:format] = schema[:format] if schema[:format] | ||
result[:nullable] = schema[:nullable] if schema.key?(:nullable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can dry this up if you want, but I decided to keep it all in the same method unless asked otherwise. I thought it best to keep it all in the same method for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
8c7f0bb
to
2418b47
Compare
@crmne - I saw the Rubocop failures. Initially, the overcommit hooks didn't run. I must not have had it set up. That is fixed now. I forced-pushed up a change to satisfy Rubocop. |
2418b47
to
df2c50e
Compare
- preserve descriptions, - distinguish integer/number types
df2c50e
to
519a10c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #355 +/- ##
==========================================
+ Coverage 87.82% 87.85% +0.03%
==========================================
Files 88 88
Lines 3483 3500 +17
Branches 719 733 +14
==========================================
+ Hits 3059 3075 +16
- Misses 424 425 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hi @BrianBorge I actually wanted the code to be a little nicer and add tests, so I went ahead and did it myself so we can release this ASAP. Thanks for starting the PR! |
What this does
Fixes three critical bugs in the Gemini schema conversion that were causing schema information loss:
integer
andnumber
types incorrectly converted to singleNUMBER
typeenum
,format
,nullable
were not preservedThe fix ensures all schema information is properly converted to Gemini format, resulting in more accurate and contextually appropriate structured outputs.
Type of change
Scope check
Quality check
overcommit --install
and all hooks passmodels.json
,aliases.json
)API changes
Related issues
Fixes #354
Before/After Examples
Description Preservation
Before: Generic responses due to ignored descriptions
After: Contextual responses using schema descriptions
Type Distinction
Before: Both integer and number became floats
After: Proper type enforcement
Attribute Preservation
After: All schema attributes now preserved:
description
for all typesenum
for string constraintsformat
for validation hintsnullable
for optional fieldsTechnical Changes
Modified
convert_schema_to_gemini
method inlib/ruby_llm/providers/gemini/chat.rb
:integer
→INTEGER
,number
→NUMBER
format
,nullable
, etc.Testing