-
Notifications
You must be signed in to change notification settings - Fork 30
Remove unsupported formats from schemas in IChatClient implementation #63
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
WalkthroughThe update introduces a schema transformation cache to modify function parameter schemas when converting AIFunction instances to FunctionDeclaration objects. The transformation relocates unsupported "format" properties into the "description" field, except for "enum" or "date-time" formats, ensuring compatibility with Gemini restrictions. The cache and transformation logic are implemented as a new private static property. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/GenerativeAI.Microsoft/Extensions/MicrosoftExtensions.cs (1)
618-621: Consider using a more structured format for the description field.When appending format information to an existing description, consider using a more structured format instead of just a newline separator. This would make the format information more distinguishable.
- schemaObj["description"] = schemaObj["description"] is { } descriptionNode && descriptionNode.GetValueKind() is JsonValueKind.String ? - $"{descriptionNode.GetValue<string>()}\n{formatNode}" : - formatNode.ToString(); + schemaObj["description"] = schemaObj["description"] is { } descriptionNode && descriptionNode.GetValueKind() is JsonValueKind.String ? + $"{descriptionNode.GetValue<string>()}\nFormat: {formatNode}" : + $"Format: {formatNode}";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/GenerativeAI.Microsoft/Extensions/MicrosoftExtensions.cs(2 hunks)
🔇 Additional comments (2)
src/GenerativeAI.Microsoft/Extensions/MicrosoftExtensions.cs (2)
47-54: LGTM! Schema transformation correctly applied before parsing.The change appropriately transforms the function schema through the cache before parsing, ensuring Gemini compatibility.
602-625: Well-implemented schema transformation for Gemini compatibility.The transformation logic correctly identifies and relocates unsupported format properties while preserving "enum" and "date-time" formats. The implementation follows a clean pattern using the AIJsonSchemaTransformCache.
|
Thank you for support. I really appreciate it! |
Summary by CodeRabbit
Bug Fixes
New Features