mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-15 11:02:36 +02:00
处理usage为类的情况
This commit is contained in:
parent
e03db313a2
commit
db26e36d37
1 changed files with 4 additions and 1 deletions
|
|
@ -102,7 +102,10 @@ class OpenAILLM(BaseLLM):
|
|||
if finish_reason:
|
||||
if hasattr(chunk, "usage") and chunk.usage is not None:
|
||||
# Some services have usage as an attribute of the chunk, such as Fireworks
|
||||
usage = CompletionUsage(**chunk.usage)
|
||||
if isinstance(chunk.usage, CompletionUsage):
|
||||
usage = chunk.usage
|
||||
else:
|
||||
usage = CompletionUsage(**chunk.usage)
|
||||
elif hasattr(chunk.choices[0], "usage"):
|
||||
# The usage of some services is an attribute of chunk.choices[0], such as Moonshot
|
||||
usage = CompletionUsage(**chunk.choices[0].usage)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue