From 21cfb6ee6f305a4310082aa4a7d9032754167a4c Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Fri, 7 Feb 2025 23:57:51 +0800 Subject: [PATCH] fix: some field may not exist in chatcmplchunk --- pkg/provider/modelmgr/requesters/chatcmpl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/provider/modelmgr/requesters/chatcmpl.py b/pkg/provider/modelmgr/requesters/chatcmpl.py index 55ee0687..0b1c4cf2 100644 --- a/pkg/provider/modelmgr/requesters/chatcmpl.py +++ b/pkg/provider/modelmgr/requesters/chatcmpl.py @@ -101,14 +101,14 @@ class OpenAIChatCompletions(requester.LLMAPIRequester): content=pending_content, 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, ) ], - model=args["model"], - service_tier=chunk.service_tier, - system_fingerprint=chunk.system_fingerprint, - usage=chunk.usage + model=chunk.model, + service_tier=chunk.service_tier if hasattr(chunk, 'service_tier') else None, + system_fingerprint=chunk.system_fingerprint if hasattr(chunk, 'system_fingerprint') else None, + usage=chunk.usage if hasattr(chunk, 'usage') else None ) if chunk else None async def _make_msg(