fix: some field may not exist in chatcmplchunk

This commit is contained in:
Junyan Qin
2025-02-07 23:57:51 +08:00
parent c72ad2b242
commit 21cfb6ee6f
+5 -5
View File
@@ -101,14 +101,14 @@ class OpenAIChatCompletions(requester.LLMAPIRequester):
content=pending_content, content=pending_content,
tool_calls=real_tool_calls if len(real_tool_calls) > 0 else None tool_calls=real_tool_calls if len(real_tool_calls) > 0 else None
), ),
finish_reason=chunk.choices[0].finish_reason, finish_reason=chunk.choices[0].finish_reason if hasattr(chunk.choices[0], 'finish_reason') and chunk.choices[0].finish_reason is not None else 'stop',
logprobs=chunk.choices[0].logprobs, logprobs=chunk.choices[0].logprobs,
) )
], ],
model=args["model"], model=chunk.model,
service_tier=chunk.service_tier, service_tier=chunk.service_tier if hasattr(chunk, 'service_tier') else None,
system_fingerprint=chunk.system_fingerprint, system_fingerprint=chunk.system_fingerprint if hasattr(chunk, 'system_fingerprint') else None,
usage=chunk.usage usage=chunk.usage if hasattr(chunk, 'usage') else None
) if chunk else None ) if chunk else None
async def _make_msg( async def _make_msg(