gemini-webapi 1.18.0__tar.gz → 1.18.1__tar.gz
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-1.18.0 → gemini_webapi-1.18.1}/PKG-INFO +20 -2
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/README.md +19 -1
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/client.py +20 -1
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/components/gem_mixin.py +11 -3
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/constants.py +1 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/parsing.py +1 -1
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/PKG-INFO +20 -2
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/tests/test_client_features.py +8 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/.github/dependabot.yml +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/.github/workflows/github-release.yml +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/.github/workflows/pypi-publish.yml +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/.gitignore +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/.vscode/launch.json +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/.vscode/settings.json +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/LICENSE +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/assets/banner.png +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/assets/favicon.png +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/assets/logo.svg +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/assets/sample.pdf +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/pyproject.toml +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/setup.cfg +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/__init__.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/components/__init__.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/exceptions.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/types/__init__.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/types/candidate.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/types/gem.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/types/grpc.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/types/image.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/types/modeloutput.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/__init__.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/decorators.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/get_access_token.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/load_browser_cookies.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/logger.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/rotate_1psidts.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/upload_file.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/SOURCES.txt +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/dependency_links.txt +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/requires.txt +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/top_level.txt +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/tests/test_gem_mixin.py +0 -0
- {gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/tests/test_save_image.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gemini-webapi
|
|
3
|
-
Version: 1.18.
|
|
3
|
+
Version: 1.18.1
|
|
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
|
|
@@ -733,6 +733,7 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
|
|
|
733
733
|
- [Generate contents with files](#generate-contents-with-files)
|
|
734
734
|
- [Conversations across multiple turns](#conversations-across-multiple-turns)
|
|
735
735
|
- [Continue previous conversations](#continue-previous-conversations)
|
|
736
|
+
- [Delete previous conversations from Gemini history](#delete-previous-conversations-from-gemini-history)
|
|
736
737
|
- [Streaming mode](#streaming-mode)
|
|
737
738
|
- [Select language model](#select-language-model)
|
|
738
739
|
- [Apply system prompt with Gemini Gems](#apply-system-prompt-with-gemini-gems)
|
|
@@ -903,6 +904,23 @@ async def main():
|
|
|
903
904
|
asyncio.run(main())
|
|
904
905
|
```
|
|
905
906
|
|
|
907
|
+
### Delete previous conversations from Gemini history
|
|
908
|
+
|
|
909
|
+
You can delete a specific chat from Gemini history on the server by calling `GeminiClient.delete_chat` with the chat id.
|
|
910
|
+
|
|
911
|
+
```python
|
|
912
|
+
async def main():
|
|
913
|
+
# Start a new chat session
|
|
914
|
+
chat = client.start_chat()
|
|
915
|
+
await chat.send_message("This is a temporary conversation.")
|
|
916
|
+
|
|
917
|
+
# Delete the chat
|
|
918
|
+
await client.delete_chat(chat.cid)
|
|
919
|
+
print(f"Chat deleted: {chat.cid}")
|
|
920
|
+
|
|
921
|
+
asyncio.run(main())
|
|
922
|
+
```
|
|
923
|
+
|
|
906
924
|
### Streaming mode
|
|
907
925
|
|
|
908
926
|
For longer responses, you can use streaming mode to receive partial outputs as they are generated. This provides a more responsive user experience, especially for real-time applications like chatbots.
|
|
@@ -981,7 +999,7 @@ System prompt can be applied to conversations via [Gemini Gems](https://gemini.g
|
|
|
981
999
|
```python
|
|
982
1000
|
async def main():
|
|
983
1001
|
# Fetch all gems for the current account, including both predefined and user-created ones
|
|
984
|
-
await client.fetch_gems(include_hidden=False)
|
|
1002
|
+
await client.fetch_gems(include_hidden=False, language="en")
|
|
985
1003
|
|
|
986
1004
|
# Once fetched, gems will be cached in `GeminiClient.gems`
|
|
987
1005
|
gems = client.gems
|
|
@@ -49,6 +49,7 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
|
|
|
49
49
|
- [Generate contents with files](#generate-contents-with-files)
|
|
50
50
|
- [Conversations across multiple turns](#conversations-across-multiple-turns)
|
|
51
51
|
- [Continue previous conversations](#continue-previous-conversations)
|
|
52
|
+
- [Delete previous conversations from Gemini history](#delete-previous-conversations-from-gemini-history)
|
|
52
53
|
- [Streaming mode](#streaming-mode)
|
|
53
54
|
- [Select language model](#select-language-model)
|
|
54
55
|
- [Apply system prompt with Gemini Gems](#apply-system-prompt-with-gemini-gems)
|
|
@@ -219,6 +220,23 @@ async def main():
|
|
|
219
220
|
asyncio.run(main())
|
|
220
221
|
```
|
|
221
222
|
|
|
223
|
+
### Delete previous conversations from Gemini history
|
|
224
|
+
|
|
225
|
+
You can delete a specific chat from Gemini history on the server by calling `GeminiClient.delete_chat` with the chat id.
|
|
226
|
+
|
|
227
|
+
```python
|
|
228
|
+
async def main():
|
|
229
|
+
# Start a new chat session
|
|
230
|
+
chat = client.start_chat()
|
|
231
|
+
await chat.send_message("This is a temporary conversation.")
|
|
232
|
+
|
|
233
|
+
# Delete the chat
|
|
234
|
+
await client.delete_chat(chat.cid)
|
|
235
|
+
print(f"Chat deleted: {chat.cid}")
|
|
236
|
+
|
|
237
|
+
asyncio.run(main())
|
|
238
|
+
```
|
|
239
|
+
|
|
222
240
|
### Streaming mode
|
|
223
241
|
|
|
224
242
|
For longer responses, you can use streaming mode to receive partial outputs as they are generated. This provides a more responsive user experience, especially for real-time applications like chatbots.
|
|
@@ -297,7 +315,7 @@ System prompt can be applied to conversations via [Gemini Gems](https://gemini.g
|
|
|
297
315
|
```python
|
|
298
316
|
async def main():
|
|
299
317
|
# Fetch all gems for the current account, including both predefined and user-created ones
|
|
300
|
-
await client.fetch_gems(include_hidden=False)
|
|
318
|
+
await client.fetch_gems(include_hidden=False, language="en")
|
|
301
319
|
|
|
302
320
|
# Once fetched, gems will be cached in `GeminiClient.gems`
|
|
303
321
|
gems = client.gems
|
|
@@ -832,6 +832,25 @@ class GeminiClient(GemMixin):
|
|
|
832
832
|
|
|
833
833
|
return ChatSession(geminiclient=self, **kwargs)
|
|
834
834
|
|
|
835
|
+
async def delete_chat(self, cid: str) -> None:
|
|
836
|
+
"""
|
|
837
|
+
Delete a specific conversation by chat id.
|
|
838
|
+
|
|
839
|
+
Parameters
|
|
840
|
+
----------
|
|
841
|
+
cid: `str`
|
|
842
|
+
The ID of the chat requiring deletion (e.g. "c_...").
|
|
843
|
+
"""
|
|
844
|
+
|
|
845
|
+
await self._batch_execute(
|
|
846
|
+
[
|
|
847
|
+
RPCData(
|
|
848
|
+
rpcid=GRPC.DELETE_CHAT,
|
|
849
|
+
payload=json.dumps([cid]),
|
|
850
|
+
),
|
|
851
|
+
]
|
|
852
|
+
)
|
|
853
|
+
|
|
835
854
|
@running(retry=2)
|
|
836
855
|
async def _batch_execute(self, payloads: list[RPCData], **kwargs) -> Response:
|
|
837
856
|
"""
|
|
@@ -856,7 +875,7 @@ class GeminiClient(GemMixin):
|
|
|
856
875
|
|
|
857
876
|
try:
|
|
858
877
|
params: dict[str, Any] = {
|
|
859
|
-
"rpcids": ",".join([p.rpcid
|
|
878
|
+
"rpcids": ",".join([p.rpcid for p in payloads]),
|
|
860
879
|
"_reqid": _reqid,
|
|
861
880
|
"rt": "c",
|
|
862
881
|
"source-path": "/app",
|
|
@@ -41,7 +41,9 @@ class GemMixin:
|
|
|
41
41
|
|
|
42
42
|
return self._gems
|
|
43
43
|
|
|
44
|
-
async def fetch_gems(
|
|
44
|
+
async def fetch_gems(
|
|
45
|
+
self, include_hidden: bool = False, language: str = "en", **kwargs
|
|
46
|
+
) -> GemJar:
|
|
45
47
|
"""
|
|
46
48
|
Get a list of available gems from gemini, including system predefined gems and user-created custom gems.
|
|
47
49
|
|
|
@@ -53,6 +55,8 @@ class GemMixin:
|
|
|
53
55
|
include_hidden: `bool`, optional
|
|
54
56
|
There are some predefined gems that by default are not shown to users (and therefore may not work properly).
|
|
55
57
|
Set this parameter to `True` to include them in the fetched gem list.
|
|
58
|
+
language: `str`, optional
|
|
59
|
+
Language code for the gems to fetch. Default is 'en'.
|
|
56
60
|
|
|
57
61
|
Returns
|
|
58
62
|
-------
|
|
@@ -64,12 +68,16 @@ class GemMixin:
|
|
|
64
68
|
[
|
|
65
69
|
RPCData(
|
|
66
70
|
rpcid=GRPC.LIST_GEMS,
|
|
67
|
-
payload=
|
|
71
|
+
payload=(
|
|
72
|
+
f"[4,['{language}'],0]"
|
|
73
|
+
if include_hidden
|
|
74
|
+
else f"[3,['{language}'],0]"
|
|
75
|
+
),
|
|
68
76
|
identifier="system",
|
|
69
77
|
),
|
|
70
78
|
RPCData(
|
|
71
79
|
rpcid=GRPC.LIST_GEMS,
|
|
72
|
-
payload="[2]",
|
|
80
|
+
payload=f"[2,['{language}'],0]",
|
|
73
81
|
identifier="custom",
|
|
74
82
|
),
|
|
75
83
|
],
|
|
@@ -56,7 +56,7 @@ def get_nested_value(
|
|
|
56
56
|
for i, key in enumerate(path):
|
|
57
57
|
found = False
|
|
58
58
|
if isinstance(key, int):
|
|
59
|
-
if isinstance(current, list) and
|
|
59
|
+
if isinstance(current, list) and -len(current) <= key < len(current):
|
|
60
60
|
current = current[key]
|
|
61
61
|
found = True
|
|
62
62
|
elif isinstance(key, str):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gemini-webapi
|
|
3
|
-
Version: 1.18.
|
|
3
|
+
Version: 1.18.1
|
|
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
|
|
@@ -733,6 +733,7 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
|
|
|
733
733
|
- [Generate contents with files](#generate-contents-with-files)
|
|
734
734
|
- [Conversations across multiple turns](#conversations-across-multiple-turns)
|
|
735
735
|
- [Continue previous conversations](#continue-previous-conversations)
|
|
736
|
+
- [Delete previous conversations from Gemini history](#delete-previous-conversations-from-gemini-history)
|
|
736
737
|
- [Streaming mode](#streaming-mode)
|
|
737
738
|
- [Select language model](#select-language-model)
|
|
738
739
|
- [Apply system prompt with Gemini Gems](#apply-system-prompt-with-gemini-gems)
|
|
@@ -903,6 +904,23 @@ async def main():
|
|
|
903
904
|
asyncio.run(main())
|
|
904
905
|
```
|
|
905
906
|
|
|
907
|
+
### Delete previous conversations from Gemini history
|
|
908
|
+
|
|
909
|
+
You can delete a specific chat from Gemini history on the server by calling `GeminiClient.delete_chat` with the chat id.
|
|
910
|
+
|
|
911
|
+
```python
|
|
912
|
+
async def main():
|
|
913
|
+
# Start a new chat session
|
|
914
|
+
chat = client.start_chat()
|
|
915
|
+
await chat.send_message("This is a temporary conversation.")
|
|
916
|
+
|
|
917
|
+
# Delete the chat
|
|
918
|
+
await client.delete_chat(chat.cid)
|
|
919
|
+
print(f"Chat deleted: {chat.cid}")
|
|
920
|
+
|
|
921
|
+
asyncio.run(main())
|
|
922
|
+
```
|
|
923
|
+
|
|
906
924
|
### Streaming mode
|
|
907
925
|
|
|
908
926
|
For longer responses, you can use streaming mode to receive partial outputs as they are generated. This provides a more responsive user experience, especially for real-time applications like chatbots.
|
|
@@ -981,7 +999,7 @@ System prompt can be applied to conversations via [Gemini Gems](https://gemini.g
|
|
|
981
999
|
```python
|
|
982
1000
|
async def main():
|
|
983
1001
|
# Fetch all gems for the current account, including both predefined and user-created ones
|
|
984
|
-
await client.fetch_gems(include_hidden=False)
|
|
1002
|
+
await client.fetch_gems(include_hidden=False, language="en")
|
|
985
1003
|
|
|
986
1004
|
# Once fetched, gems will be cached in `GeminiClient.gems`
|
|
987
1005
|
gems = client.gems
|
|
@@ -153,6 +153,14 @@ class TestGeminiClient(unittest.IsolatedAsyncioTestCase):
|
|
|
153
153
|
logger.debug(response2.text)
|
|
154
154
|
logger.debug(response2.images)
|
|
155
155
|
|
|
156
|
+
@logger.catch(reraise=True)
|
|
157
|
+
async def test_delete_chat(self):
|
|
158
|
+
chat = self.geminiclient.start_chat()
|
|
159
|
+
await chat.send_message("This is a temporary conversation.")
|
|
160
|
+
self.assertIsNotNone(chat.cid)
|
|
161
|
+
await self.geminiclient.delete_chat(chat.cid)
|
|
162
|
+
logger.debug(f"Chat deleted: {chat.cid}")
|
|
163
|
+
|
|
156
164
|
@logger.catch(reraise=True)
|
|
157
165
|
async def test_card_content(self):
|
|
158
166
|
response = await self.geminiclient.generate_content("How is today's weather?")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/load_browser_cookies.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gemini_webapi-1.18.0 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|