Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
garylin2099 opened this issue May 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@garylin2099
Copy link
Collaborator

garylin2099 commented May 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants