fix solve.py

This commit is contained in:
2026-05-08 17:41:04 +08:00
parent ef9950a9d3
commit 7dfbe907af

View File

@ -156,12 +156,20 @@ async def call_api_streaming(
try: try:
chunk = json.loads(data) chunk = json.loads(data)
logger.debug(f"[{question_name}] Chunk: {chunk}") logger.debug(f"[{question_name}] Chunk: {chunk}")
delta = chunk.get("choices", [{}])[0].get("delta", {}) choices = chunk.get("choices")
if not choices:
continue
delta = choices[0].get("delta", {})
content = delta.get("content") content = delta.get("content")
if content: if content:
full_content.append(content) full_content.append(content)
reasoning = delta.get("reasoning_content")
if reasoning:
full_content.append(reasoning)
except json.JSONDecodeError: except json.JSONDecodeError:
continue continue
except IndexError:
continue
content = "".join(full_content) content = "".join(full_content)
if not content: if not content: