You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run result
Traceback (most recent call last):
File "/home/scvrlet/other/study/grad_work/ai_requests.py", line 68, in
response = Client().chat.completions.create(
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/client/client.py", line 114, in create
return response if stream else next(response)
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/client/client.py", line 53, in iter_append_model_and_provider
for chunk in response:
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/client/client.py", line 28, in iter_response
for idx, chunk in enumerate(response):
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/providers/base_provider.py", line 216, in create_completion
yield loop.run_until_complete(await_callback(gen.anext))
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/providers/base_provider.py", line 45, in await_callback
return await callback()
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/Provider/needs_auth/OpenaiChat.py", line 473, in create_async_generator
data["messages"] = cls.create_messages(messages, image_request)
UnboundLocalError: local variable 'image_request' referenced before assignment
The text was updated successfully, but these errors were encountered:
Hey there! So, you'll need a Plus subscription if you want to upload images with OpenAI Chat. Plus, I've made some improvements to the error handling, so things should run a bit smoother now.
Code
import g4f
from g4f.client import Client
response = Client().chat.completions.create(
model="gpt-4",
provider=g4f.Provider.OpenaiChat,
messages=[{"role": "user", "content": "message"}],
image=open("joined_image.jpeg", "rb"),
image_name='joined_image.jpeg'
)
print(response.choices[0].message.content)
Run result
Traceback (most recent call last):
File "/home/scvrlet/other/study/grad_work/ai_requests.py", line 68, in
response = Client().chat.completions.create(
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/client/client.py", line 114, in create
return response if stream else next(response)
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/client/client.py", line 53, in iter_append_model_and_provider
for chunk in response:
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/client/client.py", line 28, in iter_response
for idx, chunk in enumerate(response):
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/providers/base_provider.py", line 216, in create_completion
yield loop.run_until_complete(await_callback(gen.anext))
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/providers/base_provider.py", line 45, in await_callback
return await callback()
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/Provider/needs_auth/OpenaiChat.py", line 473, in create_async_generator
data["messages"] = cls.create_messages(messages, image_request)
UnboundLocalError: local variable 'image_request' referenced before assignment
The text was updated successfully, but these errors were encountered: