save code
This commit is contained in:
+14
-11
@@ -103,20 +103,23 @@ def analyze_features(image_bytes: bytes = None, image_url: str = None):
|
||||
{"type": "image_url", "image_url": {"url": url}},
|
||||
{"type": "text", "text": _PROMPT},
|
||||
],
|
||||
# 【SDK原生支持的标准参数,绝对不报错】
|
||||
max_tokens=1024, # 限制输出长度,模型秒回
|
||||
temperature=0, # 固定输出,无随机采样,提速+结果稳定
|
||||
stream=False, # 关闭流式,单次返回结果更快
|
||||
# 【官方正确写法】扩展参数必须放在extra_body中传递
|
||||
extra_body={
|
||||
"thinking": {
|
||||
"type": "disabled" # 【核心提速】彻底关闭深度思考模式,提速50%+,官方标准格式{insert\_element\_1\_}
|
||||
}
|
||||
}
|
||||
}],
|
||||
max_tokens=1024, # 限制输出长度,模型秒回
|
||||
temperature=0, # 固定输出,无随机采样,提速+结果稳定
|
||||
stream=False, # 关闭流式,单次返回结果更快
|
||||
extra_body={
|
||||
"thinking": {
|
||||
"type": "disabled", # 彻底关闭深度思考模式,提速50%+
|
||||
},
|
||||
},
|
||||
)
|
||||
text = resp.choices[0].message.content
|
||||
raw = _parse_json(text) # doubao 原始中文字段
|
||||
logger.info("doubao raw response (first 500 chars): %s", text[:500])
|
||||
try:
|
||||
raw = _parse_json(text) # doubao 原始中文字段
|
||||
except (json.JSONDecodeError, ValueError) as e:
|
||||
logger.error("doubao 返回非 JSON,原文: %s", text[:1000])
|
||||
raise RuntimeError(f"豆包模型返回格式异常,无法解析为 JSON:{text[:200]}") from e
|
||||
if not has_face(raw):
|
||||
return None
|
||||
# 只保留 6 个英文字段(doubao 缺某字段则跳过)
|
||||
|
||||
Reference in New Issue
Block a user