vectorvein 0.1.55__py3-none-any.whl → 0.1.56__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.
@@ -216,9 +216,9 @@ class GeminiChatClient(BaseChatClient):
216
216
  ]
217
217
 
218
218
  result["usage"] = message["usage"] = {
219
- "prompt_tokens": data["usageMetadata"]["promptTokenCount"],
220
- "completion_tokens": data["usageMetadata"]["candidatesTokenCount"],
221
- "total_tokens": data["usageMetadata"]["totalTokenCount"],
219
+ "prompt_tokens": data["usageMetadata"].get("promptTokenCount", 0),
220
+ "completion_tokens": data["usageMetadata"].get("candidatesTokenCount", 0),
221
+ "total_tokens": data["usageMetadata"].get("totalTokenCount", 0),
222
222
  }
223
223
  yield ChatCompletionDeltaMessage(**message)
224
224
 
@@ -453,9 +453,9 @@ class AsyncGeminiChatClient(BaseAsyncChatClient):
453
453
  ]
454
454
 
455
455
  result["usage"] = message["usage"] = {
456
- "prompt_tokens": data["usageMetadata"]["promptTokenCount"],
457
- "completion_tokens": data["usageMetadata"]["candidatesTokenCount"],
458
- "total_tokens": data["usageMetadata"]["totalTokenCount"],
456
+ "prompt_tokens": data["usageMetadata"].get("promptTokenCount", 0),
457
+ "completion_tokens": data["usageMetadata"].get("candidatesTokenCount", 0),
458
+ "total_tokens": data["usageMetadata"].get("totalTokenCount", 0),
459
459
  }
460
460
  yield ChatCompletionDeltaMessage(**message)
461
461
 
@@ -130,10 +130,12 @@ def get_token_counts(text: str | dict, model: str = "", use_token_server_first:
130
130
  .sleep_time(1)
131
131
  .run()
132
132
  )
133
- if response is None:
134
- return 1000
135
- result = response.json()
136
- return result["total_tokens"]
133
+ if response is not None:
134
+ try:
135
+ result = response.json()
136
+ return result["total_tokens"]
137
+ except Exception as e:
138
+ print(f"Failed to parse token count response: {e}")
137
139
 
138
140
  if not isinstance(text, str):
139
141
  text = str(text)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.1.55
3
+ Version: 0.1.56
4
4
  Summary: VectorVein python SDK
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -1,13 +1,13 @@
1
- vectorvein-0.1.55.dist-info/METADATA,sha256=HKXCRg6-WfX1Um_Dx9GKaiIy97uA0yDiyePzdyTYicw,633
2
- vectorvein-0.1.55.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- vectorvein-0.1.55.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ vectorvein-0.1.56.dist-info/METADATA,sha256=3YTghMyf-ZK9VzwhaqGwf_xuhKmVI5IA7SKI1O73Sww,633
2
+ vectorvein-0.1.56.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ vectorvein-0.1.56.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
4
  vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  vectorvein/chat_clients/__init__.py,sha256=Oev7Lv1DIEWCMD-2Pm7e2cwzX7JFQTnIK-j6o4iUuyQ,17725
6
6
  vectorvein/chat_clients/anthropic_client.py,sha256=G68JGM98E0pYyi8Tjvo4VQtnug9ncugFbb4d0DrPVQo,36122
7
7
  vectorvein/chat_clients/baichuan_client.py,sha256=CVMvpgjdrZGv0BWnTOBD-f2ufZ3wq3496wqukumsAr4,526
8
8
  vectorvein/chat_clients/base_client.py,sha256=0Uj0e-JR0a68sRS_WfUMVd91Av7lzJh6-DukjutlaD0,9497
9
9
  vectorvein/chat_clients/deepseek_client.py,sha256=3qWu01NlJAP2N-Ff62d5-CZXZitlizE1fzb20LNetig,526
10
- vectorvein/chat_clients/gemini_client.py,sha256=TJZUP8dbufuDnqkRI_gxIDDCYHrIhMPCqKGI6sSwqZo,19860
10
+ vectorvein/chat_clients/gemini_client.py,sha256=DlQI5p8qG5erThMb17ojB2gofzTkwVy3veFC8_Cbpc4,19902
11
11
  vectorvein/chat_clients/groq_client.py,sha256=Uow4pgdmFi93ZQSoOol2-0PhhqkW-S0XuSldvppz5U4,498
12
12
  vectorvein/chat_clients/local_client.py,sha256=55nOsxzqUf79q3Y14MKROA71zxhsT7p7FsDZ89rts2M,422
13
13
  vectorvein/chat_clients/minimax_client.py,sha256=3HetFZbmgvEzWFaH_Gbj99lsh9DmIOhfpVdbV4HxrSI,19116
@@ -18,7 +18,7 @@ vectorvein/chat_clients/openai_compatible_client.py,sha256=D2VmhpDVct4w2y58s87An
18
18
  vectorvein/chat_clients/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  vectorvein/chat_clients/qwen_client.py,sha256=-ryh-m9PgsO0fc4ulcCmPTy1155J8YUy15uPoJQOHA0,513
20
20
  vectorvein/chat_clients/stepfun_client.py,sha256=zsD2W5ahmR4DD9cqQTXmJr3txrGuvxbRWhFlRdwNijI,519
21
- vectorvein/chat_clients/utils.py,sha256=J-lv-XNlpFwcvLREqVZWKOA4QkN1t9XsOU6h0kxkWO4,26553
21
+ vectorvein/chat_clients/utils.py,sha256=UqDV4ljwZRbndZdkyHkIBis1ciRt5gjPFOJ0vnR2Uas,26669
22
22
  vectorvein/chat_clients/xai_client.py,sha256=eLFJJrNRJ-ni3DpshODcr3S1EJQLbhVwxyO1E54LaqM,491
23
23
  vectorvein/chat_clients/yi_client.py,sha256=RNf4CRuPJfixrwLZ3-DEc3t25QDe1mvZeb9sku2f8Bc,484
24
24
  vectorvein/chat_clients/zhipuai_client.py,sha256=Ys5DSeLCuedaDXr3PfG1EW2zKXopt-awO2IylWSwY0s,519
@@ -33,4 +33,4 @@ vectorvein/types/llm_parameters.py,sha256=5o-C_yXxxQWZy_e8OWowB2107GTS-Eawx4Mvb1
33
33
  vectorvein/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  vectorvein/utilities/media_processing.py,sha256=CTRq-lGlFkFgP_FSRhNwF_qUgmOrXPf2_1Ok9HY42_g,5887
35
35
  vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM,2208
36
- vectorvein-0.1.55.dist-info/RECORD,,
36
+ vectorvein-0.1.56.dist-info/RECORD,,