Skip to content

Commit ea20e2a

Browse files
authored
chore: Update langchain README.md to run (#139)
Fixed missing or incorrect imports and added an example of how to pass invoke the compiled `langgraph` agent
1 parent bd5b728 commit ea20e2a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Each tool generated by the SDK can be represented as a LangGraph node. The
104104
node's functionality would encapsulate the execution of the corresponding tool.
105105

106106
```python
107-
from toolbox_sdk import ToolboxClient
107+
from toolbox_langchain_sdk import ToolboxClient
108108
from langgraph.graph import StateGraph, MessagesState
109109
from langgraph.prebuilt import ToolNode
110110

@@ -116,7 +116,7 @@ def call_model(state: MessagesState):
116116
return {"messages": [response]}
117117

118118
model = ChatVertexAI()
119-
builder = StateGraph()
119+
builder = StateGraph(MessagesState)
120120
tool_node = ToolNode(tools)
121121

122122
builder.add_node("agent", call_model)
@@ -131,7 +131,9 @@ from a tool can then be fed back into the LLM for further processing or
131131
decision-making.
132132

133133
```python
134+
from typing import Literal
134135
from langgraph.graph import END, START
136+
from langchain_core.messages import HumanMessage
135137

136138
# Define the function that determines whether to continue or not
137139
def should_continue(state: MessagesState) -> Literal["tools", END]:
@@ -151,6 +153,10 @@ builder.add_conditional_edges(
151153
builder.add_edge("tools", 'agent')
152154

153155
graph = builder.compile()
156+
157+
graph.invoke(
158+
{"messages": [HumanMessage(content="Do something with the tools")]},
159+
)
154160
```
155161

156162
## Manual usage

0 commit comments

Comments
 (0)