pipelines.agent.base
Agent
def Agent(
llm, agent_type:str='tool_calling', max_steps:int=20, tools:dict={}, kwargs:VAR_KEYWORD
):
Pipeline for agent-based task execution using smolagents. Extra kwargs are supplied directly to agent instantation.
Args: llm (LLM): An onprem LLM instance to use for agent reasoning agent_type (str, optional): Type of agent to use (‘tool_calling’ or ‘code’) max_steps (int, optional): Maximum number of steps the agent can take tools (dict, optional): a dictionary of tools for agent to use
Agent.add_tool
def add_tool(
name:str, tool_instance, # tool_instance is SA_Tool
):
Add a tool to the agent.
Args: name (str): The name of the tool tool_instance (Tool): The tool instance
Agent.add_function_tool
def add_function_tool(
func:Callable
):
Create a tool from a function and its documentation.
Args: func (Callable): The function to wrap as a tool name (str, optional): The name of the tool (defaults to function name) description (str, optional): The description of the tool (defaults to function docstring)
Returns: Tool: The created tool
Agent.add_vectorstore_tool
def add_vectorstore_tool(
name:str, store:VectorStore, description:str='Search a vector database for relevant information'
):
Create a tool from a VectorStore instance.
Args: name (str): The name of the vector store tool store (VectorStore): The vector store instance description (str, optional): The description of the vector store
Returns: Tool: The created tool
Agent.add_websearch_tool
def add_websearch_tool(
):
Create a tool to perform Web searches.
Returns: Tool: The created tool
Agent.add_webview_tool
def add_webview_tool(
):
Create a tool to visit Web page
Returns: Tool: The created tool
Agent.add_python_tool
def add_python_tool(
):
Create a tool to access Python interpreter
Returns: Tool: The created tool
Agent.add_mcp_tool
def add_mcp_tool(
url:str
):
Add tool to access MCP server
Agent.run
def run(
task:str
)->str:
Run the agent on a given task.
Args: task (str): The task description
Returns: str: The agent’s response