Building Agents
This system was designed to be extensible allowing you to
design new agents to be utilized by orchestrator or other tool agents.
This is achieved using recap.agents.base.BaseAgent class.
Here is an example:
from recap.agents.base import BaseAgent
from pydantic import BaseModel, Field
class ExampleInputs(BaseModel):
query: str = Field(
description="Natural language query that will be parsed to filter and search the Meta-Review Dataset"
)
another_param: int = Field(description="This is another required example parameter")
class NewAgent
description = "Description of agent to be used by orchestrator. Describe inputs, expected outputs, when to use, etc.
args_schema = ExampleInputs
name = "new_agent"
def __init__(self, model, tools: list=None) -> None:
super().__init__(model=model, tools=tools)
...
# Invoke method must match args_schema
def invoke(self, query: str, another_param) -> str:
...
# Do something
...
return json_string
To implement base image class there are 4 requirements:
name: This is used to identify the tool on frontend and load assocatied prompt.md
description: A description of the agent used as tool description for orchestrator agent
args_schema: Pydantic BaseModel with the inputs to the tool call
invoke: Python function used as tool for .run_as_tool(). The inputs must match schema defintion and it is expected to return a json string.
Once you have your agent created you can run your agent directly:
# Create model for agent to use if necessary
from langchain_ollama import ChatOllama
model = ChatOllama(
model="gemma4:e4b",
temperature=0,
num_ctx=(2048 * 4),
base_url=os.getenv("OLLAMA_BASE_URL"),
)
new_agent = NewAgent(model=model)
new_agent.invoke("This is my user query", 5)
Or use at as tool for another agent:
# Create model for agent to use if necessary
from langchain_ollama import ChatOllama
from orchestrator.a
from recap.agents import Orchestrator
model = ChatOllama(
model="gemma4:e4b",
temperature=0,
num_ctx=(2048 * 4),
base_url=os.getenv("OLLAMA_BASE_URL"),
)
new_agent = NewAgent(model=model)
orchestrator = Orchestrator(model=model, tools=[new_agent.as_tool()])