llm aliases path command, refs #151

This commit is contained in:
Simon Willison 2023-08-12 09:01:51 -07:00
parent 8fc9cd1902
commit 4a68aa408a
3 changed files with 28 additions and 0 deletions

View file

@ -59,3 +59,18 @@ Now you can run the `gpt-3.5-turbo-16k` model using the `turbo` alias like this:
```bash
llm -m turbo 'An epic Greek-style saga about a cheesecake that builds a SQL database from scratch'
```
## Viewing the aliases file
Aliases are stored in an `aliases.json` file in the LLM configuration directory.
To see the path to that file, run this:
```bash
llm aliases path
```
To view the content of that file, run this:
```bash
cat "$(llm aliases path)"
```

View file

@ -600,6 +600,12 @@ def aliases_set(alias, model_id):
path.write_text(json.dumps(current, indent=4) + "\n")
@aliases.command(name="path")
def aliases_path():
"Output the path to the aliases.json file"
click.echo(user_dir() / "aliases.json")
@cli.command(name="plugins")
def plugins_list():
"List installed plugins"

View file

@ -41,3 +41,10 @@ def test_aliases_set(user_path):
assert result.exit_code == 0
assert (user_path / "aliases.json").exists()
assert json.loads((user_path / "aliases.json").read_text("utf-8")) == {"foo": "bar"}
def test_aliases_path(user_path):
runner = CliRunner()
result = runner.invoke(cli, ["aliases", "path"])
assert result.exit_code == 0
assert result.output.strip() == str(user_path / "aliases.json")