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

OpenaiChat / OpenaiAccount Provider: ERROR:g4f.api:object async_generator can't be used in 'await' expression #2552

Open
The2Alert opened this issue Jan 8, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@The2Alert
Copy link

Request URL: http://localhost:1337/v1/chat/completions

Request Body:

{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "provider": "OpenaiAccount",
  "stream": false
}

Response:

{
    "error": {
        "message": "TypeError: object async_generator can't be used in 'await' expression"
    },
    "model": "gpt-4o",
    "provider": "OpenaiAccount"
}

Logs:

g4f  | ERROR:g4f.api:object async_generator can't be used in 'await' expression
g4f  | Traceback (most recent call last):
g4f  |   File "/app/g4f/api/__init__.py", line 305, in streaming
g4f  |     async for chunk in response:
g4f  |     ...<6 lines>...
g4f  |             yield f"data: {chunk.json()}\n\n"
g4f  |   File "/app/g4f/client/__init__.py", line 202, in async_iter_append_model_and_provider
g4f  |     async for chunk in response:
g4f  |     ...<4 lines>...
g4f  |         yield chunk
g4f  |   File "/app/g4f/client/__init__.py", line 137, in async_iter_response
g4f  |     async for chunk in response:
g4f  |     ...<31 lines>...
g4f  |             break
g4f  |   File "/app/g4f/tools/run_tools.py", line 59, in async_iter_run_tools
g4f  |     async for chunk in response:
g4f  |         yield chunk
g4f  |   File "/app/g4f/providers/asyncio.py", line 78, in to_async_iterator
g4f  |     async for item in iterator:
g4f  |         yield item
g4f  |   File "/app/g4f/providers/base_provider.py", line 470, in create_async_generator
g4f  |     auth_result = await auth_result
g4f  |                   ^^^^^^^^^^^^^^^^^
g4f  | TypeError: object async_generator can't be used in 'await' expression

Version: 4.0.8 (Docker).

@The2Alert The2Alert added the bug Something isn't working label Jan 8, 2025
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