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
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ repos:
rev: 0.9.2
hooks:
- id: uv-lock
# ์˜์กด์„ฑ ๋ฝ ํŒŒ์ผ ๋™๊ธฐํ™”
# Keep the dependency lock file in sync
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.0
hooks:
- id: ruff-check
# ์ฝ”๋“œ ํ’ˆ์งˆ ์ ๊ฒ€ ๋ฐ ์ž„ํฌํŠธ ์ •๋ฆฌ
# Lint and tidy imports
types_or: [python, pyi]
args: [--fix]
- id: ruff-format
# ์ฝ”๋“œ ํฌ๋งทํŒ…
# Format code
types_or: [python, pyi]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""[Optional] Construct agents required by the Sample Cast graph.
"""[Optional] Construct agents required by the {{ cookiecutter.cast_name }} graph.

Guidelines:
- Create agents using the `langchain.agents` module.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""[Optional] Middleware Classes for Sam graphs.
"""[Optional] Middleware Classes for the {{ cookiecutter.cast_name }} graph.

Guidelines:
- Use built-in middleware (e.g., PIIMiddleware) for common use cases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ def execute(self, state):
state: Current graph state.

Returns:
dict: State updates (must be a dict)
dict: State updates (must be a dict). Writes both ``result``
(exposed by OutputState) and ``messages`` (accumulated via
MessagesState's ``add_messages`` reducer).
"""
return {"messages": [AIMessage(content="Welcome to the Act! by Sync Node")]}
welcome = "Welcome to the Act!"
return {
"result": welcome,
"messages": [AIMessage(content=f"{welcome} by Sync Node")],
}


class AsyncSampleNode(AsyncBaseNode):
Expand All @@ -60,6 +66,12 @@ async def execute(self, state):
state: Current graph state.

Returns:
dict: State updates (must be a dict)
dict: State updates (must be a dict). Writes both ``result``
(exposed by OutputState) and ``messages`` (accumulated via
MessagesState's ``add_messages`` reducer).
"""
return {"messages": [AIMessage(content="Welcome to the Act! by Async Node")]}
welcome = "Welcome to the Act!"
return {
"result": welcome,
"messages": [AIMessage(content=f"{welcome} by Async Node")],
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""[Required] State definition shared across sam graphs.
"""[Required] State definition for the {{ cookiecutter.cast_name }} graph.

Guidelines:
- Create TypedDict classes for input, output, overall state, and any other state you need.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies = [
[dependency-groups]
test = [
"pytest",
"pytest-asyncio",
"langgraph-cli[inmem]",
]
lint = [
Expand All @@ -27,11 +28,16 @@ dev = [
[tool.pyright]
include = ["casts", "tests"]
exclude = [
"**/__pycache__/*",
".venv",
"**/__pycache__/*",
".venv",
"**/.venv"
]

[tool.pytest.ini_options]
pythonpath = ["."]
testpaths = ["tests"]
asyncio_mode = "auto"

[tool.uv.workspace]
members = ["casts/*"]
exclude = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
def test_graph_produces_message() -> None:
graph = {{ cookiecutter.cast_snake }}_graph()

# ์ตœ์†Œ ์ƒํƒœ๋กœ ๊ทธ๋ž˜ํ”„ ์‹คํ–‰
# Invoke with minimal state โ€” OutputState filter exposes only the ``result`` key.
result = graph.invoke({"query": "I'm joining Act"})

# SampleNode๊ฐ€ message ํ‚ค๋ฅผ ์ƒ์„ฑํ•˜๋Š”์ง€ ํ™•์ธ
assert "messages" in result
assert result["messages"] == "Welcome to the Act!"
# Verify SampleNode populated ``result``.
assert "result" in result
assert result["result"] == "Welcome to the Act!"
Comment thread
qjrm1430 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Test the nodes for the Sam graph.
"""Test the nodes for the {{ cookiecutter.cast_name }} graph.

Official document URL: https://docs.langchain.com/oss/python/langgraph/test"""

Expand All @@ -10,10 +10,16 @@
def test_base_node_calls_execute() -> None:
node = SampleNode()
result = node.execute({"query": "I'm joining Act"})
assert result == {"message": "Welcome to the Act!"}

assert result["result"] == "Welcome to the Act!"
assert len(result["messages"]) == 1
assert result["messages"][0].content == "Welcome to the Act! by Sync Node"


async def test_async_base_node_calls_execute() -> None:
node = AsyncSampleNode()
result = await node.execute({"query": "I'm joining Act"})
assert result == {"message": "Welcome to the Act!"}

assert result["result"] == "Welcome to the Act!"
assert len(result["messages"]) == 1
assert result["messages"][0].content == "Welcome to the Act! by Async Node"