vectorvein 0.1.29__py3-none-any.whl → 0.1.31__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.
- vectorvein/chat_clients/__init__.py +28 -0
- vectorvein/chat_clients/utils.py +22 -8
- {vectorvein-0.1.29.dist-info → vectorvein-0.1.31.dist-info}/METADATA +1 -1
- {vectorvein-0.1.29.dist-info → vectorvein-0.1.31.dist-info}/RECORD +6 -6
- {vectorvein-0.1.29.dist-info → vectorvein-0.1.31.dist-info}/WHEEL +0 -0
- {vectorvein-0.1.29.dist-info → vectorvein-0.1.31.dist-info}/entry_points.txt +0 -0
@@ -257,6 +257,20 @@ def create_chat_client(
|
|
257
257
|
) -> StepFunChatClient: ...
|
258
258
|
|
259
259
|
|
260
|
+
@overload
|
261
|
+
def create_chat_client(
|
262
|
+
backend: BackendType,
|
263
|
+
model: str | None = None,
|
264
|
+
stream: bool = False,
|
265
|
+
temperature: float = 0.7,
|
266
|
+
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
267
|
+
random_endpoint: bool = True,
|
268
|
+
endpoint_id: str = "",
|
269
|
+
http_client: httpx.Client | None = None,
|
270
|
+
**kwargs,
|
271
|
+
) -> BaseChatClient: ...
|
272
|
+
|
273
|
+
|
260
274
|
def create_chat_client(
|
261
275
|
backend: BackendType,
|
262
276
|
model: str | None = None,
|
@@ -482,6 +496,20 @@ def create_async_chat_client(
|
|
482
496
|
) -> AsyncStepFunChatClient: ...
|
483
497
|
|
484
498
|
|
499
|
+
@overload
|
500
|
+
def create_async_chat_client(
|
501
|
+
backend: BackendType,
|
502
|
+
model: str | None = None,
|
503
|
+
stream: bool = False,
|
504
|
+
temperature: float = 0.7,
|
505
|
+
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
506
|
+
random_endpoint: bool = True,
|
507
|
+
endpoint_id: str = "",
|
508
|
+
http_client: httpx.AsyncClient | None = None,
|
509
|
+
**kwargs,
|
510
|
+
) -> BaseAsyncChatClient: ...
|
511
|
+
|
512
|
+
|
485
513
|
def create_async_chat_client(
|
486
514
|
backend: BackendType,
|
487
515
|
model: str | None = None,
|
vectorvein/chat_clients/utils.py
CHANGED
@@ -21,8 +21,22 @@ from ..types.llm_parameters import (
|
|
21
21
|
)
|
22
22
|
|
23
23
|
|
24
|
-
|
25
|
-
gpt_4o_encoding =
|
24
|
+
gpt_35_encoding = None
|
25
|
+
gpt_4o_encoding = None
|
26
|
+
|
27
|
+
|
28
|
+
def get_gpt_35_encoding():
|
29
|
+
global gpt_35_encoding
|
30
|
+
if gpt_35_encoding is None:
|
31
|
+
gpt_35_encoding = tiktoken.encoding_for_model("gpt-3.5-turbo")
|
32
|
+
return gpt_35_encoding
|
33
|
+
|
34
|
+
|
35
|
+
def get_gpt_4o_encoding():
|
36
|
+
global gpt_4o_encoding
|
37
|
+
if gpt_4o_encoding is None:
|
38
|
+
gpt_4o_encoding = tiktoken.encoding_for_model("gpt-4o")
|
39
|
+
return gpt_4o_encoding
|
26
40
|
|
27
41
|
|
28
42
|
class ToolCallContentProcessor:
|
@@ -106,9 +120,9 @@ def get_token_counts(text: str | dict, model: str = "") -> int:
|
|
106
120
|
if not isinstance(text, str):
|
107
121
|
text = str(text)
|
108
122
|
if model == "gpt-3.5-turbo":
|
109
|
-
return len(
|
123
|
+
return len(get_gpt_35_encoding().encode(text))
|
110
124
|
elif model in ("gpt-4o", "gpt-4o-mini"):
|
111
|
-
return len(
|
125
|
+
return len(get_gpt_4o_encoding().encode(text))
|
112
126
|
elif model.startswith("abab"):
|
113
127
|
model_setting = settings.minimax.models[model]
|
114
128
|
if len(model_setting.endpoints) == 0:
|
@@ -140,7 +154,7 @@ def get_token_counts(text: str | dict, model: str = "") -> int:
|
|
140
154
|
elif model in ("moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"):
|
141
155
|
model_setting = settings.moonshot.models[model]
|
142
156
|
if len(model_setting.endpoints) == 0:
|
143
|
-
return len(
|
157
|
+
return len(get_gpt_35_encoding().encode(text))
|
144
158
|
endpoint_id = model_setting.endpoints[0]
|
145
159
|
endpoint = settings.get_endpoint(endpoint_id)
|
146
160
|
tokenize_url = "https://api.moonshot.cn/v1/tokenizers/estimate-token-count"
|
@@ -165,7 +179,7 @@ def get_token_counts(text: str | dict, model: str = "") -> int:
|
|
165
179
|
elif model.startswith("gemini"):
|
166
180
|
model_setting = settings.gemini.models[model]
|
167
181
|
if len(model_setting.endpoints) == 0:
|
168
|
-
return len(
|
182
|
+
return len(get_gpt_35_encoding().encode(text))
|
169
183
|
endpoint_id = model_setting.endpoints[0]
|
170
184
|
endpoint = settings.get_endpoint(endpoint_id)
|
171
185
|
url = f"{endpoint.api_base}/models/{model_setting.id}:countTokens"
|
@@ -198,7 +212,7 @@ def get_token_counts(text: str | dict, model: str = "") -> int:
|
|
198
212
|
elif model.startswith("stepfun"):
|
199
213
|
model_setting = settings.moonshot.models[model]
|
200
214
|
if len(model_setting.endpoints) == 0:
|
201
|
-
return len(
|
215
|
+
return len(get_gpt_35_encoding().encode(text))
|
202
216
|
endpoint_id = model_setting.endpoints[0]
|
203
217
|
endpoint = settings.get_endpoint(endpoint_id)
|
204
218
|
tokenize_url = "https://api.stepfun.com/v1/token/count"
|
@@ -221,7 +235,7 @@ def get_token_counts(text: str | dict, model: str = "") -> int:
|
|
221
235
|
result = response.json()
|
222
236
|
return result["data"]["total_tokens"]
|
223
237
|
else:
|
224
|
-
return len(
|
238
|
+
return len(get_gpt_35_encoding().encode(text))
|
225
239
|
|
226
240
|
|
227
241
|
def calculate_image_tokens(width: int, height: int, model: str = "gpt-4o"):
|
@@ -1,8 +1,8 @@
|
|
1
|
-
vectorvein-0.1.
|
2
|
-
vectorvein-0.1.
|
3
|
-
vectorvein-0.1.
|
1
|
+
vectorvein-0.1.31.dist-info/METADATA,sha256=RNZJEkOptnqazFSybizJ-8Vwi7EkX5dowGfkwXoC6So,502
|
2
|
+
vectorvein-0.1.31.dist-info/WHEEL,sha256=Vza3XR51HW1KmFP0iIMUVYIvz0uQuKJpIXKYOBGQyFQ,90
|
3
|
+
vectorvein-0.1.31.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
4
|
vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
vectorvein/chat_clients/__init__.py,sha256=
|
5
|
+
vectorvein/chat_clients/__init__.py,sha256=dW169oK1n3v8Z0uD8itghzlCP72rxiaS-XYn6fvI2xM,16788
|
6
6
|
vectorvein/chat_clients/anthropic_client.py,sha256=h82GxBi7h22B7leBuPofwBstxH_c12tEgGjpnKg6UDc,25007
|
7
7
|
vectorvein/chat_clients/baichuan_client.py,sha256=CVMvpgjdrZGv0BWnTOBD-f2ufZ3wq3496wqukumsAr4,526
|
8
8
|
vectorvein/chat_clients/base_client.py,sha256=wxh7WkzFG4cD4I4t4e6RGe1KiFZc8Z5llh2iVblXEZE,8415
|
@@ -17,7 +17,7 @@ vectorvein/chat_clients/openai_client.py,sha256=Nz6tV45pWcsOupxjnsRsGTicbQNJWIZy
|
|
17
17
|
vectorvein/chat_clients/openai_compatible_client.py,sha256=gfCTXji8pgFUiultiNDKcmPIGu7lFfQ9VmA8o2_Mm6c,18823
|
18
18
|
vectorvein/chat_clients/qwen_client.py,sha256=-ryh-m9PgsO0fc4ulcCmPTy1155J8YUy15uPoJQOHA0,513
|
19
19
|
vectorvein/chat_clients/stepfun_client.py,sha256=zsD2W5ahmR4DD9cqQTXmJr3txrGuvxbRWhFlRdwNijI,519
|
20
|
-
vectorvein/chat_clients/utils.py,sha256=
|
20
|
+
vectorvein/chat_clients/utils.py,sha256=1LddLLVf8r8_Hj5LEYrQRus2qfsuXkJPMOu9VsiKMys,24338
|
21
21
|
vectorvein/chat_clients/yi_client.py,sha256=RNf4CRuPJfixrwLZ3-DEc3t25QDe1mvZeb9sku2f8Bc,484
|
22
22
|
vectorvein/chat_clients/zhipuai_client.py,sha256=Ys5DSeLCuedaDXr3PfG1EW2zKXopt-awO2IylWSwY0s,519
|
23
23
|
vectorvein/settings/__init__.py,sha256=0L-2WicBq9ctaJRoSwx8ZhVtX4slS5tHrIlSGf-tJxg,3564
|
@@ -27,4 +27,4 @@ vectorvein/types/exception.py,sha256=gnW4GnJ76jND6UGnodk9xmqkcbeS7Cz2rvncA2HpD5E
|
|
27
27
|
vectorvein/types/llm_parameters.py,sha256=N6RQ8tqO1RCywMFRWPooffeAEPd9x3JW6Bl4UgQtF5I,4379
|
28
28
|
vectorvein/utilities/media_processing.py,sha256=BujciRmw1GMmc3ELRvafL8STcy6r5b2rVnh27-uA7so,2256
|
29
29
|
vectorvein/utilities/retry.py,sha256=9ePuJdeUUGx-qMWfaFxmlOvG_lQPwCQ4UB1z3Edlo34,993
|
30
|
-
vectorvein-0.1.
|
30
|
+
vectorvein-0.1.31.dist-info/RECORD,,
|
File without changes
|
File without changes
|