File tree Expand file tree Collapse file tree 9 files changed +67
-6
lines changed
template_langgraph/agents Expand file tree Collapse file tree 9 files changed +67
-6
lines changed Original file line number Diff line number Diff line change 13
13
args : [ --fix ]
14
14
- id : ruff-format
15
15
types_or : [ python, pyi ]
16
- exclude : ' generated/.*|artifacts/.*'
16
+ exclude : ' generated/.*|artifacts/.*|.*\.json$ '
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ uv run python -m template_langgraph.tasks.run_issue_formatter_agent
43
43
44
44
- [ Build a custom workflow] ( https://langchain-ai.github.io/langgraph/concepts/why-langgraph/ )
45
45
- [ LangGraphの(LLMなし)Human-in-the-loopを試してみた] ( https://qiita.com/te_yama/items/db38201af60dec76384d )
46
+ - [ 🤖 LangGraph Multi-Agent Supervisor] ( https://github.com/langchain-ai/langgraph-supervisor-py )
47
+ - [ Software Design誌「実践LLMアプリケーション開発」第24回サンプルコード] ( https://github.com/mahm/softwaredesign-llm-application/tree/main/24 )
46
48
47
49
### Sample Codes
48
50
Original file line number Diff line number Diff line change 3
3
" ."
4
4
],
5
5
"graphs" : {
6
+ "supervisor_agent" : " template_langgraph.agents.supervisor_agent:graph" ,
6
7
"chat_with_tools_agent" : " template_langgraph.agents.chat_with_tools_agent.agent:graph" ,
7
8
"kabuto_helpdesk_agent" : " template_langgraph.agents.kabuto_helpdesk_agent:graph" ,
8
9
"issue_formatter_agent" : " template_langgraph.agents.issue_formatter_agent.agent:graph" ,
9
10
"task_decomposer_agent" : " template_langgraph.agents.task_decomposer_agent.agent:graph"
10
11
},
11
12
"env" : " .env"
12
- }
13
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies = [
10
10
" langchain-openai>=0.3.28" ,
11
11
" langchain-text-splitters>=0.3.9" ,
12
12
" langgraph>=0.6.2" ,
13
+ " langgraph-supervisor>=0.0.29" ,
13
14
" openai>=1.98.0" ,
14
15
" pydantic-settings>=2.9.1" ,
15
16
" pypdf>=5.9.0" ,
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ def create_graph(self):
76
76
workflow .add_edge ("finalize" , END )
77
77
78
78
# Compile the graph
79
- return workflow .compile ()
79
+ return workflow .compile (
80
+ name = ChatWithToolsAgent .__name__ ,
81
+ )
80
82
81
83
def initialize (self , state : AgentState ) -> AgentState :
82
84
"""Initialize the agent with the given state."""
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ def create_graph(self):
24
24
workflow .add_edge ("analyze" , END )
25
25
26
26
# Compile the graph
27
- return workflow .compile ()
27
+ return workflow .compile (
28
+ name = IssueFormatterAgent .__name__ ,
29
+ )
28
30
29
31
def analyze (self , state : AgentState ) -> AgentState :
30
32
"""Analyze the issue and extract relevant information."""
Original file line number Diff line number Diff line change
1
+ from langgraph_supervisor import create_supervisor
2
+
3
+ from template_langgraph .agents .chat_with_tools_agent .agent import graph as chat_with_tools_agent_graph
4
+ from template_langgraph .agents .issue_formatter_agent .agent import graph as issue_formatter_agent_graph
5
+ from template_langgraph .agents .task_decomposer_agent .agent import graph as task_decomposer_agent_graph
6
+ from template_langgraph .llms .azure_openais import AzureOpenAiWrapper
7
+ from template_langgraph .loggers import get_logger
8
+
9
+ logger = get_logger (__name__ )
10
+
11
+ PROMPT = """
12
+ KABUTO に関する質問に答えるために、必要な情報を収集し適切な回答を提供します。
13
+ - 過去の FAQ やドキュメントを参照して、質問に対する答えを見つける必要がある場合は Chat with Tools Agent を使用します。
14
+ - 質問の内容を整理し、適切な形式で回答するために Issue Formatter Agent を使用します。
15
+ - 質問が複雑であったり追加の情報が必要な場合は、 Task Decomposer Agent を使用してタスクを分解し、順次処理します。
16
+ - 質問が明確でない場合は、追加の情報を求めるための質問を行います。
17
+ - 質問が単純な場合は、直接回答を提供します。
18
+ """
19
+
20
+
21
+ class SupervisorAgent :
22
+ def __init__ (self ):
23
+ self .agent = create_supervisor (
24
+ agents = [
25
+ chat_with_tools_agent_graph ,
26
+ issue_formatter_agent_graph ,
27
+ task_decomposer_agent_graph ,
28
+ ],
29
+ model = AzureOpenAiWrapper ().chat_model ,
30
+ prompt = PROMPT ,
31
+ debug = True ,
32
+ supervisor_name = SupervisorAgent .__name__ ,
33
+ )
34
+
35
+
36
+ graph = SupervisorAgent ().agent
Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ def create_graph(self):
32
32
"end" : END ,
33
33
},
34
34
)
35
- return workflow .compile ()
35
+ return workflow .compile (
36
+ name = TaskDecomposerAgent .__name__ ,
37
+ )
36
38
37
39
def chat (self , state : AgentState ) -> AgentState :
38
40
"""Chat with tools using the state."""
You can’t perform that action at this time.
0 commit comments