Error in code in README #1

Closed
opened 2026-02-15 17:05:09 -05:00 by yindo · 0 comments
Owner

Originally created by @logan-anderson on GitHub (Jan 20, 2024).

If you follow all of the instructions in the README you will get an error like "callModel is not defined". This is because the function is used but not defined.

Following this example, if I add the following code it works as expected.

// Define the function that calls the model
const callModel = async (state: { messages: Array<BaseMessage> }) => {
  const { messages } = state;
  const response = await newModel.invoke(messages);
  // We return a list, because this will get added to the existing list
  return {
    messages: [response],
  };
};
Originally created by @logan-anderson on GitHub (Jan 20, 2024). If you follow all of the instructions in the README you will get an error like "callModel is not defined". This is because the function is used but not defined. Following [this example](https://github.com/langchain-ai/langgraphjs/blob/main/examples/chat_agent_executor_with_function_calling/base.ipynb), if I add the following code it works as expected. ```ts // Define the function that calls the model const callModel = async (state: { messages: Array<BaseMessage> }) => { const { messages } = state; const response = await newModel.invoke(messages); // We return a list, because this will get added to the existing list return { messages: [response], }; }; ```
yindo closed this issue 2026-02-15 17:05:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#1