File size: 1,679 Bytes
363cda9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Supervisor Agent that orchestrates sub-agents for recruitment tasks.

For more transparency in langsmith UI disable memory, then run:
----------------------------------------------------------------
| >>> docker compose -f docker/docker-compose.yml up --build.  |
| >>> POSTGRES_HOST=localhost POSTGRES_PORT=5433 langgraph dev |
----------------------------------------------------------------
"""


from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from langgraph.checkpoint.memory import MemorySaver
from dotenv import load_dotenv
from src.prompts import get_prompt

load_dotenv()

# ✅ Correct import via src.agents package (which re-exports from src.agents.db_executor)
from src.agents import (
    db_executor,
    cv_screening_workflow,
    gcalendar_agent,
    gmail_agent,
    voice_judge,
)

SYSTEM_PROMPT = get_prompt(
    template_name="Supervisor",
    latest_version=True,
)

# --------- Subagents as tools ---------
subagents = [
    db_executor,
    cv_screening_workflow,
    gcalendar_agent,
    gmail_agent,
    voice_judge,
]

# --------------- Memory ----------------
# **NOTE:** 
# >>> In UI make sure to use 'thread_id' as a configurable parameter to the agent.invoke() method.
# >>> When willing to use langsmith UI, then you must remove the checkpointer=memory, 
#     otherwise it will not work.
memory = MemorySaver()

# ------------- Supervisor --------------
supervisor_model = ChatOpenAI(
    model="gpt-4o", 
    temperature=0,
)

supervisor_agent = create_agent(
    model=supervisor_model,
    tools=subagents,
    system_prompt=SYSTEM_PROMPT,
    checkpointer=memory,          # outcomment for langsmith UI
)