Skip to content

feat: Enhance FunctionDeclarationSchema to support additionalProperties, oneOf, and optional type #375

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

kartiktoogoated
Copy link

Summary

This PR enhances FunctionDeclarationSchema to:

  • Allow additionalProperties: true for dynamic object properties.
  • Support oneOf to define multiple possible types.
  • Make type optional for cases where it’s not required.

Changes Made:

  • Modified FunctionDeclarationSchema:
    • Added additionalProperties?: boolean | Schema;
    • Added oneOf?: Schema[];
    • Made type an optional field.

Issue Reference

Fixes #313


This change aligns the TypeScript schema with OpenAPI 3.0 specifications and improves flexibility for function calling. Please review and let me know if any adjustments are needed. 🚀

Test Results:

  • ✅ All tests passed successfully (183/183).
  • ⚠️ Deprecation warning for response.functionCall() (unrelated to this change).
  • 🛠 No additional test failures introduced.

🔍 Screenshot of Test Results:

Screenshot 2025-03-07 at 2 51 07 AM

@IvanLH
Copy link
Collaborator

IvanLH commented Mar 6, 2025

Sadly, our API only supports the following fields on the Schema: https://ai.google.dev/api/caching#Schema these fields are not part of them. Appreciate you took the time to work on this though.

@kartiktoogoated
Copy link
Author

Sadly, our API only supports the following fields on the Schema: https://ai.google.dev/api/caching#Schema these fields are not part of them. Appreciate you took the time to work on this though.
Thank you for the feedback! I understand that the API schema has limitations, particularly regarding fields like additionalProperties and oneOf.

I was trying to enhance flexibility for function calling, but I'll respect the schema constraints you mentioned. Could you suggest any specific areas where we can adjust the implementation within the supported schema fields?

If there are any alternatives or workarounds for supporting dynamic properties or multiple types in a way that's compatible with the API, I’d love to know.

Thanks again for your time and guidance – I look forward to aligning this change with the API’s current capabilities!

@kartiktoogoated kartiktoogoated deleted the fix/function-declaration-schema branch March 7, 2025 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FunctionDeclarationSchema is too terse and needs to support valid additional JSONSchema definitions
2 participants