Allow extensions to define a new tab
This commit is contained in:
parent
ad0b71af11
commit
ce21804ec7
4 changed files with 51 additions and 22 deletions
|
|
@ -49,18 +49,35 @@ Additionally, the script may define two special global variables:
|
|||
|
||||
#### `params` dictionary
|
||||
|
||||
`script.py` may contain a special dictionary called `params`:
|
||||
|
||||
```python
|
||||
params = {
|
||||
"language string": "ja",
|
||||
"display_name": "Google Translate",
|
||||
"is_tab": True,
|
||||
}
|
||||
```
|
||||
|
||||
This dicionary can be used to make the extension parameters customizable by adding entries to a `settings.json` file like this:
|
||||
In this dictionary, `display_name` is used to define the displayed name of the extension inside the UI, and `is_tab` is used to define whether the extension's `ui()` function should be called in a new `gr.Tab()` that will appear in the header bar. By default, the extension appears at the bottom of the "Text generation" tab.
|
||||
|
||||
Additionally, `params` may contain variables that you want to be customizable through a `settings.json` file. For instance, assuming the extension is in `extensions/google_translate`, the variable `language string` below
|
||||
|
||||
```python
|
||||
params = {
|
||||
"display_name": "Google Translate",
|
||||
"is_tab": True,
|
||||
"language string": "jp"
|
||||
}
|
||||
```
|
||||
|
||||
can be customized by adding a key called `google_translate-language string` to `settings.json`:
|
||||
|
||||
```python
|
||||
"google_translate-language string": "fr",
|
||||
```
|
||||
|
||||
That is, the syntax is `extension_name-variable_name`.
|
||||
|
||||
#### `input_hijack` dictionary
|
||||
|
||||
```python
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue