Skip to content
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

feat: Add strict_mode option to function_schema and function_tool #60

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Jai0401
Copy link
Contributor

@Jai0401 Jai0401 commented Mar 12, 2025

This PR introduces a strict_mode: bool = True option to @function_tool, allowing optional parameters when set to False. This change enables more flexibility while maintaining strict JSON schema validation by default.

resolves #43

Changes:

  • Added strict_mode parameter to @function_tool and passed it to function_schema and FunctionTool.
  • Updated function_schema.py to respect strict_mode and allow optional parameters when set to False.
  • Added unit tests to verify optional parameters work correctly, including multiple optional params with different types.

Tests:

  • Verified function calls with missing optional parameters behave as expected.
  • Added async tests to validate behavior under different configurations.

@Jai0401
Copy link
Contributor Author

Jai0401 commented Mar 12, 2025

Hey @codefromthecrypt, I used your suggested edge cases (e.g., multiple optional parameters of different types) as inspiration for the test cases in this PR. Thanks for the great examples! Let me know if you have any additional suggestions or feedback.

@Jai0401
Copy link
Contributor Author

Jai0401 commented Mar 12, 2025

Hey @rm-openai, I've implemented the strict_mode option for @function_tool() and added test cases inspired by @codefromthecrypt's suggestions. Could you review the PR when you get a chance? Let me know if any changes are needed. Thanks!

Copy link

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests look easier than I thought. you found a nice place to put them!

Co-authored-by: Adrian Cole <[email protected]>
@Jai0401 Jai0401 marked this pull request as draft March 12, 2025 09:56
@Jai0401 Jai0401 force-pushed the enhancement/function_tool-strict-mode branch from 197abec to 0c33a24 Compare March 12, 2025 10:32
@Jai0401 Jai0401 marked this pull request as ready for review March 12, 2025 10:33
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.

example @function_tool with optional parameters
2 participants