label-studio-sdk 1.0.7__py3-none-any.whl → 1.0.10__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 +26 -7
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +13 -4
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +16 -4
- label_studio_sdk/_extensions/label_studio_tools/core/utils/json_schema.py +86 -0
- label_studio_sdk/_extensions/pager_ext.py +8 -0
- label_studio_sdk/_legacy/schema/label_config_schema.json +42 -11
- label_studio_sdk/actions/client.py +91 -40
- label_studio_sdk/actions/types/actions_create_request_filters.py +14 -24
- label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +16 -26
- label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +3 -1
- label_studio_sdk/actions/types/actions_create_request_selected_items.py +1 -2
- label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +15 -25
- label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +15 -25
- label_studio_sdk/annotations/__init__.py +2 -2
- label_studio_sdk/annotations/client.py +278 -104
- label_studio_sdk/annotations/types/__init__.py +2 -1
- label_studio_sdk/annotations/types/annotations_create_bulk_request_selected_items.py +34 -0
- label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +11 -21
- label_studio_sdk/base_client.py +46 -27
- label_studio_sdk/client.py +1 -0
- label_studio_sdk/comments/client.py +190 -44
- label_studio_sdk/converter/converter.py +66 -18
- label_studio_sdk/converter/imports/yolo.py +1 -1
- label_studio_sdk/converter/utils.py +3 -2
- label_studio_sdk/core/__init__.py +21 -4
- label_studio_sdk/core/client_wrapper.py +9 -10
- label_studio_sdk/core/file.py +37 -8
- label_studio_sdk/core/http_client.py +52 -28
- label_studio_sdk/core/jsonable_encoder.py +33 -31
- label_studio_sdk/core/pagination.py +5 -4
- label_studio_sdk/core/pydantic_utilities.py +272 -4
- label_studio_sdk/core/query_encoder.py +38 -13
- label_studio_sdk/core/request_options.py +3 -0
- label_studio_sdk/core/serialization.py +272 -0
- label_studio_sdk/errors/bad_request_error.py +2 -3
- label_studio_sdk/export_storage/azure/client.py +228 -58
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +19 -29
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +19 -29
- label_studio_sdk/export_storage/client.py +48 -18
- label_studio_sdk/export_storage/gcs/client.py +228 -58
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +19 -29
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +19 -29
- label_studio_sdk/export_storage/local/client.py +222 -56
- label_studio_sdk/export_storage/local/types/local_create_response.py +17 -27
- label_studio_sdk/export_storage/local/types/local_update_response.py +17 -27
- label_studio_sdk/export_storage/redis/client.py +228 -58
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -30
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -30
- label_studio_sdk/export_storage/s3/client.py +228 -58
- label_studio_sdk/export_storage/s3/types/s3create_response.py +27 -35
- label_studio_sdk/export_storage/s3/types/s3update_response.py +27 -35
- label_studio_sdk/export_storage/s3s/client.py +187 -43
- label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +11 -21
- label_studio_sdk/files/client.py +172 -56
- label_studio_sdk/import_storage/azure/client.py +223 -53
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +22 -32
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +22 -32
- label_studio_sdk/import_storage/client.py +48 -18
- label_studio_sdk/import_storage/gcs/client.py +223 -53
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +22 -32
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +22 -32
- label_studio_sdk/import_storage/local/client.py +223 -53
- label_studio_sdk/import_storage/local/types/local_create_response.py +17 -27
- label_studio_sdk/import_storage/local/types/local_update_response.py +17 -27
- label_studio_sdk/import_storage/redis/client.py +223 -53
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -30
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -30
- label_studio_sdk/import_storage/s3/client.py +223 -53
- label_studio_sdk/import_storage/s3/types/s3create_response.py +31 -39
- label_studio_sdk/import_storage/s3/types/s3update_response.py +31 -39
- label_studio_sdk/import_storage/s3s/client.py +222 -52
- label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +11 -21
- 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/ml/client.py +280 -78
- label_studio_sdk/ml/types/ml_create_response.py +21 -31
- label_studio_sdk/ml/types/ml_update_response.py +21 -31
- label_studio_sdk/model_providers/client.py +656 -21
- label_studio_sdk/predictions/client.py +247 -101
- label_studio_sdk/projects/__init__.py +3 -0
- label_studio_sdk/projects/client.py +309 -115
- label_studio_sdk/projects/client_ext.py +16 -0
- label_studio_sdk/projects/exports/__init__.py +3 -0
- label_studio_sdk/projects/exports/client.py +447 -296
- label_studio_sdk/projects/exports/client_ext.py +134 -0
- label_studio_sdk/projects/exports/types/__init__.py +6 -0
- label_studio_sdk/projects/exports/types/exports_convert_response.py +24 -0
- label_studio_sdk/projects/exports/types/exports_list_formats_response_item.py +44 -0
- label_studio_sdk/projects/types/projects_create_response.py +29 -34
- label_studio_sdk/projects/types/projects_import_tasks_response.py +19 -29
- label_studio_sdk/projects/types/projects_list_response.py +11 -21
- label_studio_sdk/projects/types/projects_update_response.py +24 -34
- label_studio_sdk/prompts/client.py +309 -92
- label_studio_sdk/prompts/indicators/client.py +67 -23
- label_studio_sdk/prompts/runs/client.py +95 -40
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +14 -24
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +11 -21
- label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +26 -29
- label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +11 -21
- label_studio_sdk/prompts/versions/client.py +389 -75
- label_studio_sdk/tasks/client.py +263 -90
- label_studio_sdk/tasks/types/tasks_list_response.py +15 -25
- label_studio_sdk/types/__init__.py +16 -6
- label_studio_sdk/types/annotation.py +29 -38
- label_studio_sdk/types/annotation_filter_options.py +14 -24
- label_studio_sdk/types/annotations_dm_field.py +30 -39
- label_studio_sdk/types/azure_blob_export_storage.py +28 -37
- label_studio_sdk/types/azure_blob_import_storage.py +28 -37
- label_studio_sdk/types/base_task.py +30 -39
- label_studio_sdk/types/base_task_updated_by.py +3 -1
- label_studio_sdk/types/base_user.py +14 -21
- label_studio_sdk/types/comment.py +12 -21
- label_studio_sdk/types/comment_created_by.py +1 -1
- label_studio_sdk/types/converted_format.py +12 -22
- label_studio_sdk/types/data_manager_task_serializer.py +31 -40
- label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +1 -1
- label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +13 -22
- label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +15 -24
- label_studio_sdk/types/export.py +17 -26
- label_studio_sdk/types/export_format.py +25 -0
- label_studio_sdk/types/export_snapshot.py +45 -0
- label_studio_sdk/types/export_snapshot_status.py +5 -0
- label_studio_sdk/types/file_upload.py +11 -21
- label_studio_sdk/types/filter.py +16 -26
- label_studio_sdk/types/filter_group.py +12 -22
- label_studio_sdk/types/gcs_export_storage.py +28 -37
- label_studio_sdk/types/gcs_import_storage.py +28 -37
- label_studio_sdk/types/inference_run.py +14 -23
- label_studio_sdk/types/inference_run_cost_estimate.py +47 -0
- label_studio_sdk/types/inference_run_created_by.py +1 -1
- label_studio_sdk/types/inference_run_organization.py +1 -1
- label_studio_sdk/types/key_indicator_value.py +12 -22
- label_studio_sdk/types/key_indicators.py +0 -1
- label_studio_sdk/types/key_indicators_item.py +15 -25
- label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +13 -23
- label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +13 -23
- label_studio_sdk/types/local_files_export_storage.py +25 -34
- label_studio_sdk/types/local_files_import_storage.py +24 -33
- label_studio_sdk/types/ml_backend.py +23 -32
- label_studio_sdk/types/model_provider_connection.py +47 -26
- label_studio_sdk/types/model_provider_connection_budget_reset_period.py +5 -0
- label_studio_sdk/types/model_provider_connection_created_by.py +1 -1
- label_studio_sdk/types/model_provider_connection_organization.py +1 -1
- label_studio_sdk/types/model_provider_connection_provider.py +3 -1
- label_studio_sdk/types/prediction.py +21 -30
- label_studio_sdk/types/project.py +48 -55
- label_studio_sdk/types/project_import.py +21 -30
- label_studio_sdk/types/project_label_config.py +12 -22
- label_studio_sdk/types/prompt.py +24 -32
- label_studio_sdk/types/prompt_associated_projects_item.py +6 -0
- label_studio_sdk/types/prompt_associated_projects_item_id.py +20 -0
- label_studio_sdk/types/prompt_created_by.py +1 -1
- label_studio_sdk/types/prompt_organization.py +1 -1
- label_studio_sdk/types/prompt_version.py +13 -22
- label_studio_sdk/types/prompt_version_created_by.py +1 -1
- label_studio_sdk/types/prompt_version_organization.py +1 -1
- label_studio_sdk/types/prompt_version_provider.py +3 -1
- label_studio_sdk/types/redis_export_storage.py +29 -38
- label_studio_sdk/types/redis_import_storage.py +28 -37
- label_studio_sdk/types/refined_prompt_response.py +19 -29
- label_studio_sdk/types/s3export_storage.py +36 -43
- label_studio_sdk/types/s3import_storage.py +37 -44
- label_studio_sdk/types/s3s_export_storage.py +26 -33
- label_studio_sdk/types/s3s_import_storage.py +35 -42
- label_studio_sdk/types/serialization_option.py +12 -22
- label_studio_sdk/types/serialization_options.py +18 -28
- label_studio_sdk/types/task.py +46 -48
- label_studio_sdk/types/task_annotators_item.py +1 -1
- label_studio_sdk/types/task_comment_authors_item.py +5 -0
- label_studio_sdk/types/task_filter_options.py +15 -25
- label_studio_sdk/types/user_simple.py +11 -21
- label_studio_sdk/types/view.py +16 -26
- label_studio_sdk/types/webhook.py +19 -28
- label_studio_sdk/types/webhook_serializer_for_update.py +19 -28
- label_studio_sdk/types/workspace.py +22 -31
- label_studio_sdk/users/client.py +257 -63
- label_studio_sdk/users/types/users_get_token_response.py +12 -22
- label_studio_sdk/users/types/users_reset_token_response.py +12 -22
- label_studio_sdk/version.py +0 -1
- label_studio_sdk/versions/__init__.py +5 -0
- label_studio_sdk/versions/client.py +112 -0
- label_studio_sdk/versions/types/__init__.py +6 -0
- label_studio_sdk/versions/types/versions_get_response.py +73 -0
- label_studio_sdk/versions/types/versions_get_response_edition.py +5 -0
- label_studio_sdk/views/client.py +219 -52
- label_studio_sdk/views/types/views_create_request_data.py +13 -23
- label_studio_sdk/views/types/views_create_request_data_filters.py +14 -24
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +16 -26
- label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +3 -1
- label_studio_sdk/views/types/views_update_request_data.py +13 -23
- label_studio_sdk/views/types/views_update_request_data_filters.py +14 -24
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +16 -26
- label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +3 -1
- label_studio_sdk/webhooks/client.py +191 -61
- label_studio_sdk/workspaces/client.py +164 -41
- label_studio_sdk/workspaces/members/client.py +109 -31
- label_studio_sdk/workspaces/members/types/members_create_response.py +12 -22
- label_studio_sdk/workspaces/members/types/members_list_response_item.py +12 -22
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/METADATA +9 -5
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/RECORD +203 -186
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/WHEEL +1 -1
- label_studio_sdk/types/export_convert.py +0 -32
- label_studio_sdk/types/export_create.py +0 -54
- label_studio_sdk/types/export_create_status.py +0 -5
- {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/LICENSE +0 -0
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
import datetime as dt
|
|
4
3
|
import typing
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
from ..core.api_error import ApiError
|
|
8
|
-
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
-
from ..core.pydantic_utilities import pydantic_v1
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
10
5
|
from ..core.request_options import RequestOptions
|
|
11
6
|
from ..types.model_provider_connection import ModelProviderConnection
|
|
12
|
-
from ..
|
|
13
|
-
from
|
|
7
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
8
|
+
from json.decoder import JSONDecodeError
|
|
9
|
+
from ..core.api_error import ApiError
|
|
14
10
|
from ..types.model_provider_connection_provider import ModelProviderConnectionProvider
|
|
15
11
|
from ..types.model_provider_connection_scope import ModelProviderConnectionScope
|
|
12
|
+
from ..types.model_provider_connection_organization import ModelProviderConnectionOrganization
|
|
13
|
+
from ..types.model_provider_connection_created_by import ModelProviderConnectionCreatedBy
|
|
14
|
+
import datetime as dt
|
|
15
|
+
from ..types.model_provider_connection_budget_reset_period import ModelProviderConnectionBudgetResetPeriod
|
|
16
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
17
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
18
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
16
19
|
|
|
17
20
|
# this is used as the default value for optional parameters
|
|
18
21
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -22,6 +25,48 @@ class ModelProvidersClient:
|
|
|
22
25
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
23
26
|
self._client_wrapper = client_wrapper
|
|
24
27
|
|
|
28
|
+
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[ModelProviderConnection]:
|
|
29
|
+
"""
|
|
30
|
+
Get all model provider connections created by the user in the current organization.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
request_options : typing.Optional[RequestOptions]
|
|
35
|
+
Request-specific configuration.
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
typing.List[ModelProviderConnection]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
from label_studio_sdk import LabelStudio
|
|
45
|
+
|
|
46
|
+
client = LabelStudio(
|
|
47
|
+
api_key="YOUR_API_KEY",
|
|
48
|
+
)
|
|
49
|
+
client.model_providers.list()
|
|
50
|
+
"""
|
|
51
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
52
|
+
"api/model-provider-connections/",
|
|
53
|
+
method="GET",
|
|
54
|
+
request_options=request_options,
|
|
55
|
+
)
|
|
56
|
+
try:
|
|
57
|
+
if 200 <= _response.status_code < 300:
|
|
58
|
+
return typing.cast(
|
|
59
|
+
typing.List[ModelProviderConnection],
|
|
60
|
+
parse_obj_as(
|
|
61
|
+
type_=typing.List[ModelProviderConnection], # type: ignore
|
|
62
|
+
object_=_response.json(),
|
|
63
|
+
),
|
|
64
|
+
)
|
|
65
|
+
_response_json = _response.json()
|
|
66
|
+
except JSONDecodeError:
|
|
67
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
68
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
69
|
+
|
|
25
70
|
def create(
|
|
26
71
|
self,
|
|
27
72
|
*,
|
|
@@ -34,7 +79,13 @@ class ModelProvidersClient:
|
|
|
34
79
|
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
35
80
|
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
36
81
|
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
37
|
-
|
|
82
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
83
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
84
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
85
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
86
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
87
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
88
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
38
89
|
) -> ModelProviderConnection:
|
|
39
90
|
"""
|
|
40
91
|
Create a new model provider connection.
|
|
@@ -59,6 +110,24 @@ class ModelProvidersClient:
|
|
|
59
110
|
|
|
60
111
|
updated_at : typing.Optional[dt.datetime]
|
|
61
112
|
|
|
113
|
+
is_internal : typing.Optional[bool]
|
|
114
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
115
|
+
|
|
116
|
+
budget_limit : typing.Optional[float]
|
|
117
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
118
|
+
|
|
119
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
120
|
+
Date and time the budget was last reset
|
|
121
|
+
|
|
122
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
123
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
124
|
+
|
|
125
|
+
budget_total_spent : typing.Optional[float]
|
|
126
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
127
|
+
|
|
128
|
+
budget_alert_threshold : typing.Optional[float]
|
|
129
|
+
Budget alert threshold for the given provider connection
|
|
130
|
+
|
|
62
131
|
request_options : typing.Optional[RequestOptions]
|
|
63
132
|
Request-specific configuration.
|
|
64
133
|
|
|
@@ -69,7 +138,7 @@ class ModelProvidersClient:
|
|
|
69
138
|
|
|
70
139
|
Examples
|
|
71
140
|
--------
|
|
72
|
-
from label_studio_sdk
|
|
141
|
+
from label_studio_sdk import LabelStudio
|
|
73
142
|
|
|
74
143
|
client = LabelStudio(
|
|
75
144
|
api_key="YOUR_API_KEY",
|
|
@@ -87,17 +156,246 @@ class ModelProvidersClient:
|
|
|
87
156
|
"deployment_name": deployment_name,
|
|
88
157
|
"endpoint": endpoint,
|
|
89
158
|
"scope": scope,
|
|
90
|
-
"organization":
|
|
91
|
-
|
|
159
|
+
"organization": convert_and_respect_annotation_metadata(
|
|
160
|
+
object_=organization, annotation=ModelProviderConnectionOrganization, direction="write"
|
|
161
|
+
),
|
|
162
|
+
"created_by": convert_and_respect_annotation_metadata(
|
|
163
|
+
object_=created_by, annotation=ModelProviderConnectionCreatedBy, direction="write"
|
|
164
|
+
),
|
|
165
|
+
"created_at": created_at,
|
|
166
|
+
"updated_at": updated_at,
|
|
167
|
+
"is_internal": is_internal,
|
|
168
|
+
"budget_limit": budget_limit,
|
|
169
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
170
|
+
"budget_reset_period": budget_reset_period,
|
|
171
|
+
"budget_total_spent": budget_total_spent,
|
|
172
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
173
|
+
},
|
|
174
|
+
request_options=request_options,
|
|
175
|
+
omit=OMIT,
|
|
176
|
+
)
|
|
177
|
+
try:
|
|
178
|
+
if 200 <= _response.status_code < 300:
|
|
179
|
+
return typing.cast(
|
|
180
|
+
ModelProviderConnection,
|
|
181
|
+
parse_obj_as(
|
|
182
|
+
type_=ModelProviderConnection, # type: ignore
|
|
183
|
+
object_=_response.json(),
|
|
184
|
+
),
|
|
185
|
+
)
|
|
186
|
+
_response_json = _response.json()
|
|
187
|
+
except JSONDecodeError:
|
|
188
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
189
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
190
|
+
|
|
191
|
+
def get(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
|
|
192
|
+
"""
|
|
193
|
+
Get a model provider connection by ID.
|
|
194
|
+
|
|
195
|
+
Parameters
|
|
196
|
+
----------
|
|
197
|
+
pk : int
|
|
198
|
+
Model Provider Connection ID
|
|
199
|
+
|
|
200
|
+
request_options : typing.Optional[RequestOptions]
|
|
201
|
+
Request-specific configuration.
|
|
202
|
+
|
|
203
|
+
Returns
|
|
204
|
+
-------
|
|
205
|
+
ModelProviderConnection
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
Examples
|
|
209
|
+
--------
|
|
210
|
+
from label_studio_sdk import LabelStudio
|
|
211
|
+
|
|
212
|
+
client = LabelStudio(
|
|
213
|
+
api_key="YOUR_API_KEY",
|
|
214
|
+
)
|
|
215
|
+
client.model_providers.get(
|
|
216
|
+
pk=1,
|
|
217
|
+
)
|
|
218
|
+
"""
|
|
219
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
220
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
221
|
+
method="GET",
|
|
222
|
+
request_options=request_options,
|
|
223
|
+
)
|
|
224
|
+
try:
|
|
225
|
+
if 200 <= _response.status_code < 300:
|
|
226
|
+
return typing.cast(
|
|
227
|
+
ModelProviderConnection,
|
|
228
|
+
parse_obj_as(
|
|
229
|
+
type_=ModelProviderConnection, # type: ignore
|
|
230
|
+
object_=_response.json(),
|
|
231
|
+
),
|
|
232
|
+
)
|
|
233
|
+
_response_json = _response.json()
|
|
234
|
+
except JSONDecodeError:
|
|
235
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
236
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
237
|
+
|
|
238
|
+
def delete(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
239
|
+
"""
|
|
240
|
+
Delete a model provider connection by ID.
|
|
241
|
+
|
|
242
|
+
Parameters
|
|
243
|
+
----------
|
|
244
|
+
pk : int
|
|
245
|
+
Model Provider Connection ID
|
|
246
|
+
|
|
247
|
+
request_options : typing.Optional[RequestOptions]
|
|
248
|
+
Request-specific configuration.
|
|
249
|
+
|
|
250
|
+
Returns
|
|
251
|
+
-------
|
|
252
|
+
None
|
|
253
|
+
|
|
254
|
+
Examples
|
|
255
|
+
--------
|
|
256
|
+
from label_studio_sdk import LabelStudio
|
|
257
|
+
|
|
258
|
+
client = LabelStudio(
|
|
259
|
+
api_key="YOUR_API_KEY",
|
|
260
|
+
)
|
|
261
|
+
client.model_providers.delete(
|
|
262
|
+
pk=1,
|
|
263
|
+
)
|
|
264
|
+
"""
|
|
265
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
266
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
267
|
+
method="DELETE",
|
|
268
|
+
request_options=request_options,
|
|
269
|
+
)
|
|
270
|
+
try:
|
|
271
|
+
if 200 <= _response.status_code < 300:
|
|
272
|
+
return
|
|
273
|
+
_response_json = _response.json()
|
|
274
|
+
except JSONDecodeError:
|
|
275
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
276
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
277
|
+
|
|
278
|
+
def update(
|
|
279
|
+
self,
|
|
280
|
+
pk: int,
|
|
281
|
+
*,
|
|
282
|
+
provider: ModelProviderConnectionProvider,
|
|
283
|
+
api_key: typing.Optional[str] = OMIT,
|
|
284
|
+
deployment_name: typing.Optional[str] = OMIT,
|
|
285
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
286
|
+
scope: typing.Optional[ModelProviderConnectionScope] = OMIT,
|
|
287
|
+
organization: typing.Optional[ModelProviderConnectionOrganization] = OMIT,
|
|
288
|
+
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
289
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
290
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
291
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
292
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
293
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
294
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
295
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
296
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
297
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
298
|
+
) -> ModelProviderConnection:
|
|
299
|
+
"""
|
|
300
|
+
Update a model provider connection by ID.
|
|
301
|
+
|
|
302
|
+
Parameters
|
|
303
|
+
----------
|
|
304
|
+
pk : int
|
|
305
|
+
Model Provider Connection ID
|
|
306
|
+
|
|
307
|
+
provider : ModelProviderConnectionProvider
|
|
308
|
+
|
|
309
|
+
api_key : typing.Optional[str]
|
|
310
|
+
|
|
311
|
+
deployment_name : typing.Optional[str]
|
|
312
|
+
|
|
313
|
+
endpoint : typing.Optional[str]
|
|
314
|
+
|
|
315
|
+
scope : typing.Optional[ModelProviderConnectionScope]
|
|
316
|
+
|
|
317
|
+
organization : typing.Optional[ModelProviderConnectionOrganization]
|
|
318
|
+
|
|
319
|
+
created_by : typing.Optional[ModelProviderConnectionCreatedBy]
|
|
320
|
+
|
|
321
|
+
created_at : typing.Optional[dt.datetime]
|
|
322
|
+
|
|
323
|
+
updated_at : typing.Optional[dt.datetime]
|
|
324
|
+
|
|
325
|
+
is_internal : typing.Optional[bool]
|
|
326
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
327
|
+
|
|
328
|
+
budget_limit : typing.Optional[float]
|
|
329
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
330
|
+
|
|
331
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
332
|
+
Date and time the budget was last reset
|
|
333
|
+
|
|
334
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
335
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
336
|
+
|
|
337
|
+
budget_total_spent : typing.Optional[float]
|
|
338
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
339
|
+
|
|
340
|
+
budget_alert_threshold : typing.Optional[float]
|
|
341
|
+
Budget alert threshold for the given provider connection
|
|
342
|
+
|
|
343
|
+
request_options : typing.Optional[RequestOptions]
|
|
344
|
+
Request-specific configuration.
|
|
345
|
+
|
|
346
|
+
Returns
|
|
347
|
+
-------
|
|
348
|
+
ModelProviderConnection
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
Examples
|
|
352
|
+
--------
|
|
353
|
+
from label_studio_sdk import LabelStudio
|
|
354
|
+
|
|
355
|
+
client = LabelStudio(
|
|
356
|
+
api_key="YOUR_API_KEY",
|
|
357
|
+
)
|
|
358
|
+
client.model_providers.update(
|
|
359
|
+
pk=1,
|
|
360
|
+
provider="OpenAI",
|
|
361
|
+
)
|
|
362
|
+
"""
|
|
363
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
364
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
365
|
+
method="PATCH",
|
|
366
|
+
json={
|
|
367
|
+
"provider": provider,
|
|
368
|
+
"api_key": api_key,
|
|
369
|
+
"deployment_name": deployment_name,
|
|
370
|
+
"endpoint": endpoint,
|
|
371
|
+
"scope": scope,
|
|
372
|
+
"organization": convert_and_respect_annotation_metadata(
|
|
373
|
+
object_=organization, annotation=ModelProviderConnectionOrganization, direction="write"
|
|
374
|
+
),
|
|
375
|
+
"created_by": convert_and_respect_annotation_metadata(
|
|
376
|
+
object_=created_by, annotation=ModelProviderConnectionCreatedBy, direction="write"
|
|
377
|
+
),
|
|
92
378
|
"created_at": created_at,
|
|
93
379
|
"updated_at": updated_at,
|
|
380
|
+
"is_internal": is_internal,
|
|
381
|
+
"budget_limit": budget_limit,
|
|
382
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
383
|
+
"budget_reset_period": budget_reset_period,
|
|
384
|
+
"budget_total_spent": budget_total_spent,
|
|
385
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
94
386
|
},
|
|
95
387
|
request_options=request_options,
|
|
96
388
|
omit=OMIT,
|
|
97
389
|
)
|
|
98
390
|
try:
|
|
99
391
|
if 200 <= _response.status_code < 300:
|
|
100
|
-
return
|
|
392
|
+
return typing.cast(
|
|
393
|
+
ModelProviderConnection,
|
|
394
|
+
parse_obj_as(
|
|
395
|
+
type_=ModelProviderConnection, # type: ignore
|
|
396
|
+
object_=_response.json(),
|
|
397
|
+
),
|
|
398
|
+
)
|
|
101
399
|
_response_json = _response.json()
|
|
102
400
|
except JSONDecodeError:
|
|
103
401
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -108,6 +406,58 @@ class AsyncModelProvidersClient:
|
|
|
108
406
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
109
407
|
self._client_wrapper = client_wrapper
|
|
110
408
|
|
|
409
|
+
async def list(
|
|
410
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
411
|
+
) -> typing.List[ModelProviderConnection]:
|
|
412
|
+
"""
|
|
413
|
+
Get all model provider connections created by the user in the current organization.
|
|
414
|
+
|
|
415
|
+
Parameters
|
|
416
|
+
----------
|
|
417
|
+
request_options : typing.Optional[RequestOptions]
|
|
418
|
+
Request-specific configuration.
|
|
419
|
+
|
|
420
|
+
Returns
|
|
421
|
+
-------
|
|
422
|
+
typing.List[ModelProviderConnection]
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
Examples
|
|
426
|
+
--------
|
|
427
|
+
import asyncio
|
|
428
|
+
|
|
429
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
430
|
+
|
|
431
|
+
client = AsyncLabelStudio(
|
|
432
|
+
api_key="YOUR_API_KEY",
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
async def main() -> None:
|
|
437
|
+
await client.model_providers.list()
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
asyncio.run(main())
|
|
441
|
+
"""
|
|
442
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
443
|
+
"api/model-provider-connections/",
|
|
444
|
+
method="GET",
|
|
445
|
+
request_options=request_options,
|
|
446
|
+
)
|
|
447
|
+
try:
|
|
448
|
+
if 200 <= _response.status_code < 300:
|
|
449
|
+
return typing.cast(
|
|
450
|
+
typing.List[ModelProviderConnection],
|
|
451
|
+
parse_obj_as(
|
|
452
|
+
type_=typing.List[ModelProviderConnection], # type: ignore
|
|
453
|
+
object_=_response.json(),
|
|
454
|
+
),
|
|
455
|
+
)
|
|
456
|
+
_response_json = _response.json()
|
|
457
|
+
except JSONDecodeError:
|
|
458
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
459
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
460
|
+
|
|
111
461
|
async def create(
|
|
112
462
|
self,
|
|
113
463
|
*,
|
|
@@ -120,7 +470,13 @@ class AsyncModelProvidersClient:
|
|
|
120
470
|
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
121
471
|
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
122
472
|
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
123
|
-
|
|
473
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
474
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
475
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
476
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
477
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
478
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
479
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
124
480
|
) -> ModelProviderConnection:
|
|
125
481
|
"""
|
|
126
482
|
Create a new model provider connection.
|
|
@@ -145,6 +501,24 @@ class AsyncModelProvidersClient:
|
|
|
145
501
|
|
|
146
502
|
updated_at : typing.Optional[dt.datetime]
|
|
147
503
|
|
|
504
|
+
is_internal : typing.Optional[bool]
|
|
505
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
506
|
+
|
|
507
|
+
budget_limit : typing.Optional[float]
|
|
508
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
509
|
+
|
|
510
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
511
|
+
Date and time the budget was last reset
|
|
512
|
+
|
|
513
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
514
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
515
|
+
|
|
516
|
+
budget_total_spent : typing.Optional[float]
|
|
517
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
518
|
+
|
|
519
|
+
budget_alert_threshold : typing.Optional[float]
|
|
520
|
+
Budget alert threshold for the given provider connection
|
|
521
|
+
|
|
148
522
|
request_options : typing.Optional[RequestOptions]
|
|
149
523
|
Request-specific configuration.
|
|
150
524
|
|
|
@@ -155,14 +529,22 @@ class AsyncModelProvidersClient:
|
|
|
155
529
|
|
|
156
530
|
Examples
|
|
157
531
|
--------
|
|
158
|
-
|
|
532
|
+
import asyncio
|
|
533
|
+
|
|
534
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
159
535
|
|
|
160
536
|
client = AsyncLabelStudio(
|
|
161
537
|
api_key="YOUR_API_KEY",
|
|
162
538
|
)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
)
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
async def main() -> None:
|
|
542
|
+
await client.model_providers.create(
|
|
543
|
+
provider="OpenAI",
|
|
544
|
+
)
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
asyncio.run(main())
|
|
166
548
|
"""
|
|
167
549
|
_response = await self._client_wrapper.httpx_client.request(
|
|
168
550
|
"api/model-provider-connections/",
|
|
@@ -173,17 +555,270 @@ class AsyncModelProvidersClient:
|
|
|
173
555
|
"deployment_name": deployment_name,
|
|
174
556
|
"endpoint": endpoint,
|
|
175
557
|
"scope": scope,
|
|
176
|
-
"organization":
|
|
177
|
-
|
|
558
|
+
"organization": convert_and_respect_annotation_metadata(
|
|
559
|
+
object_=organization, annotation=ModelProviderConnectionOrganization, direction="write"
|
|
560
|
+
),
|
|
561
|
+
"created_by": convert_and_respect_annotation_metadata(
|
|
562
|
+
object_=created_by, annotation=ModelProviderConnectionCreatedBy, direction="write"
|
|
563
|
+
),
|
|
564
|
+
"created_at": created_at,
|
|
565
|
+
"updated_at": updated_at,
|
|
566
|
+
"is_internal": is_internal,
|
|
567
|
+
"budget_limit": budget_limit,
|
|
568
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
569
|
+
"budget_reset_period": budget_reset_period,
|
|
570
|
+
"budget_total_spent": budget_total_spent,
|
|
571
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
572
|
+
},
|
|
573
|
+
request_options=request_options,
|
|
574
|
+
omit=OMIT,
|
|
575
|
+
)
|
|
576
|
+
try:
|
|
577
|
+
if 200 <= _response.status_code < 300:
|
|
578
|
+
return typing.cast(
|
|
579
|
+
ModelProviderConnection,
|
|
580
|
+
parse_obj_as(
|
|
581
|
+
type_=ModelProviderConnection, # type: ignore
|
|
582
|
+
object_=_response.json(),
|
|
583
|
+
),
|
|
584
|
+
)
|
|
585
|
+
_response_json = _response.json()
|
|
586
|
+
except JSONDecodeError:
|
|
587
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
588
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
589
|
+
|
|
590
|
+
async def get(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
|
|
591
|
+
"""
|
|
592
|
+
Get a model provider connection by ID.
|
|
593
|
+
|
|
594
|
+
Parameters
|
|
595
|
+
----------
|
|
596
|
+
pk : int
|
|
597
|
+
Model Provider Connection ID
|
|
598
|
+
|
|
599
|
+
request_options : typing.Optional[RequestOptions]
|
|
600
|
+
Request-specific configuration.
|
|
601
|
+
|
|
602
|
+
Returns
|
|
603
|
+
-------
|
|
604
|
+
ModelProviderConnection
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
Examples
|
|
608
|
+
--------
|
|
609
|
+
import asyncio
|
|
610
|
+
|
|
611
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
612
|
+
|
|
613
|
+
client = AsyncLabelStudio(
|
|
614
|
+
api_key="YOUR_API_KEY",
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
async def main() -> None:
|
|
619
|
+
await client.model_providers.get(
|
|
620
|
+
pk=1,
|
|
621
|
+
)
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
asyncio.run(main())
|
|
625
|
+
"""
|
|
626
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
627
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
628
|
+
method="GET",
|
|
629
|
+
request_options=request_options,
|
|
630
|
+
)
|
|
631
|
+
try:
|
|
632
|
+
if 200 <= _response.status_code < 300:
|
|
633
|
+
return typing.cast(
|
|
634
|
+
ModelProviderConnection,
|
|
635
|
+
parse_obj_as(
|
|
636
|
+
type_=ModelProviderConnection, # type: ignore
|
|
637
|
+
object_=_response.json(),
|
|
638
|
+
),
|
|
639
|
+
)
|
|
640
|
+
_response_json = _response.json()
|
|
641
|
+
except JSONDecodeError:
|
|
642
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
643
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
644
|
+
|
|
645
|
+
async def delete(self, pk: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
646
|
+
"""
|
|
647
|
+
Delete a model provider connection by ID.
|
|
648
|
+
|
|
649
|
+
Parameters
|
|
650
|
+
----------
|
|
651
|
+
pk : int
|
|
652
|
+
Model Provider Connection ID
|
|
653
|
+
|
|
654
|
+
request_options : typing.Optional[RequestOptions]
|
|
655
|
+
Request-specific configuration.
|
|
656
|
+
|
|
657
|
+
Returns
|
|
658
|
+
-------
|
|
659
|
+
None
|
|
660
|
+
|
|
661
|
+
Examples
|
|
662
|
+
--------
|
|
663
|
+
import asyncio
|
|
664
|
+
|
|
665
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
666
|
+
|
|
667
|
+
client = AsyncLabelStudio(
|
|
668
|
+
api_key="YOUR_API_KEY",
|
|
669
|
+
)
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
async def main() -> None:
|
|
673
|
+
await client.model_providers.delete(
|
|
674
|
+
pk=1,
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
asyncio.run(main())
|
|
679
|
+
"""
|
|
680
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
681
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
682
|
+
method="DELETE",
|
|
683
|
+
request_options=request_options,
|
|
684
|
+
)
|
|
685
|
+
try:
|
|
686
|
+
if 200 <= _response.status_code < 300:
|
|
687
|
+
return
|
|
688
|
+
_response_json = _response.json()
|
|
689
|
+
except JSONDecodeError:
|
|
690
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
691
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
692
|
+
|
|
693
|
+
async def update(
|
|
694
|
+
self,
|
|
695
|
+
pk: int,
|
|
696
|
+
*,
|
|
697
|
+
provider: ModelProviderConnectionProvider,
|
|
698
|
+
api_key: typing.Optional[str] = OMIT,
|
|
699
|
+
deployment_name: typing.Optional[str] = OMIT,
|
|
700
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
701
|
+
scope: typing.Optional[ModelProviderConnectionScope] = OMIT,
|
|
702
|
+
organization: typing.Optional[ModelProviderConnectionOrganization] = OMIT,
|
|
703
|
+
created_by: typing.Optional[ModelProviderConnectionCreatedBy] = OMIT,
|
|
704
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
705
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
706
|
+
is_internal: typing.Optional[bool] = OMIT,
|
|
707
|
+
budget_limit: typing.Optional[float] = OMIT,
|
|
708
|
+
budget_last_reset_date: typing.Optional[dt.datetime] = OMIT,
|
|
709
|
+
budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = OMIT,
|
|
710
|
+
budget_total_spent: typing.Optional[float] = OMIT,
|
|
711
|
+
budget_alert_threshold: typing.Optional[float] = OMIT,
|
|
712
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
713
|
+
) -> ModelProviderConnection:
|
|
714
|
+
"""
|
|
715
|
+
Update a model provider connection by ID.
|
|
716
|
+
|
|
717
|
+
Parameters
|
|
718
|
+
----------
|
|
719
|
+
pk : int
|
|
720
|
+
Model Provider Connection ID
|
|
721
|
+
|
|
722
|
+
provider : ModelProviderConnectionProvider
|
|
723
|
+
|
|
724
|
+
api_key : typing.Optional[str]
|
|
725
|
+
|
|
726
|
+
deployment_name : typing.Optional[str]
|
|
727
|
+
|
|
728
|
+
endpoint : typing.Optional[str]
|
|
729
|
+
|
|
730
|
+
scope : typing.Optional[ModelProviderConnectionScope]
|
|
731
|
+
|
|
732
|
+
organization : typing.Optional[ModelProviderConnectionOrganization]
|
|
733
|
+
|
|
734
|
+
created_by : typing.Optional[ModelProviderConnectionCreatedBy]
|
|
735
|
+
|
|
736
|
+
created_at : typing.Optional[dt.datetime]
|
|
737
|
+
|
|
738
|
+
updated_at : typing.Optional[dt.datetime]
|
|
739
|
+
|
|
740
|
+
is_internal : typing.Optional[bool]
|
|
741
|
+
Whether the model provider connection is internal, not visible to the user.
|
|
742
|
+
|
|
743
|
+
budget_limit : typing.Optional[float]
|
|
744
|
+
Budget limit for the model provider connection (null if unlimited)
|
|
745
|
+
|
|
746
|
+
budget_last_reset_date : typing.Optional[dt.datetime]
|
|
747
|
+
Date and time the budget was last reset
|
|
748
|
+
|
|
749
|
+
budget_reset_period : typing.Optional[ModelProviderConnectionBudgetResetPeriod]
|
|
750
|
+
Budget reset period for the model provider connection (null if not reset)
|
|
751
|
+
|
|
752
|
+
budget_total_spent : typing.Optional[float]
|
|
753
|
+
Tracked total budget spent for the given provider connection within the current budget period
|
|
754
|
+
|
|
755
|
+
budget_alert_threshold : typing.Optional[float]
|
|
756
|
+
Budget alert threshold for the given provider connection
|
|
757
|
+
|
|
758
|
+
request_options : typing.Optional[RequestOptions]
|
|
759
|
+
Request-specific configuration.
|
|
760
|
+
|
|
761
|
+
Returns
|
|
762
|
+
-------
|
|
763
|
+
ModelProviderConnection
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
Examples
|
|
767
|
+
--------
|
|
768
|
+
import asyncio
|
|
769
|
+
|
|
770
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
771
|
+
|
|
772
|
+
client = AsyncLabelStudio(
|
|
773
|
+
api_key="YOUR_API_KEY",
|
|
774
|
+
)
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
async def main() -> None:
|
|
778
|
+
await client.model_providers.update(
|
|
779
|
+
pk=1,
|
|
780
|
+
provider="OpenAI",
|
|
781
|
+
)
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
asyncio.run(main())
|
|
785
|
+
"""
|
|
786
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
787
|
+
f"api/model-provider-connections/{jsonable_encoder(pk)}",
|
|
788
|
+
method="PATCH",
|
|
789
|
+
json={
|
|
790
|
+
"provider": provider,
|
|
791
|
+
"api_key": api_key,
|
|
792
|
+
"deployment_name": deployment_name,
|
|
793
|
+
"endpoint": endpoint,
|
|
794
|
+
"scope": scope,
|
|
795
|
+
"organization": convert_and_respect_annotation_metadata(
|
|
796
|
+
object_=organization, annotation=ModelProviderConnectionOrganization, direction="write"
|
|
797
|
+
),
|
|
798
|
+
"created_by": convert_and_respect_annotation_metadata(
|
|
799
|
+
object_=created_by, annotation=ModelProviderConnectionCreatedBy, direction="write"
|
|
800
|
+
),
|
|
178
801
|
"created_at": created_at,
|
|
179
802
|
"updated_at": updated_at,
|
|
803
|
+
"is_internal": is_internal,
|
|
804
|
+
"budget_limit": budget_limit,
|
|
805
|
+
"budget_last_reset_date": budget_last_reset_date,
|
|
806
|
+
"budget_reset_period": budget_reset_period,
|
|
807
|
+
"budget_total_spent": budget_total_spent,
|
|
808
|
+
"budget_alert_threshold": budget_alert_threshold,
|
|
180
809
|
},
|
|
181
810
|
request_options=request_options,
|
|
182
811
|
omit=OMIT,
|
|
183
812
|
)
|
|
184
813
|
try:
|
|
185
814
|
if 200 <= _response.status_code < 300:
|
|
186
|
-
return
|
|
815
|
+
return typing.cast(
|
|
816
|
+
ModelProviderConnection,
|
|
817
|
+
parse_obj_as(
|
|
818
|
+
type_=ModelProviderConnection, # type: ignore
|
|
819
|
+
object_=_response.json(),
|
|
820
|
+
),
|
|
821
|
+
)
|
|
187
822
|
_response_json = _response.json()
|
|
188
823
|
except JSONDecodeError:
|
|
189
824
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|