vectorvein 0.1.42__py3-none-any.whl → 0.1.43__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.
@@ -116,9 +116,14 @@ def convert_type(value, value_type):
116
116
 
117
117
  def get_token_counts(text: str | dict, model: str = "", use_token_server_first: bool = False) -> int:
118
118
  if use_token_server_first and settings.token_server is not None:
119
+ base_url = (
120
+ settings.token_server.url
121
+ if settings.token_server.url is not None
122
+ else f"http://{settings.token_server.host}:{settings.token_server.port}"
123
+ )
119
124
  _, response = (
120
125
  Retry(httpx.post)
121
- .args(url=settings.token_server, json={"text": text, "model": model}, timeout=None)
126
+ .args(url=f"{base_url}/count_tokens", json={"text": text, "model": model}, timeout=None)
122
127
  .retry_times(5)
123
128
  .sleep_time(1)
124
129
  .run()
@@ -199,7 +204,7 @@ def get_token_counts(text: str | dict, model: str = "", use_token_server_first:
199
204
  if isinstance(endpoint_id, dict):
200
205
  endpoint_id = endpoint_id["endpoint_id"]
201
206
  endpoint = settings.get_endpoint(endpoint_id)
202
- url = f"{endpoint.api_base}/models/{model_setting.id}:countTokens"
207
+ base_url = f"{endpoint.api_base}/models/{model_setting.id}:countTokens"
203
208
  params = {"key": endpoint.api_key}
204
209
  request_body = {
205
210
  "contents": {
@@ -211,7 +216,7 @@ def get_token_counts(text: str | dict, model: str = "", use_token_server_first:
211
216
  }
212
217
  _, response = (
213
218
  Retry(httpx.post)
214
- .args(url, json=request_body, params=params, timeout=None)
219
+ .args(base_url, json=request_body, params=params, timeout=None)
215
220
  .retry_times(5)
216
221
  .sleep_time(10)
217
222
  .run()
@@ -31,16 +31,16 @@ def run_token_server(host: str | None = None, port: int | None = None):
31
31
  port (int): 服务器端口。
32
32
  """
33
33
  if host is None or port is None:
34
- token_server_url = settings.token_server
35
- if token_server_url is None:
34
+ if settings.token_server is None:
36
35
  raise ValueError("Token server is not enabled.")
37
36
 
38
- _host, _port = token_server_url.split(":")
37
+ _host = settings.token_server.host
38
+ _port = settings.token_server.port
39
39
  else:
40
40
  _host = host
41
41
  _port = port
42
42
 
43
- uvicorn.run(token_server, host=_host, port=int(_port))
43
+ uvicorn.run(token_server, host=_host, port=_port)
44
44
 
45
45
 
46
46
  if __name__ == "__main__":
@@ -9,11 +9,17 @@ from ..types.enums import BackendType
9
9
  from ..types.llm_parameters import BackendSettings, EndpointSetting
10
10
 
11
11
 
12
+ class Server(BaseModel):
13
+ host: str
14
+ port: int
15
+ url: Optional[str]
16
+
17
+
12
18
  class Settings(BaseModel):
13
19
  endpoints: List[EndpointSetting] = Field(
14
20
  default_factory=list, description="Available endpoints for the LLM service."
15
21
  )
16
- token_server: Optional[str] = Field(default=None, description="Token server address. Format: host:port")
22
+ token_server: Optional[Server] = Field(default=None, description="Token server address. Format: host:port")
17
23
 
18
24
  anthropic: BackendSettings = Field(default_factory=BackendSettings, description="Anthropic models settings.")
19
25
  deepseek: BackendSettings = Field(default_factory=BackendSettings, description="Deepseek models settings.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.1.42
3
+ Version: 0.1.43
4
4
  Summary: Default template for PDM package
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
- vectorvein-0.1.42.dist-info/METADATA,sha256=nsKbuRtzNcT0Qkrt1q9DSNoMzlAg0PoJBcQ6570T9mU,644
2
- vectorvein-0.1.42.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- vectorvein-0.1.42.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ vectorvein-0.1.43.dist-info/METADATA,sha256=XsswO1wZoO8V45KAfoTxijw_3n7Odna2N9zw-DGeEJ4,644
2
+ vectorvein-0.1.43.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ vectorvein-0.1.43.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=dW169oK1n3v8Z0uD8itghzlCP72rxiaS-XYn6fvI2xM,16788
6
6
  vectorvein/chat_clients/anthropic_client.py,sha256=jF9pDlnkhjM6-OLPCQQxkh27xjzbTRaEY53olRd3_aY,32413
@@ -18,12 +18,12 @@ vectorvein/chat_clients/openai_compatible_client.py,sha256=FVm_ZYL9UP6t6hTUNxPyo
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=CRwjzMkYRHs0onKf87KxseG08b4zjAjZxi00-gQPYHc,25253
21
+ vectorvein/chat_clients/utils.py,sha256=mzmN5qGDiF3B4ApMY_Xq4sOWs8kiskcrI7bzyFBCsa4,25475
22
22
  vectorvein/chat_clients/yi_client.py,sha256=RNf4CRuPJfixrwLZ3-DEc3t25QDe1mvZeb9sku2f8Bc,484
23
23
  vectorvein/chat_clients/zhipuai_client.py,sha256=Ys5DSeLCuedaDXr3PfG1EW2zKXopt-awO2IylWSwY0s,519
24
24
  vectorvein/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- vectorvein/server/token_server.py,sha256=mk7hbhagBc3q-5a7q3o0wNBkx-f0A4GTShqDD2bwkqA,1367
26
- vectorvein/settings/__init__.py,sha256=tYC8hSAYIUxpcJTx7zhpTSdNqc5fVeYPE1IhOTTTpRA,3684
25
+ vectorvein/server/token_server.py,sha256=36F9PKSNOX8ZtYBXY_l-76GQTpUSmQ2Y8EMy1H7wtdQ,1353
26
+ vectorvein/settings/__init__.py,sha256=dyTCLhevXiKVJhOb1tjgZGMH38Indy4dkWVdDX543g0,3771
27
27
  vectorvein/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  vectorvein/types/defaults.py,sha256=xefmRNYBGbnWA5kjLLFKN91UM5gnHZ5-kcCNlQRfznk,22095
29
29
  vectorvein/types/enums.py,sha256=x_S0IJiEWijOAEiMNdiGDGEWGtmt7TwMriJVDqrDmTo,1637
@@ -32,4 +32,4 @@ vectorvein/types/llm_parameters.py,sha256=vhleSgCHzDl7EULYJ3dUYlu9KLbfs9y6dcPD0B
32
32
  vectorvein/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  vectorvein/utilities/media_processing.py,sha256=cnzLrU1OaJvSv87IOnc36FrDXtmGMDStPbxtIJ33YN4,5880
34
34
  vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM,2208
35
- vectorvein-0.1.42.dist-info/RECORD,,
35
+ vectorvein-0.1.43.dist-info/RECORD,,