Display available models with pricing. Args: current_model: Currently selected model ID model_catalog: Dictionary of available models with metadata
(current_model: str, model_catalog: dict)
| 9 | |
| 10 | |
| 11 | def show_models(current_model: str, model_catalog: dict) -> None: |
| 12 | """ |
| 13 | Display available models with pricing. |
| 14 | |
| 15 | Args: |
| 16 | current_model: Currently selected model ID |
| 17 | model_catalog: Dictionary of available models with metadata |
| 18 | """ |
| 19 | console.print() |
| 20 | |
| 21 | # Create table |
| 22 | table = Table( |
| 23 | title="🤖 Available Models", |
| 24 | box=box.ROUNDED, |
| 25 | show_header=True, |
| 26 | header_style="bold green", |
| 27 | border_style="dim" |
| 28 | ) |
| 29 | |
| 30 | table.add_column("#", style="dim", width=3) |
| 31 | table.add_column("Model", style="cyan", no_wrap=False) |
| 32 | table.add_column("Input", justify="right", style="green") |
| 33 | table.add_column("Output", justify="right", style="yellow") |
| 34 | table.add_column("Context", justify="center", style="blue") |
| 35 | table.add_column("Speed", justify="center", style="magenta") |
| 36 | |
| 37 | # Sort models by price (input + output) |
| 38 | sorted_models = sorted( |
| 39 | model_catalog.items(), |
| 40 | key=lambda x: x[1]["input"] + x[1]["output"] |
| 41 | ) |
| 42 | |
| 43 | # Add rows |
| 44 | for idx, (model_id, info) in enumerate(sorted_models, 1): |
| 45 | # Highlight current model |
| 46 | if model_id == current_model: |
| 47 | marker = "▶" |
| 48 | name_style = "bold green" |
| 49 | else: |
| 50 | marker = " " |
| 51 | name_style = "" |
| 52 | |
| 53 | # Format pricing |
| 54 | if info["input"] == 0.0 and info["output"] == 0.0: |
| 55 | input_price = "[bold green]FREE[/bold green]" |
| 56 | output_price = "[bold green]FREE[/bold green]" |
| 57 | else: |
| 58 | input_price = f"${info['input']:.3f}" |
| 59 | output_price = f"${info['output']:.3f}" |
| 60 | |
| 61 | # Format speed with emoji |
| 62 | speed_emoji = { |
| 63 | "very fast": "⚡", |
| 64 | "fast": "🚀", |
| 65 | "medium": "⏱️", |
| 66 | "slow": "🐢" |
| 67 | } |
| 68 | speed_display = f"{speed_emoji.get(info['speed'], '')} {info['speed']}" |