Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ repos:
args: [ --fix ]
- id: ruff-format
types_or: [ python, pyi ]
exclude: 'generated/.*|artifacts/.*'
exclude: 'generated/.*|artifacts/.*|.*\.json$'
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ uv run python -m template_langgraph.tasks.run_issue_formatter_agent

- [Build a custom workflow](https://langchain-ai.github.io/langgraph/concepts/why-langgraph/)
- [LangGraphの(LLMなし)Human-in-the-loopを試してみた](https://qiita.com/te_yama/items/db38201af60dec76384d)
- [🤖 LangGraph Multi-Agent Supervisor](https://github.com/langchain-ai/langgraph-supervisor-py)
- [Software Design誌「実践LLMアプリケーション開発」第24回サンプルコード](https://github.com/mahm/softwaredesign-llm-application/tree/main/24)

### Sample Codes

Expand Down
3 changes: 2 additions & 1 deletion langgraph.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"."
],
"graphs": {
"supervisor_agent": "template_langgraph.agents.supervisor_agent:graph",
"chat_with_tools_agent": "template_langgraph.agents.chat_with_tools_agent.agent:graph",
"kabuto_helpdesk_agent": "template_langgraph.agents.kabuto_helpdesk_agent:graph",
"issue_formatter_agent": "template_langgraph.agents.issue_formatter_agent.agent:graph",
"task_decomposer_agent": "template_langgraph.agents.task_decomposer_agent.agent:graph"
},
"env": ".env"
}
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies = [
"langchain-openai>=0.3.28",
"langchain-text-splitters>=0.3.9",
"langgraph>=0.6.2",
"langgraph-supervisor>=0.0.29",
"openai>=1.98.0",
"pydantic-settings>=2.9.1",
"pypdf>=5.9.0",
Expand Down
4 changes: 3 additions & 1 deletion template_langgraph/agents/chat_with_tools_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def create_graph(self):
workflow.add_edge("finalize", END)

# Compile the graph
return workflow.compile()
return workflow.compile(
name=ChatWithToolsAgent.__name__,
)

def initialize(self, state: AgentState) -> AgentState:
"""Initialize the agent with the given state."""
Expand Down
4 changes: 3 additions & 1 deletion template_langgraph/agents/issue_formatter_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def create_graph(self):
workflow.add_edge("analyze", END)

# Compile the graph
return workflow.compile()
return workflow.compile(
name=IssueFormatterAgent.__name__,
)

def analyze(self, state: AgentState) -> AgentState:
"""Analyze the issue and extract relevant information."""
Expand Down
36 changes: 36 additions & 0 deletions template_langgraph/agents/supervisor_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from langgraph_supervisor import create_supervisor

from template_langgraph.agents.chat_with_tools_agent.agent import graph as chat_with_tools_agent_graph
from template_langgraph.agents.issue_formatter_agent.agent import graph as issue_formatter_agent_graph
from template_langgraph.agents.task_decomposer_agent.agent import graph as task_decomposer_agent_graph
from template_langgraph.llms.azure_openais import AzureOpenAiWrapper
from template_langgraph.loggers import get_logger

logger = get_logger(__name__)

PROMPT = """
KABUTO に関する質問に答えるために、必要な情報を収集し適切な回答を提供します。
- 過去の FAQ やドキュメントを参照して、質問に対する答えを見つける必要がある場合は Chat with Tools Agent を使用します。
- 質問の内容を整理し、適切な形式で回答するために Issue Formatter Agent を使用します。
- 質問が複雑であったり追加の情報が必要な場合は、 Task Decomposer Agent を使用してタスクを分解し、順次処理します。
- 質問が明確でない場合は、追加の情報を求めるための質問を行います。
- 質問が単純な場合は、直接回答を提供します。
"""


class SupervisorAgent:
def __init__(self):
self.agent = create_supervisor(
agents=[
chat_with_tools_agent_graph,
issue_formatter_agent_graph,
task_decomposer_agent_graph,
],
model=AzureOpenAiWrapper().chat_model,
prompt=PROMPT,
debug=True,
supervisor_name=SupervisorAgent.__name__,
)


graph = SupervisorAgent().agent
4 changes: 3 additions & 1 deletion template_langgraph/agents/task_decomposer_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def create_graph(self):
"end": END,
},
)
return workflow.compile()
return workflow.compile(
name=TaskDecomposerAgent.__name__,
)

def chat(self, state: AgentState) -> AgentState:
"""Chat with tools using the state."""
Expand Down
17 changes: 16 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.