feat: unify model selection and complete favorite settings

This commit is contained in:
chenmingxuan committed 2026-10-18 20:03:41 +08:00
1 parent a4a5430922
commit 50638d4130
24 files changed
+347 -90

No files matched your search

+56 -2
View File
@@ -263,9 +263,8 @@ def test_partial_recording_update_keeps_other_favorite_settings(favorites):
item = task(favorites, recording={"codec": "h264", "fps": 10, "max_long_edge": 720})
updated = favorites.updated(item, FavoriteUpdate(task_config={"recording": {"codec": "h265"}}))
assert updated["snapshot"]["runtime_overrides"]["recording"] == {
**item["snapshot"]["runtime_overrides"]["recording"],
"codec": "h265",
"fps": 10,
"max_long_edge": 720,
}
assert item["snapshot"]["runtime_overrides"]["recording"]["codec"] == "h264"
@@ -278,6 +277,61 @@ def test_legacy_empty_recording_configuration_uses_current_defaults():
assert snapshot["runtime_overrides"]["recording"] == load_agent_config().recording.model_dump()
def test_legacy_favorite_is_completed_once_without_changing_actual_settings(favorites, monkeypatch):
from artemis.config.settings import settings
item = task(favorites, max_retries=0, record_video=False, recording={"fps": 10})
item.pop("config_version")
original = deepcopy(item)
favorites.store.put("favorite", item["id"], item)
completed = favorites.list()[0]
options = completed["snapshot"]["runtime_overrides"]
assert options["model"] == "original-model"
assert options["max_retries"] == 0
assert options["record_video"] is False
assert options["recording"]["fps"] == 10
assert options["recording"]["max_long_edge"] > 0
assert completed["created_at"] == original["created_at"]
assert completed["updated_at"] == original["updated_at"]
assert favorites.store.get("favorite", item["id"]) == completed
monkeypatch.setattr(settings, "OPENAI_MODEL", "new-global-model")
assert FavoriteService(favorites.store).get(item["id"]) == completed
def test_partial_legacy_snapshot_and_batch_complete_missing_fields(favorites):
from apps.admin_console.services.execution_config import execution_config
expected = execution_config({})["runtime_overrides"]
item = task(favorites)
item.pop("config_version")
item["snapshot"]["runtime_overrides"] = {"profile": "pro", "model": "kept-model"}
favorites.store.put("favorite", item["id"], item)
options = favorites.get(item["id"])["snapshot"]["runtime_overrides"]
assert options["model"] == "kept-model"
assert options["reasoning_effort"] == expected["reasoning_effort"]
assert options["recording"] == expected["recording"]
item["id"] = "legacy-batch"
item["kind"] = "batch"
item["snapshot"] = {
"profile": "pro",
"device_serial": "device",
"cases": [
{
"name": "一",
"goal": "检查",
"task_config": {"model": "case-model", "record_video": False},
}
],
}
favorites.store.put("favorite", item["id"], item)
options = favorites.get(item["id"])["snapshot"]["cases"][0]["task_config"]
assert options["model"] == "case-model"
assert options["profile"] == "pro"
assert options["device_serial"] == "device"
assert options["record_video"] is False
assert options["request_timeout_seconds"] == expected["request_timeout_seconds"]
@pytest.mark.asyncio
@pytest.mark.parametrize("rejected", [False, True])
async def test_restart_exploration_creates_new_conversation_and_reports_rejection(
@@ -91,19 +91,27 @@ def test_new_install_uses_playones_endpoint_without_overriding_saved_url(monkeyp
assert service.get_model_settings()["base_url"] == "https://saved.example/v1"
def test_model_presets_include_flash_pro_and_luna_without_restricting_custom_names():
def test_model_presets_keep_supported_choices_without_restricting_custom_names():
presets = service.get_model_settings()["model_presets"]
assert presets == [
"gpt-6-luna",
"gpt-6.1-sol",
"gpt-6-astra",
"gpt-5.6-luna",
"gpt-6-luna",
"mimo-v2.6-flash",
"mimo-v2.6-pro",
]
assert service.ModelSettingsUpdate(model="custom/model-v2").model == "custom/model-v2"
def test_new_install_defaults_to_luna_high_and_preserves_saved_model(isolated_settings):
from artemis.config.constants import DEFAULT_MODEL
fresh = Settings(_env_file=None)
assert DEFAULT_MODEL == fresh.OPENAI_MODEL == "gpt-6-luna"
assert fresh.OPENAI_REASONING_EFFORT == "high"
isolated_settings.write_text("OPENAI_MODEL=custom/existing\n", encoding="utf-8")
assert Settings(_env_file=isolated_settings).OPENAI_MODEL == "custom/existing"
@pytest.mark.parametrize(
"url",
[