Open LuxerIThink opened 7 months ago
Hello, LuxerIThink
This has already been developed and will be updated today.
It will be provided as asynchronous code that can save to a bytetype image or path. Thank you for your valuable feedback!
Getting same error
Getting same error
Please, try to this code.
from gemini import Gemini, GeminiImage
response = GeminiClient.generate_content("Create illustrations of Seoul, South Korea.")
generated_images = response.generated_images # Check generated images [Dict]
GeminiImage.save_sync(generated_images, save_path="cached")
# You can use byte type image dict for printing images as follow:
bytes_images_dict = GeminiImage.fetch_images_dict_sync(generated_images, cookies) # Get bytes images dict
from IPython.display import display, Image
import io
for image_name, image_bytes in bytes_images_dict.items():
print(image_name)
image = Image(data=image_bytes)
display(image)
# GeminiImage.save_images_sync(bytes_images_dict, path="cached") # Save to path
Getting same error
Please, try to this code.
from gemini import Gemini, GeminiImage response = GeminiClient.generate_content("Create illustrations of Seoul, South Korea.") generated_images = response.generated_images # Check generated images [Dict] GeminiImage.save_sync(generated_images, save_path="cached") # You can use byte type image dict for printing images as follow: bytes_images_dict = GeminiImage.fetch_images_dict_sync(generated_images, cookies) # Get bytes images dict from IPython.display import display, Image import io for image_name, image_bytes in bytes_images_dict.items(): print(image_name) image = Image(data=image_bytes) display(image) # GeminiImage.save_images_sync(bytes_images_dict, path="cached") # Save to path
Code you give us in here can't work (because cookies are not defined), but this is problem with texts not with images (I don't tested them).
Most of all, try rerunning the generate_content method without redeclaring the Gemini object.
Initial Empty Response: Check if the first response is empty due to initial data fetching by the application. Retry after a short wait.
Premature Response: Wait for a minute after the first attempt if the server settings might not be complete. Avoid redeclaring the Gemini object.
generate_content
method again. Ensure not to redeclare the Gemini object, as repeated object declarations or exporting cookies can lead to 'undefined' cookie values and errors. It's suspected that internal interfaces might reset cookies upon detection, possibly through a RotateCookie process.Logout and Restart: Log out from all synchronized Chrome accounts, cancel synchronization, and restart the browser.
Cookie Sync Issues: If the same cookies work on one PC but not another, try a fresh browser environment or delete all cookies before accessing Gemini again.
New Account or Region: Create a new Google account or set a new default country in the account settings.
Valid Cookies in Different Environments: Try using a different Google account in a new browser if valid cookies do not work.
Few Valid Cookies: Input a small number of valid cookie values as suggested on the authentication section, may require country-specific experimentation.
Other User Solutions: Look at solutions provided by other users on the issue page.
If you've found a suitable solution to this issue, please share your experience on this issue page. Thank you.
Hey, guys!
Make sure you're using version 2.4.2
or later and manually pass the complete cookie (avoid using auto_cookie).
Please test this script with the complete set of cookies collected manually: https://github.com/dsdanielpark/Gemini-API/blob/main/scripts/sample.ipynb
Using VPN or public IP, facing temporary blocks like 429 errors (due to repeated requests or authentication attempts) can disrupt the SSL/TLS handshake, resulting in an empty response. This issue isn't limited to specific accounts and might require IP-based circumvention.
Still with the return message :
{'metadata': ['c_c4d1c4aed0cb5eXX', 'r_3214ea893c673dXX'], 'prompt_class': None, 'prompt_candidates': [], 'candidates': [{'rcid': 'rc_5fbed4cbaf9e71XX', 'text': 'http://googleusercontent.com/card_content/0', 'code': {}, 'web_images': [], 'generated_images': []}]}
Describe the bug The response text is returned in a URL format that cannot be seen.
Version OS: Windows 11 Python: 3.12.2 Gemini API: 1.0.4 Using proxy: No Region: Poland
Code
Error