mirror of
https://github.com/Hopiu/llm.git
synced 2026-03-16 20:50:25 +00:00
docs: Saving reusable schemas in templates, refs #1069
This commit is contained in:
parent
3cbc37a470
commit
0da2072ade
1 changed files with 20 additions and 1 deletions
|
|
@ -456,7 +456,7 @@ This option can take multiple forms:
|
|||
- A {ref}`condensed schema definition <schemas-dsl>`: `--schema 'name,age int'`
|
||||
- The name or path of a file on disk containing a JSON schema: `--schema dogs.schema.json`
|
||||
- The hexadecimal ID of a previously logged schema: `--schema 520f7aabb121afd14d0c6c237b39ba2d` - these IDs can be found using the `llm schemas` command.
|
||||
- A schema that has been {ref}`saved in a template <prompt-templates-save>`: `--schema t:name-of-template`
|
||||
- A schema that has been {ref}`saved in a template <prompt-templates-save>`: `--schema t:name-of-template`, see {ref}`schemas-reusable`.
|
||||
|
||||
(schemas-dsl)=
|
||||
|
||||
|
|
@ -509,6 +509,25 @@ Output:
|
|||
|
||||
The Python utility function `llm.schema_dsl(schema)` can be used to convert this syntax into the equivalent JSON schema dictionary when working with schemas {ref}`in the Python API <python-api-schemas>`.
|
||||
|
||||
(schemas-reusable)=
|
||||
|
||||
## Saving reusable schemas in templates
|
||||
|
||||
If you want to store a schema with a name so you can reuse it easily in the future, the easiest way to do so is to save it {ref}`in a template <prompt-templates-schemas>`.
|
||||
|
||||
The quickest way to do that is with the `llm --save` option:
|
||||
|
||||
```bash
|
||||
llm --schema 'name, age int, one_sentence_bio' --save dog
|
||||
```
|
||||
Now you can use it like this:
|
||||
```bash
|
||||
llm --schema t:dog 'invent a dog'
|
||||
```
|
||||
Or:
|
||||
```bash
|
||||
llm --schema-multi t:dog 'invent three dogs'
|
||||
```
|
||||
(schemas-logs)=
|
||||
|
||||
## Browsing logged JSON objects created using schemas
|
||||
|
|
|
|||
Loading…
Reference in a new issue