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

Currently, nowhere on here where it states you require loguru #2

Closed
Fantasticj1 opened this issue Feb 25, 2024 · 4 comments
Closed

Comments

@Fantasticj1
Copy link

Might want to either have it auto install or put it in the git somewhere

@johnd0e
Copy link

johnd0e commented Feb 25, 2024

It seems that there are 2 packages missed in setup.py

  • loguru
  • pydantic

@dsdanielpark
Copy link
Owner

Thank you!

@dsdanielpark
Copy link
Owner

johnd0e, Fantasticj1

Please, try to use 1.0.4 or above!

We are currently modifying the package with a focus on extensive code refactoring and future maintainability, so errors may occur. We are also in the process of making adjustments to the returned dictionary for easier access in the future.

We appreciate your understanding. Thank you!!!

python uninstall python-gemini-api
python install python-gemini-api==1.0.4

@johnd0e
Copy link

johnd0e commented Mar 6, 2024

  1. GeminiClient = Gemini(cookie_fp="cookies.json")
    For this case instructions recommends ExportThisCookies, but does not mentioned that downloaded with it cookies.txt is not real json: it is necessary to trim cookies = to make it valid json.
    But even with this I have no success:

    Error loading cookie file: 'Gemini' object has no attribute 'session'
    Traceback (most recent call last):
      File "D:\AI\Gemini-API\test2.py", line 11, in <module>
        GeminiClient = Gemini(cookie_fp="cookies.json") # Or use cookie file path
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "D:\AI\Gemini-API\gemini\core.py", line 66, in __init__
        self.session = session or self._initialize_session()
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "D:\AI\Gemini-API\gemini\core.py", line 94, in _initialize_session
        self._set_sid_and_nonce()
      File "D:\AI\Gemini-API\gemini\core.py", line 213, in _set_sid_and_nonce
        self._nonce = re.search(r'"SNlM0e":"(.*?)"', response.text).group(1)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'group'
    
  2. GeminiClient = Gemini(cookies=cookies) (where cookies are __Secure-1PSID, __Secure-1PSIDTS)
    I get an output, but it is not very helpful:

    {'metadata': ['c_409da1520e77ed5f', 'r_f3670ae69c52a4e1'], 'candidates': {'rcid': 'rc_594f1013ce897401', 'text': 'http://googleusercontent.com/card_content/0', 'web_images': [], 'generated_images': []}}
    
  3. GeminiClient = Gemini(auto_cookies=True) does not work:

    Traceback (most recent call last):
      File "D:\AI\Gemini-API\test.py", line 3, in <module>
        GeminiClient = Gemini(auto_cookies=True)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "D:\AI\Gemini-API\gemini\core.py", line 66, in __init__
        self.session = session or self._initialize_session()
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "D:\AI\Gemini-API\gemini\core.py", line 92, in _initialize_session
        self._set_cookies_automatically()
      File "D:\AI\Gemini-API\gemini\core.py", line 141, in _set_cookies_automatically
        if len(getattr(self, "cookies", {})) > 5:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: object of type 'NoneType' has no len()
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants