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

Handle optional func args in tool calls when set to None #1211

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

jayeshp19
Copy link
Collaborator

This PR fixes ValueError when optional function args are set to None

Related issues:
#1185
#1208

Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: 65d0c03

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
livekit-plugins-openai Patch
livekit-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

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

nice

@davidzhao
Copy link
Member

@jayeshp19 can you add a changeset?

@jayeshp19
Copy link
Collaborator Author

It's already added, not sure why It's not detecting..

@jayeshp19
Copy link
Collaborator Author

retried and it detected

@jayeshp19 jayeshp19 merged commit 33fdc53 into main Dec 12, 2024
14 of 16 checks passed
@jayeshp19 jayeshp19 deleted the optional-func-args branch December 12, 2024 04:45
@github-actions github-actions bot mentioned this pull request Dec 12, 2024
@@ -64,13 +64,19 @@ def create_ai_function_info(
inner_type = typing.get_args(arg_info.type)[0]

Choose a reason for hiding this comment

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

fetching the first argument does not work for type definitions like Union[None, str] or None | str, where the None is passed as the first argument. The validation should verify if arguments lengths is between 1 and 2 and then take the first matched non-None-type argument.

@jayeshp19 jayeshp19 restored the optional-func-args branch December 12, 2024 11:38
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.

3 participants