mirror of
https://github.com/Hopiu/llm.git
synced 2026-04-22 22:14:46 +00:00
--save now stores -p as default parameters, closes #58
This commit is contained in:
parent
059bc1a5fe
commit
9f1085eece
3 changed files with 13 additions and 3 deletions
|
|
@ -21,6 +21,11 @@ You can set the default model for a template using `--model`:
|
|||
```bash
|
||||
llm --system 'Summarize this' --model gpt-4 --save summarize
|
||||
```
|
||||
You can also save default parameters:
|
||||
```bash
|
||||
llm --system 'Summarize this text in the voice of $voice' \
|
||||
--model gpt-4 -p voice GlaDOS --save summarize
|
||||
```
|
||||
|
||||
## Using a template
|
||||
|
||||
|
|
@ -147,7 +152,7 @@ I got this:
|
|||
You can also specify default values for parameters, using a `defaults:` key.
|
||||
|
||||
```yaml
|
||||
prompt: Summarize this text in the voice of $voice
|
||||
system: Summarize this text in the voice of $voice
|
||||
defaults:
|
||||
voice: GlaDOS
|
||||
```
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ def prompt(
|
|||
("--template", template),
|
||||
("--continue", _continue),
|
||||
("--chat", chat_id),
|
||||
("--param", param),
|
||||
):
|
||||
if var:
|
||||
bad_options.append(option)
|
||||
|
|
@ -140,6 +139,8 @@ def prompt(
|
|||
to_save["prompt"] = prompt
|
||||
if system:
|
||||
to_save["system"] = system
|
||||
if param:
|
||||
to_save["defaults"] = dict(param)
|
||||
path.write_text(
|
||||
yaml.dump(
|
||||
to_save,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,11 @@ def test_templates_list(templates_path):
|
|||
(["-t", "template"], None, "--save cannot be used with --template"),
|
||||
(["--continue"], None, "--save cannot be used with --continue"),
|
||||
(["--chat", "123"], None, "--save cannot be used with --chat"),
|
||||
(["-p", "key", "value"], None, "--save cannot be used with --param"),
|
||||
(
|
||||
["Say hello as $name", "-p", "name", "default-name"],
|
||||
{"prompt": "Say hello as $name", "defaults": {"name": "default-name"}},
|
||||
None,
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_templates_prompt_save(templates_path, args, expected_prompt, expected_error):
|
||||
|
|
|
|||
Loading…
Reference in a new issue