label-studio-sdk 1.0.5__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 +76 -0
- label_studio_sdk/_extensions/eval/categorical.py +83 -0
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +13 -4
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +35 -17
- 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/annotations/__init__.py +3 -0
- label_studio_sdk/annotations/client.py +109 -0
- label_studio_sdk/annotations/types/__init__.py +5 -0
- label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +29 -0
- label_studio_sdk/base_client.py +9 -0
- label_studio_sdk/comments/__init__.py +2 -0
- label_studio_sdk/comments/client.py +512 -0
- label_studio_sdk/converter/converter.py +11 -4
- label_studio_sdk/converter/imports/coco.py +14 -13
- label_studio_sdk/converter/utils.py +72 -3
- label_studio_sdk/core/client_wrapper.py +1 -1
- label_studio_sdk/files/client.py +26 -16
- label_studio_sdk/label_interface/control_tags.py +205 -10
- label_studio_sdk/label_interface/interface.py +117 -10
- label_studio_sdk/label_interface/region.py +1 -10
- label_studio_sdk/model_providers/__init__.py +2 -0
- label_studio_sdk/model_providers/client.py +708 -0
- label_studio_sdk/projects/client.py +32 -16
- label_studio_sdk/projects/exports/client.py +133 -40
- label_studio_sdk/prompts/__init__.py +21 -0
- label_studio_sdk/prompts/client.py +862 -0
- label_studio_sdk/prompts/indicators/__init__.py +2 -0
- label_studio_sdk/prompts/indicators/client.py +194 -0
- label_studio_sdk/prompts/runs/__init__.py +5 -0
- label_studio_sdk/prompts/runs/client.py +354 -0
- label_studio_sdk/prompts/runs/types/__init__.py +5 -0
- label_studio_sdk/prompts/runs/types/runs_list_request_project_subset.py +5 -0
- label_studio_sdk/prompts/types/__init__.py +15 -0
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +42 -0
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +29 -0
- label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +62 -0
- label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +29 -0
- label_studio_sdk/prompts/versions/__init__.py +2 -0
- label_studio_sdk/prompts/versions/client.py +1046 -0
- label_studio_sdk/types/__init__.py +58 -0
- label_studio_sdk/types/comment.py +39 -0
- label_studio_sdk/types/comment_created_by.py +5 -0
- label_studio_sdk/types/inference_run.py +43 -0
- label_studio_sdk/types/inference_run_cost_estimate.py +57 -0
- label_studio_sdk/types/inference_run_created_by.py +5 -0
- label_studio_sdk/types/inference_run_organization.py +5 -0
- label_studio_sdk/types/inference_run_project_subset.py +5 -0
- label_studio_sdk/types/inference_run_status.py +7 -0
- label_studio_sdk/types/key_indicator_value.py +30 -0
- label_studio_sdk/types/key_indicators.py +7 -0
- label_studio_sdk/types/key_indicators_item.py +51 -0
- label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +37 -0
- label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +37 -0
- label_studio_sdk/types/model_provider_connection.py +71 -0
- label_studio_sdk/types/model_provider_connection_budget_reset_period.py +5 -0
- label_studio_sdk/types/model_provider_connection_created_by.py +5 -0
- label_studio_sdk/types/model_provider_connection_organization.py +5 -0
- label_studio_sdk/types/model_provider_connection_provider.py +5 -0
- label_studio_sdk/types/model_provider_connection_scope.py +5 -0
- label_studio_sdk/types/prompt.py +79 -0
- label_studio_sdk/types/prompt_created_by.py +5 -0
- label_studio_sdk/types/prompt_organization.py +5 -0
- label_studio_sdk/types/prompt_version.py +41 -0
- label_studio_sdk/types/prompt_version_created_by.py +5 -0
- label_studio_sdk/types/prompt_version_organization.py +5 -0
- label_studio_sdk/types/prompt_version_provider.py +5 -0
- label_studio_sdk/types/refined_prompt_response.py +64 -0
- label_studio_sdk/types/refined_prompt_response_refinement_status.py +7 -0
- label_studio_sdk/types/task.py +3 -2
- label_studio_sdk/types/task_comment_authors_item.py +5 -0
- label_studio_sdk/webhooks/client.py +245 -36
- label_studio_sdk/workspaces/client.py +20 -20
- label_studio_sdk-1.0.8.dist-info/LICENSE +201 -0
- {label_studio_sdk-1.0.5.dist-info → label_studio_sdk-1.0.8.dist-info}/METADATA +19 -3
- {label_studio_sdk-1.0.5.dist-info → label_studio_sdk-1.0.8.dist-info}/RECORD +77 -24
- {label_studio_sdk-1.0.5.dist-info → label_studio_sdk-1.0.8.dist-info}/WHEEL +1 -1
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from ..core.api_error import ApiError
|
|
8
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
10
|
+
from ..core.pydantic_utilities import pydantic_v1
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..types.model_provider_connection import ModelProviderConnection
|
|
13
|
+
from ..types.model_provider_connection_budget_reset_period import ModelProviderConnectionBudgetResetPeriod
|
|
14
|
+
from ..types.model_provider_connection_created_by import ModelProviderConnectionCreatedBy
|
|
15
|
+
from ..types.model_provider_connection_organization import ModelProviderConnectionOrganization
|
|
16
|
+
from ..types.model_provider_connection_provider import ModelProviderConnectionProvider
|
|
17
|
+
from ..types.model_provider_connection_scope import ModelProviderConnectionScope
|
|
18
|
+
|
|
19
|
+
# this is used as the default value for optional parameters
|
|
20
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ModelProvidersClient:
|
|
24
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
25
|
+
self._client_wrapper = client_wrapper
|
|
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
|
+
|
|
61
|
+
def create(
|
|
62
|
+
self,
|
|
63
|
+
*,
|
|
64
|
+
provider: ModelProviderConnectionProvider,
|
|
65
|
+
api_key: typing.Optional[str] = OMIT,
|
|
66
|
+
deployment_name: typing.Optional[str] = OMIT,
|
|
67
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
68
|
+
scope: typing.Optional[ModelProviderConnectionScope] = OMIT,
|
|
69
|
+
organization: typing.Optional[ModelProviderConnectionOrganization] = OMIT,
|
|
70
|
+
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
71
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
72
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
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,
|
|
80
|
+
) -> ModelProviderConnection:
|
|
81
|
+
"""
|
|
82
|
+
Create a new model provider connection.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
provider : ModelProviderConnectionProvider
|
|
87
|
+
|
|
88
|
+
api_key : typing.Optional[str]
|
|
89
|
+
|
|
90
|
+
deployment_name : typing.Optional[str]
|
|
91
|
+
|
|
92
|
+
endpoint : typing.Optional[str]
|
|
93
|
+
|
|
94
|
+
scope : typing.Optional[ModelProviderConnectionScope]
|
|
95
|
+
|
|
96
|
+
organization : typing.Optional[ModelProviderConnectionOrganization]
|
|
97
|
+
|
|
98
|
+
created_by : typing.Optional[ModelProviderConnectionCreatedBy]
|
|
99
|
+
|
|
100
|
+
created_at : typing.Optional[dt.datetime]
|
|
101
|
+
|
|
102
|
+
updated_at : typing.Optional[dt.datetime]
|
|
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
|
+
|
|
122
|
+
request_options : typing.Optional[RequestOptions]
|
|
123
|
+
Request-specific configuration.
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
ModelProviderConnection
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Examples
|
|
131
|
+
--------
|
|
132
|
+
from label_studio_sdk.client import LabelStudio
|
|
133
|
+
|
|
134
|
+
client = LabelStudio(
|
|
135
|
+
api_key="YOUR_API_KEY",
|
|
136
|
+
)
|
|
137
|
+
client.model_providers.create(
|
|
138
|
+
provider="OpenAI",
|
|
139
|
+
)
|
|
140
|
+
"""
|
|
141
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
142
|
+
"api/model-provider-connections/",
|
|
143
|
+
method="POST",
|
|
144
|
+
json={
|
|
145
|
+
"provider": provider,
|
|
146
|
+
"api_key": api_key,
|
|
147
|
+
"deployment_name": deployment_name,
|
|
148
|
+
"endpoint": endpoint,
|
|
149
|
+
"scope": scope,
|
|
150
|
+
"organization": organization,
|
|
151
|
+
"created_by": created_by,
|
|
152
|
+
"created_at": created_at,
|
|
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,
|
|
353
|
+
},
|
|
354
|
+
request_options=request_options,
|
|
355
|
+
omit=OMIT,
|
|
356
|
+
)
|
|
357
|
+
try:
|
|
358
|
+
if 200 <= _response.status_code < 300:
|
|
359
|
+
return pydantic_v1.parse_obj_as(ModelProviderConnection, _response.json()) # type: ignore
|
|
360
|
+
_response_json = _response.json()
|
|
361
|
+
except JSONDecodeError:
|
|
362
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
363
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
class AsyncModelProvidersClient:
|
|
367
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
368
|
+
self._client_wrapper = client_wrapper
|
|
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
|
+
|
|
406
|
+
async def create(
|
|
407
|
+
self,
|
|
408
|
+
*,
|
|
409
|
+
provider: ModelProviderConnectionProvider,
|
|
410
|
+
api_key: typing.Optional[str] = OMIT,
|
|
411
|
+
deployment_name: typing.Optional[str] = OMIT,
|
|
412
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
413
|
+
scope: typing.Optional[ModelProviderConnectionScope] = OMIT,
|
|
414
|
+
organization: typing.Optional[ModelProviderConnectionOrganization] = OMIT,
|
|
415
|
+
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
416
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
417
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
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,
|
|
425
|
+
) -> ModelProviderConnection:
|
|
426
|
+
"""
|
|
427
|
+
Create a new model provider connection.
|
|
428
|
+
|
|
429
|
+
Parameters
|
|
430
|
+
----------
|
|
431
|
+
provider : ModelProviderConnectionProvider
|
|
432
|
+
|
|
433
|
+
api_key : typing.Optional[str]
|
|
434
|
+
|
|
435
|
+
deployment_name : typing.Optional[str]
|
|
436
|
+
|
|
437
|
+
endpoint : typing.Optional[str]
|
|
438
|
+
|
|
439
|
+
scope : typing.Optional[ModelProviderConnectionScope]
|
|
440
|
+
|
|
441
|
+
organization : typing.Optional[ModelProviderConnectionOrganization]
|
|
442
|
+
|
|
443
|
+
created_by : typing.Optional[ModelProviderConnectionCreatedBy]
|
|
444
|
+
|
|
445
|
+
created_at : typing.Optional[dt.datetime]
|
|
446
|
+
|
|
447
|
+
updated_at : typing.Optional[dt.datetime]
|
|
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
|
+
|
|
467
|
+
request_options : typing.Optional[RequestOptions]
|
|
468
|
+
Request-specific configuration.
|
|
469
|
+
|
|
470
|
+
Returns
|
|
471
|
+
-------
|
|
472
|
+
ModelProviderConnection
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
Examples
|
|
476
|
+
--------
|
|
477
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
478
|
+
|
|
479
|
+
client = AsyncLabelStudio(
|
|
480
|
+
api_key="YOUR_API_KEY",
|
|
481
|
+
)
|
|
482
|
+
await client.model_providers.create(
|
|
483
|
+
provider="OpenAI",
|
|
484
|
+
)
|
|
485
|
+
"""
|
|
486
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
487
|
+
"api/model-provider-connections/",
|
|
488
|
+
method="POST",
|
|
489
|
+
json={
|
|
490
|
+
"provider": provider,
|
|
491
|
+
"api_key": api_key,
|
|
492
|
+
"deployment_name": deployment_name,
|
|
493
|
+
"endpoint": endpoint,
|
|
494
|
+
"scope": scope,
|
|
495
|
+
"organization": organization,
|
|
496
|
+
"created_by": created_by,
|
|
497
|
+
"created_at": created_at,
|
|
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,
|
|
698
|
+
},
|
|
699
|
+
request_options=request_options,
|
|
700
|
+
omit=OMIT,
|
|
701
|
+
)
|
|
702
|
+
try:
|
|
703
|
+
if 200 <= _response.status_code < 300:
|
|
704
|
+
return pydantic_v1.parse_obj_as(ModelProviderConnection, _response.json()) # type: ignore
|
|
705
|
+
_response_json = _response.json()
|
|
706
|
+
except JSONDecodeError:
|
|
707
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
708
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|