-
Notifications
You must be signed in to change notification settings - Fork 715
Open
Labels
Description
Is your feature request related to a problem? Please describe.
Currently, to use the @tool decorator in Upsonic, users must create a class that inherits from Toolkit and implement the decorated methods within that class. This creates unnecessary boilerplate code for simple use cases where users just want to create a single tool function without the overhead of class creation.
For example, this simple case currently doesn't work:
from upsonic import Agent, Task
from upsonic.tools.decorators import tool
@tool(description="Fetch the stock of a product")
def fetch_warehouse_stock(product_name: str):
return f"The stock of {product_name} is 100"
def main():
web_agent = Agent(
"Warehouse Stock Agent",
model="gpt-4o-mini", # type: ignore
)
task = Task(
description="Who are you?",
tools=[fetch_warehouse_stock],
)
result = web_agent.print_do(task)
print(result)
if __name__ == "__main__":
main()Describe the solution you'd like
Enable support for standalone functions decorated with @tool to be used directly in the Task.tools list without requiring a Toolkit wrapper class. The system should automatically handle the conversion of decorated functions to the appropriate format expected by the Task validation.