Fix support for Python template syntax
All dollar signs in a template's prompt or system values are interpreted as introducing placeholders. The documentation for string.Template says that doubling a dollar sign should escape it.
Due to the custom implementation of Template.extract_vars, this did not work, as it extracted a double dollar sign as an identifier with an empty named group. By using string.Template.get_identifiers() instead, this now works. Additionally, this automatically adds support for parenthesized identifiers as well.
Tests failed on Python 3.8:
llm/templates.py:54: in Template
def extract_identifiers(cls, template: string.Template) -> list[str]:
E TypeError: 'type' object is not subscriptable
I'll fix that now.
Sorry for the bad code, I should figure out how to run the tests locally.
There, that should do it. Sorry for the noise, I was apparently coding on half a brain last week.