xinference 0.8.1__py3-none-any.whl → 0.8.3__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.

Potentially problematic release.


This version of xinference might be problematic. Click here for more details.

Files changed (95) hide show
  1. xinference/_version.py +3 -3
  2. xinference/api/oauth2/auth_service.py +132 -0
  3. xinference/api/restful_api.py +282 -78
  4. xinference/client/handlers.py +3 -0
  5. xinference/client/restful/restful_client.py +108 -75
  6. xinference/constants.py +14 -4
  7. xinference/core/cache_tracker.py +102 -0
  8. xinference/core/chat_interface.py +10 -4
  9. xinference/core/event.py +56 -0
  10. xinference/core/model.py +44 -0
  11. xinference/core/resource.py +19 -12
  12. xinference/core/status_guard.py +4 -0
  13. xinference/core/supervisor.py +278 -87
  14. xinference/core/utils.py +68 -3
  15. xinference/core/worker.py +98 -8
  16. xinference/deploy/cmdline.py +6 -3
  17. xinference/deploy/local.py +2 -2
  18. xinference/deploy/supervisor.py +2 -2
  19. xinference/model/audio/__init__.py +27 -0
  20. xinference/model/audio/core.py +161 -0
  21. xinference/model/audio/model_spec.json +79 -0
  22. xinference/model/audio/utils.py +18 -0
  23. xinference/model/audio/whisper.py +132 -0
  24. xinference/model/core.py +18 -13
  25. xinference/model/embedding/__init__.py +27 -2
  26. xinference/model/embedding/core.py +43 -3
  27. xinference/model/embedding/model_spec.json +24 -0
  28. xinference/model/embedding/model_spec_modelscope.json +24 -0
  29. xinference/model/embedding/utils.py +18 -0
  30. xinference/model/image/__init__.py +12 -1
  31. xinference/model/image/core.py +63 -9
  32. xinference/model/image/utils.py +26 -0
  33. xinference/model/llm/__init__.py +20 -1
  34. xinference/model/llm/core.py +43 -2
  35. xinference/model/llm/ggml/chatglm.py +15 -6
  36. xinference/model/llm/llm_family.json +197 -6
  37. xinference/model/llm/llm_family.py +9 -7
  38. xinference/model/llm/llm_family_modelscope.json +189 -4
  39. xinference/model/llm/pytorch/chatglm.py +3 -3
  40. xinference/model/llm/pytorch/core.py +4 -2
  41. xinference/model/{multimodal → llm/pytorch}/qwen_vl.py +10 -8
  42. xinference/model/llm/pytorch/utils.py +21 -9
  43. xinference/model/llm/pytorch/yi_vl.py +246 -0
  44. xinference/model/llm/utils.py +57 -4
  45. xinference/model/llm/vllm/core.py +5 -4
  46. xinference/model/rerank/__init__.py +25 -2
  47. xinference/model/rerank/core.py +51 -9
  48. xinference/model/rerank/model_spec.json +6 -0
  49. xinference/model/rerank/model_spec_modelscope.json +7 -0
  50. xinference/{api/oauth2/common.py → model/rerank/utils.py} +6 -2
  51. xinference/model/utils.py +5 -3
  52. xinference/thirdparty/__init__.py +0 -0
  53. xinference/thirdparty/llava/__init__.py +1 -0
  54. xinference/thirdparty/llava/conversation.py +205 -0
  55. xinference/thirdparty/llava/mm_utils.py +122 -0
  56. xinference/thirdparty/llava/model/__init__.py +1 -0
  57. xinference/thirdparty/llava/model/clip_encoder/__init__.py +0 -0
  58. xinference/thirdparty/llava/model/clip_encoder/builder.py +11 -0
  59. xinference/thirdparty/llava/model/clip_encoder/clip_encoder.py +86 -0
  60. xinference/thirdparty/llava/model/constants.py +6 -0
  61. xinference/thirdparty/llava/model/llava_arch.py +385 -0
  62. xinference/thirdparty/llava/model/llava_llama.py +163 -0
  63. xinference/thirdparty/llava/model/multimodal_projector/__init__.py +0 -0
  64. xinference/thirdparty/llava/model/multimodal_projector/builder.py +64 -0
  65. xinference/types.py +1 -1
  66. xinference/web/ui/build/asset-manifest.json +3 -3
  67. xinference/web/ui/build/index.html +1 -1
  68. xinference/web/ui/build/static/js/main.15822aeb.js +3 -0
  69. xinference/web/ui/build/static/js/main.15822aeb.js.map +1 -0
  70. xinference/web/ui/node_modules/.cache/babel-loader/139e5e4adf436923107d2b02994c7ff6dba2aac1989e9b6638984f0dfe782c4a.json +1 -0
  71. xinference/web/ui/node_modules/.cache/babel-loader/52aa27272b4b9968f62666262b47661cb1992336a2aff3b13994cc36877b3ec3.json +1 -0
  72. xinference/web/ui/node_modules/.cache/babel-loader/64accc515dc6cd584a2873796cd7da6f93de57f7e465eb5423cca9a2f3fe3eff.json +1 -0
  73. xinference/web/ui/node_modules/.cache/babel-loader/65ca3ba225b8c8dac907210545b51f2fcdb2591f0feeb7195f1c037f2bc956a0.json +1 -0
  74. xinference/web/ui/node_modules/.cache/babel-loader/b80db1012318b97c329c4e3e72454f7512fb107e57c444b437dbe4ba1a3faa5a.json +1 -0
  75. {xinference-0.8.1.dist-info → xinference-0.8.3.dist-info}/METADATA +33 -23
  76. {xinference-0.8.1.dist-info → xinference-0.8.3.dist-info}/RECORD +81 -64
  77. xinference/api/oauth2/core.py +0 -93
  78. xinference/model/multimodal/__init__.py +0 -52
  79. xinference/model/multimodal/core.py +0 -467
  80. xinference/model/multimodal/model_spec.json +0 -43
  81. xinference/model/multimodal/model_spec_modelscope.json +0 -45
  82. xinference/web/ui/build/static/js/main.b83095c2.js +0 -3
  83. xinference/web/ui/build/static/js/main.b83095c2.js.map +0 -1
  84. xinference/web/ui/node_modules/.cache/babel-loader/101923c539819f26ad11fbcbd6f6e56436b285efbb090dcc7dd648c6e924c4a8.json +0 -1
  85. xinference/web/ui/node_modules/.cache/babel-loader/4942da6bc03bf7373af068e22f916341aabc5b5df855d73c1d348c696724ce37.json +0 -1
  86. xinference/web/ui/node_modules/.cache/babel-loader/52a6136cb2dbbf9c51d461724d9b283ebe74a73fb19d5df7ba8e13c42bd7174d.json +0 -1
  87. xinference/web/ui/node_modules/.cache/babel-loader/71493aadd34d568fbe605cacaba220aa69bd09273251ee4ba27930f8d01fccd8.json +0 -1
  88. xinference/web/ui/node_modules/.cache/babel-loader/8b071db2a5a9ef68dc14d5f606540bd23d9785e365a11997c510656764d2dccf.json +0 -1
  89. xinference/web/ui/node_modules/.cache/babel-loader/a4d72d3b806ba061919115f0c513738726872e3c79cf258f007519d3f91d1a16.json +0 -1
  90. xinference/web/ui/node_modules/.cache/babel-loader/f037ffef5992af0892d6d991053c1dace364cd39a3f11f1a41f92776e8a59459.json +0 -1
  91. /xinference/web/ui/build/static/js/{main.b83095c2.js.LICENSE.txt → main.15822aeb.js.LICENSE.txt} +0 -0
  92. {xinference-0.8.1.dist-info → xinference-0.8.3.dist-info}/LICENSE +0 -0
  93. {xinference-0.8.1.dist-info → xinference-0.8.3.dist-info}/WHEEL +0 -0
  94. {xinference-0.8.1.dist-info → xinference-0.8.3.dist-info}/entry_points.txt +0 -0
  95. {xinference-0.8.1.dist-info → xinference-0.8.3.dist-info}/top_level.txt +0 -0
xinference/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-01-19T17:14:28+0800",
11
+ "date": "2024-02-02T12:27:24+0800",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "fb3985e95fbb3e6cb51a321d6d6a9a10661128fe",
15
- "version": "0.8.1"
14
+ "full-revisionid": "749ef3ff298a94b88c1e67415819fae4fb1de75c",
15
+ "version": "0.8.3"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -0,0 +1,132 @@
1
+ # Copyright 2022-2024 XProbe Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ from datetime import timedelta
15
+ from typing import List, Optional
16
+
17
+ import pydantic
18
+ from fastapi import Depends, HTTPException, status
19
+ from fastapi.security import OAuth2PasswordBearer, SecurityScopes
20
+ from jose import JWTError, jwt
21
+ from pydantic import BaseModel, ValidationError
22
+ from typing_extensions import Annotated
23
+
24
+ from .types import AuthStartupConfig, User
25
+ from .utils import create_access_token, get_password_hash, verify_password
26
+
27
+ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
28
+
29
+
30
+ class TokenData(BaseModel):
31
+ username: str
32
+ scopes: List[str] = []
33
+
34
+
35
+ class AuthService:
36
+ def __init__(self, auth_config_file: Optional[str]):
37
+ self._auth_config_file = auth_config_file
38
+ self._config = self.init_auth_config()
39
+
40
+ @property
41
+ def config(self):
42
+ return self._config
43
+
44
+ def init_auth_config(self):
45
+ if self._auth_config_file:
46
+ config: AuthStartupConfig = pydantic.parse_file_as(
47
+ path=self._auth_config_file, type_=AuthStartupConfig
48
+ )
49
+ for user in config.user_config:
50
+ user.password = get_password_hash(user.password)
51
+ return config
52
+
53
+ def __call__(
54
+ self,
55
+ security_scopes: SecurityScopes,
56
+ token: Annotated[str, Depends(oauth2_scheme)],
57
+ ):
58
+ """
59
+ Advanced dependencies. See: https://fastapi.tiangolo.com/advanced/advanced-dependencies/
60
+ """
61
+ if security_scopes.scopes:
62
+ authenticate_value = f'Bearer scope="{security_scopes.scope_str}"'
63
+ else:
64
+ authenticate_value = "Bearer"
65
+ credentials_exception = HTTPException(
66
+ status_code=status.HTTP_401_UNAUTHORIZED,
67
+ detail="Could not validate credentials",
68
+ headers={"WWW-Authenticate": authenticate_value},
69
+ )
70
+
71
+ try:
72
+ assert self._config is not None
73
+ payload = jwt.decode(
74
+ token,
75
+ self._config.auth_config.secret_key,
76
+ algorithms=[self._config.auth_config.algorithm],
77
+ options={"verify_exp": False}, # TODO: supports token expiration
78
+ )
79
+ username: str = payload.get("sub")
80
+ if username is None:
81
+ raise credentials_exception
82
+ token_scopes = payload.get("scopes", [])
83
+ token_data = TokenData(scopes=token_scopes, username=username)
84
+ except (JWTError, ValidationError):
85
+ raise credentials_exception
86
+ user = self.get_user(token_data.username)
87
+ if user is None:
88
+ raise credentials_exception
89
+ if "admin" in token_data.scopes:
90
+ return user
91
+ for scope in security_scopes.scopes:
92
+ if scope not in token_data.scopes:
93
+ raise HTTPException(
94
+ status_code=status.HTTP_403_FORBIDDEN,
95
+ detail="Not enough permissions",
96
+ headers={"WWW-Authenticate": authenticate_value},
97
+ )
98
+ return user
99
+
100
+ def get_user(self, username: str) -> Optional[User]:
101
+ for user in self._config.user_config:
102
+ if user.username == username:
103
+ return user
104
+ return None
105
+
106
+ def authenticate_user(self, username: str, password: str):
107
+ user = self.get_user(username)
108
+ if not user:
109
+ return False
110
+ if not verify_password(password, user.password):
111
+ return False
112
+ return user
113
+
114
+ def generate_token_for_user(self, username: str, password: str):
115
+ user = self.authenticate_user(username, password)
116
+ if not user:
117
+ raise HTTPException(
118
+ status_code=status.HTTP_401_UNAUTHORIZED,
119
+ detail="Incorrect username or password",
120
+ headers={"WWW-Authenticate": "Bearer"},
121
+ )
122
+ assert user is not None and isinstance(user, User)
123
+ access_token_expires = timedelta(
124
+ minutes=self._config.auth_config.token_expire_in_minutes
125
+ )
126
+ access_token = create_access_token(
127
+ data={"sub": user.username, "scopes": user.permissions},
128
+ secret_key=self._config.auth_config.secret_key,
129
+ algorithm=self._config.auth_config.algorithm,
130
+ expires_delta=access_token_expires,
131
+ )
132
+ return {"access_token": access_token, "token_type": "bearer"}