-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
[Feature Request] Relax template validation to allow for passing objects as inputs with jinja2 #840
Comments
does the above pr help? |
Wow, you're fast! 🚀 Thank you so much! I expect this will work for me ✅ FYI I'll definitely be trying to contribute with code/PRs in the future to |
ooc, what languages are you most familiar with? javascript by any chance? |
Yes, JavaScript/TypeScript. Haven't written Python in years (maybe 10+). |
@hwchase17 It would be awesome if you could add Jinja2 example(s) back to the LangChain docs. There's like, ghost references to them in various places, but no working examples I can find (had to come here to find one, lol). Would especially appreciate an example with the ChatPromptTemplate, since using OAI chat models is so common now. The use case I'm trying to hack out right now is a multiple-choice question, where I want to just be able to pass the question in and use Jinja2 template to format it. Edit: Removed example below because I figured out why it wasn't working. But still think it would be great to have examples in the docs! |
Use Case
I have complex objects with inner properties I want to use within the Jinja2 template.
Prior to #148 I believe it was possible. Fairly certain I have an older project with older langchain using this approach. Now when I update langchain I'm not able to do this.
Example
Output with error:
Workaround
Pass in a list of strings instead of objects..
Proposed Solution
I think this is the applicable code:
https://github.com/hwchase17/langchain/blame/b0d560be5636544aa9cfe305febf01a98fd83bc6/langchain/prompts/base.py#L43-L46
Even disabling validation of templates would be sufficient.
Thanks!
The text was updated successfully, but these errors were encountered: