Skip to content

Commit 030a17f

Browse files
authored
doc: Update README quickstart to fix issue with LangGraph. (#56)
* doc: Update README quickstart to fix issue with LangGraph. The quickstart earlier used the minimal example from LangChain's doc, and worked since earlier we returned `StructuredTool` from Toolbox SDK. Now with recent changes, we return a subclass of `BaseTool` which caused issues with the way this quickstart binds the tools. This PR addresses that by using the updated create_react_agent from LangGraph, and also pretty prints to better explain the output to the end-user. * doc: Make the prompt more clearer in the README.
1 parent 252ed33 commit 030a17f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,28 @@ applications, enabling advanced orchestration and interaction with GenAI models.
3636

3737
## Quickstart
3838

39-
Here's a minimal example to get you started:
39+
Here's a minimal example to get you started using
40+
[LangGraph](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.chat_agent_executor.create_react_agent):
4041

4142
```py
4243
from toolbox_langchain import ToolboxClient
4344
from langchain_google_vertexai import ChatVertexAI
45+
from langgraph.prebuilt import create_react_agent
4446

4547
toolbox = ToolboxClient("http://127.0.0.1:5000")
4648
tools = toolbox.load_toolset()
4749

4850
model = ChatVertexAI(model="gemini-1.5-pro-002")
49-
agent = model.bind_tools(tools)
50-
result = agent.invoke("How's the weather today?")
51-
print(result)
51+
agent = create_react_agent(model, tools)
52+
53+
prompt = "How's the weather today?"
54+
55+
for s in agent.stream({"messages": [("user", prompt)]}, stream_mode="values"):
56+
message = s["messages"][-1]
57+
if isinstance(message, tuple):
58+
print(message)
59+
else:
60+
message.pretty_print()
5261
```
5362

5463
## Installation

0 commit comments

Comments
 (0)