Accept provider-prefixed model selection
This commit is contained in:
@@ -524,7 +524,10 @@ class AgentState:
|
||||
with self._lock:
|
||||
config = self._config_for(account_id)
|
||||
if model is not None:
|
||||
config = replace(config, model=_normalize_chat_model_name(model))
|
||||
normalized_model = _normalize_model_id(model)
|
||||
if normalized_model is None:
|
||||
raise ValueError('model must not be empty')
|
||||
config = replace(config, model=normalized_model)
|
||||
if base_url is not None:
|
||||
config = replace(config, base_url=base_url)
|
||||
if api_key is not None:
|
||||
|
||||
@@ -71,6 +71,16 @@ class GuiServerTests(unittest.TestCase):
|
||||
self.assertTrue(data['allow_shell'])
|
||||
self.assertEqual(data['model'], 'other-model')
|
||||
|
||||
def test_state_update_accepts_provider_prefixed_model(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
client, _ = _build_client(Path(d))
|
||||
updated = client.post(
|
||||
'/api/state',
|
||||
json={'model': 'azure_openai/gpt-4o-mini'},
|
||||
)
|
||||
self.assertEqual(updated.status_code, 200)
|
||||
self.assertEqual(updated.json()['model'], 'azure_openai/gpt-4o-mini')
|
||||
|
||||
def test_state_snapshot_can_scope_to_account(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
client, _ = _build_client(Path(d))
|
||||
|
||||
Reference in New Issue
Block a user