Skip to content

Commit 64df02d

Browse files
Merge pull request #8 from langchain-ai/sr/context-schema
chore: replace `config_schema` with `context_schema`
2 parents 404a3e2 + 73d2503 commit 64df02d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ For more information on getting started with LangGraph Server, [see here](https:
5353

5454
## How to customize
5555

56-
1. **Define configurable parameters**: Modify the `Configuration` class in the `graph.py` file to expose the arguments you want to configure. For example, in a chatbot application you may want to define a dynamic system prompt or LLM to use. For more information on configurations in LangGraph, [see here](https://langchain-ai.github.io/langgraph/concepts/low_level/?h=configuration#configuration).
56+
1. **Define runtime context**: Modify the `Context` class in the `graph.py` file to expose the arguments you want to configure per assistant. For example, in a chatbot application you may want to define a dynamic system prompt or LLM to use. For more information on runtime context in LangGraph, [see here](https://langchain-ai.github.io/langgraph/agents/context/?h=context#static-runtime-context).
5757

5858
2. **Extend the graph**: The core logic of the application is defined in [graph.py](./src/agent/graph.py). You can modify this file to add new nodes, edges, or change the flow of information.
5959

src/agent/graph.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from dataclasses import dataclass
99
from typing import Any, Dict, TypedDict
1010

11-
from langchain_core.runnables import RunnableConfig
1211
from langgraph.graph import StateGraph
12+
from langgraph.runtime import Runtime
1313

1414

15-
class Configuration(TypedDict):
16-
"""Configurable parameters for the agent.
15+
class Context(TypedDict):
16+
"""Context parameters for the agent.
1717
1818
Set these when creating assistants OR when invoking the graph.
1919
See: https://langchain-ai.github.io/langgraph/cloud/how-tos/configuration_cloud/
@@ -33,21 +33,20 @@ class State:
3333
changeme: str = "example"
3434

3535

36-
async def call_model(state: State, config: RunnableConfig) -> Dict[str, Any]:
36+
async def call_model(state: State, runtime: Runtime[Context]) -> Dict[str, Any]:
3737
"""Process input and returns output.
3838
39-
Can use runtime configuration to alter behavior.
39+
Can use runtime context to alter behavior.
4040
"""
41-
configuration = config["configurable"]
4241
return {
4342
"changeme": "output from call_model. "
44-
f'Configured with {configuration.get("my_configurable_param")}'
43+
f"Configured with {runtime.context.get('my_configurable_param')}"
4544
}
4645

4746

4847
# Define the graph
4948
graph = (
50-
StateGraph(State, config_schema=Configuration)
49+
StateGraph(State, context_schema=Context)
5150
.add_node(call_model)
5251
.add_edge("__start__", "call_model")
5352
.compile(name="New Graph")

0 commit comments

Comments
 (0)