-
Notifications
You must be signed in to change notification settings - Fork 16.1k
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
Pass a JSON string and get an error mismatched or missing input parameter #7551
Comments
Answer generated by a 🤖 AnswerI understand that you're trying to pass a JSON string to the When you pass a JSON string to this method, it attempts to interpret the keys in your JSON string ("title", "description", etc.) as variable names in a template string. This is why you're seeing the error message about an invalid prompt schema and mismatched or missing input parameters. To resolve this issue, you need to convert your JSON data into a suitable template string format before passing it to the template_string = '\n'.join([f"{item['title']}: {item['description']}" for item in dict['keyfeatures']])
prompt_template = AIMessagePromptTemplate.from_template(template_string) This code will create a template string where each line is a title and description from your JSON data, and then create a prompt template from that string. Please note that this is one potential solution based on the information provided. If you believe this is a bug that could impact other users, feel free to make a pull request with a proposed fix. If this solution doesn't align with your experience, I recommend upgrading to the latest version of LangChain to ensure you have the most recent features and bug fixes. Sources
This response is meant to be useful, save you time, and share context. 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. |
The answer is not totally correct imagine that i have a prompt where i would represent as an example a prompt question and an answer that is a json The question is: Thanks in advance |
I found a solution: just use jinja as template format AIMessagePromptTemplate.from_template(msg, template_format="jinja2") and the prompt variables must use {{variable}} and not {variable} |
System Info
LangChain: 0.0.230
Python: 3.10
Who can help?
No response
Information
Related Components
Reproduction
I have a dictionary in python
i convert the dictionary in a json string
and i obtain the following string
if i pass that string to an AIMessagePromptTemplate
i get the following error:
i have already added f-string formater with multiple curly-brackets but still fail
thanks in advance
Expected behavior
the PromptMessage must import a formatted JSON string correctly without interfere with internal template curly-brackets format
The text was updated successfully, but these errors were encountered: