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

Update of tools.py to nicely manage numbers instead of concat strings #443

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions examples/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ def add_two_numbers(a: int, b: int) -> int:
Returns:
int: The sum of the two numbers
"""
return a + b

# The cast is necessary as returned tool call arguments don't always conform exactly to schema
# E.g. this would prevent "what is 30 + 12" to produce '3012' instead of 42
return int(a) + int(b)


def subtract_two_numbers(a: int, b: int) -> int:
"""
Subtract two numbers
"""
return a - b

# The cast is necessary as returned tool call arguments don't always conform exactly to schema
return int(a) - int(b)


# Tools can still be manually defined and passed into chat
Expand Down