fix: 小红书文章无正常内容(LLM推理文本污染)、模块列表不匹配、脚本独立运行缺org_id列迁移

This commit is contained in:
Yuzhiran Dev
2026-05-17 22:52:05 +08:00
parent eb472d232e
commit dc531460ea
2 changed files with 9 additions and 6 deletions
+8 -5
View File
@@ -110,7 +110,8 @@ def call_llm(
if resp.status_code != 200:
raise LLMError(f"HTTP {resp.status_code}: {resp.text[:200]}")
if stream:
full = []
content_parts = []
reasoning_parts = []
for line in resp.iter_lines():
if not line: continue
if line.startswith(b'data: '):
@@ -119,12 +120,14 @@ def call_llm(
try:
chunk = json.loads(data)
delta = chunk['choices'][0]['delta']
if delta.get('reasoning_content'):
full.append(delta['reasoning_content'])
if delta.get('content'):
full.append(delta['content'])
content_parts.append(delta['content'])
if delta.get('reasoning_content'):
reasoning_parts.append(delta['reasoning_content'])
except Exception: continue
return "".join(full)
if content_parts:
return "".join(content_parts)
return "".join(reasoning_parts)
else:
data = resp.json()
msg = data["choices"][0]["message"]