Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

It returns message "maximum recursion depth exceeded" #19

Closed
phamxtien opened this issue Mar 11, 2024 · 14 comments
Closed

It returns message "maximum recursion depth exceeded" #19

phamxtien opened this issue Mar 11, 2024 · 14 comments
Assignees
Labels
bug Something isn't working inprogress

Comments

@phamxtien
Copy link

Describe the bug
Gemini returns message "maximum recursion depth exceeded"

Version
OS: Ubuntu 23.10
Python: 3.11
Gemini API: 2.0.0
Using proxy: None
Legion:

Code

from gemini import Gemini

cookies = {} # I input my cookies here as decribe in README
GeminiClient = Gemini(cookies=cookies)

prompt = "hello, how are you?"
response = GeminiClient.generate_content(prompt)

print(response.response.dict)

Error

It returns "maximum recursion depth exceeded"
I check on gemini.google.com/app, 
it has sent prompt to gemini but not get answer from gemini.google.com/app as below image 
Bard API still runs smooth!

image

@dsdanielpark
Copy link
Owner

Thank you for reporting.

Please give me tracebacked error message.

@cacko
Copy link

cacko commented Mar 14, 2024

looks like it returns attachment instead of text now, response.bin, dunno have not dig much, so sorry if that makes no sense

@dsdanielpark
Copy link
Owner

Would it still work if I leave the Gemini object as is and only rerun the generate content method? I'll check again tomorrow. I was aware of the bot server change, but since the old bot server was still running, I didn't make the switch, though I'm a bit scared, I'll check it again.

Before posting it on the readme, I'll first post it on this issue page. Since it's difficult to code and check, I'll get back to you within 12 hours!

Thank you.

@PushkarOP
Copy link

PushkarOP commented Mar 15, 2024

Traceback (most recent call last):
  File "c:\Users\Divyanshi\Desktop\New\tets.py", line 83, in <module>
    print(geminiultra("What is the capital of France? also show images"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Divyanshi\Desktop\New\tets.py", line 45, in geminiultra
    answer = response.response_dict['candidates']['text']
             ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Divyanshi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gemini\src\model\output.py", line 47, in response_dict
    return self.response_dict
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Divyanshi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gemini\src\model\output.py", line 47, in response_dict
    return self.response_dict
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Divyanshi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gemini\src\model\output.py", line 47, in response_dict
    return self.response_dict
           ^^^^^^^^^^^^^^^^^^
  [Previous line repeated 995 more times]
RecursionError: maximum recursion depth exceeded
Traceback (most recent call last):
  File "c:\Users\Divyanshi\Desktop\New\tets.py", line 84, in <module>
    print(geminiultra("What is the capital of France? also show images"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Divyanshi\Desktop\New\tets.py", line 44, in geminiultra
    response = GeminiClient.generate_content(prompt)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Divyanshi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gemini\core.py", line 263, in generate_content
    return self._create_model_output(parsed_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Divyanshi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gemini\core.py", line 275, in _create_model_output
    candidates = self.collect_candidates(parsed_response)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Divyanshi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gemini\core.py", line 308, in collect_candidates
    collected.append(GeminiCandidate(**current))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pydantic\main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for GeminiCandidate
code
  value is not a valid list (type=type_error.list)

@dsdanielpark
Copy link
Owner

Thank you for reporting. I will check this issue ASAP.

@phamxtien
Copy link
Author

I just update to Ver 2.2.0 and it still returns "maximum recursion depth exceeded"

@dsdanielpark
Copy link
Owner

dsdanielpark commented Mar 17, 2024

phamxtien
The update in Python 3.11 is suspected to cause recursive calls leading to a "recursive exceed" error.

However, recognizing that errors could technically occur in that syntax, I have clarified and corrected it again.

I've made modifications to change the recursive calls in property definitions in GeminiModelOutput. Could you please reinstall the version from GitHub and check again?

pip install git+https://github.com/dsdanielpark/Gemini-API.git

or try to using v2.2.1

@phamxtien
Copy link
Author

Thank you for your guide
I just get newest source and it still return the same error
I will try with python3 3.8

@dsdanielpark
Copy link
Owner

Are you sure to use print(response.response_dict) ?

Or try to use rint(response.payload)

It seems the issue is related to a property, which might confuse other users. I'm concerned but will fix it as soon as possible. Please keep following the issue for updates; I'll correct it soon and adjust the settings to address the error. In reality, there's still a lot to refactor and implement, but due to a busy schedule, I haven't been able to devote much time to it. Thank you.

@phamxtien
Copy link
Author

use print(response.response_dict) ?

I use print(response.response_dict)

@dsdanielpark dsdanielpark added the bug Something isn't working label Mar 18, 2024
dsdanielpark added a commit that referenced this issue Mar 18, 2024
@dsdanielpark
Copy link
Owner

phamxtien

I release v2.2.2. Could you check?

@ghost
Copy link

ghost commented Mar 18, 2024

rint(response.payload)

it works, and response format is also changed

{'metadata': ['c_37bce86328f5eb0c', 'r_7ad361e5f2e31296'], 'prompt_class': None, 'prompt_candidates': [], 'candidates': [{'rcid': 'rc_dcc7ef3199425605', 'text': 'The capital of France is Paris. It is a major European city and a global center for art, fashion, gastronomy, and culture. \n[Image of Paris, France] ', 'code': {}, 'web_images': [{'url': 'https://sa.visamiddleeast.com/dam/VCOM/regional/cemea/generic-cemea/travel-with-visa/destinations/paris/marquee-travel-paris-800x450.jpg', 'title': '[Image of Paris, France]', 'alt': 'Paris, France'}], 'generated_images': []}, {'rcid': 'rc_af89988c3898dec1', 'text': 'The capital of France is Paris.  Paris is a major world center for art, fashion, cuisine, and culture.   \n[Image of Paris, France]', 'code': {}, 'web_images': [{'url': 'https://sa.visamiddleeast.com/dam/VCOM/regional/cemea/generic-cemea/travel-with-visa/destinations/paris/marquee-travel-paris-800x450.jpg', 'title': '[Image of 
Paris, France]', 'alt': 'Paris, France'}], 'generated_images': []}, {'rcid': 'rc_daf9c135dc80150a', 'text': "The capital of France is Paris. It's a major European city and a global center for art, fashion, gastronomy, and culture. \n[Image of Paris, France]", 'code': {}, 'web_images': [{'url': 'https://sa.visamiddleeast.com/dam/VCOM/regional/cemea/generic-cemea/travel-with-visa/destinations/paris/marquee-travel-paris-800x450.jpg', 'title': '[Image of Paris, France]', 'alt': 'Paris, France'}], 'generated_images': []}]}

@phamxtien
Copy link
Author

phamxtien

I release v2.2.2. Could you check?

Thanks, it runs smooth

@dsdanielpark
Copy link
Owner

Thank you for reporting! Have a nice day. I will close this issue as complet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working inprogress
Projects
None yet
Development

No branches or pull requests

4 participants