xinference-client 4.0.0__tar.gz → 4.2.0__tar.gz

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.
Files changed (27) hide show
  1. {xinference_client-4.0.0/xinference_client.egg-info → xinference_client-4.2.0}/PKG-INFO +1 -1
  2. {xinference_client-4.0.0 → xinference_client-4.2.0}/tests/test_async_client.py +5 -5
  3. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/_version.py +3 -3
  4. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/client/common.py +19 -2
  5. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/client/restful/async_restful_client.py +284 -81
  6. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/client/restful/restful_client.py +220 -10
  7. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/types.py +26 -2
  8. {xinference_client-4.0.0 → xinference_client-4.2.0/xinference_client.egg-info}/PKG-INFO +1 -1
  9. {xinference_client-4.0.0 → xinference_client-4.2.0}/LICENSE +0 -0
  10. {xinference_client-4.0.0 → xinference_client-4.2.0}/MANIFEST.in +0 -0
  11. {xinference_client-4.0.0 → xinference_client-4.2.0}/README.md +0 -0
  12. {xinference_client-4.0.0 → xinference_client-4.2.0}/pyproject.toml +0 -0
  13. {xinference_client-4.0.0 → xinference_client-4.2.0}/setup.cfg +0 -0
  14. {xinference_client-4.0.0 → xinference_client-4.2.0}/setup.py +0 -0
  15. {xinference_client-4.0.0 → xinference_client-4.2.0}/tests/test_async_client_cleanup.py +0 -0
  16. {xinference_client-4.0.0 → xinference_client-4.2.0}/third_party/inference/xinference/thirdparty/matcha/utils/monotonic_align/core.pyx +0 -0
  17. {xinference_client-4.0.0 → xinference_client-4.2.0}/versioneer.py +0 -0
  18. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/__init__.py +0 -0
  19. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/_compat.py +0 -0
  20. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/client/__init__.py +0 -0
  21. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/client/restful/__init__.py +0 -0
  22. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client/fields.py +0 -0
  23. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client.egg-info/SOURCES.txt +0 -0
  24. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client.egg-info/dependency_links.txt +0 -0
  25. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client.egg-info/not-zip-safe +0 -0
  26. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client.egg-info/requires.txt +0 -0
  27. {xinference_client-4.0.0 → xinference_client-4.2.0}/xinference_client.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xinference-client
3
- Version: 4.0.0
3
+ Version: 4.2.0
4
4
  Summary: Client for Xinference
5
5
  Home-page: https://github.com/xorbitsai/inference-client
6
6
  Author: Qin Xuye
@@ -5,17 +5,17 @@ from xinference_client import AsyncRESTfulClient
5
5
 
6
6
 
7
7
  @pytest.mark.asyncio
8
- async def test_list_models_and_explicit_close(monkeypatch):
9
- # Authentication discovery is synchronous; isolate it from the async server.
10
- monkeypatch.setattr(
11
- AsyncRESTfulClient, "_check_cluster_authenticated", lambda self: None
12
- )
8
+ async def test_list_models_and_explicit_close():
13
9
  model = {"id": "test-model", "model_type": "LLM"}
14
10
 
15
11
  async def list_models(request):
16
12
  return web.json_response({"data": [model]})
17
13
 
14
+ async def cluster_auth(request):
15
+ return web.json_response({"auth": False})
16
+
18
17
  app = web.Application()
18
+ app.router.add_get("/v1/cluster/auth", cluster_auth)
19
19
  app.router.add_get("/v1/models", list_models)
20
20
  runner = web.AppRunner(app)
21
21
  await runner.setup()
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2026-10-09T18:26:36+0800",
11
+ "date": "2026-11-07T16:20:12+0800",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "6ea2c66c5f76815740ebd6b2cdc1bd6a689b5c91",
15
- "version": "4.0.0"
14
+ "full-revisionid": "126f5b56ffbab1bda41d00c36731e26a91773281",
15
+ "version": "4.2.0"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -17,6 +17,18 @@ import json
17
17
  import os
18
18
  from typing import Any, AsyncIterator, Iterator, Union
19
19
 
20
+ # (connect, read) seconds for fetching an image URL, as used by the server.
21
+ # The read timeout limits inactivity, not the total download time.
22
+ IMAGE_DOWNLOAD_TIMEOUT = (10, 30)
23
+
24
+
25
+ def normalize_endpoint(endpoint: str) -> str:
26
+ return endpoint.rstrip("/")
27
+
28
+
29
+ def is_http_url(value: str) -> bool:
30
+ return value.lower().startswith(("http://", "https://"))
31
+
20
32
 
21
33
  def encode_world_reference(reference: Union[str, bytes], media_type: str) -> str:
22
34
  if isinstance(reference, str) and not os.path.isfile(reference):
@@ -71,7 +83,7 @@ def streaming_response_iterator(
71
83
  if line.startswith(b"data:"):
72
84
  json_str = line[len(b"data:") :].strip()
73
85
  if json_str == b"[DONE]":
74
- continue
86
+ break
75
87
  data = json.loads(json_str.decode("utf-8"))
76
88
  error = data.get("error", None)
77
89
  if error is not None:
@@ -81,6 +93,8 @@ def streaming_response_iterator(
81
93
 
82
94
  async def async_streaming_response_iterator(
83
95
  response_or_lines: Any,
96
+ *,
97
+ _prime: bool = False,
84
98
  ) -> AsyncIterator[Any]:
85
99
  """
86
100
  Create an AsyncIterator to handle the streaming type of generation.
@@ -110,12 +124,15 @@ async def async_streaming_response_iterator(
110
124
  )
111
125
  response_lines = response.content if response is not None else response_or_lines
112
126
  try:
127
+ if _prime:
128
+ # Enter the cleanup scope before handing the stream to the caller.
129
+ yield None
113
130
  async for line in response_lines:
114
131
  line = line.strip()
115
132
  if line.startswith(b"data:"):
116
133
  json_str = line[len(b"data:") :].strip()
117
134
  if json_str == b"[DONE]":
118
- continue
135
+ break
119
136
  data = json.loads(json_str.decode("utf-8"))
120
137
  error = data.get("error", None)
121
138
  if error is not None: