mirror of
https://github.com/Hopiu/llm.git
synced 2026-04-28 00:44:46 +00:00
llm schemas show X command, refs #781
This commit is contained in:
parent
99a1adcece
commit
4908cdfbd2
2 changed files with 37 additions and 0 deletions
13
docs/help.md
13
docs/help.md
|
|
@ -430,6 +430,7 @@ Options:
|
|||
|
||||
Commands:
|
||||
list* List stored schemas
|
||||
show Show a stored schema
|
||||
```
|
||||
|
||||
(help-schemas-list)=
|
||||
|
|
@ -445,6 +446,18 @@ Options:
|
|||
--help Show this message and exit.
|
||||
```
|
||||
|
||||
(help-schemas-show)=
|
||||
#### llm schemas show --help
|
||||
```
|
||||
Usage: llm schemas show [OPTIONS] SCHEMA_ID
|
||||
|
||||
Show a stored schema
|
||||
|
||||
Options:
|
||||
-p, --path FILE Path to log database
|
||||
--help Show this message and exit.
|
||||
```
|
||||
|
||||
(help-aliases)=
|
||||
### llm aliases --help
|
||||
```
|
||||
|
|
|
|||
24
llm/cli.py
24
llm/cli.py
|
|
@ -1441,6 +1441,30 @@ def schemas_list(path, queries):
|
|||
)
|
||||
|
||||
|
||||
@schemas.command(name="show")
|
||||
@click.argument("schema_id")
|
||||
@click.option(
|
||||
"-p",
|
||||
"--path",
|
||||
type=click.Path(readable=True, exists=True, dir_okay=False),
|
||||
help="Path to log database",
|
||||
)
|
||||
def schemas_show(schema_id, path):
|
||||
"Show a stored schema"
|
||||
path = pathlib.Path(path or logs_db_path())
|
||||
if not path.exists():
|
||||
raise click.ClickException("No log database found at {}".format(path))
|
||||
db = sqlite_utils.Database(path)
|
||||
migrate(db)
|
||||
|
||||
sql = "select content from schemas where id = ?"
|
||||
try:
|
||||
row = db["schemas"].get(schema_id)
|
||||
except sqlite_utils.db.NotFoundError:
|
||||
raise click.ClickException("Invalid schema ID")
|
||||
click.echo(json.dumps(json.loads(row["content"]), indent=2))
|
||||
|
||||
|
||||
@cli.group(
|
||||
cls=DefaultGroup,
|
||||
default="list",
|
||||
|
|
|
|||
Loading…
Reference in a new issue