# Parameter Widgets

Parameter widgets control the user interface rendering and editing behavior of parameters in valohai.yaml definitions.

## Widget Specification

The `widget` field accepts two formats:

**String format:**

```yaml
widget: <widget-type>
```

**Object format:**

```yaml
widget:
  type: <widget-type>
  settings:
    <widget-specific-settings>
```

When the `widget` field is omitted, the default widget is used.

***

## Available Widget Types

### default

A resizable text area that auto-expands based on content.

**Type identifier:** `default` (implicit when `widget` field is omitted)

**Settings:** None

**Behavior:**

* Renders as single-row text area by default
* Expands vertically as content is entered
* Accepts string input

**Example:**

```yaml
parameters:
  - name: experiment_name
    type: string
    default: "baseline"
```

***

### combobox

A searchable dropdown that combines predefined options with free-text input capability.

**Type identifier:** `combobox`

**Settings:**

* `options` (array of strings, optional): Predefined values displayed in dropdown

**Behavior:**

* Displays dropdown of predefined options when `settings.options` is provided
* Allows typing to filter displayed options
* Accepts custom values not in the options list
* Automatically adds current value to options list if not already present
* Falls back to default widget when `settings.options` is empty or undefined

**Example:**

```yaml
parameters:
  - name: model_type
    type: string
    widget:
      type: combobox
      settings:
        options:
          - resnet50
          - vgg16
          - inception_v3
```

**Example (shorthand without settings):**

```yaml
parameters:
  - name: model_type
    type: string
    widget: combobox
```

***

### sql

A code editor with SQL syntax highlighting.

**Type identifier:** `sql`

**Settings:** None

**Behavior:**

* Renders as multi-line code editor
* Applies SQL syntax highlighting via PrismJS
* Uses monospace font
* Accepts string input

**Example:**

```yaml
parameters:
  - name: filter_query
    type: string
    widget: sql
    default: "status = 'active'"
```

***

### dockerfile

A code editor with Dockerfile syntax highlighting.

**Type identifier:** `dockerfile`

**Settings:** None

**Behavior:**

* Renders as multi-line code editor
* Applies Dockerfile syntax highlighting via PrismJS
* Uses monospace font
* Accepts string input

**Example:**

```yaml
parameters:
  - name: custom_dockerfile
    type: string
    widget: dockerfile
    default: |
      FROM python:3.9
      RUN pip install numpy pandas
```

***

### datumalias

A searchable dropdown populated with datum aliases from the current project.

**Type identifier:** `datumalias`

**Settings:** None

**Behavior:**

* Fetches datum aliases from project context
* Displays only non-deleted aliases
* Renders searchable dropdown
* Allows custom value entry
* Provides clearable selection
* Shows loading state during fetch
* Requires valid `projectId` in execution context

**Example:**

```yaml
parameters:
  - name: input_data
    type: string
    widget: datumalias
```

***

## Parameter Definition Fields

Parameter definitions support the following fields:

| Field         | Type             | Required | Description                                                           |
| ------------- | ---------------- | -------- | --------------------------------------------------------------------- |
| `name`        | string           | Yes      | Parameter identifier used in command substitution                     |
| `type`        | string           | No       | Data type: `string`, `integer`, `float`, `flag`. Defaults to `string` |
| `default`     | varies           | No       | Default value matching the parameter type                             |
| `optional`    | boolean          | No       | Whether parameter can be omitted. Defaults to `false`                 |
| `description` | string           | No       | Help text displayed in user interface                                 |
| `widget`      | string or object | No       | Widget configuration as described above                               |

**Example with all fields:**

```yaml
parameters:
  - name: model_architecture
    type: string
    optional: false
    description: "Neural network architecture"
    default: "resnet50"
    widget:
      type: combobox
      settings:
        options:
          - resnet50
          - resnet101
          - vgg16
          - inception_v3
```

## Widget Selection

Widget selection follows this precedence:

1. If `widget` field is specified, that widget type is used
2. If `widget` field is omitted, the default widget is used

There is no automatic widget selection based on parameter type or other fields.

## Complete Examples

### String parameter with default widget

```yaml
parameters:
  - name: experiment_name
    type: string
    description: "Experiment identifier"
    default: "baseline"
```

### Integer parameter with combobox

```yaml
parameters:
  - name: batch_size
    type: integer
    default: 32
    widget:
      type: combobox
      settings:
        options:
          - 16
          - 32
          - 64
          - 128
```

### SQL query parameter

```yaml
parameters:
  - name: where_clause
    type: string
    description: "SQL WHERE clause for filtering"
    default: "created_at > '2025-01-01'"
    widget: sql
```

### Dockerfile parameter with multi-line default

```yaml
parameters:
  - name: base_image_config
    type: string
    widget: dockerfile
    default: |
      FROM python:3.11-slim
      RUN apt-get update && apt-get install -y git
      RUN pip install --upgrade pip
```

### Datum alias parameter

```yaml
parameters:
  - name: training_dataset
    type: string
    description: "Dataset alias for training data"
    widget: datumalias
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.valohai.com/valohai-yaml/parameter-widgets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
