How to Fix Langchain Hub Pull Error

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:

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

const prompt = await pull<ChatPromptTemplate>(
hwchase17/openai-functions-agent
);

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.],
]);

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.

Leave a Reply

Your email address will not be published. Required fields are marked *