label-studio-sdk 1.0.7__py3-none-any.whl → 1.0.8__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 label-studio-sdk might be problematic. Click here for more details.
- label_studio_sdk/__init__.py +6 -0
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +13 -4
- label_studio_sdk/_extensions/label_studio_tools/core/utils/json_schema.py +86 -0
- label_studio_sdk/_legacy/schema/label_config_schema.json +42 -11
- label_studio_sdk/converter/converter.py +10 -5
- label_studio_sdk/core/client_wrapper.py +1 -1
- label_studio_sdk/label_interface/control_tags.py +205 -10
- label_studio_sdk/label_interface/interface.py +80 -6
- label_studio_sdk/label_interface/region.py +1 -10
- label_studio_sdk/model_providers/client.py +520 -2
- label_studio_sdk/prompts/versions/client.py +125 -0
- label_studio_sdk/types/__init__.py +6 -0
- label_studio_sdk/types/inference_run_cost_estimate.py +57 -0
- label_studio_sdk/types/model_provider_connection.py +30 -0
- label_studio_sdk/types/model_provider_connection_budget_reset_period.py +5 -0
- label_studio_sdk/types/model_provider_connection_provider.py +1 -1
- label_studio_sdk/types/refined_prompt_response.py +1 -1
- label_studio_sdk/types/task.py +3 -2
- label_studio_sdk/types/task_comment_authors_item.py +5 -0
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.8.dist-info}/METADATA +3 -1
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.8.dist-info}/RECORD +23 -19
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.8.dist-info}/LICENSE +0 -0
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.8.dist-info}/WHEEL +0 -0
|
@@ -6,9 +6,11 @@ from json.decoder import JSONDecodeError
|
|
|
6
6
|
|
|
7
7
|
from ..core.api_error import ApiError
|
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
9
10
|
from ..core.pydantic_utilities import pydantic_v1
|
|
10
11
|
from ..core.request_options import RequestOptions
|
|
11
12
|
from ..types.model_provider_connection import ModelProviderConnection
|
|
13
|
+
from ..types.model_provider_connection_budget_reset_period import ModelProviderConnectionBudgetResetPeriod
|
|
12
14
|
from ..types.model_provider_connection_created_by import ModelProviderConnectionCreatedBy
|
|
13
15
|
from ..types.model_provider_connection_organization import ModelProviderConnectionOrganization
|
|
14
16
|
from ..types.model_provider_connection_provider import ModelProviderConnectionProvider
|
|
@@ -22,6 +24,40 @@ class ModelProvidersClient:
|
|
|
22
24
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
23
25
|
self._client_wrapper = client_wrapper
|
|
24
26
|
|
|
27
|
+
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[ModelProviderConnection]:
|
|
28
|
+
"""
|
|
29
|
+
Get all model provider connections created by the user in the current organization.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
request_options : typing.Optional[RequestOptions]
|
|
34
|
+
Request-specific configuration.
|
|
35
|
+
|
|
36
|
+
Returns
|
|
37
|
+
-------
|
|
38
|
+
typing.List[ModelProviderConnection]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Examples
|
|
42
|
+
--------
|
|
43
|
+
from label_studio_sdk.client import LabelStudio
|
|
44
|
+
|
|
45
|
+
client = LabelStudio(
|
|
46
|
+
api_key="YOUR_API_KEY",
|
|
47
|
+
)
|
|
48
|
+
client.model_providers.list()
|
|
49
|
+
"""
|
|
50
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
51
|
+
"api/model-provider-connections/", method="GET", request_options=request_options
|
|
52
|
+
)
|
|
53
|
+
try:
|
|
54
|
+
if 200 <= _response.status_code < 300:
|
|
55
|
+
return pydantic_v1.parse_obj_as(typing.List[ModelProviderConnection], _response.json()) # type: ignore
|
|
56
|
+
_response_json = _response.json()
|
|
57
|
+
except JSONDecodeError:
|
|
58
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
59
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
60
|
+
|
|
25
61
|
def create(
|
|
26
62
|
self,
|
|
27
63
|
*,
|
|
@@ -34,7 +70,13 @@ class ModelProvidersClient:
|
|
|
34
70
|
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
35
71
|
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
36
72
|
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
37
|
-
|
|
73
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
74
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
75
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
76
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
77
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
78
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
79
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
38
80
|
) -> ModelProviderConnection:
|
|
39
81
|
"""
|
|
40
82
|
Create a new model provider connection.
|
|
@@ -59,6 +101,24 @@ class ModelProvidersClient:
|
|
|
59
101
|
|
|
60
102
|
updated_at : typing.Optional[dt.datetime]
|
|
61
103
|
|
|
104
|
+
is_internal : typing.Optional[bool]
|
|
105
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
106
|
+
|
|
107
|
+
budget_limit : typing.Optional[float]
|
|
108
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
109
|
+
|
|
110
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
111
|
+
Date and time the budget was last reset
|
|
112
|
+
|
|
113
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
114
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
115
|
+
|
|
116
|
+
budget_total_spent : typing.Optional[float]
|
|
117
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
118
|
+
|
|
119
|
+
budget_alert_threshold : typing.Optional[float]
|
|
120
|
+
Budget alert threshold for the given provider connection
|
|
121
|
+
|
|
62
122
|
request_options : typing.Optional[RequestOptions]
|
|
63
123
|
Request-specific configuration.
|
|
64
124
|
|
|
@@ -91,6 +151,205 @@ class ModelProvidersClient:
|
|
|
91
151
|
"created_by": created_by,
|
|
92
152
|
"created_at": created_at,
|
|
93
153
|
"updated_at": updated_at,
|
|
154
|
+
"is_internal": is_internal,
|
|
155
|
+
"budget_limit": budget_limit,
|
|
156
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
157
|
+
"budget_reset_period": budget_reset_period,
|
|
158
|
+
"budget_total_spent": budget_total_spent,
|
|
159
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
160
|
+
},
|
|
161
|
+
request_options=request_options,
|
|
162
|
+
omit=OMIT,
|
|
163
|
+
)
|
|
164
|
+
try:
|
|
165
|
+
if 200 <= _response.status_code < 300:
|
|
166
|
+
return pydantic_v1.parse_obj_as(ModelProviderConnection, _response.json()) # type: ignore
|
|
167
|
+
_response_json = _response.json()
|
|
168
|
+
except JSONDecodeError:
|
|
169
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
170
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
171
|
+
|
|
172
|
+
def get(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
|
|
173
|
+
"""
|
|
174
|
+
Get a model provider connection by ID.
|
|
175
|
+
|
|
176
|
+
Parameters
|
|
177
|
+
----------
|
|
178
|
+
pk : int
|
|
179
|
+
Model Provider Connection ID
|
|
180
|
+
|
|
181
|
+
request_options : typing.Optional[RequestOptions]
|
|
182
|
+
Request-specific configuration.
|
|
183
|
+
|
|
184
|
+
Returns
|
|
185
|
+
-------
|
|
186
|
+
ModelProviderConnection
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
Examples
|
|
190
|
+
--------
|
|
191
|
+
from label_studio_sdk.client import LabelStudio
|
|
192
|
+
|
|
193
|
+
client = LabelStudio(
|
|
194
|
+
api_key="YOUR_API_KEY",
|
|
195
|
+
)
|
|
196
|
+
client.model_providers.get(
|
|
197
|
+
pk=1,
|
|
198
|
+
)
|
|
199
|
+
"""
|
|
200
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
201
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}", method="GET", request_options=request_options
|
|
202
|
+
)
|
|
203
|
+
try:
|
|
204
|
+
if 200 <= _response.status_code < 300:
|
|
205
|
+
return pydantic_v1.parse_obj_as(ModelProviderConnection, _response.json()) # type: ignore
|
|
206
|
+
_response_json = _response.json()
|
|
207
|
+
except JSONDecodeError:
|
|
208
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
209
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
210
|
+
|
|
211
|
+
def delete(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
212
|
+
"""
|
|
213
|
+
Delete a model provider connection by ID.
|
|
214
|
+
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
pk : int
|
|
218
|
+
Model Provider Connection ID
|
|
219
|
+
|
|
220
|
+
request_options : typing.Optional[RequestOptions]
|
|
221
|
+
Request-specific configuration.
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
None
|
|
226
|
+
|
|
227
|
+
Examples
|
|
228
|
+
--------
|
|
229
|
+
from label_studio_sdk.client import LabelStudio
|
|
230
|
+
|
|
231
|
+
client = LabelStudio(
|
|
232
|
+
api_key="YOUR_API_KEY",
|
|
233
|
+
)
|
|
234
|
+
client.model_providers.delete(
|
|
235
|
+
pk=1,
|
|
236
|
+
)
|
|
237
|
+
"""
|
|
238
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
239
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}", method="DELETE", request_options=request_options
|
|
240
|
+
)
|
|
241
|
+
try:
|
|
242
|
+
if 200 <= _response.status_code < 300:
|
|
243
|
+
return
|
|
244
|
+
_response_json = _response.json()
|
|
245
|
+
except JSONDecodeError:
|
|
246
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
247
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
248
|
+
|
|
249
|
+
def update(
|
|
250
|
+
self,
|
|
251
|
+
pk: int,
|
|
252
|
+
*,
|
|
253
|
+
provider: ModelProviderConnectionProvider,
|
|
254
|
+
api_key: typing.Optional[str] = OMIT,
|
|
255
|
+
deployment_name: typing.Optional[str] = OMIT,
|
|
256
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
257
|
+
scope: typing.Optional[ModelProviderConnectionScope] = OMIT,
|
|
258
|
+
organization: typing.Optional[ModelProviderConnectionOrganization] = OMIT,
|
|
259
|
+
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
260
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
261
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
262
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
263
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
264
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
265
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
266
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
267
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
268
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
269
|
+
) -> ModelProviderConnection:
|
|
270
|
+
"""
|
|
271
|
+
Update a model provider connection by ID.
|
|
272
|
+
|
|
273
|
+
Parameters
|
|
274
|
+
----------
|
|
275
|
+
pk : int
|
|
276
|
+
Model Provider Connection ID
|
|
277
|
+
|
|
278
|
+
provider : ModelProviderConnectionProvider
|
|
279
|
+
|
|
280
|
+
api_key : typing.Optional[str]
|
|
281
|
+
|
|
282
|
+
deployment_name : typing.Optional[str]
|
|
283
|
+
|
|
284
|
+
endpoint : typing.Optional[str]
|
|
285
|
+
|
|
286
|
+
scope : typing.Optional[ModelProviderConnectionScope]
|
|
287
|
+
|
|
288
|
+
organization : typing.Optional[ModelProviderConnectionOrganization]
|
|
289
|
+
|
|
290
|
+
created_by : typing.Optional[ModelProviderConnectionCreatedBy]
|
|
291
|
+
|
|
292
|
+
created_at : typing.Optional[dt.datetime]
|
|
293
|
+
|
|
294
|
+
updated_at : typing.Optional[dt.datetime]
|
|
295
|
+
|
|
296
|
+
is_internal : typing.Optional[bool]
|
|
297
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
298
|
+
|
|
299
|
+
budget_limit : typing.Optional[float]
|
|
300
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
301
|
+
|
|
302
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
303
|
+
Date and time the budget was last reset
|
|
304
|
+
|
|
305
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
306
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
307
|
+
|
|
308
|
+
budget_total_spent : typing.Optional[float]
|
|
309
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
310
|
+
|
|
311
|
+
budget_alert_threshold : typing.Optional[float]
|
|
312
|
+
Budget alert threshold for the given provider connection
|
|
313
|
+
|
|
314
|
+
request_options : typing.Optional[RequestOptions]
|
|
315
|
+
Request-specific configuration.
|
|
316
|
+
|
|
317
|
+
Returns
|
|
318
|
+
-------
|
|
319
|
+
ModelProviderConnection
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
Examples
|
|
323
|
+
--------
|
|
324
|
+
from label_studio_sdk.client import LabelStudio
|
|
325
|
+
|
|
326
|
+
client = LabelStudio(
|
|
327
|
+
api_key="YOUR_API_KEY",
|
|
328
|
+
)
|
|
329
|
+
client.model_providers.update(
|
|
330
|
+
pk=1,
|
|
331
|
+
provider="OpenAI",
|
|
332
|
+
)
|
|
333
|
+
"""
|
|
334
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
335
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
336
|
+
method="PATCH",
|
|
337
|
+
json={
|
|
338
|
+
"provider": provider,
|
|
339
|
+
"api_key": api_key,
|
|
340
|
+
"deployment_name": deployment_name,
|
|
341
|
+
"endpoint": endpoint,
|
|
342
|
+
"scope": scope,
|
|
343
|
+
"organization": organization,
|
|
344
|
+
"created_by": created_by,
|
|
345
|
+
"created_at": created_at,
|
|
346
|
+
"updated_at": updated_at,
|
|
347
|
+
"is_internal": is_internal,
|
|
348
|
+
"budget_limit": budget_limit,
|
|
349
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
350
|
+
"budget_reset_period": budget_reset_period,
|
|
351
|
+
"budget_total_spent": budget_total_spent,
|
|
352
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
94
353
|
},
|
|
95
354
|
request_options=request_options,
|
|
96
355
|
omit=OMIT,
|
|
@@ -108,6 +367,42 @@ class AsyncModelProvidersClient:
|
|
|
108
367
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
109
368
|
self._client_wrapper = client_wrapper
|
|
110
369
|
|
|
370
|
+
async def list(
|
|
371
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
372
|
+
) -> typing.List[ModelProviderConnection]:
|
|
373
|
+
"""
|
|
374
|
+
Get all model provider connections created by the user in the current organization.
|
|
375
|
+
|
|
376
|
+
Parameters
|
|
377
|
+
----------
|
|
378
|
+
request_options : typing.Optional[RequestOptions]
|
|
379
|
+
Request-specific configuration.
|
|
380
|
+
|
|
381
|
+
Returns
|
|
382
|
+
-------
|
|
383
|
+
typing.List[ModelProviderConnection]
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
Examples
|
|
387
|
+
--------
|
|
388
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
389
|
+
|
|
390
|
+
client = AsyncLabelStudio(
|
|
391
|
+
api_key="YOUR_API_KEY",
|
|
392
|
+
)
|
|
393
|
+
await client.model_providers.list()
|
|
394
|
+
"""
|
|
395
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
396
|
+
"api/model-provider-connections/", method="GET", request_options=request_options
|
|
397
|
+
)
|
|
398
|
+
try:
|
|
399
|
+
if 200 <= _response.status_code < 300:
|
|
400
|
+
return pydantic_v1.parse_obj_as(typing.List[ModelProviderConnection], _response.json()) # type: ignore
|
|
401
|
+
_response_json = _response.json()
|
|
402
|
+
except JSONDecodeError:
|
|
403
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
404
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
405
|
+
|
|
111
406
|
async def create(
|
|
112
407
|
self,
|
|
113
408
|
*,
|
|
@@ -120,7 +415,13 @@ class AsyncModelProvidersClient:
|
|
|
120
415
|
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
121
416
|
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
122
417
|
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
123
|
-
|
|
418
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
419
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
420
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
421
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
422
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
423
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
424
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
124
425
|
) -> ModelProviderConnection:
|
|
125
426
|
"""
|
|
126
427
|
Create a new model provider connection.
|
|
@@ -145,6 +446,24 @@ class AsyncModelProvidersClient:
|
|
|
145
446
|
|
|
146
447
|
updated_at : typing.Optional[dt.datetime]
|
|
147
448
|
|
|
449
|
+
is_internal : typing.Optional[bool]
|
|
450
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
451
|
+
|
|
452
|
+
budget_limit : typing.Optional[float]
|
|
453
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
454
|
+
|
|
455
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
456
|
+
Date and time the budget was last reset
|
|
457
|
+
|
|
458
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
459
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
460
|
+
|
|
461
|
+
budget_total_spent : typing.Optional[float]
|
|
462
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
463
|
+
|
|
464
|
+
budget_alert_threshold : typing.Optional[float]
|
|
465
|
+
Budget alert threshold for the given provider connection
|
|
466
|
+
|
|
148
467
|
request_options : typing.Optional[RequestOptions]
|
|
149
468
|
Request-specific configuration.
|
|
150
469
|
|
|
@@ -177,6 +496,205 @@ class AsyncModelProvidersClient:
|
|
|
177
496
|
"created_by": created_by,
|
|
178
497
|
"created_at": created_at,
|
|
179
498
|
"updated_at": updated_at,
|
|
499
|
+
"is_internal": is_internal,
|
|
500
|
+
"budget_limit": budget_limit,
|
|
501
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
502
|
+
"budget_reset_period": budget_reset_period,
|
|
503
|
+
"budget_total_spent": budget_total_spent,
|
|
504
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
505
|
+
},
|
|
506
|
+
request_options=request_options,
|
|
507
|
+
omit=OMIT,
|
|
508
|
+
)
|
|
509
|
+
try:
|
|
510
|
+
if 200 <= _response.status_code < 300:
|
|
511
|
+
return pydantic_v1.parse_obj_as(ModelProviderConnection, _response.json()) # type: ignore
|
|
512
|
+
_response_json = _response.json()
|
|
513
|
+
except JSONDecodeError:
|
|
514
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
515
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
516
|
+
|
|
517
|
+
async def get(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
|
|
518
|
+
"""
|
|
519
|
+
Get a model provider connection by ID.
|
|
520
|
+
|
|
521
|
+
Parameters
|
|
522
|
+
----------
|
|
523
|
+
pk : int
|
|
524
|
+
Model Provider Connection ID
|
|
525
|
+
|
|
526
|
+
request_options : typing.Optional[RequestOptions]
|
|
527
|
+
Request-specific configuration.
|
|
528
|
+
|
|
529
|
+
Returns
|
|
530
|
+
-------
|
|
531
|
+
ModelProviderConnection
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
Examples
|
|
535
|
+
--------
|
|
536
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
537
|
+
|
|
538
|
+
client = AsyncLabelStudio(
|
|
539
|
+
api_key="YOUR_API_KEY",
|
|
540
|
+
)
|
|
541
|
+
await client.model_providers.get(
|
|
542
|
+
pk=1,
|
|
543
|
+
)
|
|
544
|
+
"""
|
|
545
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
546
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}", method="GET", request_options=request_options
|
|
547
|
+
)
|
|
548
|
+
try:
|
|
549
|
+
if 200 <= _response.status_code < 300:
|
|
550
|
+
return pydantic_v1.parse_obj_as(ModelProviderConnection, _response.json()) # type: ignore
|
|
551
|
+
_response_json = _response.json()
|
|
552
|
+
except JSONDecodeError:
|
|
553
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
554
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
555
|
+
|
|
556
|
+
async def delete(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
557
|
+
"""
|
|
558
|
+
Delete a model provider connection by ID.
|
|
559
|
+
|
|
560
|
+
Parameters
|
|
561
|
+
----------
|
|
562
|
+
pk : int
|
|
563
|
+
Model Provider Connection ID
|
|
564
|
+
|
|
565
|
+
request_options : typing.Optional[RequestOptions]
|
|
566
|
+
Request-specific configuration.
|
|
567
|
+
|
|
568
|
+
Returns
|
|
569
|
+
-------
|
|
570
|
+
None
|
|
571
|
+
|
|
572
|
+
Examples
|
|
573
|
+
--------
|
|
574
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
575
|
+
|
|
576
|
+
client = AsyncLabelStudio(
|
|
577
|
+
api_key="YOUR_API_KEY",
|
|
578
|
+
)
|
|
579
|
+
await client.model_providers.delete(
|
|
580
|
+
pk=1,
|
|
581
|
+
)
|
|
582
|
+
"""
|
|
583
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
584
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}", method="DELETE", request_options=request_options
|
|
585
|
+
)
|
|
586
|
+
try:
|
|
587
|
+
if 200 <= _response.status_code < 300:
|
|
588
|
+
return
|
|
589
|
+
_response_json = _response.json()
|
|
590
|
+
except JSONDecodeError:
|
|
591
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
592
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
593
|
+
|
|
594
|
+
async def update(
|
|
595
|
+
self,
|
|
596
|
+
pk: int,
|
|
597
|
+
*,
|
|
598
|
+
provider: ModelProviderConnectionProvider,
|
|
599
|
+
api_key: typing.Optional[str] = OMIT,
|
|
600
|
+
deployment_name: typing.Optional[str] = OMIT,
|
|
601
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
602
|
+
scope: typing.Optional[ModelProviderConnectionScope] = OMIT,
|
|
603
|
+
organization: typing.Optional[ModelProviderConnectionOrganization] = OMIT,
|
|
604
|
+
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
605
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
606
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
607
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
608
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
609
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
610
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
611
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
612
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
613
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
614
|
+
) -> ModelProviderConnection:
|
|
615
|
+
"""
|
|
616
|
+
Update a model provider connection by ID.
|
|
617
|
+
|
|
618
|
+
Parameters
|
|
619
|
+
----------
|
|
620
|
+
pk : int
|
|
621
|
+
Model Provider Connection ID
|
|
622
|
+
|
|
623
|
+
provider : ModelProviderConnectionProvider
|
|
624
|
+
|
|
625
|
+
api_key : typing.Optional[str]
|
|
626
|
+
|
|
627
|
+
deployment_name : typing.Optional[str]
|
|
628
|
+
|
|
629
|
+
endpoint : typing.Optional[str]
|
|
630
|
+
|
|
631
|
+
scope : typing.Optional[ModelProviderConnectionScope]
|
|
632
|
+
|
|
633
|
+
organization : typing.Optional[ModelProviderConnectionOrganization]
|
|
634
|
+
|
|
635
|
+
created_by : typing.Optional[ModelProviderConnectionCreatedBy]
|
|
636
|
+
|
|
637
|
+
created_at : typing.Optional[dt.datetime]
|
|
638
|
+
|
|
639
|
+
updated_at : typing.Optional[dt.datetime]
|
|
640
|
+
|
|
641
|
+
is_internal : typing.Optional[bool]
|
|
642
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
643
|
+
|
|
644
|
+
budget_limit : typing.Optional[float]
|
|
645
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
646
|
+
|
|
647
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
648
|
+
Date and time the budget was last reset
|
|
649
|
+
|
|
650
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
651
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
652
|
+
|
|
653
|
+
budget_total_spent : typing.Optional[float]
|
|
654
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
655
|
+
|
|
656
|
+
budget_alert_threshold : typing.Optional[float]
|
|
657
|
+
Budget alert threshold for the given provider connection
|
|
658
|
+
|
|
659
|
+
request_options : typing.Optional[RequestOptions]
|
|
660
|
+
Request-specific configuration.
|
|
661
|
+
|
|
662
|
+
Returns
|
|
663
|
+
-------
|
|
664
|
+
ModelProviderConnection
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
Examples
|
|
668
|
+
--------
|
|
669
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
670
|
+
|
|
671
|
+
client = AsyncLabelStudio(
|
|
672
|
+
api_key="YOUR_API_KEY",
|
|
673
|
+
)
|
|
674
|
+
await client.model_providers.update(
|
|
675
|
+
pk=1,
|
|
676
|
+
provider="OpenAI",
|
|
677
|
+
)
|
|
678
|
+
"""
|
|
679
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
680
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
681
|
+
method="PATCH",
|
|
682
|
+
json={
|
|
683
|
+
"provider": provider,
|
|
684
|
+
"api_key": api_key,
|
|
685
|
+
"deployment_name": deployment_name,
|
|
686
|
+
"endpoint": endpoint,
|
|
687
|
+
"scope": scope,
|
|
688
|
+
"organization": organization,
|
|
689
|
+
"created_by": created_by,
|
|
690
|
+
"created_at": created_at,
|
|
691
|
+
"updated_at": updated_at,
|
|
692
|
+
"is_internal": is_internal,
|
|
693
|
+
"budget_limit": budget_limit,
|
|
694
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
695
|
+
"budget_reset_period": budget_reset_period,
|
|
696
|
+
"budget_total_spent": budget_total_spent,
|
|
697
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
180
698
|
},
|
|
181
699
|
request_options=request_options,
|
|
182
700
|
omit=OMIT,
|