|
|
@@ -38,31 +38,16 @@ def _parse_result_payload(payload: Optional[str]) -> Any:
|
|
|
return payload
|
|
|
|
|
|
|
|
|
-def _parse_web_url(web_url: Optional[str]) -> Optional[Dict[str, str]]:
|
|
|
- """解析结果表中的 web_url 字段,拆分出 pointUrl 和 weightUrl"""
|
|
|
+def _parse_web_url(web_url: Optional[str]) -> Any:
|
|
|
+ """解析结果表中的 web_url 字段(JSON 字符串 -> 对象)"""
|
|
|
if not web_url:
|
|
|
return None
|
|
|
|
|
|
- segments = [segment.strip() for segment in web_url.split(",") if segment.strip()]
|
|
|
- if not segments:
|
|
|
- return None
|
|
|
-
|
|
|
- point_url: Optional[str] = None
|
|
|
- weight_url: Optional[str] = None
|
|
|
-
|
|
|
- for segment in segments:
|
|
|
- if "weight_visualization" in segment:
|
|
|
- weight_url = segment
|
|
|
- else:
|
|
|
- point_url = segment
|
|
|
-
|
|
|
- if not point_url and not weight_url:
|
|
|
- return None
|
|
|
-
|
|
|
- return {
|
|
|
- "pointUrl": point_url or "",
|
|
|
- "weightUrl": weight_url or ""
|
|
|
- }
|
|
|
+ try:
|
|
|
+ return json.loads(web_url)
|
|
|
+ except (json.JSONDecodeError, TypeError):
|
|
|
+ # 如果不是合法 JSON,则原样返回,避免接口直接报错
|
|
|
+ return web_url
|
|
|
|
|
|
|
|
|
def _fetch_decode_result(task_id: str) -> Optional[Dict[str, Any]]:
|
|
|
@@ -85,7 +70,7 @@ def _build_result_data(
|
|
|
status: int,
|
|
|
result: Any = None,
|
|
|
reason: Optional[str] = None,
|
|
|
- url: Optional[Dict[str, str]] = None
|
|
|
+ url: Any = None
|
|
|
) -> Dict[str, Any]:
|
|
|
"""构建结果数据"""
|
|
|
data: Dict[str, Any] = {
|