DEV Community

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

Posted on

1 1

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.

API Trace View

Struggling with slow API calls? 👀

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay