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

Example of using a Vision Model doesn't work #2400

Open
xVerdy1337 opened this issue Nov 21, 2024 · 0 comments
Open

Example of using a Vision Model doesn't work #2400

xVerdy1337 opened this issue Nov 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@xVerdy1337
Copy link

Description:
I'm trying to use the example code from the documentation, but it doesn't work as expected. The code throws an error during execution. Here is the traceback:

Traceback (most recent call last):
  File "/workspaces/codespaces-blank/main.py", line 12, in <module>
    response = client.chat.completions.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/client/__init__.py", line 241, in create
    return next(response)
           ^^^^^^^^^^^^^^
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/client/__init__.py", line 97, in iter_append_model_and_provider
    for chunk in response:
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/client/__init__.py", line 54, in iter_response
    for chunk in response:
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/providers/asyncio.py", line 53, in to_sync_generator
    yield loop.run_until_complete(await_callback(gen.__anext__))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/codespace/.python/current/lib/python3.12/asyncio/base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/providers/asyncio.py", line 38, in await_callback
    return await callback()
           ^^^^^^^^^^^^^^^^
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/Provider/Bing.py", line 433, in stream_generate
    image_request = await upload_image(
                    ^^^^^^^^^^^^^^^^^^^
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/Provider/bing/upload_image.py", line 41, in upload_image
    image = to_image(image_data)
            ^^^^^^^^^^^^^^^^^^^^
  File "/home/codespace/.python/current/lib/python3.12/site-packages/g4f/image.py", line 72, in to_image
    image = open_image(image)
            ^^^^^^^^^^^^^^^^^
  File "/home/codespace/.local/lib/python3.12/site-packages/PIL/Image.py", line 3498, in open
    raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7176890f0860>

Steps to reproduce:

  1. Copy the example from the documentation.
  2. Run the code as is.
  3. Observe the traceback error.

Expected behavior:
The example should execute successfully without throwing an error.

Environment:

  • Python version: 3.12
  • Library version: 0.3.5.8
@xVerdy1337 xVerdy1337 added the bug Something isn't working label Nov 21, 2024
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