vectorvein 0.2.20__py3-none-any.whl → 0.2.22__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.
@@ -214,7 +214,7 @@ class AnthropicChatClient(BaseChatClient):
214
214
  if self.endpoint.proxy is not None and self.http_client is None:
215
215
  self.http_client = httpx.Client(proxy=self.endpoint.proxy)
216
216
 
217
- if self.endpoint.is_vertex:
217
+ if self.endpoint.is_vertex or self.endpoint.endpoint_type == "anthropic_vertex":
218
218
  if self.endpoint.credentials is None:
219
219
  raise ValueError("Anthropic Vertex endpoint requires credentials")
220
220
  self.creds = Credentials(
@@ -248,7 +248,7 @@ class AnthropicChatClient(BaseChatClient):
248
248
  access_token=self.creds.token,
249
249
  http_client=self.http_client,
250
250
  )
251
- elif self.endpoint.is_bedrock:
251
+ elif self.endpoint.is_bedrock or self.endpoint.endpoint_type == "anthropic_bedrock":
252
252
  if self.endpoint.credentials is None:
253
253
  raise ValueError("Anthropic Bedrock endpoint requires credentials")
254
254
  return AnthropicBedrock(
@@ -747,7 +747,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
747
747
  if self.endpoint.proxy is not None and self.http_client is None:
748
748
  self.http_client = httpx.AsyncClient(proxy=self.endpoint.proxy)
749
749
 
750
- if self.endpoint.is_vertex:
750
+ if self.endpoint.is_vertex or self.endpoint.endpoint_type == "anthropic_vertex":
751
751
  if self.endpoint.credentials is None:
752
752
  raise ValueError("Anthropic Vertex endpoint requires credentials")
753
753
  self.creds = Credentials(
@@ -781,7 +781,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
781
781
  access_token=self.creds.token,
782
782
  http_client=self.http_client,
783
783
  )
784
- elif self.endpoint.is_bedrock:
784
+ elif self.endpoint.is_bedrock or self.endpoint.endpoint_type == "anthropic_bedrock":
785
785
  if self.endpoint.credentials is None:
786
786
  raise ValueError("Anthropic Bedrock endpoint requires credentials")
787
787
  return AsyncAnthropicBedrock(
@@ -93,7 +93,7 @@ class OpenAICompatibleChatClient(BaseChatClient):
93
93
  if self.endpoint.proxy is not None and self.http_client is None:
94
94
  self.http_client = httpx.Client(proxy=self.endpoint.proxy)
95
95
 
96
- if self.endpoint.is_azure:
96
+ if self.endpoint.is_azure or self.endpoint.endpoint_type == "openai_azure":
97
97
  if self.endpoint.api_base is None:
98
98
  raise ValueError("Azure endpoint is not set")
99
99
  return AzureOpenAI(
@@ -568,7 +568,7 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
568
568
  if self.endpoint.proxy is not None and self.http_client is None:
569
569
  self.http_client = httpx.AsyncClient(proxy=self.endpoint.proxy)
570
570
 
571
- if self.endpoint.is_azure:
571
+ if self.endpoint.is_azure or self.endpoint.endpoint_type == "openai_azure":
572
572
  if self.endpoint.api_base is None:
573
573
  raise ValueError("Azure endpoint is not set")
574
574
  return AsyncAzureOpenAI(
@@ -230,7 +230,12 @@ def get_token_counts(text: str | dict, model: str = "", use_token_server_first:
230
230
  endpoint_id = endpoint_choice
231
231
  endpoint = settings.get_endpoint(endpoint_id)
232
232
 
233
- if endpoint.is_vertex or endpoint.is_bedrock:
233
+ if (
234
+ endpoint.is_vertex
235
+ or endpoint.is_bedrock
236
+ or endpoint.endpoint_type == "anthropic_vertex"
237
+ or endpoint.endpoint_type == "anthropic_bedrock"
238
+ ):
234
239
  continue
235
240
  elif endpoint.api_schema_type == "default":
236
241
  return (
@@ -243,7 +248,7 @@ def get_token_counts(text: str | dict, model: str = "", use_token_server_first:
243
248
  )
244
249
 
245
250
  # TODO: Use anthropic token counting
246
- warnings.warn("Anthropic token counting is not implemented yet")
251
+ warnings.warn("Anthropic token counting is not implemented in Vertex or Bedrock yet")
247
252
  return len(get_gpt_4o_encoding().encode(text))
248
253
  elif model.startswith("deepseek"):
249
254
  from deepseek_tokenizer import deepseek_tokenizer
@@ -209,5 +209,52 @@ class Settings(BaseModel):
209
209
  else:
210
210
  return super().model_dump(exclude={"backends"})
211
211
 
212
+ def upgrade_to_v2(self) -> "Settings":
213
+ """
214
+ Upgrade settings from v1 format to v2 format.
215
+ In v2 format, all backend settings are stored in the 'backends' field.
216
+
217
+ Returns:
218
+ Settings: Self with updated format
219
+ """
220
+ # If already v2, no need to upgrade
221
+ if self.VERSION == "2" and self.backends is not None:
222
+ return self
223
+
224
+ # Initialize backends if not exists
225
+ if self.backends is None:
226
+ self.backends = Backends()
227
+
228
+ # Move all backend settings to backends field
229
+ backend_names = [
230
+ "anthropic",
231
+ "deepseek",
232
+ "gemini",
233
+ "groq",
234
+ "local",
235
+ "minimax",
236
+ "mistral",
237
+ "moonshot",
238
+ "openai",
239
+ "qwen",
240
+ "yi",
241
+ "zhipuai",
242
+ "baichuan",
243
+ "stepfun",
244
+ "xai",
245
+ "ernie",
246
+ ]
247
+
248
+ for backend_name in backend_names:
249
+ backend_setting = getattr(self, backend_name)
250
+ if backend_setting is not None:
251
+ setattr(self.backends, backend_name, backend_setting)
252
+ delattr(self, backend_name)
253
+
254
+ # Set version to 2
255
+ self.VERSION = "2"
256
+
257
+ return self
258
+
212
259
 
213
260
  settings = Settings()
@@ -1,6 +1,6 @@
1
1
  # @Author: Bi Ying
2
2
  # @Date: 2024-07-26 23:48:04
3
- from typing import List, Dict, Optional, Union, Iterable
3
+ from typing import List, Dict, Optional, Union, Iterable, Literal
4
4
 
5
5
  import httpx
6
6
  from pydantic import BaseModel, Field
@@ -31,7 +31,20 @@ class EndpointSetting(BaseModel):
31
31
  region: Optional[str] = Field(None, description="The region for the endpoint.")
32
32
  api_base: Optional[str] = Field(None, description="The base URL for the API.")
33
33
  api_key: Optional[str] = Field(None, description="The API key for authentication.")
34
- api_schema_type: Optional[str] = Field(
34
+ endpoint_type: Optional[
35
+ Literal[
36
+ "default",
37
+ "openai",
38
+ "openai_azure",
39
+ "anthropic",
40
+ "anthropic_vertex",
41
+ "anthropic_bedrock",
42
+ ]
43
+ ] = Field(
44
+ "default",
45
+ description="The type of endpoint. Set to 'default' will determine the type automatically.",
46
+ )
47
+ api_schema_type: Optional[Literal["default", "openai", "anthropic"]] = Field(
35
48
  "default",
36
49
  description="The type of client for the endpoint. Set to 'default' will determine the type automatically.",
37
50
  )
@@ -70,7 +70,23 @@ class EndpointSettingDict(TypedDict):
70
70
  api_base: NotRequired[Optional[str]]
71
71
  api_key: NotRequired[str]
72
72
  region: NotRequired[str]
73
- api_schema_type: NotRequired[str]
73
+ endpoint_type: NotRequired[
74
+ Literal[
75
+ "default",
76
+ "openai",
77
+ "openai_azure",
78
+ "anthropic",
79
+ "anthropic_vertex",
80
+ "anthropic_bedrock",
81
+ ]
82
+ ]
83
+ api_schema_type: NotRequired[
84
+ Literal[
85
+ "default",
86
+ "openai",
87
+ "anthropic",
88
+ ]
89
+ ]
74
90
  credentials: NotRequired[dict]
75
91
  is_azure: NotRequired[bool]
76
92
  is_vertex: NotRequired[bool]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.2.20
3
+ Version: 0.2.22
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.2.20.dist-info/METADATA,sha256=6WQKUSKUztXILQmkVzYPwBN9JOkV6lArHUGHB_OOXxA,4414
2
- vectorvein-0.2.20.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- vectorvein-0.2.20.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ vectorvein-0.2.22.dist-info/METADATA,sha256=0ieuDuHWOgzKsC97jdtfo2Y-8Oi8ez40v14NIMHGDIg,4414
2
+ vectorvein-0.2.22.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ vectorvein-0.2.22.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
4
  vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  vectorvein/api/__init__.py,sha256=lfY-XA46fgD2iIZTU0VYP8i07AwA03Egj4Qua0vUKrQ,738
6
6
  vectorvein/api/client.py,sha256=xF-leKDQzVyyy9FnIRaz0k4eElYW1XbbzeRLcpnyk90,33047
7
7
  vectorvein/api/exceptions.py,sha256=uS_PAdx0ksC0r3dgfSGWdbLMZm4qdLeWSSqCv1g3_Gc,772
8
8
  vectorvein/api/models.py,sha256=xtPWMsB0yIJI7i-gY4B6MtvXv0ZIXnoeKspmeInH6fU,1449
9
9
  vectorvein/chat_clients/__init__.py,sha256=UIytpIgwo8qkZpIyrHVxLYTyliUOTp4J7C4iHRjbtWE,23850
10
- vectorvein/chat_clients/anthropic_client.py,sha256=KFOyUR-Vg9Ux75KYtqgOJz2B3cSYXKQoqaaapxqZfRs,58554
10
+ vectorvein/chat_clients/anthropic_client.py,sha256=6yAZ6YYsyt96yqfjugjXQCgA_YhUhEw0whvZAWrPGbM,58768
11
11
  vectorvein/chat_clients/baichuan_client.py,sha256=CVMvpgjdrZGv0BWnTOBD-f2ufZ3wq3496wqukumsAr4,526
12
12
  vectorvein/chat_clients/base_client.py,sha256=p7s-G4Wh9MSpDKEfG8wuFAeWy5DGvj5Go31hqrpQPhM,38817
13
13
  vectorvein/chat_clients/deepseek_client.py,sha256=3qWu01NlJAP2N-Ff62d5-CZXZitlizE1fzb20LNetig,526
@@ -19,25 +19,25 @@ vectorvein/chat_clients/minimax_client.py,sha256=YOILWcsHsN5tihLTMbKJIyJr9TJREMI
19
19
  vectorvein/chat_clients/mistral_client.py,sha256=1aKSylzBDaLYcFnaBIL4-sXSzWmXfBeON9Q0rq-ziWw,534
20
20
  vectorvein/chat_clients/moonshot_client.py,sha256=gbu-6nGxx8uM_U2WlI4Wus881rFRotzHtMSoYOcruGU,526
21
21
  vectorvein/chat_clients/openai_client.py,sha256=Nz6tV45pWcsOupxjnsRsGTicbQNJWIZyxuJoJ5DGMpg,527
22
- vectorvein/chat_clients/openai_compatible_client.py,sha256=L8SXCRA7OO_eXh6b-oya8k6XZZJ-j8SrJSvy8BFhCgs,48498
22
+ vectorvein/chat_clients/openai_compatible_client.py,sha256=d6V6T_FvPxEuOhHoQC-NH0Ox6h8ux9T3buOPO2_RonY,48596
23
23
  vectorvein/chat_clients/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  vectorvein/chat_clients/qwen_client.py,sha256=-ryh-m9PgsO0fc4ulcCmPTy1155J8YUy15uPoJQOHA0,513
25
25
  vectorvein/chat_clients/stepfun_client.py,sha256=zsD2W5ahmR4DD9cqQTXmJr3txrGuvxbRWhFlRdwNijI,519
26
- vectorvein/chat_clients/utils.py,sha256=sXqp-RAxCeNmNoh3SKptPoYqS0ZNb_y2Eemuz919IJk,25195
26
+ vectorvein/chat_clients/utils.py,sha256=Um_RAhZOIsmrQabb76EZkiF61bGcX2enWScUC9Pk8ik,25393
27
27
  vectorvein/chat_clients/xai_client.py,sha256=eLFJJrNRJ-ni3DpshODcr3S1EJQLbhVwxyO1E54LaqM,491
28
28
  vectorvein/chat_clients/yi_client.py,sha256=RNf4CRuPJfixrwLZ3-DEc3t25QDe1mvZeb9sku2f8Bc,484
29
29
  vectorvein/chat_clients/zhipuai_client.py,sha256=Ys5DSeLCuedaDXr3PfG1EW2zKXopt-awO2IylWSwY0s,519
30
30
  vectorvein/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  vectorvein/server/token_server.py,sha256=36F9PKSNOX8ZtYBXY_l-76GQTpUSmQ2Y8EMy1H7wtdQ,1353
32
- vectorvein/settings/__init__.py,sha256=1KHgIF3hAXFMHlNZcgB4IcQg9iRy9WMh0BZUcBq5dGI,9509
32
+ vectorvein/settings/__init__.py,sha256=fqOfdTZ_b1P1Mx_6rFOUkgaSqS06hvrjzIQArRUPjU0,10849
33
33
  vectorvein/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  vectorvein/types/__init__.py,sha256=DJYGhlshgUQgzXPfMfKW5sTpBClZUCLhqmCqF44lVuU,3329
35
35
  vectorvein/types/defaults.py,sha256=wNPrfYDwsXMNIxofgGdN-ix9-by6WQu3cGIRySl3Q2E,27350
36
36
  vectorvein/types/enums.py,sha256=LplSVkXLBK-t8TWtJKj_f7ktWTd6CSHWRLb67XKMm54,1716
37
37
  vectorvein/types/exception.py,sha256=gnW4GnJ76jND6UGnodk9xmqkcbeS7Cz2rvncA2HpD5E,69
38
- vectorvein/types/llm_parameters.py,sha256=4SxDbJKVb9oGYymyxQtNZ66YZmUQd9_CpYYg81_Inkk,7650
38
+ vectorvein/types/llm_parameters.py,sha256=1-8G6ieUj_Hb_hnJNTj7kt_7R6LkPmA6fcbNuIIiDDs,8070
39
39
  vectorvein/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- vectorvein/types/settings.py,sha256=U-pgcgwzaWIIrBl-XmSRCG4Btq5fyGgpj8toWEMFBYE,4575
40
+ vectorvein/types/settings.py,sha256=82RsherFSCc8s9-v0E7F_FK6avVh_XvC1b7EkNlFHbc,4918
41
41
  vectorvein/utilities/media_processing.py,sha256=7KtbLFzOYIn1e9QTN9G6C76NH8CBlV9kfAgiRKEIeXY,6263
42
42
  vectorvein/utilities/rate_limiter.py,sha256=dwolIUVw2wP83Odqpx0AAaE77de1GzxkYDGH4tM_u_4,10300
43
43
  vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM,2208
@@ -62,4 +62,4 @@ vectorvein/workflow/nodes/vector_db.py,sha256=t6I17q6iR3yQreiDHpRrksMdWDPIvgqJs0
62
62
  vectorvein/workflow/nodes/video_generation.py,sha256=qmdg-t_idpxq1veukd-jv_ChICMOoInKxprV9Z4Vi2w,4118
63
63
  vectorvein/workflow/nodes/web_crawlers.py,sha256=LsqomfXfqrXfHJDO1cl0Ox48f4St7X_SL12DSbAMSOw,5415
64
64
  vectorvein/workflow/utils/json_to_code.py,sha256=F7dhDy8kGc8ndOeihGLRLGFGlquoxVlb02ENtxnQ0C8,5914
65
- vectorvein-0.2.20.dist-info/RECORD,,
65
+ vectorvein-0.2.22.dist-info/RECORD,,