opik 1.9.26__py3-none-any.whl → 1.9.41__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.
Files changed (181) hide show
  1. opik/__init__.py +10 -3
  2. opik/api_objects/dataset/rest_operations.py +2 -0
  3. opik/api_objects/experiment/experiment.py +31 -5
  4. opik/api_objects/experiment/helpers.py +34 -10
  5. opik/api_objects/local_recording.py +8 -3
  6. opik/api_objects/opik_client.py +218 -46
  7. opik/api_objects/opik_query_language.py +9 -0
  8. opik/api_objects/prompt/__init__.py +11 -3
  9. opik/api_objects/prompt/base_prompt.py +69 -0
  10. opik/api_objects/prompt/base_prompt_template.py +29 -0
  11. opik/api_objects/prompt/chat/__init__.py +1 -0
  12. opik/api_objects/prompt/chat/chat_prompt.py +193 -0
  13. opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
  14. opik/api_objects/prompt/{chat_content_renderer_registry.py → chat/content_renderer_registry.py} +31 -34
  15. opik/api_objects/prompt/client.py +101 -30
  16. opik/api_objects/prompt/text/__init__.py +1 -0
  17. opik/api_objects/prompt/{prompt.py → text/prompt.py} +55 -32
  18. opik/api_objects/prompt/{prompt_template.py → text/prompt_template.py} +8 -5
  19. opik/cli/export.py +6 -2
  20. opik/config.py +0 -5
  21. opik/decorator/base_track_decorator.py +37 -40
  22. opik/evaluation/__init__.py +13 -2
  23. opik/evaluation/engine/engine.py +195 -223
  24. opik/evaluation/engine/helpers.py +8 -7
  25. opik/evaluation/engine/metrics_evaluator.py +237 -0
  26. opik/evaluation/evaluation_result.py +35 -1
  27. opik/evaluation/evaluator.py +309 -23
  28. opik/evaluation/models/litellm/util.py +78 -6
  29. opik/evaluation/report.py +14 -2
  30. opik/evaluation/rest_operations.py +6 -9
  31. opik/evaluation/test_case.py +2 -2
  32. opik/evaluation/types.py +9 -1
  33. opik/exceptions.py +17 -0
  34. opik/id_helpers.py +18 -0
  35. opik/integrations/adk/helpers.py +16 -7
  36. opik/integrations/adk/legacy_opik_tracer.py +7 -4
  37. opik/integrations/adk/opik_tracer.py +3 -1
  38. opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +7 -3
  39. opik/integrations/dspy/callback.py +1 -4
  40. opik/integrations/haystack/opik_connector.py +2 -2
  41. opik/integrations/haystack/opik_tracer.py +2 -4
  42. opik/integrations/langchain/opik_tracer.py +1 -4
  43. opik/integrations/llama_index/callback.py +2 -4
  44. opik/integrations/openai/agents/opik_tracing_processor.py +1 -2
  45. opik/integrations/openai/opik_tracker.py +1 -1
  46. opik/opik_context.py +7 -7
  47. opik/rest_api/__init__.py +127 -11
  48. opik/rest_api/dashboards/client.py +65 -2
  49. opik/rest_api/dashboards/raw_client.py +82 -0
  50. opik/rest_api/datasets/client.py +538 -2
  51. opik/rest_api/datasets/raw_client.py +1347 -441
  52. opik/rest_api/experiments/client.py +30 -2
  53. opik/rest_api/experiments/raw_client.py +26 -0
  54. opik/rest_api/optimizations/client.py +302 -0
  55. opik/rest_api/optimizations/raw_client.py +463 -0
  56. opik/rest_api/optimizations/types/optimization_update_status.py +3 -1
  57. opik/rest_api/prompts/__init__.py +2 -2
  58. opik/rest_api/prompts/client.py +34 -4
  59. opik/rest_api/prompts/raw_client.py +32 -2
  60. opik/rest_api/prompts/types/__init__.py +3 -1
  61. opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
  62. opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
  63. opik/rest_api/traces/client.py +6 -6
  64. opik/rest_api/traces/raw_client.py +4 -4
  65. opik/rest_api/types/__init__.py +125 -11
  66. opik/rest_api/types/aggregation_data.py +1 -0
  67. opik/rest_api/types/automation_rule_evaluator.py +23 -1
  68. opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +2 -0
  69. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +2 -0
  70. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +2 -0
  71. opik/rest_api/types/{automation_rule_evaluator_object_public.py → automation_rule_evaluator_object_object_public.py} +32 -10
  72. opik/rest_api/types/automation_rule_evaluator_page_public.py +2 -2
  73. opik/rest_api/types/automation_rule_evaluator_public.py +23 -1
  74. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
  75. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
  76. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
  77. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +2 -0
  78. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +2 -0
  79. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +2 -0
  80. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +2 -0
  81. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +2 -0
  82. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +2 -0
  83. opik/rest_api/types/automation_rule_evaluator_update.py +23 -1
  84. opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +2 -0
  85. opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
  86. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +2 -0
  87. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +2 -0
  88. opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +2 -0
  89. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +2 -0
  90. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +2 -0
  91. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +2 -0
  92. opik/rest_api/types/automation_rule_evaluator_write.py +23 -1
  93. opik/rest_api/types/dashboard_page_public.py +1 -0
  94. opik/rest_api/types/dataset.py +4 -0
  95. opik/rest_api/types/dataset_item.py +1 -0
  96. opik/rest_api/types/dataset_item_compare.py +1 -0
  97. opik/rest_api/types/dataset_item_page_compare.py +1 -0
  98. opik/rest_api/types/dataset_item_page_public.py +1 -0
  99. opik/rest_api/types/dataset_item_public.py +1 -0
  100. opik/rest_api/types/dataset_public.py +4 -0
  101. opik/rest_api/types/dataset_public_status.py +5 -0
  102. opik/rest_api/types/dataset_status.py +5 -0
  103. opik/rest_api/types/dataset_version_diff.py +22 -0
  104. opik/rest_api/types/dataset_version_diff_stats.py +24 -0
  105. opik/rest_api/types/dataset_version_page_public.py +23 -0
  106. opik/rest_api/types/dataset_version_public.py +54 -0
  107. opik/rest_api/types/dataset_version_summary.py +41 -0
  108. opik/rest_api/types/dataset_version_summary_public.py +41 -0
  109. opik/rest_api/types/experiment.py +2 -0
  110. opik/rest_api/types/experiment_public.py +2 -0
  111. opik/rest_api/types/experiment_score.py +20 -0
  112. opik/rest_api/types/experiment_score_public.py +20 -0
  113. opik/rest_api/types/experiment_score_write.py +20 -0
  114. opik/rest_api/types/feedback_score_public.py +4 -0
  115. opik/rest_api/types/group_content_with_aggregations.py +1 -0
  116. opik/rest_api/types/optimization.py +2 -0
  117. opik/rest_api/types/optimization_public.py +2 -0
  118. opik/rest_api/types/optimization_public_status.py +3 -1
  119. opik/rest_api/types/optimization_status.py +3 -1
  120. opik/rest_api/types/optimization_studio_config.py +27 -0
  121. opik/rest_api/types/optimization_studio_config_public.py +27 -0
  122. opik/rest_api/types/optimization_studio_config_write.py +27 -0
  123. opik/rest_api/types/optimization_studio_log.py +22 -0
  124. opik/rest_api/types/optimization_write.py +2 -0
  125. opik/rest_api/types/optimization_write_status.py +3 -1
  126. opik/rest_api/types/prompt.py +6 -0
  127. opik/rest_api/types/prompt_detail.py +6 -0
  128. opik/rest_api/types/prompt_detail_template_structure.py +5 -0
  129. opik/rest_api/types/prompt_public.py +6 -0
  130. opik/rest_api/types/prompt_public_template_structure.py +5 -0
  131. opik/rest_api/types/prompt_template_structure.py +5 -0
  132. opik/rest_api/types/prompt_version.py +2 -0
  133. opik/rest_api/types/prompt_version_detail.py +2 -0
  134. opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
  135. opik/rest_api/types/prompt_version_public.py +2 -0
  136. opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
  137. opik/rest_api/types/prompt_version_template_structure.py +5 -0
  138. opik/rest_api/types/score_name.py +1 -0
  139. opik/rest_api/types/service_toggles_config.py +5 -0
  140. opik/rest_api/types/span_filter.py +23 -0
  141. opik/rest_api/types/span_filter_operator.py +21 -0
  142. opik/rest_api/types/span_filter_write.py +23 -0
  143. opik/rest_api/types/span_filter_write_operator.py +21 -0
  144. opik/rest_api/types/span_llm_as_judge_code.py +27 -0
  145. opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
  146. opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
  147. opik/rest_api/types/studio_evaluation.py +20 -0
  148. opik/rest_api/types/studio_evaluation_public.py +20 -0
  149. opik/rest_api/types/studio_evaluation_write.py +20 -0
  150. opik/rest_api/types/studio_llm_model.py +21 -0
  151. opik/rest_api/types/studio_llm_model_public.py +21 -0
  152. opik/rest_api/types/studio_llm_model_write.py +21 -0
  153. opik/rest_api/types/studio_message.py +20 -0
  154. opik/rest_api/types/studio_message_public.py +20 -0
  155. opik/rest_api/types/studio_message_write.py +20 -0
  156. opik/rest_api/types/studio_metric.py +21 -0
  157. opik/rest_api/types/studio_metric_public.py +21 -0
  158. opik/rest_api/types/studio_metric_write.py +21 -0
  159. opik/rest_api/types/studio_optimizer.py +21 -0
  160. opik/rest_api/types/studio_optimizer_public.py +21 -0
  161. opik/rest_api/types/studio_optimizer_write.py +21 -0
  162. opik/rest_api/types/studio_prompt.py +20 -0
  163. opik/rest_api/types/studio_prompt_public.py +20 -0
  164. opik/rest_api/types/studio_prompt_write.py +20 -0
  165. opik/rest_api/types/trace.py +6 -0
  166. opik/rest_api/types/trace_public.py +6 -0
  167. opik/rest_api/types/trace_thread_filter_write.py +23 -0
  168. opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
  169. opik/rest_api/types/value_entry.py +2 -0
  170. opik/rest_api/types/value_entry_compare.py +2 -0
  171. opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +2 -0
  172. opik/rest_api/types/value_entry_public.py +2 -0
  173. opik/synchronization.py +5 -6
  174. opik/{decorator/tracing_runtime_config.py → tracing_runtime_config.py} +6 -7
  175. {opik-1.9.26.dist-info → opik-1.9.41.dist-info}/METADATA +4 -3
  176. {opik-1.9.26.dist-info → opik-1.9.41.dist-info}/RECORD +180 -120
  177. opik/api_objects/prompt/chat_prompt_template.py +0 -200
  178. {opik-1.9.26.dist-info → opik-1.9.41.dist-info}/WHEEL +0 -0
  179. {opik-1.9.26.dist-info → opik-1.9.41.dist-info}/entry_points.txt +0 -0
  180. {opik-1.9.26.dist-info → opik-1.9.41.dist-info}/licenses/LICENSE +0 -0
  181. {opik-1.9.26.dist-info → opik-1.9.41.dist-info}/top_level.txt +0 -0
@@ -14,6 +14,9 @@ from ..types.dataset_item_write import DatasetItemWrite
14
14
  from ..types.dataset_item_write_source import DatasetItemWriteSource
15
15
  from ..types.dataset_page_public import DatasetPagePublic
16
16
  from ..types.dataset_public import DatasetPublic
17
+ from ..types.dataset_version_diff import DatasetVersionDiff
18
+ from ..types.dataset_version_page_public import DatasetVersionPagePublic
19
+ from ..types.dataset_version_public import DatasetVersionPublic
17
20
  from ..types.json_node import JsonNode
18
21
  from ..types.page_columns import PageColumns
19
22
  from ..types.project_stats_public import ProjectStatsPublic
@@ -789,6 +792,7 @@ class DatasetsClient:
789
792
  *,
790
793
  page: typing.Optional[int] = None,
791
794
  size: typing.Optional[int] = None,
795
+ version: typing.Optional[str] = None,
792
796
  filters: typing.Optional[str] = None,
793
797
  truncate: typing.Optional[bool] = None,
794
798
  request_options: typing.Optional[RequestOptions] = None,
@@ -804,6 +808,8 @@ class DatasetsClient:
804
808
 
805
809
  size : typing.Optional[int]
806
810
 
811
+ version : typing.Optional[str]
812
+
807
813
  filters : typing.Optional[str]
808
814
 
809
815
  truncate : typing.Optional[bool]
@@ -823,7 +829,13 @@ class DatasetsClient:
823
829
  client.datasets.get_dataset_items(id='id', )
824
830
  """
825
831
  _response = self._raw_client.get_dataset_items(
826
- id, page=page, size=size, filters=filters, truncate=truncate, request_options=request_options
832
+ id,
833
+ page=page,
834
+ size=size,
835
+ version=version,
836
+ filters=filters,
837
+ truncate=truncate,
838
+ request_options=request_options,
827
839
  )
828
840
  return _response.data
829
841
 
@@ -897,6 +909,251 @@ class DatasetsClient:
897
909
  ) as r:
898
910
  yield from r.data
899
911
 
912
+ def compare_dataset_versions(
913
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
914
+ ) -> DatasetVersionDiff:
915
+ """
916
+ Compare the latest committed dataset version with the current draft state. This endpoint provides insights into changes made since the last version was committed. The comparison calculates additions, modifications, deletions, and unchanged items between the latest version snapshot and current draft.
917
+
918
+ Parameters
919
+ ----------
920
+ id : str
921
+
922
+ request_options : typing.Optional[RequestOptions]
923
+ Request-specific configuration.
924
+
925
+ Returns
926
+ -------
927
+ DatasetVersionDiff
928
+ Diff computed successfully
929
+
930
+ Examples
931
+ --------
932
+ from Opik import OpikApi
933
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
934
+ client.datasets.compare_dataset_versions(id='id', )
935
+ """
936
+ _response = self._raw_client.compare_dataset_versions(id, request_options=request_options)
937
+ return _response.data
938
+
939
+ def create_version_tag(
940
+ self, version_hash: str, id: str, *, tag: str, request_options: typing.Optional[RequestOptions] = None
941
+ ) -> None:
942
+ """
943
+ Add a tag to a specific dataset version for easy reference (e.g., 'baseline', 'v1.0', 'production')
944
+
945
+ Parameters
946
+ ----------
947
+ version_hash : str
948
+
949
+ id : str
950
+
951
+ tag : str
952
+
953
+ request_options : typing.Optional[RequestOptions]
954
+ Request-specific configuration.
955
+
956
+ Returns
957
+ -------
958
+ None
959
+
960
+ Examples
961
+ --------
962
+ from Opik import OpikApi
963
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
964
+ client.datasets.create_version_tag(version_hash='versionHash', id='id', tag='tag', )
965
+ """
966
+ _response = self._raw_client.create_version_tag(version_hash, id, tag=tag, request_options=request_options)
967
+ return _response.data
968
+
969
+ def list_dataset_versions(
970
+ self,
971
+ id: str,
972
+ *,
973
+ page: typing.Optional[int] = None,
974
+ size: typing.Optional[int] = None,
975
+ request_options: typing.Optional[RequestOptions] = None,
976
+ ) -> DatasetVersionPagePublic:
977
+ """
978
+ Get paginated list of versions for a dataset, ordered by creation time (newest first)
979
+
980
+ Parameters
981
+ ----------
982
+ id : str
983
+
984
+ page : typing.Optional[int]
985
+
986
+ size : typing.Optional[int]
987
+
988
+ request_options : typing.Optional[RequestOptions]
989
+ Request-specific configuration.
990
+
991
+ Returns
992
+ -------
993
+ DatasetVersionPagePublic
994
+ Dataset versions
995
+
996
+ Examples
997
+ --------
998
+ from Opik import OpikApi
999
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1000
+ client.datasets.list_dataset_versions(id='id', )
1001
+ """
1002
+ _response = self._raw_client.list_dataset_versions(id, page=page, size=size, request_options=request_options)
1003
+ return _response.data
1004
+
1005
+ def create_dataset_version(
1006
+ self,
1007
+ id: str,
1008
+ *,
1009
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1010
+ change_description: typing.Optional[str] = OMIT,
1011
+ metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
1012
+ request_options: typing.Optional[RequestOptions] = None,
1013
+ ) -> None:
1014
+ """
1015
+ Create a new immutable version of the dataset by snapshotting the current state
1016
+
1017
+ Parameters
1018
+ ----------
1019
+ id : str
1020
+
1021
+ tags : typing.Optional[typing.Sequence[str]]
1022
+ Optional list of tags for this version
1023
+
1024
+ change_description : typing.Optional[str]
1025
+ Optional description of changes in this version
1026
+
1027
+ metadata : typing.Optional[typing.Dict[str, str]]
1028
+ Optional user-defined metadata
1029
+
1030
+ request_options : typing.Optional[RequestOptions]
1031
+ Request-specific configuration.
1032
+
1033
+ Returns
1034
+ -------
1035
+ None
1036
+
1037
+ Examples
1038
+ --------
1039
+ from Opik import OpikApi
1040
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1041
+ client.datasets.create_dataset_version(id='id', )
1042
+ """
1043
+ _response = self._raw_client.create_dataset_version(
1044
+ id, tags=tags, change_description=change_description, metadata=metadata, request_options=request_options
1045
+ )
1046
+ return _response.data
1047
+
1048
+ def delete_version_tag(
1049
+ self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
1050
+ ) -> None:
1051
+ """
1052
+ Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
1053
+
1054
+ Parameters
1055
+ ----------
1056
+ version_hash : str
1057
+
1058
+ tag : str
1059
+
1060
+ id : str
1061
+
1062
+ request_options : typing.Optional[RequestOptions]
1063
+ Request-specific configuration.
1064
+
1065
+ Returns
1066
+ -------
1067
+ None
1068
+
1069
+ Examples
1070
+ --------
1071
+ from Opik import OpikApi
1072
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1073
+ client.datasets.delete_version_tag(version_hash='versionHash', tag='tag', id='id', )
1074
+ """
1075
+ _response = self._raw_client.delete_version_tag(version_hash, tag, id, request_options=request_options)
1076
+ return _response.data
1077
+
1078
+ def restore_dataset_version(
1079
+ self, id: str, *, version_ref: str, request_options: typing.Optional[RequestOptions] = None
1080
+ ) -> DatasetVersionPublic:
1081
+ """
1082
+ Restores the dataset to a previous version state. All draft items are replaced with items from the specified version. If the version is not the latest, a new version snapshot is created. If the version is the latest, only draft items are replaced (revert functionality).
1083
+
1084
+ Parameters
1085
+ ----------
1086
+ id : str
1087
+
1088
+ version_ref : str
1089
+ Version hash or tag to restore from
1090
+
1091
+ request_options : typing.Optional[RequestOptions]
1092
+ Request-specific configuration.
1093
+
1094
+ Returns
1095
+ -------
1096
+ DatasetVersionPublic
1097
+ Version restored successfully
1098
+
1099
+ Examples
1100
+ --------
1101
+ from Opik import OpikApi
1102
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1103
+ client.datasets.restore_dataset_version(id='id', version_ref='version_ref', )
1104
+ """
1105
+ _response = self._raw_client.restore_dataset_version(
1106
+ id, version_ref=version_ref, request_options=request_options
1107
+ )
1108
+ return _response.data
1109
+
1110
+ def update_dataset_version(
1111
+ self,
1112
+ version_hash: str,
1113
+ id: str,
1114
+ *,
1115
+ change_description: typing.Optional[str] = OMIT,
1116
+ tags_to_add: typing.Optional[typing.Sequence[str]] = OMIT,
1117
+ request_options: typing.Optional[RequestOptions] = None,
1118
+ ) -> DatasetVersionPublic:
1119
+ """
1120
+ Update a dataset version's change_description and/or add new tags
1121
+
1122
+ Parameters
1123
+ ----------
1124
+ version_hash : str
1125
+
1126
+ id : str
1127
+
1128
+ change_description : typing.Optional[str]
1129
+ Optional description of changes in this version
1130
+
1131
+ tags_to_add : typing.Optional[typing.Sequence[str]]
1132
+ Optional list of tags to add to this version
1133
+
1134
+ request_options : typing.Optional[RequestOptions]
1135
+ Request-specific configuration.
1136
+
1137
+ Returns
1138
+ -------
1139
+ DatasetVersionPublic
1140
+ Version updated successfully
1141
+
1142
+ Examples
1143
+ --------
1144
+ from Opik import OpikApi
1145
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1146
+ client.datasets.update_dataset_version(version_hash='versionHash', id='id', )
1147
+ """
1148
+ _response = self._raw_client.update_dataset_version(
1149
+ version_hash,
1150
+ id,
1151
+ change_description=change_description,
1152
+ tags_to_add=tags_to_add,
1153
+ request_options=request_options,
1154
+ )
1155
+ return _response.data
1156
+
900
1157
 
901
1158
  class AsyncDatasetsClient:
902
1159
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -1721,6 +1978,7 @@ class AsyncDatasetsClient:
1721
1978
  *,
1722
1979
  page: typing.Optional[int] = None,
1723
1980
  size: typing.Optional[int] = None,
1981
+ version: typing.Optional[str] = None,
1724
1982
  filters: typing.Optional[str] = None,
1725
1983
  truncate: typing.Optional[bool] = None,
1726
1984
  request_options: typing.Optional[RequestOptions] = None,
@@ -1736,6 +1994,8 @@ class AsyncDatasetsClient:
1736
1994
 
1737
1995
  size : typing.Optional[int]
1738
1996
 
1997
+ version : typing.Optional[str]
1998
+
1739
1999
  filters : typing.Optional[str]
1740
2000
 
1741
2001
  truncate : typing.Optional[bool]
@@ -1758,7 +2018,13 @@ class AsyncDatasetsClient:
1758
2018
  asyncio.run(main())
1759
2019
  """
1760
2020
  _response = await self._raw_client.get_dataset_items(
1761
- id, page=page, size=size, filters=filters, truncate=truncate, request_options=request_options
2021
+ id,
2022
+ page=page,
2023
+ size=size,
2024
+ version=version,
2025
+ filters=filters,
2026
+ truncate=truncate,
2027
+ request_options=request_options,
1762
2028
  )
1763
2029
  return _response.data
1764
2030
 
@@ -1835,3 +2101,273 @@ class AsyncDatasetsClient:
1835
2101
  ) as r:
1836
2102
  async for data in r.data:
1837
2103
  yield data
2104
+
2105
+ async def compare_dataset_versions(
2106
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2107
+ ) -> DatasetVersionDiff:
2108
+ """
2109
+ Compare the latest committed dataset version with the current draft state. This endpoint provides insights into changes made since the last version was committed. The comparison calculates additions, modifications, deletions, and unchanged items between the latest version snapshot and current draft.
2110
+
2111
+ Parameters
2112
+ ----------
2113
+ id : str
2114
+
2115
+ request_options : typing.Optional[RequestOptions]
2116
+ Request-specific configuration.
2117
+
2118
+ Returns
2119
+ -------
2120
+ DatasetVersionDiff
2121
+ Diff computed successfully
2122
+
2123
+ Examples
2124
+ --------
2125
+ from Opik import AsyncOpikApi
2126
+ import asyncio
2127
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2128
+ async def main() -> None:
2129
+ await client.datasets.compare_dataset_versions(id='id', )
2130
+ asyncio.run(main())
2131
+ """
2132
+ _response = await self._raw_client.compare_dataset_versions(id, request_options=request_options)
2133
+ return _response.data
2134
+
2135
+ async def create_version_tag(
2136
+ self, version_hash: str, id: str, *, tag: str, request_options: typing.Optional[RequestOptions] = None
2137
+ ) -> None:
2138
+ """
2139
+ Add a tag to a specific dataset version for easy reference (e.g., 'baseline', 'v1.0', 'production')
2140
+
2141
+ Parameters
2142
+ ----------
2143
+ version_hash : str
2144
+
2145
+ id : str
2146
+
2147
+ tag : str
2148
+
2149
+ request_options : typing.Optional[RequestOptions]
2150
+ Request-specific configuration.
2151
+
2152
+ Returns
2153
+ -------
2154
+ None
2155
+
2156
+ Examples
2157
+ --------
2158
+ from Opik import AsyncOpikApi
2159
+ import asyncio
2160
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2161
+ async def main() -> None:
2162
+ await client.datasets.create_version_tag(version_hash='versionHash', id='id', tag='tag', )
2163
+ asyncio.run(main())
2164
+ """
2165
+ _response = await self._raw_client.create_version_tag(
2166
+ version_hash, id, tag=tag, request_options=request_options
2167
+ )
2168
+ return _response.data
2169
+
2170
+ async def list_dataset_versions(
2171
+ self,
2172
+ id: str,
2173
+ *,
2174
+ page: typing.Optional[int] = None,
2175
+ size: typing.Optional[int] = None,
2176
+ request_options: typing.Optional[RequestOptions] = None,
2177
+ ) -> DatasetVersionPagePublic:
2178
+ """
2179
+ Get paginated list of versions for a dataset, ordered by creation time (newest first)
2180
+
2181
+ Parameters
2182
+ ----------
2183
+ id : str
2184
+
2185
+ page : typing.Optional[int]
2186
+
2187
+ size : typing.Optional[int]
2188
+
2189
+ request_options : typing.Optional[RequestOptions]
2190
+ Request-specific configuration.
2191
+
2192
+ Returns
2193
+ -------
2194
+ DatasetVersionPagePublic
2195
+ Dataset versions
2196
+
2197
+ Examples
2198
+ --------
2199
+ from Opik import AsyncOpikApi
2200
+ import asyncio
2201
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2202
+ async def main() -> None:
2203
+ await client.datasets.list_dataset_versions(id='id', )
2204
+ asyncio.run(main())
2205
+ """
2206
+ _response = await self._raw_client.list_dataset_versions(
2207
+ id, page=page, size=size, request_options=request_options
2208
+ )
2209
+ return _response.data
2210
+
2211
+ async def create_dataset_version(
2212
+ self,
2213
+ id: str,
2214
+ *,
2215
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2216
+ change_description: typing.Optional[str] = OMIT,
2217
+ metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
2218
+ request_options: typing.Optional[RequestOptions] = None,
2219
+ ) -> None:
2220
+ """
2221
+ Create a new immutable version of the dataset by snapshotting the current state
2222
+
2223
+ Parameters
2224
+ ----------
2225
+ id : str
2226
+
2227
+ tags : typing.Optional[typing.Sequence[str]]
2228
+ Optional list of tags for this version
2229
+
2230
+ change_description : typing.Optional[str]
2231
+ Optional description of changes in this version
2232
+
2233
+ metadata : typing.Optional[typing.Dict[str, str]]
2234
+ Optional user-defined metadata
2235
+
2236
+ request_options : typing.Optional[RequestOptions]
2237
+ Request-specific configuration.
2238
+
2239
+ Returns
2240
+ -------
2241
+ None
2242
+
2243
+ Examples
2244
+ --------
2245
+ from Opik import AsyncOpikApi
2246
+ import asyncio
2247
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2248
+ async def main() -> None:
2249
+ await client.datasets.create_dataset_version(id='id', )
2250
+ asyncio.run(main())
2251
+ """
2252
+ _response = await self._raw_client.create_dataset_version(
2253
+ id, tags=tags, change_description=change_description, metadata=metadata, request_options=request_options
2254
+ )
2255
+ return _response.data
2256
+
2257
+ async def delete_version_tag(
2258
+ self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
2259
+ ) -> None:
2260
+ """
2261
+ Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
2262
+
2263
+ Parameters
2264
+ ----------
2265
+ version_hash : str
2266
+
2267
+ tag : str
2268
+
2269
+ id : str
2270
+
2271
+ request_options : typing.Optional[RequestOptions]
2272
+ Request-specific configuration.
2273
+
2274
+ Returns
2275
+ -------
2276
+ None
2277
+
2278
+ Examples
2279
+ --------
2280
+ from Opik import AsyncOpikApi
2281
+ import asyncio
2282
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2283
+ async def main() -> None:
2284
+ await client.datasets.delete_version_tag(version_hash='versionHash', tag='tag', id='id', )
2285
+ asyncio.run(main())
2286
+ """
2287
+ _response = await self._raw_client.delete_version_tag(version_hash, tag, id, request_options=request_options)
2288
+ return _response.data
2289
+
2290
+ async def restore_dataset_version(
2291
+ self, id: str, *, version_ref: str, request_options: typing.Optional[RequestOptions] = None
2292
+ ) -> DatasetVersionPublic:
2293
+ """
2294
+ Restores the dataset to a previous version state. All draft items are replaced with items from the specified version. If the version is not the latest, a new version snapshot is created. If the version is the latest, only draft items are replaced (revert functionality).
2295
+
2296
+ Parameters
2297
+ ----------
2298
+ id : str
2299
+
2300
+ version_ref : str
2301
+ Version hash or tag to restore from
2302
+
2303
+ request_options : typing.Optional[RequestOptions]
2304
+ Request-specific configuration.
2305
+
2306
+ Returns
2307
+ -------
2308
+ DatasetVersionPublic
2309
+ Version restored successfully
2310
+
2311
+ Examples
2312
+ --------
2313
+ from Opik import AsyncOpikApi
2314
+ import asyncio
2315
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2316
+ async def main() -> None:
2317
+ await client.datasets.restore_dataset_version(id='id', version_ref='version_ref', )
2318
+ asyncio.run(main())
2319
+ """
2320
+ _response = await self._raw_client.restore_dataset_version(
2321
+ id, version_ref=version_ref, request_options=request_options
2322
+ )
2323
+ return _response.data
2324
+
2325
+ async def update_dataset_version(
2326
+ self,
2327
+ version_hash: str,
2328
+ id: str,
2329
+ *,
2330
+ change_description: typing.Optional[str] = OMIT,
2331
+ tags_to_add: typing.Optional[typing.Sequence[str]] = OMIT,
2332
+ request_options: typing.Optional[RequestOptions] = None,
2333
+ ) -> DatasetVersionPublic:
2334
+ """
2335
+ Update a dataset version's change_description and/or add new tags
2336
+
2337
+ Parameters
2338
+ ----------
2339
+ version_hash : str
2340
+
2341
+ id : str
2342
+
2343
+ change_description : typing.Optional[str]
2344
+ Optional description of changes in this version
2345
+
2346
+ tags_to_add : typing.Optional[typing.Sequence[str]]
2347
+ Optional list of tags to add to this version
2348
+
2349
+ request_options : typing.Optional[RequestOptions]
2350
+ Request-specific configuration.
2351
+
2352
+ Returns
2353
+ -------
2354
+ DatasetVersionPublic
2355
+ Version updated successfully
2356
+
2357
+ Examples
2358
+ --------
2359
+ from Opik import AsyncOpikApi
2360
+ import asyncio
2361
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2362
+ async def main() -> None:
2363
+ await client.datasets.update_dataset_version(version_hash='versionHash', id='id', )
2364
+ asyncio.run(main())
2365
+ """
2366
+ _response = await self._raw_client.update_dataset_version(
2367
+ version_hash,
2368
+ id,
2369
+ change_description=change_description,
2370
+ tags_to_add=tags_to_add,
2371
+ request_options=request_options,
2372
+ )
2373
+ return _response.data