trading_agent.terminal.widgets.model_picker
¶
A dialog for choosing which model a desk tries first, as the web page's model menu does.
It lists the desk's backends in their configured order, then each provider's other models, then "Auto" for the configured order with fallback. The web page shows the other models in submenus; here they follow under their provider's heading. Keys 1 to 9 pick a backend directly.
It returns a (backend, model) pair, with (None, None) for Auto, or None when the user presses Escape.
Typical usage example:
app.push_screen(ModelPicker(desk_summary), on_chosen)
ModelPicker
¶
Bases: ModalScreen[ModelChoice | None]
The model list.
Creates the dialog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk
|
dict[str, Any]
|
The desk's summary from GET /api/desks, with its backends. |
required |
Source code in src/trading_agent/terminal/widgets/model_picker.py
compose
¶
Builds the dialog.
Yields:
| Type | Description |
|---|---|
Widget
|
The title, the list and the hint. |
Source code in src/trading_agent/terminal/widgets/model_picker.py
on_mount
¶
on_key
¶
Picks a backend with its number key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Key
|
The key press. |
required |
Source code in src/trading_agent/terminal/widgets/model_picker.py
on_option_list_option_selected
¶
Returns the chosen backend and model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
OptionSelected
|
The choice. |
required |