mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-08 10:47:52 +02:00
fix example in docs of state_schema in create_react_agent (#2109)
because in
```python
def call_model(
state: AgentState,
config: RunnableConfig,
)
...
if (
(
"remaining_steps" not in state
and state["is_last_step"]
and has_tool_calls
)
```
https://github.com/langchain-ai/langgraph/blob/c0b56bf60d84ed435609c35b0691cd0305ceae78/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py#L543
the AgentState requires is_last_step to have a default value, like
`False`, and `IsLastStep` can satisfy it.
---------
Co-authored-by: Vadym Barda <vadym@langchain.dev>
This commit is contained in:
committed by
William Fu-Hinthorn
co-authored by
Vadym Barda
parent
532bc71c11
commit
6b45a281c1
@@ -382,6 +382,8 @@ def create_react_agent(
|
||||
|
||||
```pycon
|
||||
>>> from typing import TypedDict
|
||||
>>>
|
||||
>>> from langgraph.managed import IsLastStep
|
||||
>>> prompt = ChatPromptTemplate.from_messages(
|
||||
... [
|
||||
... ("system", "Today is {today}"),
|
||||
@@ -392,7 +394,7 @@ def create_react_agent(
|
||||
>>> class CustomState(TypedDict):
|
||||
... today: str
|
||||
... messages: Annotated[list[BaseMessage], add_messages]
|
||||
... is_last_step: str
|
||||
... is_last_step: IsLastStep
|
||||
>>>
|
||||
>>> graph = create_react_agent(model, tools, state_schema=CustomState, state_modifier=prompt)
|
||||
>>> inputs = {"messages": [("user", "What's today's date? And what's the weather in SF?")], "today": "July 16, 2004"}
|
||||
|
||||
Reference in New Issue
Block a user