Closed Glavin001 closed 1 year ago
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 langchain
. I'm primarily a web developer, and re-learning Python now solely to be able to use langchain
. I have other changes locally I'll try to generalize and contribute back when I have some time -- or if you and team haven't already finished those already, too ๐
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 https://github.com/hwchase17/langchain/pull/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!