Skip to content

Commit bf5e953

Browse files
authored
Fix variable name inconsistency in SQL agent tutorial (#1552)
Fixes DOC-471
1 parent 91e3172 commit bf5e953

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/oss/langgraph/sql-agent.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Use the `SQLDatabase` wrapper available in the `langchain_community` package to
169169
```python
170170
from langchain_community.agent_toolkits import SQLDatabaseToolkit
171171

172-
toolkit = SQLDatabaseToolkit(db=db, llm=llm)
172+
toolkit = SQLDatabaseToolkit(db=db, llm=model)
173173

174174
tools = toolkit.get_tools()
175175

@@ -304,7 +304,7 @@ def list_tables(state: MessagesState):
304304
def call_get_schema(state: MessagesState):
305305
# Note that LangChain enforces that all models accept `tool_choice="any"`
306306
# as well as `tool_choice=<string name of tool>`.
307-
llm_with_tools = llm.bind_tools([get_schema_tool], tool_choice="any")
307+
llm_with_tools = model.bind_tools([get_schema_tool], tool_choice="any")
308308
response = llm_with_tools.invoke(state["messages"])
309309

310310
return {"messages": [response]}
@@ -335,7 +335,7 @@ def generate_query(state: MessagesState):
335335
}
336336
# We do not force a tool call here, to allow the model to
337337
# respond naturally when it obtains the solution.
338-
llm_with_tools = llm.bind_tools([run_query_tool])
338+
llm_with_tools = model.bind_tools([run_query_tool])
339339
response = llm_with_tools.invoke([system_message] + state["messages"])
340340

341341
return {"messages": [response]}
@@ -369,7 +369,7 @@ def check_query(state: MessagesState):
369369
# Generate an artificial user message to check
370370
tool_call = state["messages"][-1].tool_calls[0]
371371
user_message = {"role": "user", "content": tool_call["args"]["query"]}
372-
llm_with_tools = llm.bind_tools([run_query_tool], tool_choice="any")
372+
llm_with_tools = model.bind_tools([run_query_tool], tool_choice="any")
373373
response = llm_with_tools.invoke([system_message, user_message])
374374
response.id = state["messages"][-1].id
375375

@@ -407,7 +407,7 @@ async function listTables(state: typeof MessagesAnnotation.State) {
407407

408408
// Example: force a model to create a tool call
409409
async function callGetSchema(state: typeof MessagesAnnotation.State) {
410-
const llmWithTools = llm.bindTools([getSchemaTool], {
410+
const llmWithTools = model.bindTools([getSchemaTool], {
411411
tool_choice: "any",
412412
});
413413
const response = await llmWithTools.invoke(state.messages);
@@ -435,7 +435,7 @@ async function generateQuery(state: typeof MessagesAnnotation.State) {
435435
const systemMessage = new SystemMessage(generateQuerySystemPrompt);
436436
// We do not force a tool call here, to allow the model to
437437
// respond naturally when it obtains the solution.
438-
const llmWithTools = llm.bindTools([queryTool]);
438+
const llmWithTools = model.bindTools([queryTool]);
439439
const response = await llmWithTools.invoke([systemMessage, ...state.messages]);
440440

441441
return { messages: [response] };
@@ -469,7 +469,7 @@ async function checkQuery(state: typeof MessagesAnnotation.State) {
469469
}
470470
const toolCall = lastMessage.tool_calls[0];
471471
const userMessage = new HumanMessage(toolCall.args.query);
472-
const llmWithTools = llm.bindTools([queryTool], {
472+
const llmWithTools = model.bindTools([queryTool], {
473473
tool_choice: "any",
474474
});
475475
const response = await llmWithTools.invoke([systemMessage, userMessage]);

0 commit comments

Comments
 (0)