Numbered-list model picker with ``[c] Custom`` escape.
(
console: Console,
strings: dict[str, str],
*,
models: list[str],
current: str = "",
custom_prompt_label: str | None = None,
)
| 727 | |
| 728 | |
| 729 | def select_model( |
| 730 | console: Console, |
| 731 | strings: dict[str, str], |
| 732 | *, |
| 733 | models: list[str], |
| 734 | current: str = "", |
| 735 | custom_prompt_label: str | None = None, |
| 736 | ) -> str: |
| 737 | """Numbered-list model picker with ``[c] Custom`` escape.""" |
| 738 | if not models: |
| 739 | return typer.prompt( |
| 740 | custom_prompt_label or strings["init.custom_model"], |
| 741 | default=current or "", |
| 742 | ) |
| 743 | |
| 744 | options = [(m, m, "") for m in models] |
| 745 | extra = {"c": strings["init.custom_model"]} |
| 746 | default_key = current if current in models else models[0] |
| 747 | pick = select_from_options( |
| 748 | console, |
| 749 | title=strings["init.pick_model"].format(marker="[c]"), |
| 750 | options=options, |
| 751 | default_key=default_key, |
| 752 | extra_keys=extra, |
| 753 | prompt_label=strings["init.choice"], |
| 754 | invalid_label=strings["init.choice_invalid"], |
| 755 | ) |
| 756 | if pick == "c": |
| 757 | return typer.prompt( |
| 758 | custom_prompt_label or strings["init.custom_model"], |
| 759 | default=current or "", |
| 760 | ) |
| 761 | return pick |
| 762 | |
| 763 | |
| 764 | # --- Connectivity probe -------------------------------------------------------- |
nothing calls this directly
no test coverage detected