sophhub 0.4.41 → 0.4.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sophhub",
3
- "version": "0.4.41",
3
+ "version": "0.4.42",
4
4
  "description": "SophHub CLI - Manage and download AI Agent skills and agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "image-description",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "types": [
5
5
  "store"
6
6
  ],
7
7
  "displayName": "图片描述",
8
8
  "description": "生成图片描述",
9
9
  "changelog": [
10
+ {
11
+ "changes": [
12
+ "ana_image.py:HTTP 200 但无法提取非空 content 时 stderr 报错并 exit 1,移除 json.dumps fallback"
13
+ ],
14
+ "date": "2026-06-10",
15
+ "version": "1.0.3"
16
+ },
10
17
  {
11
18
  "changes": [
12
19
  "SKILL:补充何时使用、输出契约与注意事项;脚本:异常输出至 stderr、非零退出,错误文案补充 data URL"
@@ -30,5 +37,5 @@
30
37
  }
31
38
  ],
32
39
  "createdAt": "2026-04-21",
33
- "updatedAt": "2026-05-14"
40
+ "updatedAt": "2026-06-10"
34
41
  }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "image-description"
3
- version = "1.0.2"
3
+ version = "1.0.3"
4
4
  description = "Generate image descriptions with Sophnet via chat/completions"
5
5
  requires-python = ">=3.10"
6
6
  dependencies = [
@@ -88,10 +88,36 @@ def call_vlm(image_input: str) -> str:
88
88
  except urllib.error.URLError as exc:
89
89
  raise RuntimeError(f"URLError: {exc.reason}") from exc
90
90
 
91
- try:
92
- return data["choices"][0]["message"]["content"]
93
- except (KeyError, IndexError, TypeError):
94
- return json.dumps(data, ensure_ascii=False, indent=2)
91
+ return _extract_description(data)
92
+
93
+
94
+ def _extract_description(data: dict) -> str:
95
+ error = data.get("error")
96
+ if isinstance(error, dict):
97
+ message = error.get("message")
98
+ if isinstance(message, str) and message.strip():
99
+ raise RuntimeError(f"图片描述失败:API 返回错误:{message.strip()}")
100
+ raise RuntimeError(
101
+ f"图片描述失败:API 返回错误:{json.dumps(error, ensure_ascii=False)}"
102
+ )
103
+
104
+ choices = data.get("choices")
105
+ if not isinstance(choices, list) or not choices:
106
+ raise RuntimeError("图片描述失败:模型未返回 choices")
107
+
108
+ first = choices[0]
109
+ if not isinstance(first, dict):
110
+ raise RuntimeError("图片描述失败:choices[0] 格式异常")
111
+
112
+ message = first.get("message")
113
+ if not isinstance(message, dict):
114
+ raise RuntimeError("图片描述失败:响应中缺少 message")
115
+
116
+ content = message.get("content")
117
+ if not isinstance(content, str) or not content.strip():
118
+ raise RuntimeError("图片描述失败:模型返回空描述")
119
+
120
+ return content.strip()
95
121
 
96
122
 
97
123
  def build_parser():