Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/recruiter/langgraph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": ["."],
"graphs": {
"research": "./recruiter_agent.py:create_agent"
},
"env": ".env"
}
73 changes: 73 additions & 0 deletions examples/recruiter/recruiter_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import os

from exa_py import Exa

from deepagents import create_deep_agent, SubAgent

exa = Exa(api_key = os.environ['EXA_API_KEY'])






# Search tool to use to do research
def linkedin_search(
query: str,
num_results: int = 5,
):
"""Run a linkedin search"""
return exa.search_and_contents(
query,
text=True,
num_results=num_results,
type="auto",
category="linkedin profile"
)


sub_research_prompt = """You are a dedicated researcher. Your job is to source candidates for the role described.

Write down any new candidates in candidates.json

only include candidates if they look good

Respond to the user saying how many candidates you wrote down."""

research_sub_agent = {
"name": "research-agent",
"description": "Used to kick off in depth searches. Give it a brief to research.",
"prompt": sub_research_prompt,
"tools": ["linkedin_search"]
}

# Prompt prefix to steer the agent to be an expert researcher
research_instructions = """You are an expert sourcer

Use the research agent to run specific searches. It will write its results to candidates.json"""

# Create the agent
agent = create_deep_agent(
[linkedin_search],
research_instructions,
subagents=[research_sub_agent],
).with_config({"recursion_limit": 1000})

from pydantic import BaseModel

class Config(BaseModel):
instructions: str = research_instructions
subagents: list[SubAgent] = [research_sub_agent]

from langchain_core.runnables import RunnableConfig

def create_agent(config: RunnableConfig):
config = config.get('configurable', {})
config_fields = {k: v for k,v in config.items() if k in ['instructions', 'subagents']}
config = Config(**config_fields)
return create_deep_agent(
[linkedin_search],
config.instructions,
subagents=config.subagents,
config_schema=Config,
).with_config({"recursion_limit": 1000})
3 changes: 3 additions & 0 deletions examples/recruiter/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
deepagents
langgraph-cli[inmem]
exa-py
2 changes: 1 addition & 1 deletion src/deepagents/sub_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from deepagents.state import DeepAgentState
from langgraph.prebuilt import create_react_agent
from langchain_core.tools import BaseTool
from typing import TypedDict
from typing_extensions import TypedDict
from langchain_core.tools import tool, InjectedToolCallId
from langchain_core.messages import ToolMessage
from typing import Annotated, NotRequired
Expand Down