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 1313 args : [ --fix ]
1414 - id : ruff-format
1515 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
4343
4444- [ Build a custom workflow] ( https://langchain-ai.github.io/langgraph/concepts/why-langgraph/ )
4545- [ 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 )
4648
4749### Sample Codes
4850
Original file line number Diff line number Diff line change 33 " ."
44 ],
55 "graphs" : {
6+ "supervisor_agent" : " template_langgraph.agents.supervisor_agent:graph" ,
67 "chat_with_tools_agent" : " template_langgraph.agents.chat_with_tools_agent.agent:graph" ,
78 "kabuto_helpdesk_agent" : " template_langgraph.agents.kabuto_helpdesk_agent:graph" ,
89 "issue_formatter_agent" : " template_langgraph.agents.issue_formatter_agent.agent:graph" ,
910 "task_decomposer_agent" : " template_langgraph.agents.task_decomposer_agent.agent:graph"
1011 },
1112 "env" : " .env"
12- }
13+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies = [
1010 " langchain-openai>=0.3.28" ,
1111 " langchain-text-splitters>=0.3.9" ,
1212 " langgraph>=0.6.2" ,
13+ " langgraph-supervisor>=0.0.29" ,
1314 " openai>=1.98.0" ,
1415 " pydantic-settings>=2.9.1" ,
1516 " pypdf>=5.9.0" ,
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ def create_graph(self):
7676 workflow .add_edge ("finalize" , END )
7777
7878 # Compile the graph
79- return workflow .compile ()
79+ return workflow .compile (
80+ name = ChatWithToolsAgent .__name__ ,
81+ )
8082
8183 def initialize (self , state : AgentState ) -> AgentState :
8284 """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):
2424 workflow .add_edge ("analyze" , END )
2525
2626 # Compile the graph
27- return workflow .compile ()
27+ return workflow .compile (
28+ name = IssueFormatterAgent .__name__ ,
29+ )
2830
2931 def analyze (self , state : AgentState ) -> AgentState :
3032 """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):
3232 "end" : END ,
3333 },
3434 )
35- return workflow .compile ()
35+ return workflow .compile (
36+ name = TaskDecomposerAgent .__name__ ,
37+ )
3638
3739 def chat (self , state : AgentState ) -> AgentState :
3840 """Chat with tools using the state."""
You can’t perform that action at this time.
0 commit comments