Function _achat_completion_stream in metagpt/provider/openai_api.py produced TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not NoneType #1275
Labels
bug
Something isn't working
Bug description
Running the example code llm_hello_world.py on branch v0.8-release will produce a TypeError. See logs below.
Screenshots or logs
Traceback (most recent call last):
File "/workspaces/MetaGPT/examples/llm_hello_world.py", line 43, in
asyncio.run(main())
File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/workspaces/MetaGPT/examples/llm_hello_world.py", line 19, in main
logger.info(await llm.aask(question))
File "/workspaces/MetaGPT/metagpt/provider/base_llm.py", line 150, in aask
rsp = await self.acompletion_text(message, stream=stream, timeout=self.get_timeout(timeout))
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
return await fn(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 47, in call
do = self.iter(retry_state=retry_state)
File "/usr/local/lib/python3.9/site-packages/tenacity/init.py", line 314, in iter
return fut.result()
File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 439, in result
return self.__get_result()
File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
raise self._exception
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 50, in call
result = await fn(*args, **kwargs)
File "/workspaces/MetaGPT/metagpt/provider/openai_api.py", line 141, in acompletion_text
return await self._achat_completion_stream(messages, timeout=timeout)
File "/workspaces/MetaGPT/metagpt/provider/openai_api.py", line 94, in _achat_completion_stream
usage = CompletionUsage(**chunk.usage)
TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not NoneType
The text was updated successfully, but these errors were encountered: