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.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more