fix: distinguish image connection and generation checks
This commit is contained in:
@@ -342,7 +342,9 @@ class EncryptedSettingsStore:
|
||||
document["tests"] = {
|
||||
target: result
|
||||
for target, result in document["tests"].items()
|
||||
if not target.startswith("model:") or target.removeprefix("model:") in current_ids
|
||||
if not (
|
||||
target.startswith("model:") or target.startswith("generation:")
|
||||
) or target.split(":", 1)[1] in current_ids
|
||||
}
|
||||
self.save_document(document)
|
||||
|
||||
@@ -525,8 +527,8 @@ class EncryptedSettingsStore:
|
||||
) -> dict[str, dict[str, Any]]:
|
||||
current: dict[str, dict[str, Any]] = {}
|
||||
for target, result in tests.items():
|
||||
if target.startswith("model:"):
|
||||
model_id = target.removeprefix("model:")
|
||||
if target.startswith("model:") or target.startswith("generation:"):
|
||||
model_id = target.split(":", 1)[1]
|
||||
if not any(item.get("id") == model_id for item in values.get("model_pool", [])):
|
||||
continue
|
||||
item = dict(result)
|
||||
@@ -542,8 +544,8 @@ class EncryptedSettingsStore:
|
||||
"database_url": self.bootstrap.database_url,
|
||||
"redis_url": self.bootstrap.redis_url,
|
||||
}
|
||||
elif target.startswith("model:"):
|
||||
model_id = target.removeprefix("model:")
|
||||
elif target.startswith("model:") or target.startswith("generation:"):
|
||||
model_id = target.split(":", 1)[1]
|
||||
relevant = next(
|
||||
(item for item in values.get("model_pool", []) if item.get("id") == model_id),
|
||||
{"id": model_id, "missing": True},
|
||||
@@ -742,7 +744,34 @@ async def test_model_pool_item(values: dict[str, Any], model_id: str) -> Runtime
|
||||
for candidate in rows
|
||||
if isinstance(candidate, dict) and candidate.get("id")
|
||||
}
|
||||
protocol_error = _validate_image_protocol(item)
|
||||
if protocol_error:
|
||||
return RuntimeSettingsTestResult(
|
||||
target=target,
|
||||
ok=False,
|
||||
message=f"模型“{name}”的生图协议配置不正确:{protocol_error}",
|
||||
details={"model_id": item["model_id"], "model_count": len(listed_ids)},
|
||||
)
|
||||
is_aigc_media = (
|
||||
"image_generation" in item.get("capabilities", [])
|
||||
and item.get("image_protocol") == "aigc_media"
|
||||
)
|
||||
if not listed_ids:
|
||||
if is_aigc_media:
|
||||
return RuntimeSettingsTestResult(
|
||||
target=target,
|
||||
ok=True,
|
||||
message=(
|
||||
f"模型“{name}”的 API Key 与模型列表接口连接正常;平台未在 /v1/models 中公开媒体模型 ID"
|
||||
f"“{item['model_id']}”,这里只完成连接与鉴权验证。最终可用性以“试生成”为准。"
|
||||
),
|
||||
details={
|
||||
"model_id": item["model_id"],
|
||||
"model_count": 0,
|
||||
"id_advertised": False,
|
||||
"verification": "connectivity_only",
|
||||
},
|
||||
)
|
||||
return RuntimeSettingsTestResult(
|
||||
target=target,
|
||||
ok=False,
|
||||
@@ -750,20 +779,27 @@ async def test_model_pool_item(values: dict[str, Any], model_id: str) -> Runtime
|
||||
details={"model_id": item["model_id"], "model_count": 0},
|
||||
)
|
||||
if item["model_id"] not in listed_ids:
|
||||
if is_aigc_media:
|
||||
return RuntimeSettingsTestResult(
|
||||
target=target,
|
||||
ok=True,
|
||||
message=(
|
||||
f"模型“{name}”的 API Key 与模型列表接口连接正常;平台返回了 {len(listed_ids)} 个模型,"
|
||||
f"但未公开媒体模型 ID“{item['model_id']}”。这不是生图失败,最终可用性以“试生成”为准。"
|
||||
),
|
||||
details={
|
||||
"model_id": item["model_id"],
|
||||
"model_count": len(listed_ids),
|
||||
"id_advertised": False,
|
||||
"verification": "connectivity_only",
|
||||
},
|
||||
)
|
||||
return RuntimeSettingsTestResult(
|
||||
target=target,
|
||||
ok=False,
|
||||
message=f"模型“{name}”测试失败:账号模型列表中未找到 ID“{item['model_id']}”。",
|
||||
details={"model_id": item["model_id"], "model_count": len(listed_ids)},
|
||||
)
|
||||
protocol_error = _validate_image_protocol(item)
|
||||
if protocol_error:
|
||||
return RuntimeSettingsTestResult(
|
||||
target=target,
|
||||
ok=False,
|
||||
message=f"模型“{name}”的 ID 可用,但生图协议配置不正确:{protocol_error}",
|
||||
details={"model_id": item["model_id"], "model_count": len(listed_ids)},
|
||||
)
|
||||
return RuntimeSettingsTestResult(
|
||||
target=target,
|
||||
ok=True,
|
||||
|
||||
Reference in New Issue
Block a user