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

TypeError: 'NoneType' object is not subscriptable while generating images #18

Closed
onur222 opened this issue May 31, 2024 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@onur222
Copy link

onur222 commented May 31, 2024

File "/gemini_webapi/client.py", line 370, in <listcomp> url=image[0][3][3], ~~~~~~~~^^^ TypeError: 'NoneType' object is not subscriptable

I receive this error while running this code:

`

async def main():
    client = GeminiClient(proxies=None)
    # Create Layout

    response = await client.generate_content("Generate some pictures of cats")
    print(response)

asyncio.run(main())

`

@HanaokaYuzu
Copy link
Owner

HanaokaYuzu commented May 31, 2024

Cannot reproduce. Does this happen every time or randomly? And can you try this prompt on https://gemini.google.com/app and see if it works?

@HanaokaYuzu HanaokaYuzu added the invalid This doesn't seem right label May 31, 2024
@onur222
Copy link
Author

onur222 commented Jun 7, 2024

I happens every time.
The code can produce images but links to those images are not returned.
I can see the images on https://gemini.google.com/app

I also can produce images on https://gemini.google.com/app with the same prompt.

@FuseFairy
Copy link

I have same issue.

@HanaokaYuzu HanaokaYuzu changed the title TypeError: 'NoneType' object is not subscriptable while generating imaged TypeError: 'NoneType' object is not subscriptable while generating images Aug 1, 2024
@HanaokaYuzu
Copy link
Owner

Unfortunately this error never happens on my side and I'm not able to debug it without the response body you got. Guess that for some reason response structure can be different by account or region.

Needs someone with basic python debugging skill to set a breakpoint here and find out the valid indexes (or simply print out and send the full condidate object to me).

generated_images = (
candidate[12]
and candidate[12][7]
and candidate[12][7][0]
and [
GeneratedImage(
url=image[0][3][3],
title=f"[Generated Image {image[3][6]}]",
alt=len(image[3][5]) > i
and image[3][5][i]
or image[3][5][0],
proxies=self.proxies,
cookies=self.cookies,
)
for i, image in enumerate(candidate[12][7][0])
]
or []
)

@HanaokaYuzu HanaokaYuzu added bug Something isn't working help wanted Extra attention is needed and removed invalid This doesn't seem right labels Aug 1, 2024
@HanaokaYuzu HanaokaYuzu removed the help wanted Extra attention is needed label Sep 11, 2024
@HanaokaYuzu
Copy link
Owner

Fixed in #34

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

3 participants