Skip to content

chore: allow dict input for Tool Schema #67

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

Closed
wants to merge 2 commits into from

Conversation

twishabansal
Copy link
Contributor

No description provided.

@twishabansal twishabansal marked this pull request as ready for review February 27, 2025 09:39
@twishabansal twishabansal requested a review from a team as a code owner February 27, 2025 09:39
Copy link
Contributor

@anubhav756 anubhav756 left a comment

Choose a reason for hiding this comment

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

Curious, is there a specific reason for this?

I guess I was able to pass a dict without any issues.

Did you find any specific issue with that?

@twishabansal
Copy link
Contributor Author

Curious, is there a specific reason for this?

I guess I was able to pass a dict without any issues.

Did you find any specific issue with that?

It is best practice to define the type hints correctly.

@anubhav756
Copy link
Contributor

anubhav756 commented Feb 27, 2025

Curious, is there a specific reason for this?
I guess I was able to pass a dict without any issues.
Did you find any specific issue with that?

It is best practice to define the type hints correctly.

Agree, we should define the type hints correctly. Here's how I'm thinking about this, we encourage users to ideally provide a ToolSchema only, but since we can't enforce users to provide one, we have to put a schema = ToolSchema(**schema) check just in case someone accidentally passes a dict for instance.

I might be mistaken but I somehow still prefer ToolSchema over Union[ToolSchema, dict]. I feel that provides stronger type safety and a clearer API, while dict introduces ambiguity and weakens static analysis (unless we use something like TypedDict to specify the required set of keys 🤔 ).

Thoughts?

CC: @kurtisvg

@twishabansal
Copy link
Contributor Author

Curious, is there a specific reason for this?
I guess I was able to pass a dict without any issues.
Did you find any specific issue with that?

It is best practice to define the type hints correctly.

Agree, we should define the type hints correctly. Here's how I'm thinking about this, we encourage users to ideally provide a ToolSchema only, but since we can't enforce users to provide one, we have to put a schema = ToolSchema(**schema) check just in case someone accidentally passes a dict for instance.

I might be mistaken but I somehow still prefer ToolSchema over Union[ToolSchema, dict]. I feel that provides stronger type safety and a clearer API, while dict introduces ambiguity and weakens static analysis (unless we use something like TypedDict to specify the required set of keys 🤔 ).

Thoughts?

CC: @kurtisvg

This makes sense. Perhaps, this would encourage users to use ToolSchema instead of a dict.

@anubhav756 anubhav756 deleted the twishabansal-patch-3 branch March 4, 2025 04:59
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.

2 participants