feat: Extend ChatPromptBuilder with insert tag - #11486
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
|
@anakin87 I'd appreciate your review on this when you're back since it modifies the Jinja2 extension you built. |
anakin87
left a comment
There was a problem hiding this comment.
I left some minor comments. Looks good in general
I am just a little afraid of using {% messages %} (very similar to {% message %}). WDYT?
We might also decide to use something like {% insert messages %}
Done in e98c8cf I agree that it's better it also allows for more customization by not requiring the param name to be |
ChatPromptBuilder with messages tagChatPromptBuilder with insert tag
Related Issues
user_promptandsystem_promptfromAgentandLLMrun methods #11209 (comment)Proposed Changes:
Add a new
messagestag in ourChatPromptBuilder({% messages %}) to support building prompts likeso users can interleave a list of chat messages into their prompt.
I also added support for subscripting (e.g.
{% messages[0] %},{% messages[-1:] %}) to allow users to select which of the incoming messages they would like to include or not.How did you test it?
Added new unit tests.
Notes for the reviewer
The immediate use case for this would be to use this new format for
Agent. So get rid ofsystem_promptanduser_promptfromAgent's init method and replace it with a singularmessages_template(orprompt_template) variable. The defaultprompt_templatewould be{% messages %}which translates to the Agent expecting themessagesvariable to be provided at runtime. Then if users want to customize and add new additional messages like a system message they can easily update theprompt_templatetoand any new jinja2 params added would then be expected runtime params.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.