From f5cd30ad3ce7e3672613be9362b20c7ea1e01da2 Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Wed, 14 May 2025 06:53:07 -0700 Subject: [PATCH] Update test & description --- pyproject.toml | 3 +++ src/agent/graph.py | 12 +++++++----- tests/conftest.py | 6 ++++++ tests/integration_tests/test_graph.py | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 tests/conftest.py diff --git a/pyproject.toml b/pyproject.toml index 34b8734..a6237d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,4 +59,7 @@ convention = "google" dev = [ "anyio>=4.7.0", "langgraph-cli[inmem]>=0.2.8", + "mypy>=1.13.0", + "pytest>=8.3.5", + "ruff>=0.8.2", ] diff --git a/src/agent/graph.py b/src/agent/graph.py index f4d03ac..2cecc0b 100644 --- a/src/agent/graph.py +++ b/src/agent/graph.py @@ -18,6 +18,7 @@ class Configuration(TypedDict): Set these when creating assistants OR when invoking the graph. See: https://langchain-ai.github.io/langgraph/cloud/how-tos/configuration_cloud/ """ + my_configurable_param: str @@ -28,17 +29,18 @@ class State: Defines the initial structure of incoming data. See: https://langchain-ai.github.io/langgraph/concepts/low_level/#state """ + changeme: str = "example" -async def my_node(state: State, config: RunnableConfig) -> Dict[str, Any]: - """Example node: processes input and returns output. +async def call_model(state: State, config: RunnableConfig) -> Dict[str, Any]: + """Process input and returns output. Can use runtime configuration to alter behavior. """ configuration = config["configurable"] return { - "changeme": "output from my_node. " + "changeme": "output from call_model. " f'Configured with {configuration.get("my_configurable_param")}' } @@ -46,7 +48,7 @@ async def my_node(state: State, config: RunnableConfig) -> Dict[str, Any]: # Define the graph graph = ( StateGraph(State, config_schema=Configuration) - .add_node(my_node) - .add_edge("__start__", "my_node") + .add_node(call_model) + .add_edge("__start__", "call_model") .compile(name="New Graph") ) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..26262e4 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,6 @@ +import pytest + + +@pytest.fixture(scope="session") +def anyio_backend(): + return "asyncio" diff --git a/tests/integration_tests/test_graph.py b/tests/integration_tests/test_graph.py index 1c52b2a..68169be 100644 --- a/tests/integration_tests/test_graph.py +++ b/tests/integration_tests/test_graph.py @@ -2,8 +2,11 @@ import pytest from agent import graph +pytestmark = pytest.mark.anyio + @pytest.mark.langsmith async def test_agent_simple_passthrough() -> None: - res = await graph.ainvoke({"changeme": "some_val"}) + inputs = {"changeme": "some_val"} + res = await graph.ainvoke(inputs) assert res is not None