-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use default stringtemplate delimiters for prompt templates #444
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
Use default stringtemplate delimiters for prompt templates #444
Conversation
Upon reviewing the PR, I've considered that using Furthermore, since this delimiter usage is common across several frameworks, it could also lead to improved readability. It seems to me that this might have been the author's intention. nit |
I don't follow the comment regarding Between easier json embedding into the prompt or sending react code, I'd go with easier json embedding. That said, it sounds like the delimiter should be configurable to better accommodate all cases. My intention was to support the python F-string syntax. How does python handle the case of inserting json into a f-string? I'd need to reproduce the original issue, what does embedding json into the TextTemplate look like? |
What I intended was similar to what you mentioned about F-String, as various languages or frameworks use Changing the delimiter to To fundamentally solve these issues, developing custom parsers, renderers, or using flexible variable templates through the injection of ST with various delimiters might be a good approach. |
I agree, that it might be the best to introduce a configuration option for the delimiters. @markpollack an example prompt could be:
This prompt fails if used with the ST Template Prompt mechanism. |
I shared some thoughts on the issue for this PR about the templating strategy: #355 (comment) |
So how do we proceed with this? I am fine with changing it, but will only start working once there is a commitment to a solution ;) |
I have created a code that functions similarly to F-string. |
I agree that PromptTemplate should provide an API for users to use different delimiters based on their own scenarios. However, can we keep the default delimiter as { } to avoid unnecessary compatibility changes for existing users? |
I also agree that we should allow different delimiters, and I've also had requests for different template engines. I do not want to change the default |
Voted for this. The { and } characters are used a lot to put examples for the JSON output of the prompt. Using them by default will cause a lot of pains for the user. |
Given the history and the default usage of |
Closing this PR but leaving the relevant issue #355 open |
The current set delimiters
{
and}
do not follow the stringtemplate default and need escaping if you want to build a prompt with JSON (as described in issue #355). This pull request will address this issue.