Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update the code snippet for LangGraph Agent template #4856

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions vertexai/preview/reasoning_engines/templates/langgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,18 @@ def __init__(
llm = ChatVertexAI(model_name=model, **model_kwargs)

# runnable_builder
from langchain import agents
from langchain_core.runnables.history import RunnableWithMessageHistory
from langgraph.prebuilt import create_react_agent
llm_with_tools = llm.bind_tools(tools=tools, **model_tool_kwargs)
agent_executor = agents.AgentExecutor(
agent=prompt | llm_with_tools | output_parser,
runnable = create_react_agent(
llm_with_tools,
tools=tools,
**agent_executor_kwargs,
)
runnable = RunnableWithMessageHistory(
runnable=agent_executor,
get_session_history=chat_history,
**runnable_kwargs,
)
```

By default, no checkpointer is used. To enable checkpointing, provide a
`checkpointer_builder` function that returns a checkpointer instance.
By default, no checkpointer is used (i.e. there is no state history). To
enable checkpointing, provide a `checkpointer_builder` function that
returns a checkpointer instance.

**Example using Spanner:**
```python
Expand Down
Loading