-
Notifications
You must be signed in to change notification settings - Fork 16.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specific prompt adds false input variables #14343
Comments
🤖 Hello @A-Roucher, Nice to meet you! I'm Dosu, a bot with the ability to help you solve bugs, answer questions, and guide you through contributing to our project. I'm here to assist you while we wait for a human maintainer. Let's work together on this! Based on the information you've provided and the similar issues I found in the LangChain repository, it seems like the problem is with the curly brackets There are a few ways you can address this issue:
text_with_call = """You are a helpful assistant. Here is a function call that you should not imitate: <functioncall> {{{{"name":"generate_anagram", "arguments": {{"word": "listen"}}}}}
"""
from langchain_core.prompts import PromptTemplate
# Define the variables that should not be recognized as input variables
partial_variables = {
"agent_scratchpad": "your_value_here"
}
# Create the PromptTemplate
prompt = PromptTemplate.from_template(
template="Your template here",
template_format="f-string",
partial_variables=partial_variables
) In this example,
from langchain.schema import HumanMessage
messages=[HumanMessage(content=text_with_call)] I hope this helps! If you have any other questions or if the issue persists, please let me know. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Thanks a lot, dear bot, the first solution (escaping the curly brackets by doubling them} does the job! |
System Info
python3.10.13
langchain==0.0.346
langchain-core==0.0.10
Who can help?
@agola11, @hwchase17
Information
Related Components
Reproduction
Expected behavior
I would expect not to get an error.
I get error:
KeyError: 'Input to ChatPromptTemplate is missing variable \'"name"\'. Expected: [\'"name"\', \'agent_scratchpad\', \'input\'] Received: [\'input\', \'agent_scratchpad\']'
So the possible solutions I see :
But I would like to make use of the
agent_scratchpad
, so the ChatPromptTemplate is needed in my case.Do you have any ideas? Thanks for your help 😃
The text was updated successfully, but these errors were encountered: