rapidata 2.28.5__py3-none-any.whl → 2.29.0__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.

Files changed (84) hide show
  1. rapidata/__init__.py +1 -1
  2. rapidata/api_client/__init__.py +41 -8
  3. rapidata/api_client/api/__init__.py +1 -0
  4. rapidata/api_client/api/benchmark_api.py +2766 -0
  5. rapidata/api_client/api/customer_rapid_api.py +332 -1
  6. rapidata/api_client/api/dataset_api.py +16 -0
  7. rapidata/api_client/api/leaderboard_api.py +1392 -270
  8. rapidata/api_client/models/__init__.py +40 -8
  9. rapidata/api_client/models/add_campaign_model.py +3 -3
  10. rapidata/api_client/models/and_user_filter_model.py +106 -0
  11. rapidata/api_client/models/and_user_filter_model_filters_inner.py +282 -0
  12. rapidata/api_client/models/benchmark_query_result.py +94 -0
  13. rapidata/api_client/models/benchmark_query_result_paged_result.py +105 -0
  14. rapidata/api_client/models/boost_leaderboard_model.py +89 -0
  15. rapidata/api_client/models/create_benchmark_model.py +87 -0
  16. rapidata/api_client/models/create_benchmark_participant_model.py +87 -0
  17. rapidata/api_client/models/create_benchmark_participant_result.py +89 -0
  18. rapidata/api_client/models/create_benchmark_result.py +87 -0
  19. rapidata/api_client/models/create_datapoint_result.py +4 -16
  20. rapidata/api_client/models/create_leaderboard_model.py +18 -2
  21. rapidata/api_client/models/create_leaderboard_result.py +5 -3
  22. rapidata/api_client/models/create_order_model.py +3 -3
  23. rapidata/api_client/models/file_asset_input.py +104 -0
  24. rapidata/api_client/models/file_asset_input1.py +104 -0
  25. rapidata/api_client/models/file_asset_input1_file.py +168 -0
  26. rapidata/api_client/models/file_asset_input2.py +104 -0
  27. rapidata/api_client/models/file_asset_input_file.py +182 -0
  28. rapidata/api_client/models/form_file_wrapper.py +120 -0
  29. rapidata/api_client/models/get_benchmark_by_id_query.py +96 -0
  30. rapidata/api_client/models/get_benchmark_by_id_query_result.py +94 -0
  31. rapidata/api_client/models/get_benchmark_by_id_query_result_paged_result.py +105 -0
  32. rapidata/api_client/models/get_benchmark_by_id_result.py +94 -0
  33. rapidata/api_client/models/get_participant_by_id_result.py +6 -26
  34. rapidata/api_client/models/get_standing_by_id_result.py +113 -0
  35. rapidata/api_client/models/local_file_wrapper.py +120 -0
  36. rapidata/api_client/models/multi_asset_input.py +110 -0
  37. rapidata/api_client/models/multi_asset_input1.py +110 -0
  38. rapidata/api_client/models/multi_asset_input1_assets_inner.py +170 -0
  39. rapidata/api_client/models/multi_asset_input2.py +110 -0
  40. rapidata/api_client/models/multi_asset_input_assets_inner.py +170 -0
  41. rapidata/api_client/models/not_user_filter_model.py +3 -3
  42. rapidata/api_client/models/or_user_filter_model.py +3 -3
  43. rapidata/api_client/models/participant_by_benchmark.py +102 -0
  44. rapidata/api_client/models/participant_by_benchmark_paged_result.py +105 -0
  45. rapidata/api_client/models/participant_status.py +1 -4
  46. rapidata/api_client/models/potential_validation_rapid.py +103 -0
  47. rapidata/api_client/models/potential_validation_rapid_paged_result.py +105 -0
  48. rapidata/api_client/models/potential_validation_rapid_truth.py +280 -0
  49. rapidata/api_client/models/prompt_asset_metadata_input.py +3 -3
  50. rapidata/api_client/models/prompt_asset_metadata_input_asset.py +170 -0
  51. rapidata/api_client/models/prompt_by_benchmark_result.py +92 -0
  52. rapidata/api_client/models/prompt_by_benchmark_result_paged_result.py +105 -0
  53. rapidata/api_client/models/prompt_metadata_input.py +5 -3
  54. rapidata/api_client/models/proxy_file_wrapper.py +114 -0
  55. rapidata/api_client/models/query_validation_model.py +97 -0
  56. rapidata/api_client/models/standing_by_leaderboard.py +113 -0
  57. rapidata/api_client/models/standing_by_leaderboard_paged_result.py +105 -0
  58. rapidata/api_client/models/standing_status.py +38 -0
  59. rapidata/api_client/models/stream_file_wrapper.py +116 -0
  60. rapidata/api_client/models/submit_prompt_model.py +89 -0
  61. rapidata/api_client/models/text_asset_input.py +100 -0
  62. rapidata/api_client/models/transcription_metadata_input.py +5 -3
  63. rapidata/api_client/models/zip_entry_file_wrapper.py +120 -0
  64. rapidata/api_client_README.md +62 -16
  65. rapidata/rapidata_client/benchmark/leaderboard/__init__.py +0 -0
  66. rapidata/rapidata_client/benchmark/leaderboard/rapidata_leaderboard.py +62 -0
  67. rapidata/rapidata_client/benchmark/rapidata_benchmark.py +227 -0
  68. rapidata/rapidata_client/benchmark/rapidata_benchmark_manager.py +83 -0
  69. rapidata/rapidata_client/filter/not_filter.py +2 -2
  70. rapidata/rapidata_client/filter/or_filter.py +2 -2
  71. rapidata/rapidata_client/metadata/__init__.py +1 -0
  72. rapidata/rapidata_client/metadata/_media_asset_metadata.py +8 -1
  73. rapidata/rapidata_client/metadata/_prompt_identifier_metadata.py +15 -0
  74. rapidata/rapidata_client/order/_rapidata_dataset.py +6 -6
  75. rapidata/rapidata_client/order/_rapidata_order_builder.py +4 -4
  76. rapidata/rapidata_client/rapidata_client.py +3 -3
  77. rapidata/service/openapi_service.py +5 -0
  78. {rapidata-2.28.5.dist-info → rapidata-2.29.0.dist-info}/METADATA +1 -1
  79. {rapidata-2.28.5.dist-info → rapidata-2.29.0.dist-info}/RECORD +82 -35
  80. rapidata/rapidata_client/leaderboard/rapidata_leaderboard.py +0 -127
  81. rapidata/rapidata_client/leaderboard/rapidata_leaderboard_manager.py +0 -92
  82. /rapidata/rapidata_client/{leaderboard → benchmark}/__init__.py +0 -0
  83. {rapidata-2.28.5.dist-info → rapidata-2.29.0.dist-info}/LICENSE +0 -0
  84. {rapidata-2.28.5.dist-info → rapidata-2.29.0.dist-info}/WHEEL +0 -0
@@ -1,127 +0,0 @@
1
- from rapidata.api_client.models.create_leaderboard_participant_model import CreateLeaderboardParticipantModel
2
- from rapidata.api_client.models.page_info import PageInfo
3
- from rapidata.api_client.models.query_model import QueryModel
4
-
5
- from rapidata.rapidata_client.order._rapidata_dataset import RapidataDataset
6
- from rapidata.rapidata_client.assets import MediaAsset
7
- from rapidata.rapidata_client.metadata import PromptMetadata
8
- from rapidata.service.openapi_service import OpenAPIService
9
-
10
-
11
- class RapidataLeaderboard:
12
- """
13
- An instance of a Rapidata leaderboard.
14
-
15
- Used to interact with a specific leaderboard in the Rapidata system, such as retrieving prompts and evaluating models.
16
-
17
- Args:
18
- name: The name that will be used to identify the leaderboard on the overview.
19
- instruction: The instruction that will determine what how the models will be evaluated.
20
- show_prompt: Whether to show the prompt to the users.
21
- id: The ID of the leaderboard.
22
- openapi_service: The OpenAPIService instance for API interaction.
23
- """
24
- def __init__(self, name: str, instruction: str, show_prompt: bool, id: str, openapi_service: OpenAPIService):
25
- self.__openapi_service = openapi_service
26
- self.name = name
27
- self.instruction = instruction
28
- self.show_prompt = show_prompt
29
- self._prompts: list[str] = []
30
- self.id = id
31
-
32
- @property
33
- def prompts(self) -> list[str]:
34
- """
35
- Returns the prompts that are registered for the leaderboard.
36
- """
37
- if not self._prompts:
38
- current_page = 1
39
- total_pages = None
40
-
41
- while True:
42
- prompts_result = self.__openapi_service.leaderboard_api.leaderboard_leaderboard_id_prompts_get(
43
- leaderboard_id=self.id,
44
- request=QueryModel(
45
- page=PageInfo(
46
- index=current_page,
47
- size=100
48
- )
49
- )
50
- )
51
-
52
- if prompts_result.total_pages is None:
53
- raise ValueError("An error occurred while fetching prompts: total_pages is None")
54
-
55
- total_pages = prompts_result.total_pages
56
-
57
- self._prompts.extend([prompt.prompt for prompt in prompts_result.items])
58
-
59
- if current_page >= total_pages:
60
- break
61
-
62
- current_page += 1
63
-
64
- return self._prompts
65
-
66
- def _register_prompts(self, prompts: list[str]):
67
- """
68
- Registers the prompts for the leaderboard.
69
- """
70
- for prompt in prompts:
71
- self.__openapi_service.leaderboard_api.leaderboard_leaderboard_id_prompts_post(
72
- leaderboard_id=self.id,
73
- body=prompt
74
- )
75
- self._prompts = prompts
76
-
77
- def evaluate_model(self, name: str, media: list[str], prompts: list[str]) -> None:
78
- """
79
- Evaluates a model on the leaderboard.
80
-
81
- Args:
82
- name: The name of the model.
83
- media: The generated images/videos that will be used to evaluate the model.
84
- prompts: The prompts that correspond to the media. The order of the prompts must match the order of the media.
85
- The prompts that are used must be registered for the leaderboard. To see the registered prompts, use the prompts property.
86
- """
87
- if not media:
88
- raise ValueError("Media must be a non-empty list of strings")
89
-
90
- if len(media) != len(prompts):
91
- raise ValueError("Media and prompts must have the same length")
92
-
93
- if not all(prompt in self.prompts for prompt in prompts):
94
- raise ValueError("All prompts must be in the registered prompts list. To see the registered prompts, use the prompts property.")
95
-
96
- # happens before the creation of the participant to ensure all media paths are valid
97
- assets = []
98
- prompts_metadata: list[list[PromptMetadata]] = []
99
- for media_path, prompt in zip(media, prompts):
100
- assets.append(MediaAsset(media_path))
101
- prompts_metadata.append([PromptMetadata(prompt)])
102
-
103
- participant_result = self.__openapi_service.leaderboard_api.leaderboard_leaderboard_id_participants_post(
104
- leaderboard_id=self.id,
105
- create_leaderboard_participant_model=CreateLeaderboardParticipantModel(
106
- name=name,
107
- )
108
- )
109
- dataset = RapidataDataset(participant_result.dataset_id, self.__openapi_service)
110
-
111
- dataset._add_datapoints(assets, prompts_metadata)
112
-
113
- self.__openapi_service.leaderboard_api.leaderboard_leaderboard_id_participants_participant_id_submit_post(
114
- leaderboard_id=self.id,
115
- participant_id=participant_result.participant_id
116
- )
117
-
118
- def __str__(self) -> str:
119
- return f"RapidataLeaderboard(name={self.name}, instruction={self.instruction}, show_prompt={self.show_prompt}, leaderboard_id={self.id})"
120
-
121
- def __repr__(self) -> str:
122
- return self.__str__()
123
-
124
-
125
-
126
-
127
-
@@ -1,92 +0,0 @@
1
- from rapidata.service.openapi_service import OpenAPIService
2
- from rapidata.rapidata_client.leaderboard.rapidata_leaderboard import RapidataLeaderboard
3
- from rapidata.api_client.models.query_model import QueryModel
4
- from rapidata.api_client.models.page_info import PageInfo
5
- from rapidata.api_client.models.root_filter import RootFilter
6
- from rapidata.api_client.models.filter import Filter
7
- from rapidata.api_client.models.sort_criterion import SortCriterion
8
- from rapidata.api_client.models.create_leaderboard_model import CreateLeaderboardModel
9
-
10
- class RapidataLeaderboardManager:
11
- """
12
- A manager for leaderboards.
13
-
14
- Used to create and retrieve leaderboards.
15
-
16
- Args:
17
- openapi_service: The OpenAPIService instance for API interaction.
18
- """
19
- def __init__(self, openapi_service: OpenAPIService):
20
- self.__openapi_service = openapi_service
21
-
22
- def create_new_leaderboard(self, name: str, instruction: str, prompts: list[str], show_prompt: bool = False) -> RapidataLeaderboard:
23
- """
24
- Creates a new leaderboard with the given name, instruction, and prompts.
25
-
26
- Args:
27
- leaderboard_name: The name of the leaderboard. Will be used to identify the leaderboard on the overview.
28
- instruction: The instruction for the leaderboard. Will determine how the models will be evaluated.
29
- prompts: The prompts for the leaderboard. Will be registered for the leaderboard and able to be retrieved again later.
30
- show_prompt: Whether to show the prompt to the users when they are evaluating the models.
31
- """
32
- if not isinstance(name, str):
33
- raise ValueError("Name must be a string.")
34
-
35
- if not isinstance(instruction, str):
36
- raise ValueError("Instruction must be a string.")
37
-
38
- if not isinstance(show_prompt, bool):
39
- raise ValueError("Show prompt must be a boolean.")
40
-
41
- if not isinstance(prompts, list) or not all(isinstance(prompt, str) for prompt in prompts):
42
- raise ValueError("Prompts must be a list of strings.")
43
-
44
- leaderboard_id = self.__register_new_leaderboard(name, instruction, show_prompt)
45
- leaderboard = RapidataLeaderboard(name, instruction, show_prompt, leaderboard_id, self.__openapi_service)
46
- leaderboard._register_prompts(prompts)
47
- return leaderboard
48
-
49
- def get_leaderboard_by_id(self, leaderboard_id: str) -> RapidataLeaderboard:
50
- """
51
- Retrieves a leaderboard by its ID.
52
-
53
- Args:
54
- leaderboard_id: The ID of the leaderboard.
55
- """
56
- leaderboard_result = self.__openapi_service.leaderboard_api.leaderboard_leaderboard_id_get(
57
- leaderboard_id=leaderboard_id
58
- )
59
- return RapidataLeaderboard(leaderboard_result.name, leaderboard_result.instruction, leaderboard_result.show_prompt, leaderboard_id, self.__openapi_service)
60
-
61
- def find_leaderboards(self, name: str = "", amount: int = 10) -> list[RapidataLeaderboard]:
62
- """
63
- Find your recent leaderboards given criteria. If nothing is provided, it will return the most recent leaderboard.
64
-
65
- Args:
66
- name (str, optional): The name of the leaderboard - matching leaderboard will contain the name. Defaults to "" for any leaderboard.
67
- amount (int, optional): The amount of leaderboards to return. Defaults to 10.
68
- """
69
- leaderboard_result = self.__openapi_service.leaderboard_api.leaderboards_get(
70
- request=QueryModel(
71
- page=PageInfo(
72
- index=1,
73
- size=amount
74
- ),
75
- filter=RootFilter(filters=[Filter(field="Name", operator="Contains", value=name)]),
76
- sortCriteria=[SortCriterion(direction="Desc", propertyName="CreatedAt")]
77
- )
78
- )
79
- leaderboards = []
80
- for leaderboard in leaderboard_result.items:
81
- leaderboards.append(RapidataLeaderboard(leaderboard.name, leaderboard.instruction, leaderboard.show_prompt, leaderboard.id, self.__openapi_service))
82
- return leaderboards
83
-
84
- def __register_new_leaderboard(self, name: str, instruction: str, show_prompt: bool) -> str:
85
- leaderboard_id = self.__openapi_service.leaderboard_api.leaderboard_post(
86
- CreateLeaderboardModel(
87
- name=name,
88
- instruction=instruction,
89
- showPrompt=show_prompt
90
- )
91
- ).id
92
- return leaderboard_id