gemini-webapi 1.18.0__py3-none-any.whl → 1.18.1__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/client.py CHANGED
@@ -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.value for p in payloads]),
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(self, include_hidden: bool = False, **kwargs) -> GemJar:
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="[4]" if include_hidden else "[3]",
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
  ],
@@ -18,6 +18,7 @@ class GRPC(StrEnum):
18
18
  # Chat methods
19
19
  LIST_CHATS = "MaZiqc"
20
20
  READ_CHAT = "hNvQHb"
21
+ DELETE_CHAT = "GzXR5e"
21
22
 
22
23
  # Gem methods
23
24
  LIST_GEMS = "CNgdBe"
@@ -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 0 <= key < len(current):
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.0
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
@@ -1,9 +1,9 @@
1
1
  gemini_webapi/__init__.py,sha256=7ELCiUoI10ea3daeJxnv0UwqLVKpM7rxsgOZsPMstO8,150
2
- gemini_webapi/client.py,sha256=qZtedP9sNU48LEPv4fAPPQTbkwgMscsViu9uAwV-EN0,41669
3
- gemini_webapi/constants.py,sha256=5VfdSCoWqq5dMjzrFXdBoF-ishctux6jdhyWJtqNadg,3519
2
+ gemini_webapi/client.py,sha256=qD6XwOkrzk1FXmUdcaq_-xoJjVpVkxAuXDy2-7vCf4A,42123
3
+ gemini_webapi/constants.py,sha256=VluH20wYib_9z1LPTFHQvv__mBUTNudVcb6YJWMrGt0,3546
4
4
  gemini_webapi/exceptions.py,sha256=qkXrIpr0L7LtGbq3VcTO8D1xZ50pJtt0dDRp5I3uDSg,1038
5
5
  gemini_webapi/components/__init__.py,sha256=wolxuAJJ32-jmHOKgpsesexP7hXea1JMo5vI52wysTI,48
6
- gemini_webapi/components/gem_mixin.py,sha256=QyXNjUspcB4Kr4FAFDIwVagFG9JKJ8V1ZQ6n5J0-vpI,9477
6
+ gemini_webapi/components/gem_mixin.py,sha256=cSyxDyGmr-O2WK9XF1I74l3uIDGAKG4M2EOukDBkvS4,9763
7
7
  gemini_webapi/types/__init__.py,sha256=1DU4JEw2KHQJbtOgOuvoEXtzQCMwAkyo0koSFVdT9JY,192
8
8
  gemini_webapi/types/candidate.py,sha256=5Gy2UiOgwlsrFZ7wQsuHyS2jmKsgQLGkSHbqbPTEnqg,1549
9
9
  gemini_webapi/types/gem.py,sha256=3Ppjq9V22Zp4Lb9a9ZnDviDKQpfSQf8UZxqOEjeEWd4,4070
@@ -15,11 +15,11 @@ gemini_webapi/utils/decorators.py,sha256=iTTVIgG1fxOVMluy9fKeVrTmj4_K1h1q4lVLCjF
15
15
  gemini_webapi/utils/get_access_token.py,sha256=6EcLhcpS8_-hxodBvQwu76PECVBnQQtzt9AYqSi0ps8,8162
16
16
  gemini_webapi/utils/load_browser_cookies.py,sha256=OHCfe27DpV_rloIDgW9Xpeb0mkfzbYONNiholw0ElXU,1791
17
17
  gemini_webapi/utils/logger.py,sha256=0VcxhVLhHBRDQutNCpapP1y_MhPoQ2ud1uIFLqxC3Z8,958
18
- gemini_webapi/utils/parsing.py,sha256=AHENFsQxLJFswUw7eOsKHnkytvUk0X7S850GNVSsOos,7279
18
+ gemini_webapi/utils/parsing.py,sha256=iNrczcArdaCQ9_xD0isf4LDEwSTbBjq_frgvMdqm1Tk,7291
19
19
  gemini_webapi/utils/rotate_1psidts.py,sha256=7W_D5NGJ9_dpF0EgVaU_ykL1ebvQK7P28bQN2HVlX5M,2359
20
20
  gemini_webapi/utils/upload_file.py,sha256=TiLnXdNvY8NRFZih-wp_BpDA6LxAVQDQakzmq2Ur9Ak,2781
21
- gemini_webapi-1.18.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
22
- gemini_webapi-1.18.0.dist-info/METADATA,sha256=JIP7x5zMUIJn-c7YsEraDhH3G2JNZN0jE49HzB0gCD0,62719
23
- gemini_webapi-1.18.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
24
- gemini_webapi-1.18.0.dist-info/top_level.txt,sha256=dtWtug_ZrmnUqCYuu8NmGzTgWglHeNzhHU_hXmqZGWE,14
25
- gemini_webapi-1.18.0.dist-info/RECORD,,
21
+ gemini_webapi-1.18.1.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
22
+ gemini_webapi-1.18.1.dist-info/METADATA,sha256=y4Kg_-Dn4PZDk2xtBmjtBAUnDI6fqHb0F-NHAQ91sTk,63301
23
+ gemini_webapi-1.18.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
24
+ gemini_webapi-1.18.1.dist-info/top_level.txt,sha256=dtWtug_ZrmnUqCYuu8NmGzTgWglHeNzhHU_hXmqZGWE,14
25
+ gemini_webapi-1.18.1.dist-info/RECORD,,