Skip to content

decorator based tool-use#19

Merged
williamFalcon merged 10 commits into
mainfrom
aniket/tool-decorator
Jul 30, 2025
Merged

decorator based tool-use#19
williamFalcon merged 10 commits into
mainfrom
aniket/tool-decorator

Conversation

@aniketmaurya
Copy link
Copy Markdown
Collaborator

@aniketmaurya aniketmaurya commented Jul 30, 2025

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Users will be able to perform tool-use using a simple decorator based definition.

from litai import LLM, tool

@tool
def get_weather(location: str):
    return f"The weather in {location} is sunny"

llm = LLM(model="openai/gpt-4")
response = llm.chat("What's the weather in Tokyo?", tools=[get_weather])
result = llm.call_tool(response, tools=[get_weather])
print(result)

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@aniketmaurya aniketmaurya changed the title Add tool use as a decorator decorator based tool-use Jul 30, 2025
@aniketmaurya
Copy link
Copy Markdown
Collaborator Author

looking into the failing CI

@williamFalcon
Copy link
Copy Markdown
Contributor

let's use this syntax so we don't need 2 lines of imports...

from litai import LLM, tool

@tool
def get_weather(location: str):
    return f"The weather in {location} is sunny"
...

@williamFalcon williamFalcon merged commit 5ffdad9 into main Jul 30, 2025
29 checks passed
@williamFalcon williamFalcon deleted the aniket/tool-decorator branch July 30, 2025 15:03
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