You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At Pampa, we're currently testing a new framework and need to implement a StructuredTool class, similar to LangChain's StructuredTool. This class would encapsulate any function, allowing it to be used seamlessly by an agent while maintaining a clear input/output schema (BaseModel).
Our goal is to use this to wrap the tool definitions for an API. By defining clear input and output schemas, we’re creating a structured and standardized approach for interacting with the API. You can see this in the following example, we have a generic function and we have available the schemas.
deftool_util(client, tool_id):
# Wrapper function to executedeftool_wrapper(*args, **kwargs):
response=client.tools.execute(
tool_name=tool_id,
inputs=kwargs,
)
returnresponse# Get tool definitiontool_def=client.tools.get(tool_id=tool_id)
# Create and return the structured toolreturnStructuredTool.from_function(
func=tool_wrapper,
name=tool_name,
description=description,
args_schema=args_schema
)
Currently, I am exploring the implementation by inheriting from the Tool class. Do you have any recommendations or best practices for implementing this functionality?
Thanks,
The text was updated successfully, but these errors were encountered:
Hi @lgesuellip, you don't need to inherit from Tool, especially as it's currently private and it's signature may change.
As part of #110 I'm intending to expose Tool as a reusable wrapper for tools, but until then, I think you can just create functions and reuse them, e.g.
Hi Team,
At Pampa, we're currently testing a new framework and need to implement a StructuredTool class, similar to LangChain's StructuredTool. This class would encapsulate any function, allowing it to be used seamlessly by an agent while maintaining a clear input/output schema (BaseModel).
Our goal is to use this to wrap the tool definitions for an API. By defining clear input and output schemas, we’re creating a structured and standardized approach for interacting with the API. You can see this in the following example, we have a generic function and we have available the schemas.
Currently, I am exploring the implementation by inheriting from the Tool class. Do you have any recommendations or best practices for implementing this functionality?
Thanks,
The text was updated successfully, but these errors were encountered: