MCPcopy Create free account
hub / github.com/RightNow-AI/rightnow-cli / select_model

Function select_model

rightnow_cli/ui/model_selector.py:95–127  ·  view source on GitHub ↗

Select a model by number or reset to default. Args: choice: User's choice (number or "reset") model_catalog: Dictionary of available models default_model: Default (cheapest) model ID Returns: Selected model ID or None if invalid

(choice: str, model_catalog: dict, default_model: str)

Source from the content-addressed store, hash-verified

93
94
95def select_model(choice: str, model_catalog: dict, default_model: str) -> str:
96 """
97 Select a model by number or reset to default.
98
99 Args:
100 choice: User's choice (number or "reset")
101 model_catalog: Dictionary of available models
102 default_model: Default (cheapest) model ID
103
104 Returns:
105 Selected model ID or None if invalid
106 """
107 if choice.lower() == "reset":
108 return default_model
109
110 try:
111 # Parse number
112 idx = int(choice)
113
114 # Sort models same way as display
115 sorted_models = sorted(
116 model_catalog.items(),
117 key=lambda x: x[1]["input"] + x[1]["output"]
118 )
119
120 # Get model by index
121 if 1 <= idx <= len(sorted_models):
122 model_id, info = sorted_models[idx - 1]
123 return model_id
124 else:
125 return None
126 except ValueError:
127 return None

Callers 1

handle_commandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected