gemini-webapi 1.12.2__py3-none-any.whl → 1.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gemini_webapi/__init__.py +1 -1
- gemini_webapi/client.py +2 -2
- gemini_webapi/constants.py +3 -3
- gemini_webapi/utils/logger.py +27 -29
- {gemini_webapi-1.12.2.dist-info → gemini_webapi-1.13.0.dist-info}/METADATA +8 -4
- {gemini_webapi-1.12.2.dist-info → gemini_webapi-1.13.0.dist-info}/RECORD +9 -9
- {gemini_webapi-1.12.2.dist-info → gemini_webapi-1.13.0.dist-info}/WHEEL +0 -0
- {gemini_webapi-1.12.2.dist-info → gemini_webapi-1.13.0.dist-info}/licenses/LICENSE +0 -0
- {gemini_webapi-1.12.2.dist-info → gemini_webapi-1.13.0.dist-info}/top_level.txt +0 -0
gemini_webapi/__init__.py
CHANGED
gemini_webapi/client.py
CHANGED
|
@@ -422,7 +422,7 @@ class GeminiClient:
|
|
|
422
422
|
for candidate_index, candidate in enumerate(body[4]):
|
|
423
423
|
text = candidate[1][0]
|
|
424
424
|
if re.match(
|
|
425
|
-
r"^http://googleusercontent\.com/card_content/\d
|
|
425
|
+
r"^http://googleusercontent\.com/card_content/\d+", text
|
|
426
426
|
):
|
|
427
427
|
text = candidate[22] and candidate[22][0] or text
|
|
428
428
|
|
|
@@ -470,7 +470,7 @@ class GeminiClient:
|
|
|
470
470
|
img_candidate = img_body[4][candidate_index]
|
|
471
471
|
|
|
472
472
|
text = re.sub(
|
|
473
|
-
r"http://googleusercontent\.com/image_generation_content/\d
|
|
473
|
+
r"http://googleusercontent\.com/image_generation_content/\d+",
|
|
474
474
|
"",
|
|
475
475
|
img_candidate[1][0],
|
|
476
476
|
).rstrip()
|
gemini_webapi/constants.py
CHANGED
|
@@ -27,7 +27,7 @@ class Model(Enum):
|
|
|
27
27
|
UNSPECIFIED = ("unspecified", {}, False)
|
|
28
28
|
G_2_5_FLASH = (
|
|
29
29
|
"gemini-2.5-flash",
|
|
30
|
-
{"x-goog-ext-525001261-jspb": '[1,null,null,null,"
|
|
30
|
+
{"x-goog-ext-525001261-jspb": '[1,null,null,null,"71c2d248d3b102ff"]'},
|
|
31
31
|
False,
|
|
32
32
|
)
|
|
33
33
|
G_2_5_PRO = (
|
|
@@ -49,12 +49,12 @@ class Model(Enum):
|
|
|
49
49
|
"gemini-2.0-exp-advanced",
|
|
50
50
|
{"x-goog-ext-525001261-jspb": '[null,null,null,null,"b1e46a6037e6aa9f"]'},
|
|
51
51
|
True,
|
|
52
|
-
)
|
|
52
|
+
) # Deprecated
|
|
53
53
|
G_2_5_EXP_ADVANCED = (
|
|
54
54
|
"gemini-2.5-exp-advanced",
|
|
55
55
|
{"x-goog-ext-525001261-jspb": '[null,null,null,null,"203e6bb81620bcfe"]'},
|
|
56
56
|
True,
|
|
57
|
-
)
|
|
57
|
+
) # Deprecated
|
|
58
58
|
|
|
59
59
|
def __init__(self, name, header, advanced_only):
|
|
60
60
|
self.model_name = name
|
gemini_webapi/utils/logger.py
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
from
|
|
1
|
+
import sys
|
|
2
|
+
from loguru import logger as _logger
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
from loguru._logger import Logger as _Logger
|
|
4
|
+
_handler_id = None
|
|
6
5
|
|
|
7
|
-
logger = _Logger(
|
|
8
|
-
core=_Core(),
|
|
9
|
-
exception=None,
|
|
10
|
-
depth=0,
|
|
11
|
-
record=False,
|
|
12
|
-
lazy=False,
|
|
13
|
-
colors=False,
|
|
14
|
-
raw=False,
|
|
15
|
-
capture=True,
|
|
16
|
-
patchers=[],
|
|
17
|
-
extra={},
|
|
18
|
-
)
|
|
19
6
|
|
|
20
|
-
|
|
21
|
-
logger.add(stderr, level="INFO")
|
|
22
|
-
|
|
23
|
-
atexit.register(logger.remove)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def set_log_level(level: str):
|
|
7
|
+
def set_log_level(level: str | int) -> None:
|
|
27
8
|
"""
|
|
28
|
-
Set the log level for
|
|
9
|
+
Set the log level for gemini_webapi. The default log level is "INFO".
|
|
10
|
+
|
|
11
|
+
Note: calling this function for the first time will globally remove all existing loguru
|
|
12
|
+
handlers. To avoid this, you may want to set logging behaviors directly with loguru.
|
|
29
13
|
|
|
30
14
|
Parameters
|
|
31
15
|
----------
|
|
32
|
-
level : str
|
|
33
|
-
|
|
16
|
+
level : `str | int`
|
|
17
|
+
Log level: "TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
|
|
18
|
+
|
|
19
|
+
Examples
|
|
20
|
+
--------
|
|
21
|
+
>>> from gemini_webapi import set_log_level
|
|
22
|
+
>>> set_log_level("DEBUG") # Show debug messages
|
|
23
|
+
>>> set_log_level("ERROR") # Only show errors
|
|
34
24
|
"""
|
|
35
25
|
|
|
36
|
-
|
|
26
|
+
global _handler_id
|
|
27
|
+
|
|
28
|
+
_logger.remove(_handler_id)
|
|
29
|
+
|
|
30
|
+
_handler_id = _logger.add(
|
|
31
|
+
sys.stderr,
|
|
32
|
+
level=level,
|
|
33
|
+
filter=lambda record: record["extra"].get("name") == "gemini_webapi",
|
|
34
|
+
)
|
|
35
|
+
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
logger.add(stderr, level=level)
|
|
37
|
+
logger = _logger.bind(name="gemini_webapi")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gemini-webapi
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.13.0
|
|
4
4
|
Summary: ✨ An elegant async Python wrapper for Google Gemini web app
|
|
5
5
|
Author: UZQueen
|
|
6
6
|
License: GNU AFFERO GENERAL PUBLIC LICENSE
|
|
@@ -736,7 +736,7 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
|
|
|
736
736
|
- [Generate images with Imagen3](#generate-images-with-imagen3)
|
|
737
737
|
- [Generate contents with Gemini extensions](#generate-contents-with-gemini-extensions)
|
|
738
738
|
- [Check and switch to other reply candidates](#check-and-switch-to-other-reply-candidates)
|
|
739
|
-
- [
|
|
739
|
+
- [Logging Configuration](#logging-configuration)
|
|
740
740
|
- [References](#references)
|
|
741
741
|
- [Stargazers](#stargazers)
|
|
742
742
|
|
|
@@ -1036,9 +1036,9 @@ async def main():
|
|
|
1036
1036
|
asyncio.run(main())
|
|
1037
1037
|
```
|
|
1038
1038
|
|
|
1039
|
-
###
|
|
1039
|
+
### Logging Configuration
|
|
1040
1040
|
|
|
1041
|
-
|
|
1041
|
+
This package uses [loguru](https://loguru.readthedocs.io/en/stable/) for logging, and exposes a function `set_log_level` to control log level. You can set log level to one of the following values: `DEBUG`, `INFO`, `WARNING`, `ERROR` and `CRITICAL`. The default value is `INFO`.
|
|
1042
1042
|
|
|
1043
1043
|
```python
|
|
1044
1044
|
from gemini_webapi import set_log_level
|
|
@@ -1046,6 +1046,10 @@ from gemini_webapi import set_log_level
|
|
|
1046
1046
|
set_log_level("DEBUG")
|
|
1047
1047
|
```
|
|
1048
1048
|
|
|
1049
|
+
> [!NOTE]
|
|
1050
|
+
>
|
|
1051
|
+
> Calling `set_log_level` for the first time will **globally** remove all existing loguru handlers. You may want to configure logging directly with loguru to avoid this issue and have more advanced control over logging behaviors.
|
|
1052
|
+
|
|
1049
1053
|
## References
|
|
1050
1054
|
|
|
1051
1055
|
[Google AI Studio](https://ai.google.dev/tutorials/ai-studio_quickstart)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
gemini_webapi/__init__.py,sha256=
|
|
2
|
-
gemini_webapi/client.py,sha256=
|
|
3
|
-
gemini_webapi/constants.py,sha256=
|
|
1
|
+
gemini_webapi/__init__.py,sha256=UBrwmqT-7nWrEr90xz78KqWqMIdapIdjkUyYEZsIktc,202
|
|
2
|
+
gemini_webapi/client.py,sha256=wyLDWl-CXLg4YN13HqWj8TKX-IzAzArDP8Jwofppj18,25396
|
|
3
|
+
gemini_webapi/constants.py,sha256=2KKPqz0r3DKYuxQhwCQpTBQmp9sqFMrH88n3wG41V7g,2572
|
|
4
4
|
gemini_webapi/exceptions.py,sha256=qkXrIpr0L7LtGbq3VcTO8D1xZ50pJtt0dDRp5I3uDSg,1038
|
|
5
5
|
gemini_webapi/types/__init__.py,sha256=d2kvXnE004s2E2KDmPPLi5N-BQ59FgDSlrGrO3Wphww,163
|
|
6
6
|
gemini_webapi/types/candidate.py,sha256=67BhY75toE5mVuB21cmHcTFtw332V_KmCjr3-9VTbJo,1477
|
|
@@ -9,11 +9,11 @@ gemini_webapi/types/modeloutput.py,sha256=h07kQOkL5r-oPLvZ59uVtO1eP4FGy5ZpzuYQzA
|
|
|
9
9
|
gemini_webapi/utils/__init__.py,sha256=tO6Sx-3fcPeyITZcvUmcFKBFlR5XW87xUFbNrIh3_mE,374
|
|
10
10
|
gemini_webapi/utils/get_access_token.py,sha256=uyb6tuzPr3mHttCjiM86M29ykrnHqsUClYdf5sVkyEQ,5465
|
|
11
11
|
gemini_webapi/utils/load_browser_cookies.py,sha256=A5n_VsB7Rm8ck5lpy856UNJEhv30l3dvQ3j0g3ln1fE,1535
|
|
12
|
-
gemini_webapi/utils/logger.py,sha256=
|
|
12
|
+
gemini_webapi/utils/logger.py,sha256=0VcxhVLhHBRDQutNCpapP1y_MhPoQ2ud1uIFLqxC3Z8,958
|
|
13
13
|
gemini_webapi/utils/rotate_1psidts.py,sha256=NyQ9OYPLBOcvpc8bodvEYDIVFrsYN0kdfc831lPEctM,1680
|
|
14
14
|
gemini_webapi/utils/upload_file.py,sha256=SJOMr6kryK_ClrKmqI96fqZBNFOMPsyAvFINAGAU3rk,1468
|
|
15
|
-
gemini_webapi-1.
|
|
16
|
-
gemini_webapi-1.
|
|
17
|
-
gemini_webapi-1.
|
|
18
|
-
gemini_webapi-1.
|
|
19
|
-
gemini_webapi-1.
|
|
15
|
+
gemini_webapi-1.13.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
16
|
+
gemini_webapi-1.13.0.dist-info/METADATA,sha256=4JhYUbv5-iqYquPepYL_wE46lut6y6dFw5DFdBP89vg,57546
|
|
17
|
+
gemini_webapi-1.13.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
18
|
+
gemini_webapi-1.13.0.dist-info/top_level.txt,sha256=dtWtug_ZrmnUqCYuu8NmGzTgWglHeNzhHU_hXmqZGWE,14
|
|
19
|
+
gemini_webapi-1.13.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|