Open ZhangShenao opened 1 month ago
I have been using the same parser. After updating the langchain and langchain_community from 0.2.5 to 0.2.7 this bug occurs. For immediate fix I think reverting to 0.2.5 should solve it
Should be fixed by this: https://github.com/langchain-ai/langchain/pull/23967/files
I could reproduce this error with langchain-core==0.2.33
.
KeyError: "Input to PromptTemplate is missing variables {'completion'}. Expected: ['completion', 'error', 'instructions'] Received: ['instructions', 'input', 'error']"
when called with chat model.
Similar: #24105
Checked other resources
Example Code
The following code:
Error Message and Stack Trace (if applicable)
Traceback (most recent call last): File "/Users/zhangshenao/Desktop/LLM/happy-langchain/6-输出解析/2.使用OutputFixingParser自动修复解析器.py", line 39, in
print(new_parser.parse(misformatted))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain/output_parsers/fix.py", line 74, in parse
completion = self.retry_chain.invoke(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 2497, in invoke
input = step.invoke(input, config, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/prompts/base.py", line 179, in invoke
return self._call_with_config(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1593, in _call_with_config
context.run(
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/runnables/config.py", line 380, in call_func_with_variable_args
return func(input, kwargs) # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/prompts/base.py", line 153, in _format_prompt_with_error_handling
_inner_input = self._validate_input(inner_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/prompts/base.py", line 145, in _validate_input
raise KeyError(
KeyError: "Input to PromptTemplate is missing variables {'completion'}. Expected: ['completion', 'error', 'instructions'] Received: ['instructions', 'input', 'error']"
Description
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found: