This project provides a flexible and modular way to build AI agents using LangGraph. It allows you to define agent behaviors and configurations through YAML files, making it easy to modify and extend agent capabilities without changing the core code.
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Create a
.envfile with your configuration (see Configuration section)
Create a .env file in the project root with the following variables:
OPENAI_API_KEY=your_api_key_here
The project uses YAML files to define agent behaviors and workflows. Here's how to configure your agents:
subgraphs:
my_agent:
prompt: "MY_AGENT_PROMPT" # Name of the prompt variable
tools: # Tools available to the agent
- tool1
- tool2
- tool3
route_function: "default_route_actor" # Routing function to use
agent_name: "actor" # Agent implementation name
next: "END" # Next node in the graphrouter:
type: "function"
function: "router_node"
routes:
agent1: "agent1_graph"
agent2: "agent2_graph"
agent3: "agent3_graph"-
Add Prompts
- Add your prompt in
/tools/agent/prompts.py - Use a descriptive variable name (e.g.,
MY_AGENT_PROMPT)
- Add your prompt in
-
Create Tools
- Create a new Python file in
/tools/agent/tools/(e.g.,my_tool.py) - Use the
@tooldecorator and provide a description:
@tool def my_tool(): """Description of what the tool does.""" # Tool implementation
- Create a new Python file in
-
Register Tools
- Add your tool to
/tools/agent/tools/__init__.py:
from .my_tool import my_tool __all__ = [ # ... existing tools ... "my_tool" ]
- Add your tool to
-
Register Prompts
- Register the prompt in
/tools/agent/prompts/__init__.py:
from .prompts import MY_AGENT_PROMPT __all__ = [ # ... existing prompts ... "MY_AGENT_PROMPT" ]
- Register the prompt in
- Route names in the YAML must match exactly with the prompt responses
- Each subgraph must specify a
nextnode orEND - Tool names in the YAML must match the registered tool names
- The router configuration must be updated when adding new subgraphs
- The error handling expects an other agent in case the router prompt doesnt return a existing agent
- Integrate with other models as well as non API implementations (e.g.: ollama)
- Add option for creating graph image