rapidata 1.7.1__py3-none-any.whl → 1.8.1__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 rapidata might be problematic. Click here for more details.
- rapidata/api_client/__init__.py +1 -0
- rapidata/api_client/api/identity_api.py +15 -5
- rapidata/api_client/models/__init__.py +1 -0
- rapidata/api_client/models/evaluation_workflow_config.py +5 -3
- rapidata/api_client/models/evaluation_workflow_model.py +5 -3
- rapidata/api_client/models/read_bridge_token_keys_result.py +31 -3
- rapidata/api_client/models/register_temporary_customer_result.py +112 -0
- rapidata/api_client_README.md +1 -0
- rapidata/rapidata_client/assets/__init__.py +1 -1
- rapidata/rapidata_client/assets/media_asset.py +3 -0
- rapidata/rapidata_client/assets/text_asset.py +3 -0
- rapidata/rapidata_client/country_codes/country_codes.py +1 -1
- rapidata/rapidata_client/dataset/rapid_builders/__init__.py +4 -0
- rapidata/rapidata_client/dataset/rapid_builders/base_rapid_builder.py +33 -0
- rapidata/rapidata_client/dataset/rapid_builders/classify_rapid_builders.py +166 -0
- rapidata/rapidata_client/dataset/rapid_builders/compare_rapid_builders.py +145 -0
- rapidata/rapidata_client/dataset/rapid_builders/rapids.py +32 -0
- rapidata/rapidata_client/dataset/rapid_builders/transcription_rapid_builders.py +132 -0
- rapidata/rapidata_client/dataset/rapidata_dataset.py +3 -1
- rapidata/rapidata_client/dataset/rapidata_validation_set.py +24 -7
- rapidata/rapidata_client/dataset/validation_set_builder.py +115 -8
- rapidata/rapidata_client/filter/country_filter.py +3 -0
- rapidata/rapidata_client/filter/language_filter.py +3 -0
- rapidata/rapidata_client/metadata/prompt_metadata.py +5 -1
- rapidata/rapidata_client/order/rapidata_order.py +1 -1
- rapidata/rapidata_client/order/rapidata_order_builder.py +5 -5
- rapidata/rapidata_client/rapidata_client.py +39 -11
- rapidata/rapidata_client/settings/__init__.py +1 -1
- rapidata/rapidata_client/settings/settings.py +10 -9
- rapidata/rapidata_client/simple_builders/simple_classification_builders.py +132 -21
- rapidata/rapidata_client/simple_builders/simple_compare_builders.py +141 -15
- rapidata/rapidata_client/simple_builders/simple_free_text_builders.py +180 -0
- rapidata/rapidata_client/simple_builders/simple_transcription_builders.py +194 -0
- rapidata/service/openapi_service.py +4 -2
- {rapidata-1.7.1.dist-info → rapidata-1.8.1.dist-info}/METADATA +2 -2
- {rapidata-1.7.1.dist-info → rapidata-1.8.1.dist-info}/RECORD +38 -30
- rapidata/rapidata_client/config.py +0 -9
- {rapidata-1.7.1.dist-info → rapidata-1.8.1.dist-info}/LICENSE +0 -0
- {rapidata-1.7.1.dist-info → rapidata-1.8.1.dist-info}/WHEEL +0 -0
rapidata/api_client/__init__.py
CHANGED
|
@@ -245,6 +245,7 @@ from rapidata.api_client.models.rapid_result_model_result import RapidResultMode
|
|
|
245
245
|
from rapidata.api_client.models.rapid_skipped_model import RapidSkippedModel
|
|
246
246
|
from rapidata.api_client.models.read_bridge_token_keys_result import ReadBridgeTokenKeysResult
|
|
247
247
|
from rapidata.api_client.models.register_temporary_customer_model import RegisterTemporaryCustomerModel
|
|
248
|
+
from rapidata.api_client.models.register_temporary_customer_result import RegisterTemporaryCustomerResult
|
|
248
249
|
from rapidata.api_client.models.root_filter import RootFilter
|
|
249
250
|
from rapidata.api_client.models.send_completion_mail_step_model import SendCompletionMailStepModel
|
|
250
251
|
from rapidata.api_client.models.shape import Shape
|
|
@@ -22,6 +22,7 @@ from typing_extensions import Annotated
|
|
|
22
22
|
from rapidata.api_client.models.create_bridge_token_result import CreateBridgeTokenResult
|
|
23
23
|
from rapidata.api_client.models.read_bridge_token_keys_result import ReadBridgeTokenKeysResult
|
|
24
24
|
from rapidata.api_client.models.register_temporary_customer_model import RegisterTemporaryCustomerModel
|
|
25
|
+
from rapidata.api_client.models.register_temporary_customer_result import RegisterTemporaryCustomerResult
|
|
25
26
|
|
|
26
27
|
from rapidata.api_client.api_client import ApiClient, RequestSerialized
|
|
27
28
|
from rapidata.api_client.api_response import ApiResponse
|
|
@@ -589,7 +590,7 @@ class IdentityApi:
|
|
|
589
590
|
_content_type: Optional[StrictStr] = None,
|
|
590
591
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
591
592
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
592
|
-
) ->
|
|
593
|
+
) -> RegisterTemporaryCustomerResult:
|
|
593
594
|
"""Registers and logs in a temporary customer.
|
|
594
595
|
|
|
595
596
|
|
|
@@ -626,7 +627,7 @@ class IdentityApi:
|
|
|
626
627
|
)
|
|
627
628
|
|
|
628
629
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
629
|
-
'200':
|
|
630
|
+
'200': "RegisterTemporaryCustomerResult",
|
|
630
631
|
}
|
|
631
632
|
response_data = self.api_client.call_api(
|
|
632
633
|
*_param,
|
|
@@ -655,7 +656,7 @@ class IdentityApi:
|
|
|
655
656
|
_content_type: Optional[StrictStr] = None,
|
|
656
657
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
657
658
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
658
|
-
) -> ApiResponse[
|
|
659
|
+
) -> ApiResponse[RegisterTemporaryCustomerResult]:
|
|
659
660
|
"""Registers and logs in a temporary customer.
|
|
660
661
|
|
|
661
662
|
|
|
@@ -692,7 +693,7 @@ class IdentityApi:
|
|
|
692
693
|
)
|
|
693
694
|
|
|
694
695
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
695
|
-
'200':
|
|
696
|
+
'200': "RegisterTemporaryCustomerResult",
|
|
696
697
|
}
|
|
697
698
|
response_data = self.api_client.call_api(
|
|
698
699
|
*_param,
|
|
@@ -758,7 +759,7 @@ class IdentityApi:
|
|
|
758
759
|
)
|
|
759
760
|
|
|
760
761
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
761
|
-
'200':
|
|
762
|
+
'200': "RegisterTemporaryCustomerResult",
|
|
762
763
|
}
|
|
763
764
|
response_data = self.api_client.call_api(
|
|
764
765
|
*_param,
|
|
@@ -799,6 +800,15 @@ class IdentityApi:
|
|
|
799
800
|
_body_params = register_temporary_customer_model
|
|
800
801
|
|
|
801
802
|
|
|
803
|
+
# set the HTTP header `Accept`
|
|
804
|
+
if 'Accept' not in _header_params:
|
|
805
|
+
_header_params['Accept'] = self.api_client.select_header_accept(
|
|
806
|
+
[
|
|
807
|
+
'text/plain',
|
|
808
|
+
'application/json',
|
|
809
|
+
'text/json'
|
|
810
|
+
]
|
|
811
|
+
)
|
|
802
812
|
|
|
803
813
|
# set the HTTP header `Content-Type`
|
|
804
814
|
if _content_type:
|
|
@@ -213,6 +213,7 @@ from rapidata.api_client.models.rapid_result_model_result import RapidResultMode
|
|
|
213
213
|
from rapidata.api_client.models.rapid_skipped_model import RapidSkippedModel
|
|
214
214
|
from rapidata.api_client.models.read_bridge_token_keys_result import ReadBridgeTokenKeysResult
|
|
215
215
|
from rapidata.api_client.models.register_temporary_customer_model import RegisterTemporaryCustomerModel
|
|
216
|
+
from rapidata.api_client.models.register_temporary_customer_result import RegisterTemporaryCustomerResult
|
|
216
217
|
from rapidata.api_client.models.root_filter import RootFilter
|
|
217
218
|
from rapidata.api_client.models.send_completion_mail_step_model import SendCompletionMailStepModel
|
|
218
219
|
from rapidata.api_client.models.shape import Shape
|
|
@@ -17,7 +17,7 @@ import pprint
|
|
|
17
17
|
import re # noqa: F401
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
|
-
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
|
|
21
21
|
from typing import Any, ClassVar, Dict, List
|
|
22
22
|
from rapidata.api_client.models.compare_workflow_model1_referee import CompareWorkflowModel1Referee
|
|
23
23
|
from typing import Optional, Set
|
|
@@ -30,7 +30,8 @@ class EvaluationWorkflowConfig(BaseModel):
|
|
|
30
30
|
t: StrictStr = Field(description="Discriminator value for EvaluationWorkflowConfig", alias="_t")
|
|
31
31
|
validation_set_id: StrictStr = Field(alias="validationSetId")
|
|
32
32
|
referee: CompareWorkflowModel1Referee
|
|
33
|
-
|
|
33
|
+
should_accept_incorrect: StrictBool = Field(alias="shouldAcceptIncorrect")
|
|
34
|
+
__properties: ClassVar[List[str]] = ["_t", "validationSetId", "referee", "shouldAcceptIncorrect"]
|
|
34
35
|
|
|
35
36
|
@field_validator('t')
|
|
36
37
|
def t_validate_enum(cls, value):
|
|
@@ -95,7 +96,8 @@ class EvaluationWorkflowConfig(BaseModel):
|
|
|
95
96
|
_obj = cls.model_validate({
|
|
96
97
|
"_t": obj.get("_t") if obj.get("_t") is not None else 'EvaluationWorkflowConfig',
|
|
97
98
|
"validationSetId": obj.get("validationSetId"),
|
|
98
|
-
"referee": CompareWorkflowModel1Referee.from_dict(obj["referee"]) if obj.get("referee") is not None else None
|
|
99
|
+
"referee": CompareWorkflowModel1Referee.from_dict(obj["referee"]) if obj.get("referee") is not None else None,
|
|
100
|
+
"shouldAcceptIncorrect": obj.get("shouldAcceptIncorrect")
|
|
99
101
|
})
|
|
100
102
|
return _obj
|
|
101
103
|
|
|
@@ -17,7 +17,7 @@ import pprint
|
|
|
17
17
|
import re # noqa: F401
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
|
-
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
|
|
21
21
|
from typing import Any, ClassVar, Dict, List
|
|
22
22
|
from typing import Optional, Set
|
|
23
23
|
from typing_extensions import Self
|
|
@@ -28,7 +28,8 @@ class EvaluationWorkflowModel(BaseModel):
|
|
|
28
28
|
""" # noqa: E501
|
|
29
29
|
t: StrictStr = Field(description="Discriminator value for EvaluationWorkflow", alias="_t")
|
|
30
30
|
validation_set_id: StrictStr = Field(description="The Validation Set Id is used to as a source for the tasks that will be sent to the user.", alias="validationSetId")
|
|
31
|
-
|
|
31
|
+
should_accept_incorrect: StrictBool = Field(description="Indicates if the user should get feedback on their answers if they answer wrong. If set to true the user will not notice that he was tested.", alias="shouldAcceptIncorrect")
|
|
32
|
+
__properties: ClassVar[List[str]] = ["_t", "validationSetId", "shouldAcceptIncorrect"]
|
|
32
33
|
|
|
33
34
|
@field_validator('t')
|
|
34
35
|
def t_validate_enum(cls, value):
|
|
@@ -89,7 +90,8 @@ class EvaluationWorkflowModel(BaseModel):
|
|
|
89
90
|
|
|
90
91
|
_obj = cls.model_validate({
|
|
91
92
|
"_t": obj.get("_t") if obj.get("_t") is not None else 'EvaluationWorkflow',
|
|
92
|
-
"validationSetId": obj.get("validationSetId")
|
|
93
|
+
"validationSetId": obj.get("validationSetId"),
|
|
94
|
+
"shouldAcceptIncorrect": obj.get("shouldAcceptIncorrect")
|
|
93
95
|
})
|
|
94
96
|
return _obj
|
|
95
97
|
|
|
@@ -17,7 +17,7 @@ import pprint
|
|
|
17
17
|
import re # noqa: F401
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
|
-
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
|
21
21
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
22
|
from typing import Optional, Set
|
|
23
23
|
from typing_extensions import Self
|
|
@@ -27,8 +27,12 @@ class ReadBridgeTokenKeysResult(BaseModel):
|
|
|
27
27
|
ReadBridgeTokenKeysResult
|
|
28
28
|
""" # noqa: E501
|
|
29
29
|
access_token: Optional[StrictStr] = Field(alias="accessToken")
|
|
30
|
+
expires_in: Optional[StrictInt] = Field(alias="expiresIn")
|
|
30
31
|
refresh_token: Optional[StrictStr] = Field(alias="refreshToken")
|
|
31
|
-
|
|
32
|
+
id_token: Optional[StrictStr] = Field(alias="idToken")
|
|
33
|
+
token_type: Optional[StrictStr] = Field(alias="tokenType")
|
|
34
|
+
scope: Optional[StrictStr]
|
|
35
|
+
__properties: ClassVar[List[str]] = ["accessToken", "expiresIn", "refreshToken", "idToken", "tokenType", "scope"]
|
|
32
36
|
|
|
33
37
|
model_config = ConfigDict(
|
|
34
38
|
populate_by_name=True,
|
|
@@ -74,11 +78,31 @@ class ReadBridgeTokenKeysResult(BaseModel):
|
|
|
74
78
|
if self.access_token is None and "access_token" in self.model_fields_set:
|
|
75
79
|
_dict['accessToken'] = None
|
|
76
80
|
|
|
81
|
+
# set to None if expires_in (nullable) is None
|
|
82
|
+
# and model_fields_set contains the field
|
|
83
|
+
if self.expires_in is None and "expires_in" in self.model_fields_set:
|
|
84
|
+
_dict['expiresIn'] = None
|
|
85
|
+
|
|
77
86
|
# set to None if refresh_token (nullable) is None
|
|
78
87
|
# and model_fields_set contains the field
|
|
79
88
|
if self.refresh_token is None and "refresh_token" in self.model_fields_set:
|
|
80
89
|
_dict['refreshToken'] = None
|
|
81
90
|
|
|
91
|
+
# set to None if id_token (nullable) is None
|
|
92
|
+
# and model_fields_set contains the field
|
|
93
|
+
if self.id_token is None and "id_token" in self.model_fields_set:
|
|
94
|
+
_dict['idToken'] = None
|
|
95
|
+
|
|
96
|
+
# set to None if token_type (nullable) is None
|
|
97
|
+
# and model_fields_set contains the field
|
|
98
|
+
if self.token_type is None and "token_type" in self.model_fields_set:
|
|
99
|
+
_dict['tokenType'] = None
|
|
100
|
+
|
|
101
|
+
# set to None if scope (nullable) is None
|
|
102
|
+
# and model_fields_set contains the field
|
|
103
|
+
if self.scope is None and "scope" in self.model_fields_set:
|
|
104
|
+
_dict['scope'] = None
|
|
105
|
+
|
|
82
106
|
return _dict
|
|
83
107
|
|
|
84
108
|
@classmethod
|
|
@@ -92,7 +116,11 @@ class ReadBridgeTokenKeysResult(BaseModel):
|
|
|
92
116
|
|
|
93
117
|
_obj = cls.model_validate({
|
|
94
118
|
"accessToken": obj.get("accessToken"),
|
|
95
|
-
"
|
|
119
|
+
"expiresIn": obj.get("expiresIn"),
|
|
120
|
+
"refreshToken": obj.get("refreshToken"),
|
|
121
|
+
"idToken": obj.get("idToken"),
|
|
122
|
+
"tokenType": obj.get("tokenType"),
|
|
123
|
+
"scope": obj.get("scope")
|
|
96
124
|
})
|
|
97
125
|
return _obj
|
|
98
126
|
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Rapidata.Dataset
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: v1
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class RegisterTemporaryCustomerResult(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
The access parameters of the newly registered temporary customer.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
access_token: StrictStr = Field(description="The access token to authenticate the user.")
|
|
30
|
+
expires_in: Optional[StrictInt] = Field(default=None, description="The time in seconds until the access token expires.")
|
|
31
|
+
refresh_token: Optional[StrictStr] = Field(default=None, description="The refresh token to refresh the access token.")
|
|
32
|
+
id_token: StrictStr = Field(description="The id token to identify the user.")
|
|
33
|
+
token_type: StrictStr = Field(description="The type of token. Usually, this is \"Bearer\".")
|
|
34
|
+
scope: Optional[StrictStr] = Field(default=None, description="The scope of access the token has.")
|
|
35
|
+
__properties: ClassVar[List[str]] = ["access_token", "expires_in", "refresh_token", "id_token", "token_type", "scope"]
|
|
36
|
+
|
|
37
|
+
model_config = ConfigDict(
|
|
38
|
+
populate_by_name=True,
|
|
39
|
+
validate_assignment=True,
|
|
40
|
+
protected_namespaces=(),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def to_str(self) -> str:
|
|
45
|
+
"""Returns the string representation of the model using alias"""
|
|
46
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
47
|
+
|
|
48
|
+
def to_json(self) -> str:
|
|
49
|
+
"""Returns the JSON representation of the model using alias"""
|
|
50
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
51
|
+
return json.dumps(self.to_dict())
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
55
|
+
"""Create an instance of RegisterTemporaryCustomerResult from a JSON string"""
|
|
56
|
+
return cls.from_dict(json.loads(json_str))
|
|
57
|
+
|
|
58
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
59
|
+
"""Return the dictionary representation of the model using alias.
|
|
60
|
+
|
|
61
|
+
This has the following differences from calling pydantic's
|
|
62
|
+
`self.model_dump(by_alias=True)`:
|
|
63
|
+
|
|
64
|
+
* `None` is only added to the output dict for nullable fields that
|
|
65
|
+
were set at model initialization. Other fields with value `None`
|
|
66
|
+
are ignored.
|
|
67
|
+
"""
|
|
68
|
+
excluded_fields: Set[str] = set([
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
_dict = self.model_dump(
|
|
72
|
+
by_alias=True,
|
|
73
|
+
exclude=excluded_fields,
|
|
74
|
+
exclude_none=True,
|
|
75
|
+
)
|
|
76
|
+
# set to None if expires_in (nullable) is None
|
|
77
|
+
# and model_fields_set contains the field
|
|
78
|
+
if self.expires_in is None and "expires_in" in self.model_fields_set:
|
|
79
|
+
_dict['expires_in'] = None
|
|
80
|
+
|
|
81
|
+
# set to None if refresh_token (nullable) is None
|
|
82
|
+
# and model_fields_set contains the field
|
|
83
|
+
if self.refresh_token is None and "refresh_token" in self.model_fields_set:
|
|
84
|
+
_dict['refresh_token'] = None
|
|
85
|
+
|
|
86
|
+
# set to None if scope (nullable) is None
|
|
87
|
+
# and model_fields_set contains the field
|
|
88
|
+
if self.scope is None and "scope" in self.model_fields_set:
|
|
89
|
+
_dict['scope'] = None
|
|
90
|
+
|
|
91
|
+
return _dict
|
|
92
|
+
|
|
93
|
+
@classmethod
|
|
94
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
95
|
+
"""Create an instance of RegisterTemporaryCustomerResult from a dict"""
|
|
96
|
+
if obj is None:
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
if not isinstance(obj, dict):
|
|
100
|
+
return cls.model_validate(obj)
|
|
101
|
+
|
|
102
|
+
_obj = cls.model_validate({
|
|
103
|
+
"access_token": obj.get("access_token"),
|
|
104
|
+
"expires_in": obj.get("expires_in"),
|
|
105
|
+
"refresh_token": obj.get("refresh_token"),
|
|
106
|
+
"id_token": obj.get("id_token"),
|
|
107
|
+
"token_type": obj.get("token_type"),
|
|
108
|
+
"scope": obj.get("scope")
|
|
109
|
+
})
|
|
110
|
+
return _obj
|
|
111
|
+
|
|
112
|
+
|
rapidata/api_client_README.md
CHANGED
|
@@ -344,6 +344,7 @@ Class | Method | HTTP request | Description
|
|
|
344
344
|
- [RapidSkippedModel](rapidata/api_client/docs/RapidSkippedModel.md)
|
|
345
345
|
- [ReadBridgeTokenKeysResult](rapidata/api_client/docs/ReadBridgeTokenKeysResult.md)
|
|
346
346
|
- [RegisterTemporaryCustomerModel](rapidata/api_client/docs/RegisterTemporaryCustomerModel.md)
|
|
347
|
+
- [RegisterTemporaryCustomerResult](rapidata/api_client/docs/RegisterTemporaryCustomerResult.md)
|
|
347
348
|
- [RootFilter](rapidata/api_client/docs/RootFilter.md)
|
|
348
349
|
- [SendCompletionMailStepModel](rapidata/api_client/docs/SendCompletionMailStepModel.md)
|
|
349
350
|
- [Shape](rapidata/api_client/docs/Shape.md)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This package provides classes for different types of assets, including MediaAsset, TextAsset, and MultiAsset.
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
from .base_asset import BaseAsset
|
|
6
6
|
from .media_asset import MediaAsset
|
|
7
7
|
from .text_asset import TextAsset
|
|
8
8
|
from .multi_asset import MultiAsset
|
|
@@ -31,6 +31,9 @@ class MediaAsset(BaseAsset):
|
|
|
31
31
|
Raises:
|
|
32
32
|
FileNotFoundError: If the provided file path does not exist.
|
|
33
33
|
"""
|
|
34
|
+
if not isinstance(path, str):
|
|
35
|
+
raise ValueError("Media must be a string, either a local file path or an image URL")
|
|
36
|
+
|
|
34
37
|
if re.match(r'^https?://', path):
|
|
35
38
|
self.path = MediaAsset.get_image_bytes(path)
|
|
36
39
|
self.name = path.split('/')[-1]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from rapidata.service.openapi_service import OpenAPIService
|
|
2
|
+
from rapidata.rapidata_client.dataset.rapid_builders import ClassifyRapidQuestionBuilder, CompareRapidCriteriaBuilder, TranscriptionRapidInstructionBuilder
|
|
3
|
+
|
|
4
|
+
class BaseRapidBuilder:
|
|
5
|
+
"""Base class for creating different types of rapids.
|
|
6
|
+
|
|
7
|
+
This class provides factory methods to create specific rapids
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
def classify_rapid(self):
|
|
11
|
+
"""Creates a classification rapid.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
ClassifyRapidQuestionBuilder: A builder for creating the classification question.
|
|
15
|
+
"""
|
|
16
|
+
return ClassifyRapidQuestionBuilder()
|
|
17
|
+
|
|
18
|
+
def compare_rapid(self):
|
|
19
|
+
"""Creates a compare rapid.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
CompareRapidCriteriaBuilder: A builder for creating a comparison criteria.
|
|
23
|
+
"""
|
|
24
|
+
return CompareRapidCriteriaBuilder()
|
|
25
|
+
|
|
26
|
+
def transcription_rapid(self):
|
|
27
|
+
"""Creates a transcription rapid.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
TranscriptionRapidInstructionBuilder: A builder for creating the transcription instruction.
|
|
31
|
+
"""
|
|
32
|
+
return TranscriptionRapidInstructionBuilder()
|
|
33
|
+
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from rapidata.rapidata_client.assets import MediaAsset, TextAsset
|
|
2
|
+
from rapidata.rapidata_client.metadata import PromptMetadata
|
|
3
|
+
from rapidata.rapidata_client.dataset.rapid_builders.rapids import ClassificationRapid
|
|
4
|
+
|
|
5
|
+
class ClassifyRapidBuilder:
|
|
6
|
+
"""Final builder class for classification rapid.
|
|
7
|
+
|
|
8
|
+
This class handles the final construction of a classification rapid with all required parameters.
|
|
9
|
+
"""
|
|
10
|
+
def __init__(self, question: str, options: list[str], truths: list[str], asset: MediaAsset | TextAsset):
|
|
11
|
+
self._question = question
|
|
12
|
+
self._options = options
|
|
13
|
+
self._truths = truths
|
|
14
|
+
self._asset = asset
|
|
15
|
+
self._metadata = []
|
|
16
|
+
|
|
17
|
+
def prompt(self, prompt: str):
|
|
18
|
+
"""Add a prompt to provide additional context for the classification task.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
prompt (str): Additional instructions or context
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
ClassifyRapidBuilder: The builder instance for method chaining
|
|
25
|
+
"""
|
|
26
|
+
self._metadata.append(PromptMetadata(prompt))
|
|
27
|
+
return self
|
|
28
|
+
|
|
29
|
+
def build(self):
|
|
30
|
+
"""Constructs and returns the final classification rapid.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
ClassificationRapid: The constructed classification rapid
|
|
34
|
+
"""
|
|
35
|
+
return ClassificationRapid(
|
|
36
|
+
question=self._question,
|
|
37
|
+
options=self._options,
|
|
38
|
+
truths=self._truths,
|
|
39
|
+
asset=self._asset,
|
|
40
|
+
metadata=self._metadata
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
class ClassifyRapidTruthBuilder:
|
|
44
|
+
"""Builder class for the truths of the classification rapid.
|
|
45
|
+
|
|
46
|
+
This adds the truths to the classification rapid.
|
|
47
|
+
"""
|
|
48
|
+
def __init__(self, question: str, options: list[str], asset: MediaAsset | TextAsset):
|
|
49
|
+
self._question = question
|
|
50
|
+
self._options = options
|
|
51
|
+
self._asset = asset
|
|
52
|
+
self._truths = None
|
|
53
|
+
|
|
54
|
+
def truths(self, truths: list[str]):
|
|
55
|
+
"""Set the truths for the classification rapid.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
truths (list[str]): The correct answers for the classification task"""
|
|
59
|
+
|
|
60
|
+
if not isinstance(truths, list) or not all(isinstance(truth, str) for truth in truths):
|
|
61
|
+
raise ValueError("Truths must be a list of strings")
|
|
62
|
+
|
|
63
|
+
if not all(truth in self._options for truth in truths):
|
|
64
|
+
raise ValueError("Truths must be one of the selectable options")
|
|
65
|
+
|
|
66
|
+
self._truths = truths
|
|
67
|
+
return self._build()
|
|
68
|
+
|
|
69
|
+
def _build(self):
|
|
70
|
+
if self._truths is None:
|
|
71
|
+
raise ValueError("Truths are required")
|
|
72
|
+
return ClassifyRapidBuilder(
|
|
73
|
+
question=self._question,
|
|
74
|
+
options=self._options,
|
|
75
|
+
asset=self._asset,
|
|
76
|
+
truths=self._truths,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
class ClassifyRapidMediaBuilder:
|
|
80
|
+
"""Builder class for the media asset of the classification rapid.
|
|
81
|
+
|
|
82
|
+
This class adds the media asset to the classification rapid.
|
|
83
|
+
"""
|
|
84
|
+
def __init__(self, question: str, options: list[str]):
|
|
85
|
+
self._question = question
|
|
86
|
+
self._options = options
|
|
87
|
+
self._asset: MediaAsset | TextAsset | None = None
|
|
88
|
+
|
|
89
|
+
def media(self, media: str):
|
|
90
|
+
"""Set the media asset for the classification rapid.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
media (str): A local file path or an image URL. The image will be displayed with the classification task"""
|
|
94
|
+
self._asset = MediaAsset(media)
|
|
95
|
+
|
|
96
|
+
return self._build()
|
|
97
|
+
|
|
98
|
+
def text(self, text: str):
|
|
99
|
+
"""Set the text asset for the classification rapid.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
text (str): The text to be displayed with the classification task"""
|
|
103
|
+
self._asset = TextAsset(text)
|
|
104
|
+
|
|
105
|
+
return self._build()
|
|
106
|
+
|
|
107
|
+
def _build(self):
|
|
108
|
+
if self._asset is None:
|
|
109
|
+
raise ValueError("Assets are required")
|
|
110
|
+
|
|
111
|
+
return ClassifyRapidTruthBuilder(
|
|
112
|
+
question=self._question,
|
|
113
|
+
options=self._options,
|
|
114
|
+
asset=self._asset,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
class ClassifyRapidOptionsBuilder:
|
|
118
|
+
def __init__(self, question: str):
|
|
119
|
+
self._question = question
|
|
120
|
+
self._options = None
|
|
121
|
+
|
|
122
|
+
def options(self, options: list[str]):
|
|
123
|
+
"""Set the options for the classification rapid.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
options (list[str]): The selectable options for the classification task"""
|
|
127
|
+
|
|
128
|
+
if not isinstance(options, list) or not all(isinstance(option, str) for option in options):
|
|
129
|
+
raise ValueError("Options must be a list of strings")
|
|
130
|
+
|
|
131
|
+
self._options = options
|
|
132
|
+
return self._build()
|
|
133
|
+
|
|
134
|
+
def _build(self):
|
|
135
|
+
if self._options is None:
|
|
136
|
+
raise ValueError("Options are required")
|
|
137
|
+
|
|
138
|
+
return ClassifyRapidMediaBuilder(
|
|
139
|
+
question=self._question,
|
|
140
|
+
options=self._options,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class ClassifyRapidQuestionBuilder:
|
|
145
|
+
def __init__(self):
|
|
146
|
+
self._question = None
|
|
147
|
+
|
|
148
|
+
def question(self, question: str):
|
|
149
|
+
"""Set the question for the classification rapid.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
question (str): The question to be answered by the classification task"""
|
|
153
|
+
|
|
154
|
+
if not isinstance(question, str):
|
|
155
|
+
raise ValueError("Question must be a string")
|
|
156
|
+
|
|
157
|
+
self._question = question
|
|
158
|
+
return self._build()
|
|
159
|
+
|
|
160
|
+
def _build(self):
|
|
161
|
+
if self._question is None:
|
|
162
|
+
raise ValueError("Question is required")
|
|
163
|
+
|
|
164
|
+
return ClassifyRapidOptionsBuilder(
|
|
165
|
+
question=self._question,
|
|
166
|
+
)
|