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

Added type hints existence validation to make error message when miss… #5211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ilyasst
Copy link

@ilyasst ilyasst commented Jan 27, 2025

Change: Added type hints existence validation to make error message when missing more explicit.

Why are these changes needed?

The FunctionTool class requires type hints on function parameters to generate proper schemas for input validation and LLM interaction. Previously, when type hints were missing, the error message was not explicit enough to help users understand the requirement. This change adds explicit validation to check for type hints existence and provides a clearer error message when they are missing.

I spent sometime trying to figure out the vagye error message, found another person reporting this issue: #5142

Related issue number

Not an issue, but a discussion here: #5142

Checks

@@ -1,6 +1,7 @@
import asyncio
import functools
import warnings
import typing
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use from typing import get_type_hints?

# Validate type hints exist
hints = typing.get_type_hints(func)
if not hints:
raise TypeError(f"Function '{func.__name__}' has no type hints. All parameters must be annotated.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

The issue you referenced, the function argument has type hint. Can this catch the same error?

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