Open tylerbrandt opened 8 months ago
For now I am working around it by using a var $schema
and passing the value using -p schema "$(cat file)"
but it would be nice to not have to do that.
Example command for what @tylerbrandt mentioned above:
llm -t your-template -p schema "$(cat your-actual-system-prompt.txt)"
Where your-tempalte.yaml
should look something like this:
model: "gpt-4"
system: |
$schema
Slightly annoying to work around, especially considering $$
escape doesn't work but it's good enough for now.
It does look like either of these PRs would resolve this from a quick look: https://github.com/simonw/llm/pull/469 or https://github.com/simonw/llm/pull/429 @simonw
Summary
I was trying to include some JSON schema in my template and I ran across this bug where if the input contains an escaped identifier like
$$var
(per https://docs.python.org/3/library/string.html#template-strings),llm -t
crashes.Repro
It looks like the error arises due to the use of
template.pattern
inextract_vars
which returns a list of a singleNone
value per escaped var;Template.get_identifiers
(new in 3.11) does not exhibit this behavior (returns no list items instead for such vars).