rapidata 2.29.0__py3-none-any.whl → 2.29.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/__init__.py +1 -1
- rapidata/api_client/__init__.py +4 -0
- rapidata/api_client/api/benchmark_api.py +267 -0
- rapidata/api_client/models/__init__.py +4 -0
- rapidata/api_client/models/create_leaderboard_model.py +3 -1
- rapidata/api_client/models/create_leaderboard_result.py +13 -3
- rapidata/api_client/models/file_asset_input3.py +104 -0
- rapidata/api_client/models/get_leaderboard_by_id_result.py +11 -3
- rapidata/api_client/models/leaderboard_query_result.py +11 -3
- rapidata/api_client/models/multi_asset_input3.py +110 -0
- rapidata/api_client/models/multi_asset_input3_assets_inner.py +170 -0
- rapidata/api_client/models/submit_prompt_model.py +20 -4
- rapidata/api_client/models/submit_prompt_model_prompt_asset.py +174 -0
- rapidata/api_client_README.md +5 -0
- rapidata/rapidata_client/benchmark/leaderboard/rapidata_leaderboard.py +57 -4
- rapidata/rapidata_client/benchmark/rapidata_benchmark.py +31 -2
- {rapidata-2.29.0.dist-info → rapidata-2.29.1.dist-info}/METADATA +1 -1
- {rapidata-2.29.0.dist-info → rapidata-2.29.1.dist-info}/RECORD +20 -16
- {rapidata-2.29.0.dist-info → rapidata-2.29.1.dist-info}/LICENSE +0 -0
- {rapidata-2.29.0.dist-info → rapidata-2.29.1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
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 json
|
|
17
|
+
import pprint
|
|
18
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
|
19
|
+
from typing import Any, List, Optional
|
|
20
|
+
from rapidata.api_client.models.file_asset_input3 import FileAssetInput3
|
|
21
|
+
from rapidata.api_client.models.text_asset_input import TextAssetInput
|
|
22
|
+
from rapidata.api_client.models.url_asset_input import UrlAssetInput
|
|
23
|
+
from pydantic import StrictStr, Field
|
|
24
|
+
from typing import Union, List, Set, Optional, Dict
|
|
25
|
+
from typing_extensions import Literal, Self
|
|
26
|
+
|
|
27
|
+
MULTIASSETINPUT3ASSETSINNER_ONE_OF_SCHEMAS = ["FileAssetInput3", "MultiAssetInput3", "TextAssetInput", "UrlAssetInput"]
|
|
28
|
+
|
|
29
|
+
class MultiAssetInput3AssetsInner(BaseModel):
|
|
30
|
+
"""
|
|
31
|
+
MultiAssetInput3AssetsInner
|
|
32
|
+
"""
|
|
33
|
+
# data type: FileAssetInput3
|
|
34
|
+
oneof_schema_1_validator: Optional[FileAssetInput3] = None
|
|
35
|
+
# data type: MultiAssetInput3
|
|
36
|
+
oneof_schema_2_validator: Optional[MultiAssetInput3] = None
|
|
37
|
+
# data type: TextAssetInput
|
|
38
|
+
oneof_schema_3_validator: Optional[TextAssetInput] = None
|
|
39
|
+
# data type: UrlAssetInput
|
|
40
|
+
oneof_schema_4_validator: Optional[UrlAssetInput] = None
|
|
41
|
+
actual_instance: Optional[Union[FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput]] = None
|
|
42
|
+
one_of_schemas: Set[str] = { "FileAssetInput3", "MultiAssetInput3", "TextAssetInput", "UrlAssetInput" }
|
|
43
|
+
|
|
44
|
+
model_config = ConfigDict(
|
|
45
|
+
validate_assignment=True,
|
|
46
|
+
protected_namespaces=(),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
discriminator_value_class_map: Dict[str, str] = {
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
54
|
+
if args:
|
|
55
|
+
if len(args) > 1:
|
|
56
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
57
|
+
if kwargs:
|
|
58
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
59
|
+
super().__init__(actual_instance=args[0])
|
|
60
|
+
else:
|
|
61
|
+
super().__init__(**kwargs)
|
|
62
|
+
|
|
63
|
+
@field_validator('actual_instance')
|
|
64
|
+
def actual_instance_must_validate_oneof(cls, v):
|
|
65
|
+
instance = MultiAssetInput3AssetsInner.model_construct()
|
|
66
|
+
error_messages = []
|
|
67
|
+
match = 0
|
|
68
|
+
# validate data type: FileAssetInput3
|
|
69
|
+
if not isinstance(v, FileAssetInput3):
|
|
70
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `FileAssetInput3`")
|
|
71
|
+
else:
|
|
72
|
+
match += 1
|
|
73
|
+
# validate data type: MultiAssetInput3
|
|
74
|
+
if not isinstance(v, MultiAssetInput3):
|
|
75
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `MultiAssetInput3`")
|
|
76
|
+
else:
|
|
77
|
+
match += 1
|
|
78
|
+
# validate data type: TextAssetInput
|
|
79
|
+
if not isinstance(v, TextAssetInput):
|
|
80
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `TextAssetInput`")
|
|
81
|
+
else:
|
|
82
|
+
match += 1
|
|
83
|
+
# validate data type: UrlAssetInput
|
|
84
|
+
if not isinstance(v, UrlAssetInput):
|
|
85
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `UrlAssetInput`")
|
|
86
|
+
else:
|
|
87
|
+
match += 1
|
|
88
|
+
if match > 1:
|
|
89
|
+
# more than 1 match
|
|
90
|
+
raise ValueError("Multiple matches found when setting `actual_instance` in MultiAssetInput3AssetsInner with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
91
|
+
elif match == 0:
|
|
92
|
+
# no match
|
|
93
|
+
raise ValueError("No match found when setting `actual_instance` in MultiAssetInput3AssetsInner with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
94
|
+
else:
|
|
95
|
+
return v
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
|
|
99
|
+
return cls.from_json(json.dumps(obj))
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_json(cls, json_str: str) -> Self:
|
|
103
|
+
"""Returns the object represented by the json string"""
|
|
104
|
+
instance = cls.model_construct()
|
|
105
|
+
error_messages = []
|
|
106
|
+
match = 0
|
|
107
|
+
|
|
108
|
+
# deserialize data into FileAssetInput3
|
|
109
|
+
try:
|
|
110
|
+
instance.actual_instance = FileAssetInput3.from_json(json_str)
|
|
111
|
+
match += 1
|
|
112
|
+
except (ValidationError, ValueError) as e:
|
|
113
|
+
error_messages.append(str(e))
|
|
114
|
+
# deserialize data into MultiAssetInput3
|
|
115
|
+
try:
|
|
116
|
+
instance.actual_instance = MultiAssetInput3.from_json(json_str)
|
|
117
|
+
match += 1
|
|
118
|
+
except (ValidationError, ValueError) as e:
|
|
119
|
+
error_messages.append(str(e))
|
|
120
|
+
# deserialize data into TextAssetInput
|
|
121
|
+
try:
|
|
122
|
+
instance.actual_instance = TextAssetInput.from_json(json_str)
|
|
123
|
+
match += 1
|
|
124
|
+
except (ValidationError, ValueError) as e:
|
|
125
|
+
error_messages.append(str(e))
|
|
126
|
+
# deserialize data into UrlAssetInput
|
|
127
|
+
try:
|
|
128
|
+
instance.actual_instance = UrlAssetInput.from_json(json_str)
|
|
129
|
+
match += 1
|
|
130
|
+
except (ValidationError, ValueError) as e:
|
|
131
|
+
error_messages.append(str(e))
|
|
132
|
+
|
|
133
|
+
if match > 1:
|
|
134
|
+
# more than 1 match
|
|
135
|
+
raise ValueError("Multiple matches found when deserializing the JSON string into MultiAssetInput3AssetsInner with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
136
|
+
elif match == 0:
|
|
137
|
+
# no match
|
|
138
|
+
raise ValueError("No match found when deserializing the JSON string into MultiAssetInput3AssetsInner with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
139
|
+
else:
|
|
140
|
+
return instance
|
|
141
|
+
|
|
142
|
+
def to_json(self) -> str:
|
|
143
|
+
"""Returns the JSON representation of the actual instance"""
|
|
144
|
+
if self.actual_instance is None:
|
|
145
|
+
return "null"
|
|
146
|
+
|
|
147
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
148
|
+
return self.actual_instance.to_json()
|
|
149
|
+
else:
|
|
150
|
+
return json.dumps(self.actual_instance)
|
|
151
|
+
|
|
152
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput]]:
|
|
153
|
+
"""Returns the dict representation of the actual instance"""
|
|
154
|
+
if self.actual_instance is None:
|
|
155
|
+
return None
|
|
156
|
+
|
|
157
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
158
|
+
return self.actual_instance.to_dict()
|
|
159
|
+
else:
|
|
160
|
+
# primitive type
|
|
161
|
+
return self.actual_instance
|
|
162
|
+
|
|
163
|
+
def to_str(self) -> str:
|
|
164
|
+
"""Returns the string representation of the actual instance"""
|
|
165
|
+
return pprint.pformat(self.model_dump())
|
|
166
|
+
|
|
167
|
+
from rapidata.api_client.models.multi_asset_input3 import MultiAssetInput3
|
|
168
|
+
# TODO: Rewrite to not use raise_errors
|
|
169
|
+
MultiAssetInput3AssetsInner.model_rebuild(raise_errors=False)
|
|
170
|
+
|
|
@@ -18,7 +18,8 @@ import re # noqa: F401
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
21
|
-
from typing import Any, ClassVar, Dict, List
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from rapidata.api_client.models.submit_prompt_model_prompt_asset import SubmitPromptModelPromptAsset
|
|
22
23
|
from typing import Optional, Set
|
|
23
24
|
from typing_extensions import Self
|
|
24
25
|
|
|
@@ -26,9 +27,10 @@ class SubmitPromptModel(BaseModel):
|
|
|
26
27
|
"""
|
|
27
28
|
The model user for submitting a prompt to a benchmark.
|
|
28
29
|
""" # noqa: E501
|
|
29
|
-
prompt: StrictStr = Field(description="The prompt")
|
|
30
30
|
identifier: StrictStr = Field(description="An identifier associated to the prompt")
|
|
31
|
-
|
|
31
|
+
prompt: Optional[StrictStr] = Field(default=None, description="The prompt")
|
|
32
|
+
prompt_asset: Optional[SubmitPromptModelPromptAsset] = Field(default=None, alias="promptAsset")
|
|
33
|
+
__properties: ClassVar[List[str]] = ["identifier", "prompt", "promptAsset"]
|
|
32
34
|
|
|
33
35
|
model_config = ConfigDict(
|
|
34
36
|
populate_by_name=True,
|
|
@@ -69,6 +71,19 @@ class SubmitPromptModel(BaseModel):
|
|
|
69
71
|
exclude=excluded_fields,
|
|
70
72
|
exclude_none=True,
|
|
71
73
|
)
|
|
74
|
+
# override the default output from pydantic by calling `to_dict()` of prompt_asset
|
|
75
|
+
if self.prompt_asset:
|
|
76
|
+
_dict['promptAsset'] = self.prompt_asset.to_dict()
|
|
77
|
+
# set to None if prompt (nullable) is None
|
|
78
|
+
# and model_fields_set contains the field
|
|
79
|
+
if self.prompt is None and "prompt" in self.model_fields_set:
|
|
80
|
+
_dict['prompt'] = None
|
|
81
|
+
|
|
82
|
+
# set to None if prompt_asset (nullable) is None
|
|
83
|
+
# and model_fields_set contains the field
|
|
84
|
+
if self.prompt_asset is None and "prompt_asset" in self.model_fields_set:
|
|
85
|
+
_dict['promptAsset'] = None
|
|
86
|
+
|
|
72
87
|
return _dict
|
|
73
88
|
|
|
74
89
|
@classmethod
|
|
@@ -81,8 +96,9 @@ class SubmitPromptModel(BaseModel):
|
|
|
81
96
|
return cls.model_validate(obj)
|
|
82
97
|
|
|
83
98
|
_obj = cls.model_validate({
|
|
99
|
+
"identifier": obj.get("identifier"),
|
|
84
100
|
"prompt": obj.get("prompt"),
|
|
85
|
-
"
|
|
101
|
+
"promptAsset": SubmitPromptModelPromptAsset.from_dict(obj["promptAsset"]) if obj.get("promptAsset") is not None else None
|
|
86
102
|
})
|
|
87
103
|
return _obj
|
|
88
104
|
|
|
@@ -0,0 +1,174 @@
|
|
|
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 json
|
|
17
|
+
import pprint
|
|
18
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
|
19
|
+
from typing import Any, List, Optional
|
|
20
|
+
from rapidata.api_client.models.file_asset_input3 import FileAssetInput3
|
|
21
|
+
from rapidata.api_client.models.multi_asset_input3 import MultiAssetInput3
|
|
22
|
+
from rapidata.api_client.models.text_asset_input import TextAssetInput
|
|
23
|
+
from rapidata.api_client.models.url_asset_input import UrlAssetInput
|
|
24
|
+
from pydantic import StrictStr, Field
|
|
25
|
+
from typing import Union, List, Set, Optional, Dict
|
|
26
|
+
from typing_extensions import Literal, Self
|
|
27
|
+
|
|
28
|
+
SUBMITPROMPTMODELPROMPTASSET_ONE_OF_SCHEMAS = ["FileAssetInput3", "MultiAssetInput3", "TextAssetInput", "UrlAssetInput"]
|
|
29
|
+
|
|
30
|
+
class SubmitPromptModelPromptAsset(BaseModel):
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
# data type: FileAssetInput3
|
|
35
|
+
oneof_schema_1_validator: Optional[FileAssetInput3] = None
|
|
36
|
+
# data type: MultiAssetInput3
|
|
37
|
+
oneof_schema_2_validator: Optional[MultiAssetInput3] = None
|
|
38
|
+
# data type: TextAssetInput
|
|
39
|
+
oneof_schema_3_validator: Optional[TextAssetInput] = None
|
|
40
|
+
# data type: UrlAssetInput
|
|
41
|
+
oneof_schema_4_validator: Optional[UrlAssetInput] = None
|
|
42
|
+
actual_instance: Optional[Union[FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput]] = None
|
|
43
|
+
one_of_schemas: Set[str] = { "FileAssetInput3", "MultiAssetInput3", "TextAssetInput", "UrlAssetInput" }
|
|
44
|
+
|
|
45
|
+
model_config = ConfigDict(
|
|
46
|
+
validate_assignment=True,
|
|
47
|
+
protected_namespaces=(),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
discriminator_value_class_map: Dict[str, str] = {
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
55
|
+
if args:
|
|
56
|
+
if len(args) > 1:
|
|
57
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
58
|
+
if kwargs:
|
|
59
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
60
|
+
super().__init__(actual_instance=args[0])
|
|
61
|
+
else:
|
|
62
|
+
super().__init__(**kwargs)
|
|
63
|
+
|
|
64
|
+
@field_validator('actual_instance')
|
|
65
|
+
def actual_instance_must_validate_oneof(cls, v):
|
|
66
|
+
if v is None:
|
|
67
|
+
return v
|
|
68
|
+
|
|
69
|
+
instance = SubmitPromptModelPromptAsset.model_construct()
|
|
70
|
+
error_messages = []
|
|
71
|
+
match = 0
|
|
72
|
+
# validate data type: FileAssetInput3
|
|
73
|
+
if not isinstance(v, FileAssetInput3):
|
|
74
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `FileAssetInput3`")
|
|
75
|
+
else:
|
|
76
|
+
match += 1
|
|
77
|
+
# validate data type: MultiAssetInput3
|
|
78
|
+
if not isinstance(v, MultiAssetInput3):
|
|
79
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `MultiAssetInput3`")
|
|
80
|
+
else:
|
|
81
|
+
match += 1
|
|
82
|
+
# validate data type: TextAssetInput
|
|
83
|
+
if not isinstance(v, TextAssetInput):
|
|
84
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `TextAssetInput`")
|
|
85
|
+
else:
|
|
86
|
+
match += 1
|
|
87
|
+
# validate data type: UrlAssetInput
|
|
88
|
+
if not isinstance(v, UrlAssetInput):
|
|
89
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `UrlAssetInput`")
|
|
90
|
+
else:
|
|
91
|
+
match += 1
|
|
92
|
+
if match > 1:
|
|
93
|
+
# more than 1 match
|
|
94
|
+
raise ValueError("Multiple matches found when setting `actual_instance` in SubmitPromptModelPromptAsset with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
95
|
+
elif match == 0:
|
|
96
|
+
# no match
|
|
97
|
+
raise ValueError("No match found when setting `actual_instance` in SubmitPromptModelPromptAsset with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
98
|
+
else:
|
|
99
|
+
return v
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
|
|
103
|
+
return cls.from_json(json.dumps(obj))
|
|
104
|
+
|
|
105
|
+
@classmethod
|
|
106
|
+
def from_json(cls, json_str: Optional[str]) -> Self:
|
|
107
|
+
"""Returns the object represented by the json string"""
|
|
108
|
+
instance = cls.model_construct()
|
|
109
|
+
if json_str is None:
|
|
110
|
+
return instance
|
|
111
|
+
|
|
112
|
+
error_messages = []
|
|
113
|
+
match = 0
|
|
114
|
+
|
|
115
|
+
# deserialize data into FileAssetInput3
|
|
116
|
+
try:
|
|
117
|
+
instance.actual_instance = FileAssetInput3.from_json(json_str)
|
|
118
|
+
match += 1
|
|
119
|
+
except (ValidationError, ValueError) as e:
|
|
120
|
+
error_messages.append(str(e))
|
|
121
|
+
# deserialize data into MultiAssetInput3
|
|
122
|
+
try:
|
|
123
|
+
instance.actual_instance = MultiAssetInput3.from_json(json_str)
|
|
124
|
+
match += 1
|
|
125
|
+
except (ValidationError, ValueError) as e:
|
|
126
|
+
error_messages.append(str(e))
|
|
127
|
+
# deserialize data into TextAssetInput
|
|
128
|
+
try:
|
|
129
|
+
instance.actual_instance = TextAssetInput.from_json(json_str)
|
|
130
|
+
match += 1
|
|
131
|
+
except (ValidationError, ValueError) as e:
|
|
132
|
+
error_messages.append(str(e))
|
|
133
|
+
# deserialize data into UrlAssetInput
|
|
134
|
+
try:
|
|
135
|
+
instance.actual_instance = UrlAssetInput.from_json(json_str)
|
|
136
|
+
match += 1
|
|
137
|
+
except (ValidationError, ValueError) as e:
|
|
138
|
+
error_messages.append(str(e))
|
|
139
|
+
|
|
140
|
+
if match > 1:
|
|
141
|
+
# more than 1 match
|
|
142
|
+
raise ValueError("Multiple matches found when deserializing the JSON string into SubmitPromptModelPromptAsset with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
143
|
+
elif match == 0:
|
|
144
|
+
# no match
|
|
145
|
+
raise ValueError("No match found when deserializing the JSON string into SubmitPromptModelPromptAsset with oneOf schemas: FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput. Details: " + ", ".join(error_messages))
|
|
146
|
+
else:
|
|
147
|
+
return instance
|
|
148
|
+
|
|
149
|
+
def to_json(self) -> str:
|
|
150
|
+
"""Returns the JSON representation of the actual instance"""
|
|
151
|
+
if self.actual_instance is None:
|
|
152
|
+
return "null"
|
|
153
|
+
|
|
154
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
155
|
+
return self.actual_instance.to_json()
|
|
156
|
+
else:
|
|
157
|
+
return json.dumps(self.actual_instance)
|
|
158
|
+
|
|
159
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], FileAssetInput3, MultiAssetInput3, TextAssetInput, UrlAssetInput]]:
|
|
160
|
+
"""Returns the dict representation of the actual instance"""
|
|
161
|
+
if self.actual_instance is None:
|
|
162
|
+
return None
|
|
163
|
+
|
|
164
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
165
|
+
return self.actual_instance.to_dict()
|
|
166
|
+
else:
|
|
167
|
+
# primitive type
|
|
168
|
+
return self.actual_instance
|
|
169
|
+
|
|
170
|
+
def to_str(self) -> str:
|
|
171
|
+
"""Returns the string representation of the actual instance"""
|
|
172
|
+
return pprint.pformat(self.model_dump())
|
|
173
|
+
|
|
174
|
+
|
rapidata/api_client_README.md
CHANGED
|
@@ -74,6 +74,7 @@ Class | Method | HTTP request | Description
|
|
|
74
74
|
------------ | ------------- | ------------- | -------------
|
|
75
75
|
*BenchmarkApi* | [**benchmark_benchmark_id_delete**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_delete) | **DELETE** /benchmark/{benchmarkId} | Deletes a single benchmark.
|
|
76
76
|
*BenchmarkApi* | [**benchmark_benchmark_id_get**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_get) | **GET** /benchmark/{benchmarkId} | Returns a single benchmark by its ID.
|
|
77
|
+
*BenchmarkApi* | [**benchmark_benchmark_id_participant_participant_id_delete**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_participant_participant_id_delete) | **DELETE** /benchmark/{benchmarkId}/participant/{participantId} | Deletes a participant on a benchmark.
|
|
77
78
|
*BenchmarkApi* | [**benchmark_benchmark_id_participant_participant_id_get**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_participant_participant_id_get) | **GET** /benchmark/{benchmarkId}/participant/{participantId} | Gets a participant by it's Id.
|
|
78
79
|
*BenchmarkApi* | [**benchmark_benchmark_id_participants_get**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_participants_get) | **GET** /benchmark/{benchmarkId}/participants | Query all participants within a benchmark
|
|
79
80
|
*BenchmarkApi* | [**benchmark_benchmark_id_participants_participant_id_submit_post**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_participants_participant_id_submit_post) | **POST** /benchmark/{benchmarkId}/participants/{participantId}/submit | Submits a participant to a benchmark.
|
|
@@ -326,6 +327,7 @@ Class | Method | HTTP request | Description
|
|
|
326
327
|
- [FileAssetInput1](rapidata/api_client/docs/FileAssetInput1.md)
|
|
327
328
|
- [FileAssetInput1File](rapidata/api_client/docs/FileAssetInput1File.md)
|
|
328
329
|
- [FileAssetInput2](rapidata/api_client/docs/FileAssetInput2.md)
|
|
330
|
+
- [FileAssetInput3](rapidata/api_client/docs/FileAssetInput3.md)
|
|
329
331
|
- [FileAssetInputFile](rapidata/api_client/docs/FileAssetInputFile.md)
|
|
330
332
|
- [FileAssetModel](rapidata/api_client/docs/FileAssetModel.md)
|
|
331
333
|
- [FileAssetModelMetadataValue](rapidata/api_client/docs/FileAssetModelMetadataValue.md)
|
|
@@ -406,6 +408,8 @@ Class | Method | HTTP request | Description
|
|
|
406
408
|
- [MultiAssetInput1](rapidata/api_client/docs/MultiAssetInput1.md)
|
|
407
409
|
- [MultiAssetInput1AssetsInner](rapidata/api_client/docs/MultiAssetInput1AssetsInner.md)
|
|
408
410
|
- [MultiAssetInput2](rapidata/api_client/docs/MultiAssetInput2.md)
|
|
411
|
+
- [MultiAssetInput3](rapidata/api_client/docs/MultiAssetInput3.md)
|
|
412
|
+
- [MultiAssetInput3AssetsInner](rapidata/api_client/docs/MultiAssetInput3AssetsInner.md)
|
|
409
413
|
- [MultiAssetInputAssetsInner](rapidata/api_client/docs/MultiAssetInputAssetsInner.md)
|
|
410
414
|
- [MultiAssetModel](rapidata/api_client/docs/MultiAssetModel.md)
|
|
411
415
|
- [MultiCompareTruth](rapidata/api_client/docs/MultiCompareTruth.md)
|
|
@@ -512,6 +516,7 @@ Class | Method | HTTP request | Description
|
|
|
512
516
|
- [SubmitCocoResult](rapidata/api_client/docs/SubmitCocoResult.md)
|
|
513
517
|
- [SubmitParticipantResult](rapidata/api_client/docs/SubmitParticipantResult.md)
|
|
514
518
|
- [SubmitPromptModel](rapidata/api_client/docs/SubmitPromptModel.md)
|
|
519
|
+
- [SubmitPromptModelPromptAsset](rapidata/api_client/docs/SubmitPromptModelPromptAsset.md)
|
|
515
520
|
- [TextAsset](rapidata/api_client/docs/TextAsset.md)
|
|
516
521
|
- [TextAssetInput](rapidata/api_client/docs/TextAssetInput.md)
|
|
517
522
|
- [TextAssetModel](rapidata/api_client/docs/TextAssetModel.md)
|
|
@@ -20,13 +20,66 @@ class RapidataLeaderboard:
|
|
|
20
20
|
id: The ID of the leaderboard.
|
|
21
21
|
openapi_service: The OpenAPIService instance for API interaction.
|
|
22
22
|
"""
|
|
23
|
-
def __init__(self,
|
|
23
|
+
def __init__(self,
|
|
24
|
+
name: str,
|
|
25
|
+
instruction: str,
|
|
26
|
+
show_prompt: bool,
|
|
27
|
+
inverse_ranking: bool,
|
|
28
|
+
min_responses: int,
|
|
29
|
+
response_budget: int,
|
|
30
|
+
id: str,
|
|
31
|
+
openapi_service: OpenAPIService):
|
|
24
32
|
self.__openapi_service = openapi_service
|
|
25
|
-
self.
|
|
26
|
-
self.
|
|
27
|
-
self.
|
|
33
|
+
self.__name = name
|
|
34
|
+
self.__instruction = instruction
|
|
35
|
+
self.__show_prompt = show_prompt
|
|
36
|
+
self.__inverse_ranking = inverse_ranking
|
|
37
|
+
self.__min_responses = min_responses
|
|
38
|
+
self.__response_budget = response_budget
|
|
28
39
|
self.id = id
|
|
29
40
|
|
|
41
|
+
@property
|
|
42
|
+
def response_budget(self) -> int:
|
|
43
|
+
"""
|
|
44
|
+
Returns the response budget of the leaderboard.
|
|
45
|
+
"""
|
|
46
|
+
return self.__response_budget
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def min_responses(self) -> int:
|
|
50
|
+
"""
|
|
51
|
+
Returns the minimum number of responses required to be considered for the leaderboard.
|
|
52
|
+
"""
|
|
53
|
+
return self.__min_responses
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def inverse_ranking(self) -> bool:
|
|
57
|
+
"""
|
|
58
|
+
Returns whether the ranking is inverse.
|
|
59
|
+
"""
|
|
60
|
+
return self.__inverse_ranking
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def show_prompt(self) -> bool:
|
|
64
|
+
"""
|
|
65
|
+
Returns whether the prompt is shown to the users.
|
|
66
|
+
"""
|
|
67
|
+
return self.__show_prompt
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def instruction(self) -> str:
|
|
71
|
+
"""
|
|
72
|
+
Returns the instruction of the leaderboard.
|
|
73
|
+
"""
|
|
74
|
+
return self.__instruction
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def name(self) -> str:
|
|
78
|
+
"""
|
|
79
|
+
Returns the name of the leaderboard.
|
|
80
|
+
"""
|
|
81
|
+
return self.__name
|
|
82
|
+
|
|
30
83
|
def get_standings(self) -> pd.DataFrame:
|
|
31
84
|
"""
|
|
32
85
|
Returns the standings of the leaderboard.
|
|
@@ -112,6 +112,9 @@ class RapidataBenchmark:
|
|
|
112
112
|
leaderboard.name,
|
|
113
113
|
leaderboard.instruction,
|
|
114
114
|
leaderboard.show_prompt,
|
|
115
|
+
leaderboard.is_inversed,
|
|
116
|
+
leaderboard.min_responses,
|
|
117
|
+
leaderboard.response_budget,
|
|
115
118
|
leaderboard.id,
|
|
116
119
|
self.__openapi_service
|
|
117
120
|
) for leaderboard in leaderboards_result.items])
|
|
@@ -144,16 +147,39 @@ class RapidataBenchmark:
|
|
|
144
147
|
)
|
|
145
148
|
)
|
|
146
149
|
|
|
147
|
-
def create_leaderboard(
|
|
150
|
+
def create_leaderboard(
|
|
151
|
+
self,
|
|
152
|
+
name: str,
|
|
153
|
+
instruction: str,
|
|
154
|
+
show_prompt: bool,
|
|
155
|
+
inverse_ranking: bool = False,
|
|
156
|
+
min_responses: int | None = None,
|
|
157
|
+
response_budget: int | None = None
|
|
158
|
+
) -> RapidataLeaderboard:
|
|
148
159
|
"""
|
|
149
160
|
Creates a new leaderboard for the benchmark.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
name: The name of the leaderboard. (not shown to the users)
|
|
164
|
+
instruction: The instruction decides how the models will be evaluated.
|
|
165
|
+
show_prompt: Whether to show the prompt to the users.
|
|
166
|
+
inverse_ranking: Whether to inverse the ranking of the leaderboard. (if the question is inversed, e.g. "Which video is worse?")
|
|
167
|
+
min_responses: The minimum amount of responses that get collected per comparison. if None, it will be defaulted.
|
|
168
|
+
response_budget: The total amount of responses that get collected per new model evaluation. if None, it will be defaulted. Values below 2000 are not recommended.
|
|
150
169
|
"""
|
|
170
|
+
|
|
171
|
+
if response_budget is not None and response_budget < 2000:
|
|
172
|
+
logger.warning("Response budget is below 2000. This is not recommended.")
|
|
173
|
+
|
|
151
174
|
leaderboard_result = self.__openapi_service.leaderboard_api.leaderboard_post(
|
|
152
175
|
create_leaderboard_model=CreateLeaderboardModel(
|
|
153
176
|
benchmarkId=self.id,
|
|
154
177
|
name=name,
|
|
155
178
|
instruction=instruction,
|
|
156
|
-
showPrompt=show_prompt
|
|
179
|
+
showPrompt=show_prompt,
|
|
180
|
+
isInversed=inverse_ranking,
|
|
181
|
+
minResponses=min_responses,
|
|
182
|
+
responseBudget=response_budget
|
|
157
183
|
)
|
|
158
184
|
)
|
|
159
185
|
|
|
@@ -163,6 +189,9 @@ class RapidataBenchmark:
|
|
|
163
189
|
name,
|
|
164
190
|
instruction,
|
|
165
191
|
show_prompt,
|
|
192
|
+
inverse_ranking,
|
|
193
|
+
leaderboard_result.min_responses,
|
|
194
|
+
leaderboard_result.response_budget,
|
|
166
195
|
leaderboard_result.id,
|
|
167
196
|
self.__openapi_service
|
|
168
197
|
)
|