label-studio-sdk 2.0.5__py3-none-any.whl → 2.0.7__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.

Files changed (92) hide show
  1. label_studio_sdk/__init__.py +70 -0
  2. label_studio_sdk/annotation_history/__init__.py +5 -0
  3. label_studio_sdk/annotation_history/client.py +415 -0
  4. label_studio_sdk/annotation_history/types/__init__.py +5 -0
  5. label_studio_sdk/annotation_history/types/annotation_history_delete_response.py +22 -0
  6. label_studio_sdk/annotation_reviews/__init__.py +2 -0
  7. label_studio_sdk/annotation_reviews/client.py +713 -0
  8. label_studio_sdk/base_client.py +20 -0
  9. label_studio_sdk/blueprints/__init__.py +2 -0
  10. label_studio_sdk/blueprints/client.py +272 -0
  11. label_studio_sdk/core/client_wrapper.py +2 -1
  12. label_studio_sdk/export_storage/__init__.py +2 -2
  13. label_studio_sdk/export_storage/azure_spi/__init__.py +2 -0
  14. label_studio_sdk/export_storage/azure_spi/client.py +1354 -0
  15. label_studio_sdk/export_storage/client.py +8 -0
  16. label_studio_sdk/export_storage/gcswif/__init__.py +2 -0
  17. label_studio_sdk/export_storage/gcswif/client.py +1376 -0
  18. label_studio_sdk/import_storage/__init__.py +2 -2
  19. label_studio_sdk/import_storage/azure_spi/__init__.py +2 -0
  20. label_studio_sdk/import_storage/azure_spi/client.py +1378 -0
  21. label_studio_sdk/import_storage/client.py +8 -0
  22. label_studio_sdk/import_storage/gcswif/__init__.py +2 -0
  23. label_studio_sdk/import_storage/gcswif/client.py +1400 -0
  24. label_studio_sdk/jwt_settings/client.py +10 -8
  25. label_studio_sdk/label_interface/control_tags.py +38 -0
  26. label_studio_sdk/label_interface/data_examples.json +10 -0
  27. label_studio_sdk/label_interface/interface.py +13 -0
  28. label_studio_sdk/label_interface/object_tags.py +9 -0
  29. label_studio_sdk/ml/client.py +124 -0
  30. label_studio_sdk/organizations/__init__.py +3 -2
  31. label_studio_sdk/organizations/client.py +536 -1
  32. label_studio_sdk/organizations/invites/__init__.py +2 -0
  33. label_studio_sdk/organizations/invites/client.py +368 -0
  34. label_studio_sdk/organizations/types/__init__.py +5 -0
  35. label_studio_sdk/organizations/types/patched_default_role_request_custom_scripts_editable_by.py +7 -0
  36. label_studio_sdk/project_templates/__init__.py +2 -0
  37. label_studio_sdk/project_templates/client.py +909 -0
  38. label_studio_sdk/projects/client.py +8 -0
  39. label_studio_sdk/projects/members/__init__.py +2 -2
  40. label_studio_sdk/projects/members/bulk/client.py +46 -2
  41. label_studio_sdk/projects/members/client.py +4 -0
  42. label_studio_sdk/projects/members/paginated/__init__.py +2 -0
  43. label_studio_sdk/projects/members/paginated/client.py +248 -0
  44. label_studio_sdk/session_policy/__init__.py +2 -0
  45. label_studio_sdk/session_policy/client.py +247 -0
  46. label_studio_sdk/tasks/client.py +371 -0
  47. label_studio_sdk/types/__init__.py +56 -0
  48. label_studio_sdk/types/action_enum.py +19 -0
  49. label_studio_sdk/types/all_roles_project_list.py +1 -1
  50. label_studio_sdk/types/annotation.py +7 -0
  51. label_studio_sdk/types/annotation_history.py +81 -0
  52. label_studio_sdk/types/annotation_history_action.py +7 -0
  53. label_studio_sdk/types/annotation_request.py +7 -0
  54. label_studio_sdk/types/annotation_review.py +61 -0
  55. label_studio_sdk/types/annotation_review_request.py +41 -0
  56. label_studio_sdk/types/azure_service_principal_export_storage.py +114 -0
  57. label_studio_sdk/types/azure_service_principal_export_storage_request.py +107 -0
  58. label_studio_sdk/types/azure_service_principal_import_storage.py +115 -0
  59. label_studio_sdk/types/azure_service_principal_import_storage_request.py +108 -0
  60. label_studio_sdk/types/blueprint.py +41 -0
  61. label_studio_sdk/types/default_role.py +75 -0
  62. label_studio_sdk/types/default_role_custom_scripts_editable_by.py +7 -0
  63. label_studio_sdk/types/gcswif_export_storage.py +119 -0
  64. label_studio_sdk/types/gcswif_export_storage_request.py +112 -0
  65. label_studio_sdk/types/gcswif_import_storage.py +120 -0
  66. label_studio_sdk/types/gcswif_import_storage_request.py +113 -0
  67. label_studio_sdk/types/lse_project.py +223 -0
  68. label_studio_sdk/types/lse_project_sampling.py +7 -0
  69. label_studio_sdk/types/lse_project_skip_queue.py +7 -0
  70. label_studio_sdk/types/lse_project_update.py +1 -0
  71. label_studio_sdk/types/lse_task.py +1 -0
  72. label_studio_sdk/types/lse_task_serializer_for_reviewers.py +1 -0
  73. label_studio_sdk/types/lsejwt_settings.py +1 -5
  74. label_studio_sdk/types/paginated_annotation_history_list.py +23 -0
  75. label_studio_sdk/types/paginated_lse_user_list.py +23 -0
  76. label_studio_sdk/types/paginated_paginated_project_member_list.py +23 -0
  77. label_studio_sdk/types/paginated_project_member.py +50 -0
  78. label_studio_sdk/types/project_member_bulk_assign_roles_request.py +21 -0
  79. label_studio_sdk/types/project_template.py +41 -0
  80. label_studio_sdk/types/project_template_request.py +38 -0
  81. label_studio_sdk/types/review_settings.py +5 -0
  82. label_studio_sdk/types/review_settings_request.py +5 -0
  83. label_studio_sdk/types/session_timeout_policy.py +31 -0
  84. label_studio_sdk/types/task_event.py +61 -0
  85. label_studio_sdk/workspaces/members/__init__.py +2 -2
  86. label_studio_sdk/workspaces/members/client.py +4 -0
  87. label_studio_sdk/workspaces/members/paginated/__init__.py +2 -0
  88. label_studio_sdk/workspaces/members/paginated/client.py +212 -0
  89. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.7.dist-info}/METADATA +2 -2
  90. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.7.dist-info}/RECORD +92 -36
  91. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.7.dist-info}/LICENSE +0 -0
  92. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.7.dist-info}/WHEEL +0 -0
@@ -62,7 +62,7 @@ class JwtSettingsClient:
62
62
  def update(
63
63
  self,
64
64
  *,
65
- api_token_ttl_days: typing.Optional[int] = OMIT,
65
+ api_token_ttl_days: int,
66
66
  api_tokens_enabled: typing.Optional[bool] = OMIT,
67
67
  legacy_api_tokens_enabled: typing.Optional[bool] = OMIT,
68
68
  request_options: typing.Optional[RequestOptions] = None,
@@ -72,8 +72,7 @@ class JwtSettingsClient:
72
72
 
73
73
  Parameters
74
74
  ----------
75
- api_token_ttl_days : typing.Optional[int]
76
- Number of days before JWT API tokens expire
75
+ api_token_ttl_days : int
77
76
 
78
77
  api_tokens_enabled : typing.Optional[bool]
79
78
  Enable JWT API token authentication for this organization
@@ -96,7 +95,9 @@ class JwtSettingsClient:
96
95
  client = LabelStudio(
97
96
  api_key="YOUR_API_KEY",
98
97
  )
99
- client.jwt_settings.update()
98
+ client.jwt_settings.update(
99
+ api_token_ttl_days=1,
100
+ )
100
101
  """
101
102
  _response = self._client_wrapper.httpx_client.request(
102
103
  "api/jwt/settings",
@@ -184,7 +185,7 @@ class AsyncJwtSettingsClient:
184
185
  async def update(
185
186
  self,
186
187
  *,
187
- api_token_ttl_days: typing.Optional[int] = OMIT,
188
+ api_token_ttl_days: int,
188
189
  api_tokens_enabled: typing.Optional[bool] = OMIT,
189
190
  legacy_api_tokens_enabled: typing.Optional[bool] = OMIT,
190
191
  request_options: typing.Optional[RequestOptions] = None,
@@ -194,8 +195,7 @@ class AsyncJwtSettingsClient:
194
195
 
195
196
  Parameters
196
197
  ----------
197
- api_token_ttl_days : typing.Optional[int]
198
- Number of days before JWT API tokens expire
198
+ api_token_ttl_days : int
199
199
 
200
200
  api_tokens_enabled : typing.Optional[bool]
201
201
  Enable JWT API token authentication for this organization
@@ -223,7 +223,9 @@ class AsyncJwtSettingsClient:
223
223
 
224
224
 
225
225
  async def main() -> None:
226
- await client.jwt_settings.update()
226
+ await client.jwt_settings.update(
227
+ api_token_ttl_days=1,
228
+ )
227
229
 
228
230
 
229
231
  asyncio.run(main())
@@ -39,6 +39,7 @@ _TAG_TO_CLASS = {
39
39
  "taxonomy": "TaxonomyTag",
40
40
  "textarea": "TextAreaTag",
41
41
  "timeserieslabels": "TimeSeriesLabelsTag",
42
+ "chatmessage": "ChatMessageTag",
42
43
  }
43
44
 
44
45
 
@@ -950,6 +951,43 @@ class RatingTag(ControlTag):
950
951
  }
951
952
 
952
953
 
954
+ class ChatMessageContent(BaseModel):
955
+ role: str
956
+ content: str
957
+ createdAt: Optional[int] = None
958
+
959
+
960
+ class ChatMessageValue(BaseModel):
961
+ chatmessage: ChatMessageContent
962
+
963
+
964
+ class ChatMessageTag(ControlTag):
965
+ """Control tag for chat messages targeting a `<Chat>` object.
966
+
967
+ This tag is a hybrid where `from_name == to_name` and `type == 'chatmessage'`.
968
+ """
969
+ tag: str = "ChatMessage"
970
+ _value_class: Type[ChatMessageValue] = ChatMessageValue
971
+
972
+ def to_json_schema(self):
973
+ return {
974
+ "type": "object",
975
+ "required": ["chatmessage"],
976
+ "properties": {
977
+ "chatmessage": {
978
+ "type": "object",
979
+ "required": ["role", "content"],
980
+ "properties": {
981
+ "role": {"type": "string"},
982
+ "content": {"type": "string"},
983
+ "createdAt": {"type": "number"}
984
+ }
985
+ }
986
+ },
987
+ "description": f"Chat message for {self.to_name[0]}"
988
+ }
989
+
990
+
953
991
  class RelationsTag(ControlTag):
954
992
  """ """
955
993
  tag: str = "Relations"
@@ -10,6 +10,12 @@
10
10
  "Header": "Task header",
11
11
  "Paragraphs": [{"author": "Alice", "text": "Hi, Bob."}, {"author": "Bob", "text": "Hello, Alice!"}, {"author": "Alice", "text": "What's up?"}, {"author": "Bob", "text": "Good. Ciao!"}, {"author": "Alice", "text": "Bye, Bob."}],
12
12
  "ParagraphsUrl": "<HOSTNAME>/samples/paragraphs.json?",
13
+ "Chat": [
14
+ {"role": "user", "content": "Hi there!", "createdAt": 1710000000000},
15
+ {"role": "assistant", "content": "Hello! How can I help you today?", "createdAt": 1710000005000},
16
+ {"role": "user", "content": "Can you summarize our onboarding checklist?", "createdAt": 1710000010000},
17
+ {"role": "assistant", "content": "Sure. It includes account setup, roles, labeling instructions, GT tasks, overlap and review.", "createdAt": 1710000015000}
18
+ ],
13
19
  "Table": {"Card number": 18799210, "First name": "Max", "Last name": "Nobel"},
14
20
  "$videoHack": "<video src='<HOSTNAME>/static/samples/opossum_snow.mp4' width=100% controls>",
15
21
  "Video": "<HOSTNAME>/static/samples/opossum_snow.mp4",
@@ -85,6 +91,10 @@
85
91
  "AudioPlus": "<HOSTNAME>/static/samples/game.wav",
86
92
  "Header": "Task header",
87
93
  "Paragraphs": [{"author": "Alice", "text": "Hi, Bob."}, {"author": "Bob", "text": "Hello, Alice!"}, {"author": "Alice", "text": "What's up?"}, {"author": "Bob", "text": "Good. Ciao!"}, {"author": "Alice", "text": "Bye, Bob."}],
94
+ "Chat": [
95
+ {"role": "user", "content": "Hello!", "createdAt": 1710000000000},
96
+ {"role": "assistant", "content": "Hi! What can I do for you?", "createdAt": 1710000004000}
97
+ ],
88
98
  "Table": {"Card number": 18799210, "First name": "Max", "Last name": "Nobel"},
89
99
  "$videoHack": "<video src='static/samples/opossum_snow.mp4' width=100% controls>",
90
100
  "Video": "<HOSTNAME>/static/samples/opossum_snow.mp4",
@@ -27,6 +27,7 @@ from label_studio_sdk._legacy.exceptions import (
27
27
 
28
28
  from .base import LabelStudioTag
29
29
  from .control_tags import (
30
+ ChatMessageTag,
30
31
  ControlTag,
31
32
  ChoicesTag,
32
33
  LabelsTag,
@@ -623,6 +624,18 @@ class LabelInterface:
623
624
  if lb:
624
625
  labels[lb.parent_name][lb.value] = lb
625
626
 
627
+ # Special handling: auto-create ChatMessage control for each Chat object
628
+ chat_object_names = [name for name, obj in objects.items() if getattr(obj, 'tag', '').lower() == 'chat']
629
+ for name in chat_object_names:
630
+ if name not in controls:
631
+ controls[name] = ChatMessageTag(
632
+ tag='ChatMessage',
633
+ name=name,
634
+ to_name=[name],
635
+ attr={"name": name, "toName": name}
636
+ )
637
+
638
+
626
639
  return controls, objects, labels, xml_tree
627
640
 
628
641
  @classmethod
@@ -20,6 +20,7 @@ _TAG_TO_CLASS = {
20
20
  "list": "ListTag",
21
21
  "paragraphs": "ParagraphsTag",
22
22
  "timeseries": "TimeSeriesTag",
23
+ "chat": "ChatTag",
23
24
  }
24
25
 
25
26
  _DATA_EXAMPLES = None
@@ -306,3 +307,11 @@ class TimeSeriesTag(ObjectTag):
306
307
  else:
307
308
  # data is JSON
308
309
  return generate_time_series_json(time_column, value_columns, time_format)
310
+
311
+ class ChatTag(ObjectTag):
312
+ """ """
313
+ tag: str = "Chat"
314
+
315
+ def _generate_example(self, examples, only_urls=False):
316
+ """ """
317
+ return examples.get("Chat")
@@ -457,6 +457,64 @@ class MlClient:
457
457
  raise ApiError(status_code=_response.status_code, body=_response.text)
458
458
  raise ApiError(status_code=_response.status_code, body=_response_json)
459
459
 
460
+ def predict_all_tasks(
461
+ self,
462
+ id: int,
463
+ *,
464
+ batch_size: typing.Optional[int] = None,
465
+ request_options: typing.Optional[RequestOptions] = None,
466
+ ) -> None:
467
+ """
468
+ Note: not available in the community edition of Label Studio.
469
+
470
+ Create predictions for all tasks using a specific ML backend so that you can set up an active learning strategy based on the confidence or uncertainty scores associated with the predictions. Creating predictions requires a Label Studio ML backend set up and configured for your project.
471
+
472
+ See [Set up machine learning](https://labelstud.io/guide/ml.html) for more details about a Label Studio ML backend.
473
+
474
+ Reference the ML backend ID in the path of this API call. Get the ML backend ID by [listing the ML backends for a project](https://labelstud.io/api/#operation/api_ml_list).
475
+
476
+ Parameters
477
+ ----------
478
+ id : int
479
+ A unique integer value identifying this ML backend.
480
+
481
+ batch_size : typing.Optional[int]
482
+ Computed number of tasks without predictions that the ML backend needs to predict.
483
+
484
+ request_options : typing.Optional[RequestOptions]
485
+ Request-specific configuration.
486
+
487
+ Returns
488
+ -------
489
+ None
490
+
491
+ Examples
492
+ --------
493
+ from label_studio_sdk import LabelStudio
494
+
495
+ client = LabelStudio(
496
+ api_key="YOUR_API_KEY",
497
+ )
498
+ client.ml.predict_all_tasks(
499
+ id=1,
500
+ )
501
+ """
502
+ _response = self._client_wrapper.httpx_client.request(
503
+ f"api/ml/{jsonable_encoder(id)}/predict",
504
+ method="POST",
505
+ params={
506
+ "batch_size": batch_size,
507
+ },
508
+ request_options=request_options,
509
+ )
510
+ try:
511
+ if 200 <= _response.status_code < 300:
512
+ return
513
+ _response_json = _response.json()
514
+ except JSONDecodeError:
515
+ raise ApiError(status_code=_response.status_code, body=_response.text)
516
+ raise ApiError(status_code=_response.status_code, body=_response_json)
517
+
460
518
  def train(
461
519
  self,
462
520
  id: int,
@@ -1064,6 +1122,72 @@ class AsyncMlClient:
1064
1122
  raise ApiError(status_code=_response.status_code, body=_response.text)
1065
1123
  raise ApiError(status_code=_response.status_code, body=_response_json)
1066
1124
 
1125
+ async def predict_all_tasks(
1126
+ self,
1127
+ id: int,
1128
+ *,
1129
+ batch_size: typing.Optional[int] = None,
1130
+ request_options: typing.Optional[RequestOptions] = None,
1131
+ ) -> None:
1132
+ """
1133
+ Note: not available in the community edition of Label Studio.
1134
+
1135
+ Create predictions for all tasks using a specific ML backend so that you can set up an active learning strategy based on the confidence or uncertainty scores associated with the predictions. Creating predictions requires a Label Studio ML backend set up and configured for your project.
1136
+
1137
+ See [Set up machine learning](https://labelstud.io/guide/ml.html) for more details about a Label Studio ML backend.
1138
+
1139
+ Reference the ML backend ID in the path of this API call. Get the ML backend ID by [listing the ML backends for a project](https://labelstud.io/api/#operation/api_ml_list).
1140
+
1141
+ Parameters
1142
+ ----------
1143
+ id : int
1144
+ A unique integer value identifying this ML backend.
1145
+
1146
+ batch_size : typing.Optional[int]
1147
+ Computed number of tasks without predictions that the ML backend needs to predict.
1148
+
1149
+ request_options : typing.Optional[RequestOptions]
1150
+ Request-specific configuration.
1151
+
1152
+ Returns
1153
+ -------
1154
+ None
1155
+
1156
+ Examples
1157
+ --------
1158
+ import asyncio
1159
+
1160
+ from label_studio_sdk import AsyncLabelStudio
1161
+
1162
+ client = AsyncLabelStudio(
1163
+ api_key="YOUR_API_KEY",
1164
+ )
1165
+
1166
+
1167
+ async def main() -> None:
1168
+ await client.ml.predict_all_tasks(
1169
+ id=1,
1170
+ )
1171
+
1172
+
1173
+ asyncio.run(main())
1174
+ """
1175
+ _response = await self._client_wrapper.httpx_client.request(
1176
+ f"api/ml/{jsonable_encoder(id)}/predict",
1177
+ method="POST",
1178
+ params={
1179
+ "batch_size": batch_size,
1180
+ },
1181
+ request_options=request_options,
1182
+ )
1183
+ try:
1184
+ if 200 <= _response.status_code < 300:
1185
+ return
1186
+ _response_json = _response.json()
1187
+ except JSONDecodeError:
1188
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1189
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1190
+
1067
1191
  async def train(
1068
1192
  self,
1069
1193
  id: int,
@@ -1,5 +1,6 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from . import members
3
+ from .types import PatchedDefaultRoleRequestCustomScriptsEditableBy
4
+ from . import invites, members
4
5
 
5
- __all__ = ["members"]
6
+ __all__ = ["PatchedDefaultRoleRequestCustomScriptsEditableBy", "invites", "members"]