I have noticed that PromptTemplate currently uses Mustache directly to generate the final string from a template string. However, in the real world, Python f-strings and Jinja2 are widely used to describe prompt templates. I suggest abstracting an interface for the template engine and integrating it into PromptTemplate to handle different styles of template strings (of course we can have a default handler).
For Mustache, we can use the following maven package:
Oops...ChatGPT told me about com.github.squidfunk:python-string-format, but it doesn't exist...
Now I'm using regex ways to resolve f-string templates.
I have noticed that PromptTemplate currently uses Mustache directly to generate the final string from a template string. However, in the real world, Python f-strings and Jinja2 are widely used to describe prompt templates. I suggest abstracting an interface for the template engine and integrating it into PromptTemplate to handle different styles of template strings (of course we can have a default handler).
For Mustache, we can use the following maven package:
For Python f-strings, we can use the following maven package:
For Jinja2/Jinjava, we can use the following maven package:
(Since it uses {{...}} style placeholders like Mustache, maybe we don't need to integrate it.)