DEV Community

Cover image for How to Fix Langchain Hub Pull Error
NJOKU SAMSON EBERE
NJOKU SAMSON EBERE

Posted on

How to Fix Langchain Hub Pull Error

When trying to run your first agent (https://js.langchain.com/docs/integrations/tools/tavily_search#usage) in Langchain, you will probably run into the following error:

Langchain Hub Pull Error

The problem is that Hub Pull returns false. That is this part of the code:

const prompt = await pull<ChatPromptTemplate>(
  "hwchase17/openai-functions-agent"
);
Enter fullscreen mode Exit fullscreen mode

To solve the problem, remove the code above and define a different prompt with a MessagesPlaceholder of "agent_scratchpad" like so:

 const prompt = ChatPromptTemplate.fromMessages([
  new MessagesPlaceholder("agent_scratchpad"),
  ["user", "{input}"],
  ["user", "Answer the question in detail and state your source."],
 ]);
Enter fullscreen mode Exit fullscreen mode

The text ("Answer the question in detail and state your source.") can be any instructions you want.

This fixed mine.

You can find more tutorials on my YouTube channel (https://www.youtube.com/@njokusamsonebere2589) where I teach JavaScript and AI extensively.

Top comments (0)