Skip to content

Commit 9e6cc62

Browse files
yeesiancopybara-github
authored andcommittedJan 16, 2025·
docs: update the code snippet for LangGraph Agent template
PiperOrigin-RevId: 716303416
1 parent de85a0c commit 9e6cc62

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed
 

‎vertexai/preview/reasoning_engines/templates/langgraph.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,18 @@ def __init__(
260260
llm = ChatVertexAI(model_name=model, **model_kwargs)
261261
262262
# runnable_builder
263-
from langchain import agents
264-
from langchain_core.runnables.history import RunnableWithMessageHistory
263+
from langgraph.prebuilt import create_react_agent
265264
llm_with_tools = llm.bind_tools(tools=tools, **model_tool_kwargs)
266-
agent_executor = agents.AgentExecutor(
267-
agent=prompt | llm_with_tools | output_parser,
265+
runnable = create_react_agent(
266+
llm_with_tools,
268267
tools=tools,
269-
**agent_executor_kwargs,
270-
)
271-
runnable = RunnableWithMessageHistory(
272-
runnable=agent_executor,
273-
get_session_history=chat_history,
274268
**runnable_kwargs,
275269
)
276270
```
277271
278-
By default, no checkpointer is used. To enable checkpointing, provide a
279-
`checkpointer_builder` function that returns a checkpointer instance.
272+
By default, no checkpointer is used (i.e. there is no state history). To
273+
enable checkpointing, provide a `checkpointer_builder` function that
274+
returns a checkpointer instance.
280275
281276
**Example using Spanner:**
282277
```python

0 commit comments

Comments
 (0)
Please sign in to comment.