-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Mechanism for storing prompt templates #23
Comments
The trickiest thing about these templates is their design. The simplest form of template is some text with a replacement variable where the user's additional input is pasted in - something like this:
But there are all sorts of other things to consider:
I'm leaning towards YAML for this, because it has neat support for multi-line text blocks. |
Templates can go in Will I force them to be YAML files, or can you have one that is pure text if it's a really simple one? |
I think YAML will do. A YAML file can contain just a string, and it will be treated right unless it happens to contain a colon character or similar: >>> import yaml
>>> yaml.safe_load("this is just a string")
'this is just a string'
>>> yaml.safe_load("this is just a string: hooray")
{'this is just a string': 'hooray'}
>>> yaml.safe_load("\"this is just a string: hooray\"")
'this is just a string: hooray' I can explain enough of this in the documentation to avoid people getting caught out. |
What should I use for the actual variable substitution part of this? I'd like to keep that to the Python standard library if possible. I'm tempted to just use this: >>> s = "Summarize: {input}"
>>> s.format(blah='foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'input'
>>> s.format(input='foo')
'Summarize: foo' Another option is Template strings: https://docs.python.org/3/library/string.html#template-strings
>>> from string import Template
>>> t = Template("Summarize: $input")
>>> t.substitute(input="Hello")
'Summarize: Hello'
>>> t.substitute(input2="Hello")
Traceback (most recent call last):
...
KeyError: 'input' |
OK, I think I'm going to go with If it's a dictionary it can have If you just have a Any other |
So a set of commands:
|
Templates can also have a |
I can use this: https://click.palletsprojects.com/en/8.1.x/utils/#launching-editors >>> import click
>>> click.edit(filename='/tmp/hello.txt') |
Idea from:
|
It would be amazing if you could install new templates by installing Python packages - using a plugin hook. Could be a neat way to distribute more follows templates, especially ones that include functions. |
This will allow users to store templates for complex prompts (both as system prompts and regular prompts that have strings interpolated into them) so they can use them in the future.
With a shortcut so
llm -t summary
works too.The text was updated successfully, but these errors were encountered: