xtekky / gpt4free

The official gpt4free repository | various collection of powerful language models
https://g4f.ai
GNU General Public License v3.0
59.41k stars 13.2k forks source link

DeepInfra Model Bug #1961

Closed noneherel closed 2 months ago

noneherel commented 2 months ago

I'm trying to use DeepInfra provider for creating images but there's no model works with it this is my code:

from g4f.client import Client as client_ai
from g4f.Provider import DeepInfra
client = client_ai(provider=DeepInfra, image_provider=DeepInfra)
response = client.images.generate(
    api_key= '',
    model='stability-ai/sdxl',
    prompt='a white cat on the moon.',
)
image_url = response.data[0].url
print(image_url)

and this is the error i got:

C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\curl_cffi\aio.py:39: RuntimeWarning: 
    Proactor event loop does not implement add_reader family of methods required.
    Registering an additional selector thread for add_reader support.
    To avoid this warning use:
        asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())

  warnings.warn(PROACTOR_WARNING, RuntimeWarning)
Traceback (most recent call last):
  File "d:\VisualStudio\AI_tests\photo.py", line 4, in <module>
    response = client.images.generate(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\g4f\client\client.py", line 151, in generate
    image = iter_image_response(response)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mega\AppData\Local\Programs\Python\Python312\Lib\site-packages\g4f\client\client.py", line 123, in iter_image_response
    for chunk in list(response):
                 ^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\g4f\providers\base_provider.py", line 216, in create_completion
    yield loop.run_until_complete(await_callback(gen.__anext__))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\g4f\providers\base_provider.py", line 45, in await_callback
    return await callback()
           ^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\g4f\Provider\needs_auth\Openai.py", line 70, in create_async_generator
    await raise_for_status(response)
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python312\Lib\site-packages\g4f\requests\raise_for_status.py", line 28, in raise_for_status_async
    raise ResponseStatusError(f"Response {response.status}: {message}")
g4f.errors.ResponseStatusError: Response 404: {"error":{"message":"The model `meta-llama/Meta-Llama-3-70b-instruct` does not exist","type":"invalid_request_error","param":null,"code":"model_not_found"}}
hlohaus commented 2 months ago

Try using DeepInfraImage as the image_provider.

noneherel commented 2 months ago

Try using DeepInfraImage as the image_provider.

oh thanks that's worked.

but you are saying in the Image and Vision Models section of README that the provider for image is g4f.Provider.DeepInfra i think that's why i got confuse.

BTW thankyou it worked.