Replies: 1 comment
-
Ah yes, the classic LangChain ValueError: Missing some input keys: {'history'} From your screenshot and code, here’s what’s going on: 🚨 Diagnosis:Even though you're passing I noticed in your code: prompt = PromptTemplate(
template=custom_prompt_template,
input_variables=["context", "history", "question"]
) But later when invoking: answer = qa.invoke({"query": pregunta, "history": memory_variables}) You’re passing ➡️ So LangChain is like “hey, I expected ✅ Solution:Just align the variable names in both places. Either: Option 1: Match the PromptTemplate qa.invoke({
"context": context,
"history": memory_variables,
"question": pregunta
}) or Option 2: Adjust the prompt's (But I wouldn’t recommend this unless you want extra confusion.) 🧠 Bonus Tip:You're doing well passing memory manually, but you might want to try using (And yes — full-text system prompts + drunk mode parsing + memory injection protection — all open source.) More of these issues (with reproducible examples + workarounds) are mapped here: Hope this helps! Let me know if you need a minimal fix snippet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I'm trying to implement chat memory using ConversationBufferMemory, and use the chat history in the prompt to provide context in the awnser of the chat questions
the way I implemented the memory is storing correctly the messages and the answers.
The issue is that the cant pass it to the propt.
I'm trying by using an input_variable History: {history} but have the error : (ValueError: Missing some input keys: {'history'}) even though I'm passing explicity the history: answer= qa.invoke({"query": pregunta,"history": memory_variables})
cold you help me? whats wrong or how this should be done ?
System Info
windows 11
langchain_ollama 0.3.3
LangChain 0.3.26
Beta Was this translation helpful? Give feedback.
All reactions