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
client = Client()
response = client.chat.completions.create(
model="gemini",
messages=[{"role": "user", "content": "What do you see?"}],
image=open("156_2.jpeg", "rb"),
)
print(response.choices[0].message.content)
Run result
Traceback (most recent call last):
File "/home/scvrlet/other/study/grad_work/ai_requests.py", line 83, 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/Gemini.py", line 146, in create_async_generator
image_url = await cls.upload_image(base_connector, to_bytes(image), image_name) if image else None
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/Provider/needs_auth/Gemini.py", line 229, in upload_image
await raise_for_status(response)
UnboundLocalError: local variable 'response' referenced before assignment
Environment
Python 3.10.12
location Switzerland
The text was updated successfully, but these errors were encountered:
Bug description
Can't upload an image.
Code
from g4f.client import Client
from g4f.cookies import set_cookies
set_cookies(
".google.com",
{
"__Secure-1PSID": "",
"__Secure-1PSIDCC": "",
"__Secure-1PSIDTS": "",
},
)
client = Client()
response = client.chat.completions.create(
model="gemini",
messages=[{"role": "user", "content": "What do you see?"}],
image=open("156_2.jpeg", "rb"),
)
print(response.choices[0].message.content)
Run result
Traceback (most recent call last):
File "/home/scvrlet/other/study/grad_work/ai_requests.py", line 83, 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/Gemini.py", line 146, in create_async_generator
image_url = await cls.upload_image(base_connector, to_bytes(image), image_name) if image else None
File "/home/scvrlet/.local/lib/python3.10/site-packages/g4f/Provider/needs_auth/Gemini.py", line 229, in upload_image
await raise_for_status(response)
UnboundLocalError: local variable 'response' referenced before assignment
Environment
Python 3.10.12
The text was updated successfully, but these errors were encountered: