Spaces:
Runtime error
Runtime error
Refactor app.py
Browse filesRemoved the Tool class definition and the calculator_tool invocation that was causing issues.
6 unmodified lines7891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071726 unmodified linesfrom Gradio_UI import GradioUI## This is a class dedicated for creating toolsclass Tool:"""A class representing a reusable piece of code (Tool).Attributes:name (str): Name of the tool.description (str): A textual description of what the tool does.func (callable): The function this tool wraps.arguments (list): A list of argument.outputs (str or list): The return type(s) of the wrapped function."""def __init__(self,name: str,description: str,func: callable,arguments: list,outputs: str):self.name = nameself.description = descriptionself.func = funcself.arguments = argumentsself.outputs = outputsdef to_string(self) -> str:"""Return a string representation of the tool,including its name, description, arguments, and outputs."""args_str = ", ".join([f"{arg_name}: {arg_type}" for arg_name, arg_type in self.arguments])return (f"Tool Name: {self.name,}"f"Description: {self.description,}"f"Arguments: {args_str},"f"Outputs: {self.outputs}")def __call__(self, *args, **kwargs):"""Invoke the underlying function (callable) with provided arguments."""return self.func(*args, **kwargs)# Here are tools created the Tool classcalculator_tool = Tool("calculator","Multiply",calculator,[("a", "int"), ("b", "int")],"int",)# Below is an example of a tool that does nothing. Amaze us with your creativity!6 unmodified lines7891011126 unmodified linesfrom Gradio_UI import GradioUI# Below is an example of a tool that does nothing. Amaze us with your creativity!
app.py-60