I was working on a simple LangChain example in JavaScript and got the following error:
throw new Error(`(f-string) Missing value for input ${node.name}`)
The code was simple. I was testing a chain made of a prompt, a model, and a string output parser:
const prompt = PromptTemplate.fromTemplate(
`Which country has the highest population in { continent } ?`
)
const chain = prompt
.pipe(model)
.pipe(new StringOutputParser())
const response = await chain.invoke({continent: 'Africa'})
console.log(response)
No matter what I was passing to the continent parameter I ended up with the same (f-string) Missing value for input ${node.name} error.
After almost two hours of agonizing trial and error, it seemed that the reason for the error was the extra white spaces from the curly braces surrounding the prompt input:
Just removing those spaces seemed to fix the error:
// { param } VS {param}
// āļø throws an error because of the extra spaces in { continent }
PromptTemplate.fromTemplate(
`Which country has the highest population in { continent } ?`
)
// ā
removing the extra spaces clears the error
PromptTemplate.fromTemplate(
`Which country has the highest population in {continent} ?`
)
Hope this one will help you save some time and nerves.
š Build a full trivia game app with LangChain
Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js
š Build a full trivia game app with LangChain
Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js