Add presets documentation (#1266)

This commit is contained in:
Evan Simkowitz 2024-11-11 15:57:00 -08:00 committed by GitHub
parent d96542f691
commit 3e11450374
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 99 additions and 0 deletions

View file

@ -21,6 +21,8 @@ wsh editconfig
:::
## Configuration Keys
| Key Name | Type | Function |
| ---------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ai:preset | string | the default AI preset to use |
@ -172,3 +174,100 @@ wsh editconfig termthemes.json
| background | CSS color | | | background color (default when no color code is applied), must have alpha channel (#rrggbbaa) if you want the terminal to be transparent |
| cursorAccent | CSS color | | | color for cursor |
| selectionBackground | CSS color | | | background color for selected text |
## Presets
Presets can be used to apply multiple setting overrides to either a tab or a block. They are currently supported in two scenarios: tab backgrounds and AI models.
You can set presets either by placing them in `~/.config/waveterm/presets.json` or by placing them in a JSON file in the `~/.config/waveterm/presets/` directory. All presets will be aggregated regardless of which file they're placed in so you can use the `presets` directory to organize them as you see fit.
### File format
Presets follow the following format:
```json
{
...
"<preset-type>@<preset-key>": {
"display:name": "<Preset name>",
"display:order": "<number>", // optional
"<overridden-config-key-1>": "<overridden-config-value-1>"
...
}
}
```
A complete example of a preset for a tab background is the following:
```json
{
"bg@rainbow": {
"display:name": "Rainbow",
"display:order": 2.1,
"bg:*": true,
"bg": "linear-gradient( 226.4deg, rgba(255,26,1,1) 28.9%, rgba(254,155,1,1) 33%, rgba(255,241,0,1) 48.6%, rgba(34,218,1,1) 65.3%, rgba(0,141,254,1) 80.6%, rgba(113,63,254,1) 100.1% )",
"bg:opacity": 0.3
}
}
```
A complete example of a preset for an AI model is the following:
```json
{
"ai@wave": {
"display:name": "Ollama - llama3.1",
"display:order": 0,
"ai:baseurl": "http://localhost:11434",
"ai:model": "llama3.1:latest"
}
}
```
### Preset type
The type of the preset determines where it can be discovered in the app. Currently, the two types that will be discovered in the app are `bg` and `ai`.
`bg` will be served in the "Backgrounds" submenu of the Tab context menu (which can be found by right-clicking on a tab).
![screenshot showing the default options in the backgrounds submenu of the tab context menu](./img/backgrounds-menu.png)
`ai` will be served in the models dropdown in the block header of the "Wave AI" widget.
![screenshot showing the default options in the models dropdown in the block header of the "Wave AI" widget](./img/waveai-model-dropdown.png)
### Available configuration keys
The following configuration keys are available for use in presets:
#### AI configurations:
| Key Name | Type | Function |
| ------------- | ------ | -------------------------------------------------------------------------------- |
| ai:preset | string | the default AI preset to use |
| ai:baseurl | string | Set the AI Base Url (must be OpenAI compatible) |
| ai:apitoken | string | your AI api token |
| ai:apitype | string | defaults to "open_ai", but can also set to "azure" for special Azure AI handling |
| ai:name | string | string to display in the Wave AI block header |
| ai:model | string | model name to pass to API |
| ai:apiversion | string | for Azure AI only (when apitype is "azure", this will default to "2023-05-15") |
| ai:orgid | string | |
| ai:maxtokens | int | max tokens to pass to API |
| ai:timeoutms | int | timeout (in milliseconds) for AI calls |
#### Background configurations:
| Key Name | Type | Function |
| -------------------- | ------ | ----------------------------------------------------------------------------------------------- |
| bg:opacity | float | the opacity of the background |
| bg:blendmode | string | the [blend mode](https://developer.mozilla.org/en-US/docs/Web/CSS/blend-mode) of the background |
| bg:bordercolor | string | the color of the border |
| bg:activebordercolor | string | the color of the border when a block is active |
#### Clear key
Configs in a preset are applied in order to override the default config values, which will persist for the remainder of the tab or block's lifetime. Setting `bg:*` or `ai:*` to `"true"` will clear the values of any previously overridden Background or AI configurations, respectively, setting them back to their defaults.
#### Unset a default value
To unset a default value in a preset, add an override that sets it to an empty string, like `""`.

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB