langgraph-cli 0.4.2__tar.gz → 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/PKG-INFO +2 -2
  2. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graph_prerelease_reqs/agent.py +1 -7
  3. langgraph_cli-0.4.4/examples/graph_prerelease_reqs/deps/additional_deps/pyproject.toml +9 -0
  4. langgraph_cli-0.4.4/examples/graph_prerelease_reqs/deps/zuper_deps/pyproject.toml +9 -0
  5. langgraph_cli-0.4.4/examples/graph_prerelease_reqs/langgraph.json +13 -0
  6. langgraph_cli-0.4.4/examples/graph_prerelease_reqs/pyproject.toml +14 -0
  7. langgraph_cli-0.4.4/examples/graph_prerelease_reqs_fail/agent.py +89 -0
  8. langgraph_cli-0.4.4/examples/graph_prerelease_reqs_fail/pyproject.toml +11 -0
  9. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs/agent.py +8 -7
  10. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs/langgraph.json +1 -0
  11. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs/storm.py +6 -6
  12. {langgraph_cli-0.4.2/examples/graphs_reqs_b → langgraph_cli-0.4.4/examples/graphs_reqs_a}/graphs_submod/agent.py +9 -5
  13. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_a/langgraph.json +1 -0
  14. {langgraph_cli-0.4.2/examples/graphs_reqs_a → langgraph_cli-0.4.4/examples/graphs_reqs_b}/graphs_submod/agent.py +9 -4
  15. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_b/langgraph.json +1 -0
  16. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/pyproject.toml +1 -1
  17. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/langgraph.json +1 -0
  18. langgraph_cli-0.4.4/langgraph_cli/__init__.py +1 -0
  19. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/cli.py +38 -39
  20. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/config.py +102 -68
  21. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/docker.py +17 -17
  22. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/exec.py +8 -7
  23. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/progress.py +1 -1
  24. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/templates.py +3 -4
  25. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/pyproject.toml +3 -1
  26. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/apps/agent/langgraph.json +1 -0
  27. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/schemas/schema.json +30 -12
  28. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/schemas/schema.v0.json +30 -12
  29. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/cli/test_cli.py +2 -2
  30. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/test_config.py +22 -22
  31. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/test_docker.py +22 -0
  32. langgraph_cli-0.4.4/tests/unit_tests/test_util.py +188 -0
  33. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/uv.lock +552 -530
  34. langgraph_cli-0.4.2/examples/graph_prerelease_reqs/requirements.txt +0 -6
  35. langgraph_cli-0.4.2/langgraph_cli/__init__.py +0 -1
  36. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/.gitignore +0 -0
  37. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/LICENSE +0 -0
  38. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/Makefile +0 -0
  39. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/README.md +0 -0
  40. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/.env.example +0 -0
  41. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/.gitignore +0 -0
  42. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/Makefile +0 -0
  43. {langgraph_cli-0.4.2/examples/graph_prerelease_reqs → langgraph_cli-0.4.4/examples/graph_prerelease_reqs_fail}/langgraph.json +0 -0
  44. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_a/__init__.py +0 -0
  45. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_a/graphs_submod/__init__.py +0 -0
  46. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_a/graphs_submod/subprompt.txt +0 -0
  47. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_a/hello.py +0 -0
  48. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_a/prompt.txt +0 -0
  49. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_a/requirements.txt +0 -0
  50. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_b/graphs_submod/subprompt.txt +0 -0
  51. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_b/hello.py +0 -0
  52. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_b/prompt.txt +0 -0
  53. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_b/requirements.txt +0 -0
  54. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_b/utils/__init__.py +0 -0
  55. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/graphs_reqs_b/utils/greeter.py +0 -0
  56. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/langgraph.json +0 -0
  57. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/my_app.py +0 -0
  58. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/pipconf.txt +0 -0
  59. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/examples/poetry.lock +0 -0
  60. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/generate_schema.py +0 -0
  61. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/.dockerignore +0 -0
  62. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/.env.example +0 -0
  63. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/.eslintrc.cjs +0 -0
  64. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/.gitignore +0 -0
  65. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/LICENSE +0 -0
  66. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/README.md +0 -0
  67. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/jest.config.js +0 -0
  68. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/package.json +0 -0
  69. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/src/agent/graph.ts +0 -0
  70. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/src/agent/state.ts +0 -0
  71. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/static/studio.png +0 -0
  72. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/tests/agent.test.ts +0 -0
  73. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/tests/graph.int.test.ts +0 -0
  74. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/tsconfig.json +0 -0
  75. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-examples/yarn.lock +0 -0
  76. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/.eslintrc.cjs +0 -0
  77. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/apps/agent/langgraph.json +0 -0
  78. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/apps/agent/package.json +0 -0
  79. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/apps/agent/src/graph.ts +0 -0
  80. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/apps/agent/src/state.ts +0 -0
  81. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/apps/agent/tsconfig.json +0 -0
  82. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/libs/shared/package.json +0 -0
  83. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/libs/shared/src/index.ts +0 -0
  84. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/libs/shared/tsconfig.json +0 -0
  85. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/package.json +0 -0
  86. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/tsconfig.json +0 -0
  87. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/turbo.json +0 -0
  88. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/js-monorepo-example/yarn.lock +0 -0
  89. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/__main__.py +0 -0
  90. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/analytics.py +0 -0
  91. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/constants.py +0 -0
  92. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/py.typed +0 -0
  93. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/util.py +0 -0
  94. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/langgraph_cli/version.py +0 -0
  95. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/apps/agent/.env.example +0 -0
  96. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/apps/agent/pyproject.toml +0 -0
  97. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/apps/agent/src/agent/__init__.py +0 -0
  98. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/apps/agent/src/agent/graph.py +0 -0
  99. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/apps/agent/src/agent/state.py +0 -0
  100. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/libs/common/__init__.py +0 -0
  101. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/libs/common/helpers.py +0 -0
  102. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/libs/shared/pyproject.toml +0 -0
  103. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/libs/shared/src/shared/__init__.py +0 -0
  104. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/libs/shared/src/shared/utils.py +0 -0
  105. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/python-monorepo-example/pyproject.toml +0 -0
  106. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/schemas/version.schema.json +0 -0
  107. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/__init__.py +0 -0
  108. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/integration_tests/__init__.py +0 -0
  109. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/integration_tests/test_cli.py +0 -0
  110. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/__init__.py +0 -0
  111. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/agent.py +0 -0
  112. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/cli/__init__.py +0 -0
  113. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/cli/langgraph.json +0 -0
  114. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/cli/pyproject.toml +0 -0
  115. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/cli/test_templates.py +0 -0
  116. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/conftest.py +0 -0
  117. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/graphs/agent.py +0 -0
  118. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/helpers.py +0 -0
  119. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/multiplatform/js.mts +0 -0
  120. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/multiplatform/python.py +0 -0
  121. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/pipconfig.txt +0 -0
  122. {langgraph_cli-0.4.2 → langgraph_cli-0.4.4}/tests/unit_tests/test_config.json +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-cli
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: CLI for interacting with LangGraph API
5
5
  Project-URL: Repository, https://www.github.com/langchain-ai/langgraph
6
6
  License-Expression: MIT
7
7
  License-File: LICENSE
8
- Requires-Python: >=3.9
8
+ Requires-Python: >=3.10
9
9
  Requires-Dist: click>=8.1.7
10
10
  Requires-Dist: langgraph-sdk>=0.1.0; python_version >= '3.11'
11
11
  Provides-Extra: inmem
@@ -1,7 +1,6 @@
1
1
  from collections.abc import Sequence
2
2
  from typing import Annotated, Literal, TypedDict
3
3
 
4
- from langchain.chat_models import init_chat_model
5
4
  from langchain_community.tools.tavily_search import TavilySearchResults
6
5
  from langchain_core.messages import BaseMessage
7
6
  from langchain_openai import ChatOpenAI
@@ -10,10 +9,8 @@ from langgraph.prebuilt import ToolNode
10
9
 
11
10
  tools = [TavilySearchResults(max_results=1)]
12
11
 
13
- model_anth = init_chat_model("claude-3-7-sonnet-20250219", model_provider="anthropic")
14
12
  model_oai = ChatOpenAI(temperature=0)
15
13
 
16
- model_anth = model_anth.bind_tools(tools)
17
14
  model_oai = model_oai.bind_tools(tools)
18
15
 
19
16
 
@@ -35,10 +32,7 @@ def should_continue(state):
35
32
 
36
33
  # Define the function that calls the model
37
34
  def call_model(state, config):
38
- if config["configurable"].get("model", "anthropic") == "anthropic":
39
- model = model_anth
40
- else:
41
- model = model_oai
35
+ model = model_oai
42
36
  messages = state["messages"]
43
37
  response = model.invoke(messages)
44
38
  # We return a list, because this will get added to the existing list
@@ -0,0 +1,9 @@
1
+ [project]
2
+ name = "graph-prerelease-reqs-additional-deps"
3
+ version = "0.1.0"
4
+ description = "Test for prerelease stuff"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "langgraph==0.6.0"
9
+ ]
@@ -0,0 +1,9 @@
1
+ [project]
2
+ name = "graph-prerelease-reqs-zuper-deps"
3
+ version = "0.1.0"
4
+ description = "Test for prerelease stuff"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "langchain-openai==0.3.0"
9
+ ]
@@ -0,0 +1,13 @@
1
+ {
2
+ "python_version": "3.12",
3
+ "dependencies": [
4
+ ".",
5
+ "./deps/additional_deps",
6
+ "./deps/zuper_deps"
7
+ ],
8
+ "graphs": {
9
+ "agent": "./agent.py:graph"
10
+ },
11
+ "env": "../.env"
12
+ }
13
+
@@ -0,0 +1,14 @@
1
+ [project]
2
+ name = "graph-prerelease-reqs"
3
+ version = "0.1.0"
4
+ description = "Test for prerelease stuff"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "langchain-openai==1.0.0a2",
9
+ "langgraph==1.0.0a2",
10
+ "langchain_community>=0.3.0",
11
+ ]
12
+
13
+ [tool.uv]
14
+ prerelease = "allow"
@@ -0,0 +1,89 @@
1
+ from collections.abc import Sequence
2
+ from typing import Annotated, Literal, TypedDict
3
+
4
+ from langchain_community.tools.tavily_search import TavilySearchResults
5
+ from langchain_core.messages import BaseMessage
6
+ from langchain_openai import ChatOpenAI
7
+ from langgraph.graph import END, StateGraph, add_messages
8
+ from langgraph.prebuilt import ToolNode
9
+
10
+ tools = [TavilySearchResults(max_results=1)]
11
+
12
+ model_oai = ChatOpenAI(temperature=0)
13
+
14
+ model_oai = model_oai.bind_tools(tools)
15
+
16
+
17
+ class AgentState(TypedDict):
18
+ messages: Annotated[Sequence[BaseMessage], add_messages]
19
+
20
+
21
+ # Define the function that determines whether to continue or not
22
+ def should_continue(state):
23
+ messages = state["messages"]
24
+ last_message = messages[-1]
25
+ # If there are no tool calls, then we finish
26
+ if not last_message.tool_calls:
27
+ return "end"
28
+ # Otherwise if there is, we continue
29
+ else:
30
+ return "continue"
31
+
32
+
33
+ # Define the function that calls the model
34
+ def call_model(state, config):
35
+ model = model_oai
36
+ messages = state["messages"]
37
+ response = model.invoke(messages)
38
+ # We return a list, because this will get added to the existing list
39
+ return {"messages": [response]}
40
+
41
+
42
+ # Define the function to execute tools
43
+ tool_node = ToolNode(tools)
44
+
45
+
46
+ class ContextSchema(TypedDict):
47
+ model: Literal["anthropic", "openai"]
48
+
49
+
50
+ # Define a new graph
51
+ workflow = StateGraph(AgentState, context_schema=ContextSchema)
52
+
53
+ # Define the two nodes we will cycle between
54
+ workflow.add_node("agent", call_model)
55
+ workflow.add_node("action", tool_node)
56
+
57
+ # Set the entrypoint as `agent`
58
+ # This means that this node is the first one called
59
+ workflow.set_entry_point("agent")
60
+
61
+ # We now add a conditional edge
62
+ workflow.add_conditional_edges(
63
+ # First, we define the start node. We use `agent`.
64
+ # This means these are the edges taken after the `agent` node is called.
65
+ "agent",
66
+ # Next, we pass in the function that will determine which node is called next.
67
+ should_continue,
68
+ # Finally we pass in a mapping.
69
+ # The keys are strings, and the values are other nodes.
70
+ # END is a special node marking that the graph should finish.
71
+ # What will happen is we will call `should_continue`, and then the output of that
72
+ # will be matched against the keys in this mapping.
73
+ # Based on which one it matches, that node will then be called.
74
+ {
75
+ # If `tools`, then we call the tool node.
76
+ "continue": "action",
77
+ # Otherwise we finish.
78
+ "end": END,
79
+ },
80
+ )
81
+
82
+ # We now add a normal edge from `tools` to `agent`.
83
+ # This means that after `tools` is called, `agent` node is called next.
84
+ workflow.add_edge("action", "agent")
85
+
86
+ # Finally, we compile it!
87
+ # This compiles it into a LangChain Runnable,
88
+ # meaning you can use it as you would any other runnable
89
+ graph = workflow.compile()
@@ -0,0 +1,11 @@
1
+ [project]
2
+ name = "graph-prerelease-reqs"
3
+ version = "0.1.0"
4
+ description = "Test for prerelease stuff"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "langchain-openai==1.0.0a2",
9
+ "langgraph==1.0.0a2",
10
+ "langchain_community>=0.3.0",
11
+ ]
@@ -7,6 +7,7 @@ from langchain_core.messages import BaseMessage
7
7
  from langchain_openai import ChatOpenAI
8
8
  from langgraph.graph import END, StateGraph, add_messages
9
9
  from langgraph.prebuilt import ToolNode
10
+ from langgraph.runtime import Runtime
10
11
 
11
12
  tools = [TavilySearchResults(max_results=1)]
12
13
 
@@ -17,6 +18,10 @@ model_anth = model_anth.bind_tools(tools)
17
18
  model_oai = model_oai.bind_tools(tools)
18
19
 
19
20
 
21
+ class AgentContext(TypedDict):
22
+ model: Literal["anthropic", "openai"]
23
+
24
+
20
25
  class AgentState(TypedDict):
21
26
  messages: Annotated[Sequence[BaseMessage], add_messages]
22
27
 
@@ -34,8 +39,8 @@ def should_continue(state):
34
39
 
35
40
 
36
41
  # Define the function that calls the model
37
- def call_model(state, config):
38
- if config["configurable"].get("model", "anthropic") == "anthropic":
42
+ def call_model(state, runtime: Runtime[AgentContext]):
43
+ if runtime.context.get("model", "anthropic") == "anthropic":
39
44
  model = model_anth
40
45
  else:
41
46
  model = model_oai
@@ -49,12 +54,8 @@ def call_model(state, config):
49
54
  tool_node = ToolNode(tools)
50
55
 
51
56
 
52
- class ContextSchema(TypedDict):
53
- model: Literal["anthropic", "openai"]
54
-
55
-
56
57
  # Define a new graph
57
- workflow = StateGraph(AgentState, context_schema=ContextSchema)
58
+ workflow = StateGraph(AgentState, context_schema=AgentContext)
58
59
 
59
60
  # Define the two nodes we will cycle between
60
61
  workflow.add_node("agent", call_model)
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://langgra.ph/schema.json",
2
3
  "python_version": "3.12",
3
4
  "dependencies": [
4
5
  "langchain_community",
@@ -1,6 +1,6 @@
1
1
  import asyncio
2
2
  import json
3
- from typing import Annotated, Optional
3
+ from typing import Annotated
4
4
 
5
5
  from langchain_community.retrievers import WikipediaRetriever
6
6
  from langchain_community.tools.tavily_search import TavilySearchResults
@@ -51,7 +51,7 @@ class Subsection(BaseModel):
51
51
  class Section(BaseModel):
52
52
  section_title: str = Field(..., title="Title of the section")
53
53
  description: str = Field(..., title="Content of the section")
54
- subsections: Optional[list[Subsection]] = Field(
54
+ subsections: list[Subsection] | None = Field(
55
55
  default=None,
56
56
  title="Titles and descriptions for each subsection of the Wikipedia page.",
57
57
  )
@@ -201,8 +201,8 @@ def update_editor(editor, new_editor):
201
201
 
202
202
  class InterviewState(TypedDict):
203
203
  messages: Annotated[list[AnyMessage], add_messages]
204
- references: Annotated[Optional[dict], update_references]
205
- editor: Annotated[Optional[Editor], update_editor]
204
+ references: Annotated[dict | None, update_references]
205
+ editor: Annotated[Editor | None, update_editor]
206
206
 
207
207
 
208
208
  gen_qn_prompt = ChatPromptTemplate.from_messages(
@@ -321,7 +321,7 @@ async def search_engine(query: str):
321
321
 
322
322
  async def gen_answer(
323
323
  state: InterviewState,
324
- config: Optional[RunnableConfig] = None,
324
+ config: RunnableConfig | None = None,
325
325
  name: str = "Subject_Matter_Expert",
326
326
  max_str_len: int = 15000,
327
327
  ):
@@ -437,7 +437,7 @@ class SubSection(BaseModel):
437
437
  class WikiSection(BaseModel):
438
438
  section_title: str = Field(..., title="Title of the section")
439
439
  content: str = Field(..., title="Full content of the section")
440
- subsections: Optional[list[Subsection]] = Field(
440
+ subsections: list[Subsection] | None = Field(
441
441
  default=None,
442
442
  title="Titles and descriptions for each subsection of the Wikipedia page.",
443
443
  )
@@ -1,6 +1,6 @@
1
1
  from collections.abc import Sequence
2
2
  from pathlib import Path
3
- from typing import Annotated, TypedDict
3
+ from typing import Annotated, Literal, TypedDict
4
4
 
5
5
  from langchain_anthropic import ChatAnthropic
6
6
  from langchain_community.tools.tavily_search import TavilySearchResults
@@ -8,6 +8,7 @@ from langchain_core.messages import BaseMessage
8
8
  from langchain_openai import ChatOpenAI
9
9
  from langgraph.graph import END, StateGraph, add_messages
10
10
  from langgraph.prebuilt import ToolNode
11
+ from langgraph.runtime import Runtime
11
12
 
12
13
  tools = [TavilySearchResults(max_results=1)]
13
14
 
@@ -21,6 +22,10 @@ prompt = open(Path(__file__).parent.parent / "prompt.txt").read()
21
22
  subprompt = open(Path(__file__).parent / "subprompt.txt").read()
22
23
 
23
24
 
25
+ class AgentContext(TypedDict):
26
+ model: Literal["anthropic", "openai"]
27
+
28
+
24
29
  class AgentState(TypedDict):
25
30
  messages: Annotated[Sequence[BaseMessage], add_messages]
26
31
 
@@ -38,8 +43,8 @@ def should_continue(state):
38
43
 
39
44
 
40
45
  # Define the function that calls the model
41
- def call_model(state, config):
42
- if config["configurable"].get("model", "anthropic") == "anthropic":
46
+ def call_model(state, runtime: Runtime[AgentContext]):
47
+ if runtime.context.get("model", "anthropic") == "anthropic":
43
48
  model = model_anth
44
49
  else:
45
50
  model = model_oai
@@ -52,9 +57,8 @@ def call_model(state, config):
52
57
  # Define the function to execute tools
53
58
  tool_node = ToolNode(tools)
54
59
 
55
-
56
60
  # Define a new graph
57
- workflow = StateGraph(AgentState)
61
+ workflow = StateGraph(AgentState, context_schema=AgentContext)
58
62
 
59
63
  # Define the two nodes we will cycle between
60
64
  workflow.add_node("agent", call_model)
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://langgra.ph/schema.json",
2
3
  "dependencies": [
3
4
  "."
4
5
  ],
@@ -1,6 +1,6 @@
1
1
  from collections.abc import Sequence
2
2
  from pathlib import Path
3
- from typing import Annotated, TypedDict
3
+ from typing import Annotated, Literal, TypedDict
4
4
 
5
5
  from langchain_anthropic import ChatAnthropic
6
6
  from langchain_community.tools.tavily_search import TavilySearchResults
@@ -8,6 +8,7 @@ from langchain_core.messages import BaseMessage
8
8
  from langchain_openai import ChatOpenAI
9
9
  from langgraph.graph import END, StateGraph, add_messages
10
10
  from langgraph.prebuilt import ToolNode
11
+ from langgraph.runtime import Runtime
11
12
 
12
13
  tools = [TavilySearchResults(max_results=1)]
13
14
 
@@ -21,6 +22,10 @@ prompt = open(Path(__file__).parent.parent / "prompt.txt").read()
21
22
  subprompt = open(Path(__file__).parent / "subprompt.txt").read()
22
23
 
23
24
 
25
+ class AgentContext(TypedDict):
26
+ model: Literal["anthropic", "openai"]
27
+
28
+
24
29
  class AgentState(TypedDict):
25
30
  messages: Annotated[Sequence[BaseMessage], add_messages]
26
31
 
@@ -38,8 +43,8 @@ def should_continue(state):
38
43
 
39
44
 
40
45
  # Define the function that calls the model
41
- def call_model(state, config):
42
- if config["configurable"].get("model", "anthropic") == "anthropic":
46
+ def call_model(state, runtime: Runtime[AgentContext]):
47
+ if runtime.context.get("model", "anthropic") == "anthropic":
43
48
  model = model_anth
44
49
  else:
45
50
  model = model_oai
@@ -54,7 +59,7 @@ tool_node = ToolNode(tools)
54
59
 
55
60
 
56
61
  # Define a new graph
57
- workflow = StateGraph(AgentState)
62
+ workflow = StateGraph(AgentState, context_schema=AgentContext)
58
63
 
59
64
  # Define the two nodes we will cycle between
60
65
  workflow.add_node("agent", call_model)
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://langgra.ph/schema.json",
2
3
  "dependencies": [
3
4
  "."
4
5
  ],
@@ -7,7 +7,7 @@ name = "langgraph-examples"
7
7
  version = "0.1.0"
8
8
  description = ""
9
9
  readme = "README.md"
10
- requires-python = ">=3.9"
10
+ requires-python = ">=3.10"
11
11
  dependencies = [
12
12
  "langgraph-cli",
13
13
  "langgraph-sdk",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://langgra.ph/schema.json",
2
3
  "node_version": "20",
3
4
  "graphs": {
4
5
  "agent": "./src/agent/graph.ts:graph"
@@ -0,0 +1 @@
1
+ __version__ = "0.4.4"
@@ -4,8 +4,7 @@ import os
4
4
  import pathlib
5
5
  import shutil
6
6
  import sys
7
- from collections.abc import Sequence
8
- from typing import Callable, Optional
7
+ from collections.abc import Callable, Sequence
9
8
 
10
9
  import click
11
10
  import click.exceptions
@@ -200,23 +199,23 @@ def cli():
200
199
  @log_command
201
200
  def up(
202
201
  config: pathlib.Path,
203
- docker_compose: Optional[pathlib.Path],
202
+ docker_compose: pathlib.Path | None,
204
203
  port: int,
205
204
  recreate: bool,
206
205
  pull: bool,
207
206
  watch: bool,
208
207
  wait: bool,
209
208
  verbose: bool,
210
- debugger_port: Optional[int],
211
- debugger_base_url: Optional[str],
212
- postgres_uri: Optional[str],
213
- api_version: Optional[str],
214
- image: Optional[str],
215
- base_image: Optional[str],
209
+ debugger_port: int | None,
210
+ debugger_base_url: str | None,
211
+ postgres_uri: str | None,
212
+ api_version: str | None,
213
+ image: str | None,
214
+ base_image: str | None,
216
215
  ):
217
216
  click.secho("Starting LangGraph API server...", fg="green")
218
217
  click.secho(
219
- """For local dev, requires env var LANGSMITH_API_KEY with access to LangGraph Platform.
218
+ """For local dev, requires env var LANGSMITH_API_KEY with access to LangSmith Deployment.
220
219
  For production use, requires a license key in env var LANGGRAPH_CLOUD_LICENSE_KEY.""",
221
220
  )
222
221
  with Runner() as runner, Progress(message="Pulling...") as set:
@@ -298,13 +297,13 @@ def _build(
298
297
  set: Callable[[str], None],
299
298
  config: pathlib.Path,
300
299
  config_json: dict,
301
- base_image: Optional[str],
302
- api_version: Optional[str],
300
+ base_image: str | None,
301
+ api_version: str | None,
303
302
  pull: bool,
304
303
  tag: str,
305
304
  passthrough: Sequence[str] = (),
306
- install_command: Optional[str] = None,
307
- build_command: Optional[str] = None,
305
+ install_command: str | None = None,
306
+ build_command: str | None = None,
308
307
  ):
309
308
  # pull latest images
310
309
  if pull:
@@ -403,12 +402,12 @@ def _build(
403
402
  def build(
404
403
  config: pathlib.Path,
405
404
  docker_build_args: Sequence[str],
406
- base_image: Optional[str],
407
- api_version: Optional[str],
405
+ base_image: str | None,
406
+ api_version: str | None,
408
407
  pull: bool,
409
408
  tag: str,
410
- install_command: Optional[str],
411
- build_command: Optional[str],
409
+ install_command: str | None,
410
+ build_command: str | None,
412
411
  ):
413
412
  with Runner() as runner, Progress(message="Pulling...") as set:
414
413
  if shutil.which("docker") is None:
@@ -512,8 +511,8 @@ def dockerfile(
512
511
  save_path: str,
513
512
  config: pathlib.Path,
514
513
  add_docker_compose: bool,
515
- base_image: Optional[str] = None,
516
- api_version: Optional[str] = None,
514
+ base_image: str | None = None,
515
+ api_version: str | None = None,
517
516
  ) -> None:
518
517
  save_path = pathlib.Path(save_path).absolute()
519
518
  secho(f"🔍 Validating configuration at path: {config}", fg="yellow")
@@ -584,7 +583,7 @@ def dockerfile(
584
583
  "\n",
585
584
  "# LANGSMITH_API_KEY=your-api-key",
586
585
  "\n",
587
- "# Or if you have a LangGraph Platform license key, "
586
+ "# Or if you have a LangSmith Deployment license key, "
588
587
  "then uncomment the following line: ",
589
588
  "\n",
590
589
  "# LANGGRAPH_CLOUD_LICENSE_KEY=your-license-key",
@@ -688,11 +687,11 @@ def dev(
688
687
  port: int,
689
688
  no_reload: bool,
690
689
  config: str,
691
- n_jobs_per_worker: Optional[int],
690
+ n_jobs_per_worker: int | None,
692
691
  no_browser: bool,
693
- debug_port: Optional[int],
692
+ debug_port: int | None,
694
693
  wait_for_client: bool,
695
- studio_url: Optional[str],
694
+ studio_url: str | None,
696
695
  allow_blocking: bool,
697
696
  tunnel: bool,
698
697
  server_log_level: str,
@@ -776,7 +775,7 @@ def dev(
776
775
  )
777
776
  @cli.command("new", help="🌱 Create a new LangGraph project from a template.")
778
777
  @log_command
779
- def new(path: Optional[str], template: Optional[str]) -> None:
778
+ def new(path: str | None, template: str | None) -> None:
780
779
  """Create a new LangGraph project from a template."""
781
780
  return create_new(path, template)
782
781
 
@@ -786,17 +785,17 @@ def prepare_args_and_stdin(
786
785
  capabilities: DockerCapabilities,
787
786
  config_path: pathlib.Path,
788
787
  config: Config,
789
- docker_compose: Optional[pathlib.Path],
788
+ docker_compose: pathlib.Path | None,
790
789
  port: int,
791
790
  watch: bool,
792
- debugger_port: Optional[int] = None,
793
- debugger_base_url: Optional[str] = None,
794
- postgres_uri: Optional[str] = None,
795
- api_version: Optional[str] = None,
791
+ debugger_port: int | None = None,
792
+ debugger_base_url: str | None = None,
793
+ postgres_uri: str | None = None,
794
+ api_version: str | None = None,
796
795
  # Like "my-tag" (if you already built it locally)
797
- image: Optional[str] = None,
796
+ image: str | None = None,
798
797
  # Like "langchain/langgraphjs-api" or "langchain/langgraph-api
799
- base_image: Optional[str] = None,
798
+ base_image: str | None = None,
800
799
  ) -> tuple[list[str], str]:
801
800
  assert config_path.exists(), f"Config file not found: {config_path}"
802
801
  # prepare args
@@ -835,17 +834,17 @@ def prepare(
835
834
  *,
836
835
  capabilities: DockerCapabilities,
837
836
  config_path: pathlib.Path,
838
- docker_compose: Optional[pathlib.Path],
837
+ docker_compose: pathlib.Path | None,
839
838
  port: int,
840
839
  pull: bool,
841
840
  watch: bool,
842
841
  verbose: bool,
843
- debugger_port: Optional[int] = None,
844
- debugger_base_url: Optional[str] = None,
845
- postgres_uri: Optional[str] = None,
846
- api_version: Optional[str] = None,
847
- image: Optional[str] = None,
848
- base_image: Optional[str] = None,
842
+ debugger_port: int | None = None,
843
+ debugger_base_url: str | None = None,
844
+ postgres_uri: str | None = None,
845
+ api_version: str | None = None,
846
+ image: str | None = None,
847
+ base_image: str | None = None,
849
848
  ) -> tuple[list[str], str]:
850
849
  """Prepare the arguments and stdin for running the LangGraph API server."""
851
850
  config_json = langgraph_cli.config.validate_config_file(config_path)