opik 1.9.5__py3-none-any.whl → 1.9.39__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.
- opik/__init__.py +10 -3
- opik/anonymizer/__init__.py +5 -0
- opik/anonymizer/anonymizer.py +12 -0
- opik/anonymizer/factory.py +80 -0
- opik/anonymizer/recursive_anonymizer.py +64 -0
- opik/anonymizer/rules.py +56 -0
- opik/anonymizer/rules_anonymizer.py +35 -0
- opik/api_objects/dataset/rest_operations.py +5 -0
- opik/api_objects/experiment/experiment.py +46 -49
- opik/api_objects/experiment/helpers.py +34 -10
- opik/api_objects/local_recording.py +8 -3
- opik/api_objects/opik_client.py +230 -48
- opik/api_objects/opik_query_language.py +9 -0
- opik/api_objects/prompt/__init__.py +11 -3
- opik/api_objects/prompt/base_prompt.py +69 -0
- opik/api_objects/prompt/base_prompt_template.py +29 -0
- opik/api_objects/prompt/chat/__init__.py +1 -0
- opik/api_objects/prompt/chat/chat_prompt.py +193 -0
- opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
- opik/api_objects/prompt/{chat_content_renderer_registry.py → chat/content_renderer_registry.py} +37 -35
- opik/api_objects/prompt/client.py +101 -30
- opik/api_objects/prompt/text/__init__.py +1 -0
- opik/api_objects/prompt/text/prompt.py +174 -0
- opik/api_objects/prompt/{prompt_template.py → text/prompt_template.py} +10 -6
- opik/api_objects/prompt/types.py +1 -1
- opik/cli/export.py +6 -2
- opik/cli/usage_report/charts.py +39 -10
- opik/cli/usage_report/cli.py +164 -45
- opik/cli/usage_report/pdf.py +14 -1
- opik/config.py +0 -5
- opik/decorator/base_track_decorator.py +37 -40
- opik/decorator/context_manager/span_context_manager.py +9 -0
- opik/decorator/context_manager/trace_context_manager.py +5 -0
- opik/dict_utils.py +3 -3
- opik/evaluation/__init__.py +13 -2
- opik/evaluation/engine/engine.py +195 -223
- opik/evaluation/engine/helpers.py +8 -7
- opik/evaluation/engine/metrics_evaluator.py +237 -0
- opik/evaluation/evaluation_result.py +35 -1
- opik/evaluation/evaluator.py +318 -30
- opik/evaluation/models/litellm/util.py +78 -6
- opik/evaluation/models/model_capabilities.py +33 -0
- opik/evaluation/report.py +14 -2
- opik/evaluation/rest_operations.py +36 -33
- opik/evaluation/test_case.py +2 -2
- opik/evaluation/types.py +9 -1
- opik/exceptions.py +17 -0
- opik/hooks/__init__.py +17 -1
- opik/hooks/anonymizer_hook.py +36 -0
- opik/id_helpers.py +18 -0
- opik/integrations/adk/helpers.py +16 -7
- opik/integrations/adk/legacy_opik_tracer.py +7 -4
- opik/integrations/adk/opik_tracer.py +3 -1
- opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +7 -3
- opik/integrations/adk/recursive_callback_injector.py +1 -6
- opik/integrations/dspy/callback.py +1 -4
- opik/integrations/haystack/opik_connector.py +2 -2
- opik/integrations/haystack/opik_tracer.py +2 -4
- opik/integrations/langchain/opik_tracer.py +273 -82
- opik/integrations/llama_index/callback.py +110 -108
- opik/integrations/openai/agents/opik_tracing_processor.py +1 -2
- opik/integrations/openai/opik_tracker.py +1 -1
- opik/message_processing/batching/batchers.py +11 -7
- opik/message_processing/encoder_helpers.py +79 -0
- opik/message_processing/messages.py +25 -1
- opik/message_processing/online_message_processor.py +23 -8
- opik/opik_context.py +7 -7
- opik/rest_api/__init__.py +188 -12
- opik/rest_api/client.py +3 -0
- opik/rest_api/dashboards/__init__.py +4 -0
- opik/rest_api/dashboards/client.py +462 -0
- opik/rest_api/dashboards/raw_client.py +648 -0
- opik/rest_api/datasets/client.py +893 -89
- opik/rest_api/datasets/raw_client.py +1328 -87
- opik/rest_api/experiments/client.py +30 -2
- opik/rest_api/experiments/raw_client.py +26 -0
- opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -1
- opik/rest_api/optimizations/client.py +302 -0
- opik/rest_api/optimizations/raw_client.py +463 -0
- opik/rest_api/optimizations/types/optimization_update_status.py +3 -1
- opik/rest_api/prompts/__init__.py +2 -2
- opik/rest_api/prompts/client.py +34 -4
- opik/rest_api/prompts/raw_client.py +32 -2
- opik/rest_api/prompts/types/__init__.py +3 -1
- opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
- opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
- opik/rest_api/spans/__init__.py +0 -2
- opik/rest_api/spans/client.py +148 -64
- opik/rest_api/spans/raw_client.py +210 -83
- opik/rest_api/spans/types/__init__.py +0 -2
- opik/rest_api/traces/client.py +241 -73
- opik/rest_api/traces/raw_client.py +344 -90
- opik/rest_api/types/__init__.py +200 -15
- opik/rest_api/types/aggregation_data.py +1 -0
- opik/rest_api/types/alert_trigger_config_public_type.py +6 -1
- opik/rest_api/types/alert_trigger_config_type.py +6 -1
- opik/rest_api/types/alert_trigger_config_write_type.py +6 -1
- opik/rest_api/types/automation_rule_evaluator.py +23 -1
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +2 -0
- opik/rest_api/types/{automation_rule_evaluator_object_public.py → automation_rule_evaluator_object_object_public.py} +32 -10
- opik/rest_api/types/automation_rule_evaluator_page_public.py +2 -2
- opik/rest_api/types/automation_rule_evaluator_public.py +23 -1
- opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update.py +23 -1
- opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_write.py +23 -1
- opik/rest_api/types/boolean_feedback_definition.py +25 -0
- opik/rest_api/types/boolean_feedback_definition_create.py +20 -0
- opik/rest_api/types/boolean_feedback_definition_public.py +25 -0
- opik/rest_api/types/boolean_feedback_definition_update.py +20 -0
- opik/rest_api/types/boolean_feedback_detail.py +29 -0
- opik/rest_api/types/boolean_feedback_detail_create.py +29 -0
- opik/rest_api/types/boolean_feedback_detail_public.py +29 -0
- opik/rest_api/types/boolean_feedback_detail_update.py +29 -0
- opik/rest_api/types/dashboard_page_public.py +24 -0
- opik/rest_api/types/dashboard_public.py +30 -0
- opik/rest_api/types/dataset.py +2 -0
- opik/rest_api/types/dataset_item.py +2 -0
- opik/rest_api/types/dataset_item_compare.py +2 -0
- opik/rest_api/types/dataset_item_filter.py +23 -0
- opik/rest_api/types/dataset_item_filter_operator.py +21 -0
- opik/rest_api/types/dataset_item_page_compare.py +1 -0
- opik/rest_api/types/dataset_item_page_public.py +1 -0
- opik/rest_api/types/dataset_item_public.py +2 -0
- opik/rest_api/types/dataset_item_update.py +39 -0
- opik/rest_api/types/dataset_item_write.py +1 -0
- opik/rest_api/types/dataset_public.py +2 -0
- opik/rest_api/types/dataset_public_status.py +5 -0
- opik/rest_api/types/dataset_status.py +5 -0
- opik/rest_api/types/dataset_version_diff.py +22 -0
- opik/rest_api/types/dataset_version_diff_stats.py +24 -0
- opik/rest_api/types/dataset_version_page_public.py +23 -0
- opik/rest_api/types/dataset_version_public.py +49 -0
- opik/rest_api/types/experiment.py +2 -0
- opik/rest_api/types/experiment_public.py +2 -0
- opik/rest_api/types/experiment_score.py +20 -0
- opik/rest_api/types/experiment_score_public.py +20 -0
- opik/rest_api/types/experiment_score_write.py +20 -0
- opik/rest_api/types/feedback.py +20 -1
- opik/rest_api/types/feedback_create.py +16 -1
- opik/rest_api/types/feedback_object_public.py +22 -1
- opik/rest_api/types/feedback_public.py +20 -1
- opik/rest_api/types/feedback_score_public.py +4 -0
- opik/rest_api/types/feedback_update.py +16 -1
- opik/rest_api/types/image_url.py +20 -0
- opik/rest_api/types/image_url_public.py +20 -0
- opik/rest_api/types/image_url_write.py +20 -0
- opik/rest_api/types/llm_as_judge_message.py +5 -1
- opik/rest_api/types/llm_as_judge_message_content.py +24 -0
- opik/rest_api/types/llm_as_judge_message_content_public.py +24 -0
- opik/rest_api/types/llm_as_judge_message_content_write.py +24 -0
- opik/rest_api/types/llm_as_judge_message_public.py +5 -1
- opik/rest_api/types/llm_as_judge_message_write.py +5 -1
- opik/rest_api/types/llm_as_judge_model_parameters.py +2 -0
- opik/rest_api/types/llm_as_judge_model_parameters_public.py +2 -0
- opik/rest_api/types/llm_as_judge_model_parameters_write.py +2 -0
- opik/rest_api/types/optimization.py +2 -0
- opik/rest_api/types/optimization_public.py +2 -0
- opik/rest_api/types/optimization_public_status.py +3 -1
- opik/rest_api/types/optimization_status.py +3 -1
- opik/rest_api/types/optimization_studio_config.py +27 -0
- opik/rest_api/types/optimization_studio_config_public.py +27 -0
- opik/rest_api/types/optimization_studio_config_write.py +27 -0
- opik/rest_api/types/optimization_studio_log.py +22 -0
- opik/rest_api/types/optimization_write.py +2 -0
- opik/rest_api/types/optimization_write_status.py +3 -1
- opik/rest_api/types/prompt.py +6 -0
- opik/rest_api/types/prompt_detail.py +6 -0
- opik/rest_api/types/prompt_detail_template_structure.py +5 -0
- opik/rest_api/types/prompt_public.py +6 -0
- opik/rest_api/types/prompt_public_template_structure.py +5 -0
- opik/rest_api/types/prompt_template_structure.py +5 -0
- opik/rest_api/types/prompt_version.py +2 -0
- opik/rest_api/types/prompt_version_detail.py +2 -0
- opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
- opik/rest_api/types/prompt_version_public.py +2 -0
- opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
- opik/rest_api/types/prompt_version_template_structure.py +5 -0
- opik/rest_api/types/score_name.py +1 -0
- opik/rest_api/types/service_toggles_config.py +6 -0
- opik/rest_api/types/span_enrichment_options.py +31 -0
- opik/rest_api/types/span_filter.py +23 -0
- opik/rest_api/types/span_filter_operator.py +21 -0
- opik/rest_api/types/span_filter_write.py +23 -0
- opik/rest_api/types/span_filter_write_operator.py +21 -0
- opik/rest_api/types/span_llm_as_judge_code.py +27 -0
- opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
- opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
- opik/rest_api/types/span_update.py +46 -0
- opik/rest_api/types/studio_evaluation.py +20 -0
- opik/rest_api/types/studio_evaluation_public.py +20 -0
- opik/rest_api/types/studio_evaluation_write.py +20 -0
- opik/rest_api/types/studio_llm_model.py +21 -0
- opik/rest_api/types/studio_llm_model_public.py +21 -0
- opik/rest_api/types/studio_llm_model_write.py +21 -0
- opik/rest_api/types/studio_message.py +20 -0
- opik/rest_api/types/studio_message_public.py +20 -0
- opik/rest_api/types/studio_message_write.py +20 -0
- opik/rest_api/types/studio_metric.py +21 -0
- opik/rest_api/types/studio_metric_public.py +21 -0
- opik/rest_api/types/studio_metric_write.py +21 -0
- opik/rest_api/types/studio_optimizer.py +21 -0
- opik/rest_api/types/studio_optimizer_public.py +21 -0
- opik/rest_api/types/studio_optimizer_write.py +21 -0
- opik/rest_api/types/studio_prompt.py +20 -0
- opik/rest_api/types/studio_prompt_public.py +20 -0
- opik/rest_api/types/studio_prompt_write.py +20 -0
- opik/rest_api/types/trace.py +6 -0
- opik/rest_api/types/trace_public.py +6 -0
- opik/rest_api/types/trace_thread_filter_write.py +23 -0
- opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
- opik/rest_api/types/trace_thread_update.py +19 -0
- opik/rest_api/types/trace_update.py +39 -0
- opik/rest_api/types/value_entry.py +2 -0
- opik/rest_api/types/value_entry_compare.py +2 -0
- opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +2 -0
- opik/rest_api/types/value_entry_public.py +2 -0
- opik/rest_api/types/video_url.py +19 -0
- opik/rest_api/types/video_url_public.py +19 -0
- opik/rest_api/types/video_url_write.py +19 -0
- opik/synchronization.py +5 -6
- opik/{decorator/tracing_runtime_config.py → tracing_runtime_config.py} +6 -7
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/METADATA +5 -4
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/RECORD +246 -151
- opik/api_objects/prompt/chat_prompt_template.py +0 -164
- opik/api_objects/prompt/prompt.py +0 -131
- /opik/rest_api/{spans/types → types}/span_update_type.py +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/WHEEL +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/entry_points.txt +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/licenses/LICENSE +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/top_level.txt +0 -0
opik/rest_api/datasets/client.py
CHANGED
|
@@ -5,14 +5,22 @@ import typing
|
|
|
5
5
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
6
|
from ..core.request_options import RequestOptions
|
|
7
7
|
from ..types.dataset_expansion_response import DatasetExpansionResponse
|
|
8
|
+
from ..types.dataset_item_filter import DatasetItemFilter
|
|
8
9
|
from ..types.dataset_item_page_compare import DatasetItemPageCompare
|
|
9
10
|
from ..types.dataset_item_page_public import DatasetItemPagePublic
|
|
10
11
|
from ..types.dataset_item_public import DatasetItemPublic
|
|
12
|
+
from ..types.dataset_item_update import DatasetItemUpdate
|
|
11
13
|
from ..types.dataset_item_write import DatasetItemWrite
|
|
14
|
+
from ..types.dataset_item_write_source import DatasetItemWriteSource
|
|
12
15
|
from ..types.dataset_page_public import DatasetPagePublic
|
|
13
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
|
|
20
|
+
from ..types.json_node import JsonNode
|
|
14
21
|
from ..types.page_columns import PageColumns
|
|
15
22
|
from ..types.project_stats_public import ProjectStatsPublic
|
|
23
|
+
from ..types.span_enrichment_options import SpanEnrichmentOptions
|
|
16
24
|
from ..types.trace_enrichment_options import TraceEnrichmentOptions
|
|
17
25
|
from .raw_client import AsyncRawDatasetsClient, RawDatasetsClient
|
|
18
26
|
from .types.dataset_update_visibility import DatasetUpdateVisibility
|
|
@@ -37,6 +45,49 @@ class DatasetsClient:
|
|
|
37
45
|
"""
|
|
38
46
|
return self._raw_client
|
|
39
47
|
|
|
48
|
+
def batch_update_dataset_items(
|
|
49
|
+
self,
|
|
50
|
+
*,
|
|
51
|
+
update: DatasetItemUpdate,
|
|
52
|
+
ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
53
|
+
filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
|
|
54
|
+
merge_tags: typing.Optional[bool] = OMIT,
|
|
55
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
56
|
+
) -> None:
|
|
57
|
+
"""
|
|
58
|
+
Update multiple dataset items
|
|
59
|
+
|
|
60
|
+
Parameters
|
|
61
|
+
----------
|
|
62
|
+
update : DatasetItemUpdate
|
|
63
|
+
|
|
64
|
+
ids : typing.Optional[typing.Sequence[str]]
|
|
65
|
+
List of dataset item IDs to update (max 1000). Mutually exclusive with 'filters'.
|
|
66
|
+
|
|
67
|
+
filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
|
|
68
|
+
|
|
69
|
+
merge_tags : typing.Optional[bool]
|
|
70
|
+
If true, merge tags with existing tags instead of replacing them. Default: false. When using 'filters', this is automatically set to true.
|
|
71
|
+
|
|
72
|
+
request_options : typing.Optional[RequestOptions]
|
|
73
|
+
Request-specific configuration.
|
|
74
|
+
|
|
75
|
+
Returns
|
|
76
|
+
-------
|
|
77
|
+
None
|
|
78
|
+
|
|
79
|
+
Examples
|
|
80
|
+
--------
|
|
81
|
+
from Opik import OpikApi
|
|
82
|
+
from Opik import DatasetItemUpdate
|
|
83
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
84
|
+
client.datasets.batch_update_dataset_items(update=DatasetItemUpdate(), )
|
|
85
|
+
"""
|
|
86
|
+
_response = self._raw_client.batch_update_dataset_items(
|
|
87
|
+
update=update, ids=ids, filters=filters, merge_tags=merge_tags, request_options=request_options
|
|
88
|
+
)
|
|
89
|
+
return _response.data
|
|
90
|
+
|
|
40
91
|
def find_datasets(
|
|
41
92
|
self,
|
|
42
93
|
*,
|
|
@@ -182,6 +233,80 @@ class DatasetsClient:
|
|
|
182
233
|
)
|
|
183
234
|
return _response.data
|
|
184
235
|
|
|
236
|
+
def create_dataset_items_from_csv(
|
|
237
|
+
self,
|
|
238
|
+
*,
|
|
239
|
+
file: typing.Dict[str, typing.Optional[typing.Any]],
|
|
240
|
+
dataset_id: str,
|
|
241
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
242
|
+
) -> None:
|
|
243
|
+
"""
|
|
244
|
+
Create dataset items from uploaded CSV file. CSV should have headers in the first row. Processing happens asynchronously in batches.
|
|
245
|
+
|
|
246
|
+
Parameters
|
|
247
|
+
----------
|
|
248
|
+
file : typing.Dict[str, typing.Optional[typing.Any]]
|
|
249
|
+
|
|
250
|
+
dataset_id : str
|
|
251
|
+
|
|
252
|
+
request_options : typing.Optional[RequestOptions]
|
|
253
|
+
Request-specific configuration.
|
|
254
|
+
|
|
255
|
+
Returns
|
|
256
|
+
-------
|
|
257
|
+
None
|
|
258
|
+
|
|
259
|
+
Examples
|
|
260
|
+
--------
|
|
261
|
+
from Opik import OpikApi
|
|
262
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
263
|
+
client.datasets.create_dataset_items_from_csv(file={'key': 'value'
|
|
264
|
+
}, dataset_id='dataset_id', )
|
|
265
|
+
"""
|
|
266
|
+
_response = self._raw_client.create_dataset_items_from_csv(
|
|
267
|
+
file=file, dataset_id=dataset_id, request_options=request_options
|
|
268
|
+
)
|
|
269
|
+
return _response.data
|
|
270
|
+
|
|
271
|
+
def create_dataset_items_from_spans(
|
|
272
|
+
self,
|
|
273
|
+
dataset_id: str,
|
|
274
|
+
*,
|
|
275
|
+
span_ids: typing.Sequence[str],
|
|
276
|
+
enrichment_options: SpanEnrichmentOptions,
|
|
277
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
278
|
+
) -> None:
|
|
279
|
+
"""
|
|
280
|
+
Create dataset items from spans with enriched metadata
|
|
281
|
+
|
|
282
|
+
Parameters
|
|
283
|
+
----------
|
|
284
|
+
dataset_id : str
|
|
285
|
+
|
|
286
|
+
span_ids : typing.Sequence[str]
|
|
287
|
+
Set of span IDs to add to the dataset
|
|
288
|
+
|
|
289
|
+
enrichment_options : SpanEnrichmentOptions
|
|
290
|
+
|
|
291
|
+
request_options : typing.Optional[RequestOptions]
|
|
292
|
+
Request-specific configuration.
|
|
293
|
+
|
|
294
|
+
Returns
|
|
295
|
+
-------
|
|
296
|
+
None
|
|
297
|
+
|
|
298
|
+
Examples
|
|
299
|
+
--------
|
|
300
|
+
from Opik import OpikApi
|
|
301
|
+
from Opik import SpanEnrichmentOptions
|
|
302
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
303
|
+
client.datasets.create_dataset_items_from_spans(dataset_id='dataset_id', span_ids=['span_ids'], enrichment_options=SpanEnrichmentOptions(), )
|
|
304
|
+
"""
|
|
305
|
+
_response = self._raw_client.create_dataset_items_from_spans(
|
|
306
|
+
dataset_id, span_ids=span_ids, enrichment_options=enrichment_options, request_options=request_options
|
|
307
|
+
)
|
|
308
|
+
return _response.data
|
|
309
|
+
|
|
185
310
|
def create_dataset_items_from_traces(
|
|
186
311
|
self,
|
|
187
312
|
dataset_id: str,
|
|
@@ -604,12 +729,70 @@ class DatasetsClient:
|
|
|
604
729
|
_response = self._raw_client.get_dataset_item_by_id(item_id, request_options=request_options)
|
|
605
730
|
return _response.data
|
|
606
731
|
|
|
732
|
+
def patch_dataset_item(
|
|
733
|
+
self,
|
|
734
|
+
item_id: str,
|
|
735
|
+
*,
|
|
736
|
+
source: DatasetItemWriteSource,
|
|
737
|
+
data: JsonNode,
|
|
738
|
+
id: typing.Optional[str] = OMIT,
|
|
739
|
+
trace_id: typing.Optional[str] = OMIT,
|
|
740
|
+
span_id: typing.Optional[str] = OMIT,
|
|
741
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
742
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
743
|
+
) -> None:
|
|
744
|
+
"""
|
|
745
|
+
Partially update dataset item by id. Only provided fields will be updated.
|
|
746
|
+
|
|
747
|
+
Parameters
|
|
748
|
+
----------
|
|
749
|
+
item_id : str
|
|
750
|
+
|
|
751
|
+
source : DatasetItemWriteSource
|
|
752
|
+
|
|
753
|
+
data : JsonNode
|
|
754
|
+
|
|
755
|
+
id : typing.Optional[str]
|
|
756
|
+
|
|
757
|
+
trace_id : typing.Optional[str]
|
|
758
|
+
|
|
759
|
+
span_id : typing.Optional[str]
|
|
760
|
+
|
|
761
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
762
|
+
|
|
763
|
+
request_options : typing.Optional[RequestOptions]
|
|
764
|
+
Request-specific configuration.
|
|
765
|
+
|
|
766
|
+
Returns
|
|
767
|
+
-------
|
|
768
|
+
None
|
|
769
|
+
|
|
770
|
+
Examples
|
|
771
|
+
--------
|
|
772
|
+
from Opik import OpikApi
|
|
773
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
774
|
+
client.datasets.patch_dataset_item(item_id='itemId', source="manual", data={'key': 'value'
|
|
775
|
+
}, )
|
|
776
|
+
"""
|
|
777
|
+
_response = self._raw_client.patch_dataset_item(
|
|
778
|
+
item_id,
|
|
779
|
+
source=source,
|
|
780
|
+
data=data,
|
|
781
|
+
id=id,
|
|
782
|
+
trace_id=trace_id,
|
|
783
|
+
span_id=span_id,
|
|
784
|
+
tags=tags,
|
|
785
|
+
request_options=request_options,
|
|
786
|
+
)
|
|
787
|
+
return _response.data
|
|
788
|
+
|
|
607
789
|
def get_dataset_items(
|
|
608
790
|
self,
|
|
609
791
|
id: str,
|
|
610
792
|
*,
|
|
611
793
|
page: typing.Optional[int] = None,
|
|
612
794
|
size: typing.Optional[int] = None,
|
|
795
|
+
version: typing.Optional[str] = None,
|
|
613
796
|
filters: typing.Optional[str] = None,
|
|
614
797
|
truncate: typing.Optional[bool] = None,
|
|
615
798
|
request_options: typing.Optional[RequestOptions] = None,
|
|
@@ -625,6 +808,8 @@ class DatasetsClient:
|
|
|
625
808
|
|
|
626
809
|
size : typing.Optional[int]
|
|
627
810
|
|
|
811
|
+
version : typing.Optional[str]
|
|
812
|
+
|
|
628
813
|
filters : typing.Optional[str]
|
|
629
814
|
|
|
630
815
|
truncate : typing.Optional[bool]
|
|
@@ -644,7 +829,13 @@ class DatasetsClient:
|
|
|
644
829
|
client.datasets.get_dataset_items(id='id', )
|
|
645
830
|
"""
|
|
646
831
|
_response = self._raw_client.get_dataset_items(
|
|
647
|
-
id,
|
|
832
|
+
id,
|
|
833
|
+
page=page,
|
|
834
|
+
size=size,
|
|
835
|
+
version=version,
|
|
836
|
+
filters=filters,
|
|
837
|
+
truncate=truncate,
|
|
838
|
+
request_options=request_options,
|
|
648
839
|
)
|
|
649
840
|
return _response.data
|
|
650
841
|
|
|
@@ -718,110 +909,123 @@ class DatasetsClient:
|
|
|
718
909
|
) as r:
|
|
719
910
|
yield from r.data
|
|
720
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.
|
|
721
917
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
918
|
+
Parameters
|
|
919
|
+
----------
|
|
920
|
+
id : str
|
|
725
921
|
|
|
726
|
-
|
|
727
|
-
|
|
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', )
|
|
728
935
|
"""
|
|
729
|
-
|
|
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.
|
|
730
955
|
|
|
731
956
|
Returns
|
|
732
957
|
-------
|
|
733
|
-
|
|
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', )
|
|
734
965
|
"""
|
|
735
|
-
|
|
966
|
+
_response = self._raw_client.create_version_tag(version_hash, id, tag=tag, request_options=request_options)
|
|
967
|
+
return _response.data
|
|
736
968
|
|
|
737
|
-
|
|
969
|
+
def list_dataset_versions(
|
|
738
970
|
self,
|
|
971
|
+
id: str,
|
|
739
972
|
*,
|
|
740
973
|
page: typing.Optional[int] = None,
|
|
741
974
|
size: typing.Optional[int] = None,
|
|
742
|
-
with_experiments_only: typing.Optional[bool] = None,
|
|
743
|
-
with_optimizations_only: typing.Optional[bool] = None,
|
|
744
|
-
prompt_id: typing.Optional[str] = None,
|
|
745
|
-
name: typing.Optional[str] = None,
|
|
746
|
-
sorting: typing.Optional[str] = None,
|
|
747
|
-
filters: typing.Optional[str] = None,
|
|
748
975
|
request_options: typing.Optional[RequestOptions] = None,
|
|
749
|
-
) ->
|
|
976
|
+
) -> DatasetVersionPagePublic:
|
|
750
977
|
"""
|
|
751
|
-
|
|
978
|
+
Get paginated list of versions for a dataset, ordered by creation time (newest first)
|
|
752
979
|
|
|
753
980
|
Parameters
|
|
754
981
|
----------
|
|
982
|
+
id : str
|
|
983
|
+
|
|
755
984
|
page : typing.Optional[int]
|
|
756
985
|
|
|
757
986
|
size : typing.Optional[int]
|
|
758
987
|
|
|
759
|
-
with_experiments_only : typing.Optional[bool]
|
|
760
|
-
|
|
761
|
-
with_optimizations_only : typing.Optional[bool]
|
|
762
|
-
|
|
763
|
-
prompt_id : typing.Optional[str]
|
|
764
|
-
|
|
765
|
-
name : typing.Optional[str]
|
|
766
|
-
|
|
767
|
-
sorting : typing.Optional[str]
|
|
768
|
-
|
|
769
|
-
filters : typing.Optional[str]
|
|
770
|
-
|
|
771
988
|
request_options : typing.Optional[RequestOptions]
|
|
772
989
|
Request-specific configuration.
|
|
773
990
|
|
|
774
991
|
Returns
|
|
775
992
|
-------
|
|
776
|
-
|
|
777
|
-
Dataset
|
|
993
|
+
DatasetVersionPagePublic
|
|
994
|
+
Dataset versions
|
|
778
995
|
|
|
779
996
|
Examples
|
|
780
997
|
--------
|
|
781
|
-
from Opik import
|
|
782
|
-
|
|
783
|
-
client
|
|
784
|
-
async def main() -> None:
|
|
785
|
-
await client.datasets.find_datasets()
|
|
786
|
-
asyncio.run(main())
|
|
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', )
|
|
787
1001
|
"""
|
|
788
|
-
_response =
|
|
789
|
-
page=page,
|
|
790
|
-
size=size,
|
|
791
|
-
with_experiments_only=with_experiments_only,
|
|
792
|
-
with_optimizations_only=with_optimizations_only,
|
|
793
|
-
prompt_id=prompt_id,
|
|
794
|
-
name=name,
|
|
795
|
-
sorting=sorting,
|
|
796
|
-
filters=filters,
|
|
797
|
-
request_options=request_options,
|
|
798
|
-
)
|
|
1002
|
+
_response = self._raw_client.list_dataset_versions(id, page=page, size=size, request_options=request_options)
|
|
799
1003
|
return _response.data
|
|
800
1004
|
|
|
801
|
-
|
|
1005
|
+
def create_dataset_version(
|
|
802
1006
|
self,
|
|
1007
|
+
id: str,
|
|
803
1008
|
*,
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
808
|
-
description: typing.Optional[str] = OMIT,
|
|
1009
|
+
tag: typing.Optional[str] = OMIT,
|
|
1010
|
+
change_description: typing.Optional[str] = OMIT,
|
|
1011
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
809
1012
|
request_options: typing.Optional[RequestOptions] = None,
|
|
810
1013
|
) -> None:
|
|
811
1014
|
"""
|
|
812
|
-
Create dataset
|
|
1015
|
+
Create a new immutable version of the dataset by snapshotting the current state
|
|
813
1016
|
|
|
814
1017
|
Parameters
|
|
815
1018
|
----------
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
id : typing.Optional[str]
|
|
1019
|
+
id : str
|
|
819
1020
|
|
|
820
|
-
|
|
1021
|
+
tag : typing.Optional[str]
|
|
1022
|
+
Optional tag for this version
|
|
821
1023
|
|
|
822
|
-
|
|
1024
|
+
change_description : typing.Optional[str]
|
|
1025
|
+
Optional description of changes in this version
|
|
823
1026
|
|
|
824
|
-
|
|
1027
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
1028
|
+
Optional user-defined metadata
|
|
825
1029
|
|
|
826
1030
|
request_options : typing.Optional[RequestOptions]
|
|
827
1031
|
Request-specific configuration.
|
|
@@ -832,38 +1036,28 @@ class AsyncDatasetsClient:
|
|
|
832
1036
|
|
|
833
1037
|
Examples
|
|
834
1038
|
--------
|
|
835
|
-
from Opik import
|
|
836
|
-
|
|
837
|
-
client
|
|
838
|
-
async def main() -> None:
|
|
839
|
-
await client.datasets.create_dataset(name='name', )
|
|
840
|
-
asyncio.run(main())
|
|
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', )
|
|
841
1042
|
"""
|
|
842
|
-
_response =
|
|
843
|
-
|
|
1043
|
+
_response = self._raw_client.create_dataset_version(
|
|
1044
|
+
id, tag=tag, change_description=change_description, metadata=metadata, request_options=request_options
|
|
844
1045
|
)
|
|
845
1046
|
return _response.data
|
|
846
1047
|
|
|
847
|
-
|
|
848
|
-
self,
|
|
849
|
-
*,
|
|
850
|
-
items: typing.Sequence[DatasetItemWrite],
|
|
851
|
-
dataset_name: typing.Optional[str] = OMIT,
|
|
852
|
-
dataset_id: typing.Optional[str] = OMIT,
|
|
853
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1048
|
+
def delete_version_tag(
|
|
1049
|
+
self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
854
1050
|
) -> None:
|
|
855
1051
|
"""
|
|
856
|
-
|
|
1052
|
+
Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
|
|
857
1053
|
|
|
858
1054
|
Parameters
|
|
859
1055
|
----------
|
|
860
|
-
|
|
1056
|
+
version_hash : str
|
|
861
1057
|
|
|
862
|
-
|
|
863
|
-
If null, dataset_id must be provided
|
|
1058
|
+
tag : str
|
|
864
1059
|
|
|
865
|
-
|
|
866
|
-
If null, dataset_name must be provided
|
|
1060
|
+
id : str
|
|
867
1061
|
|
|
868
1062
|
request_options : typing.Optional[RequestOptions]
|
|
869
1063
|
Request-specific configuration.
|
|
@@ -874,11 +1068,252 @@ class AsyncDatasetsClient:
|
|
|
874
1068
|
|
|
875
1069
|
Examples
|
|
876
1070
|
--------
|
|
877
|
-
from Opik import
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
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
|
+
|
|
1111
|
+
class AsyncDatasetsClient:
|
|
1112
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
1113
|
+
self._raw_client = AsyncRawDatasetsClient(client_wrapper=client_wrapper)
|
|
1114
|
+
|
|
1115
|
+
@property
|
|
1116
|
+
def with_raw_response(self) -> AsyncRawDatasetsClient:
|
|
1117
|
+
"""
|
|
1118
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
1119
|
+
|
|
1120
|
+
Returns
|
|
1121
|
+
-------
|
|
1122
|
+
AsyncRawDatasetsClient
|
|
1123
|
+
"""
|
|
1124
|
+
return self._raw_client
|
|
1125
|
+
|
|
1126
|
+
async def batch_update_dataset_items(
|
|
1127
|
+
self,
|
|
1128
|
+
*,
|
|
1129
|
+
update: DatasetItemUpdate,
|
|
1130
|
+
ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1131
|
+
filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
|
|
1132
|
+
merge_tags: typing.Optional[bool] = OMIT,
|
|
1133
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1134
|
+
) -> None:
|
|
1135
|
+
"""
|
|
1136
|
+
Update multiple dataset items
|
|
1137
|
+
|
|
1138
|
+
Parameters
|
|
1139
|
+
----------
|
|
1140
|
+
update : DatasetItemUpdate
|
|
1141
|
+
|
|
1142
|
+
ids : typing.Optional[typing.Sequence[str]]
|
|
1143
|
+
List of dataset item IDs to update (max 1000). Mutually exclusive with 'filters'.
|
|
1144
|
+
|
|
1145
|
+
filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
|
|
1146
|
+
|
|
1147
|
+
merge_tags : typing.Optional[bool]
|
|
1148
|
+
If true, merge tags with existing tags instead of replacing them. Default: false. When using 'filters', this is automatically set to true.
|
|
1149
|
+
|
|
1150
|
+
request_options : typing.Optional[RequestOptions]
|
|
1151
|
+
Request-specific configuration.
|
|
1152
|
+
|
|
1153
|
+
Returns
|
|
1154
|
+
-------
|
|
1155
|
+
None
|
|
1156
|
+
|
|
1157
|
+
Examples
|
|
1158
|
+
--------
|
|
1159
|
+
from Opik import AsyncOpikApi
|
|
1160
|
+
from Opik import DatasetItemUpdate
|
|
1161
|
+
import asyncio
|
|
1162
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1163
|
+
async def main() -> None:
|
|
1164
|
+
await client.datasets.batch_update_dataset_items(update=DatasetItemUpdate(), )
|
|
1165
|
+
asyncio.run(main())
|
|
1166
|
+
"""
|
|
1167
|
+
_response = await self._raw_client.batch_update_dataset_items(
|
|
1168
|
+
update=update, ids=ids, filters=filters, merge_tags=merge_tags, request_options=request_options
|
|
1169
|
+
)
|
|
1170
|
+
return _response.data
|
|
1171
|
+
|
|
1172
|
+
async def find_datasets(
|
|
1173
|
+
self,
|
|
1174
|
+
*,
|
|
1175
|
+
page: typing.Optional[int] = None,
|
|
1176
|
+
size: typing.Optional[int] = None,
|
|
1177
|
+
with_experiments_only: typing.Optional[bool] = None,
|
|
1178
|
+
with_optimizations_only: typing.Optional[bool] = None,
|
|
1179
|
+
prompt_id: typing.Optional[str] = None,
|
|
1180
|
+
name: typing.Optional[str] = None,
|
|
1181
|
+
sorting: typing.Optional[str] = None,
|
|
1182
|
+
filters: typing.Optional[str] = None,
|
|
1183
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1184
|
+
) -> DatasetPagePublic:
|
|
1185
|
+
"""
|
|
1186
|
+
Find datasets
|
|
1187
|
+
|
|
1188
|
+
Parameters
|
|
1189
|
+
----------
|
|
1190
|
+
page : typing.Optional[int]
|
|
1191
|
+
|
|
1192
|
+
size : typing.Optional[int]
|
|
1193
|
+
|
|
1194
|
+
with_experiments_only : typing.Optional[bool]
|
|
1195
|
+
|
|
1196
|
+
with_optimizations_only : typing.Optional[bool]
|
|
1197
|
+
|
|
1198
|
+
prompt_id : typing.Optional[str]
|
|
1199
|
+
|
|
1200
|
+
name : typing.Optional[str]
|
|
1201
|
+
|
|
1202
|
+
sorting : typing.Optional[str]
|
|
1203
|
+
|
|
1204
|
+
filters : typing.Optional[str]
|
|
1205
|
+
|
|
1206
|
+
request_options : typing.Optional[RequestOptions]
|
|
1207
|
+
Request-specific configuration.
|
|
1208
|
+
|
|
1209
|
+
Returns
|
|
1210
|
+
-------
|
|
1211
|
+
DatasetPagePublic
|
|
1212
|
+
Dataset resource
|
|
1213
|
+
|
|
1214
|
+
Examples
|
|
1215
|
+
--------
|
|
1216
|
+
from Opik import AsyncOpikApi
|
|
1217
|
+
import asyncio
|
|
1218
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1219
|
+
async def main() -> None:
|
|
1220
|
+
await client.datasets.find_datasets()
|
|
1221
|
+
asyncio.run(main())
|
|
1222
|
+
"""
|
|
1223
|
+
_response = await self._raw_client.find_datasets(
|
|
1224
|
+
page=page,
|
|
1225
|
+
size=size,
|
|
1226
|
+
with_experiments_only=with_experiments_only,
|
|
1227
|
+
with_optimizations_only=with_optimizations_only,
|
|
1228
|
+
prompt_id=prompt_id,
|
|
1229
|
+
name=name,
|
|
1230
|
+
sorting=sorting,
|
|
1231
|
+
filters=filters,
|
|
1232
|
+
request_options=request_options,
|
|
1233
|
+
)
|
|
1234
|
+
return _response.data
|
|
1235
|
+
|
|
1236
|
+
async def create_dataset(
|
|
1237
|
+
self,
|
|
1238
|
+
*,
|
|
1239
|
+
name: str,
|
|
1240
|
+
id: typing.Optional[str] = OMIT,
|
|
1241
|
+
visibility: typing.Optional[DatasetWriteVisibility] = OMIT,
|
|
1242
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1243
|
+
description: typing.Optional[str] = OMIT,
|
|
1244
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1245
|
+
) -> None:
|
|
1246
|
+
"""
|
|
1247
|
+
Create dataset
|
|
1248
|
+
|
|
1249
|
+
Parameters
|
|
1250
|
+
----------
|
|
1251
|
+
name : str
|
|
1252
|
+
|
|
1253
|
+
id : typing.Optional[str]
|
|
1254
|
+
|
|
1255
|
+
visibility : typing.Optional[DatasetWriteVisibility]
|
|
1256
|
+
|
|
1257
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
1258
|
+
|
|
1259
|
+
description : typing.Optional[str]
|
|
1260
|
+
|
|
1261
|
+
request_options : typing.Optional[RequestOptions]
|
|
1262
|
+
Request-specific configuration.
|
|
1263
|
+
|
|
1264
|
+
Returns
|
|
1265
|
+
-------
|
|
1266
|
+
None
|
|
1267
|
+
|
|
1268
|
+
Examples
|
|
1269
|
+
--------
|
|
1270
|
+
from Opik import AsyncOpikApi
|
|
1271
|
+
import asyncio
|
|
1272
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1273
|
+
async def main() -> None:
|
|
1274
|
+
await client.datasets.create_dataset(name='name', )
|
|
1275
|
+
asyncio.run(main())
|
|
1276
|
+
"""
|
|
1277
|
+
_response = await self._raw_client.create_dataset(
|
|
1278
|
+
name=name, id=id, visibility=visibility, tags=tags, description=description, request_options=request_options
|
|
1279
|
+
)
|
|
1280
|
+
return _response.data
|
|
1281
|
+
|
|
1282
|
+
async def create_or_update_dataset_items(
|
|
1283
|
+
self,
|
|
1284
|
+
*,
|
|
1285
|
+
items: typing.Sequence[DatasetItemWrite],
|
|
1286
|
+
dataset_name: typing.Optional[str] = OMIT,
|
|
1287
|
+
dataset_id: typing.Optional[str] = OMIT,
|
|
1288
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1289
|
+
) -> None:
|
|
1290
|
+
"""
|
|
1291
|
+
Create/update dataset items based on dataset item id
|
|
1292
|
+
|
|
1293
|
+
Parameters
|
|
1294
|
+
----------
|
|
1295
|
+
items : typing.Sequence[DatasetItemWrite]
|
|
1296
|
+
|
|
1297
|
+
dataset_name : typing.Optional[str]
|
|
1298
|
+
If null, dataset_id must be provided
|
|
1299
|
+
|
|
1300
|
+
dataset_id : typing.Optional[str]
|
|
1301
|
+
If null, dataset_name must be provided
|
|
1302
|
+
|
|
1303
|
+
request_options : typing.Optional[RequestOptions]
|
|
1304
|
+
Request-specific configuration.
|
|
1305
|
+
|
|
1306
|
+
Returns
|
|
1307
|
+
-------
|
|
1308
|
+
None
|
|
1309
|
+
|
|
1310
|
+
Examples
|
|
1311
|
+
--------
|
|
1312
|
+
from Opik import AsyncOpikApi
|
|
1313
|
+
from Opik import DatasetItemWrite
|
|
1314
|
+
import asyncio
|
|
1315
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1316
|
+
async def main() -> None:
|
|
882
1317
|
await client.datasets.create_or_update_dataset_items(items=[DatasetItemWrite(source="manual", data={'key': 'value'
|
|
883
1318
|
}, )], )
|
|
884
1319
|
asyncio.run(main())
|
|
@@ -888,6 +1323,86 @@ class AsyncDatasetsClient:
|
|
|
888
1323
|
)
|
|
889
1324
|
return _response.data
|
|
890
1325
|
|
|
1326
|
+
async def create_dataset_items_from_csv(
|
|
1327
|
+
self,
|
|
1328
|
+
*,
|
|
1329
|
+
file: typing.Dict[str, typing.Optional[typing.Any]],
|
|
1330
|
+
dataset_id: str,
|
|
1331
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1332
|
+
) -> None:
|
|
1333
|
+
"""
|
|
1334
|
+
Create dataset items from uploaded CSV file. CSV should have headers in the first row. Processing happens asynchronously in batches.
|
|
1335
|
+
|
|
1336
|
+
Parameters
|
|
1337
|
+
----------
|
|
1338
|
+
file : typing.Dict[str, typing.Optional[typing.Any]]
|
|
1339
|
+
|
|
1340
|
+
dataset_id : str
|
|
1341
|
+
|
|
1342
|
+
request_options : typing.Optional[RequestOptions]
|
|
1343
|
+
Request-specific configuration.
|
|
1344
|
+
|
|
1345
|
+
Returns
|
|
1346
|
+
-------
|
|
1347
|
+
None
|
|
1348
|
+
|
|
1349
|
+
Examples
|
|
1350
|
+
--------
|
|
1351
|
+
from Opik import AsyncOpikApi
|
|
1352
|
+
import asyncio
|
|
1353
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1354
|
+
async def main() -> None:
|
|
1355
|
+
await client.datasets.create_dataset_items_from_csv(file={'key': 'value'
|
|
1356
|
+
}, dataset_id='dataset_id', )
|
|
1357
|
+
asyncio.run(main())
|
|
1358
|
+
"""
|
|
1359
|
+
_response = await self._raw_client.create_dataset_items_from_csv(
|
|
1360
|
+
file=file, dataset_id=dataset_id, request_options=request_options
|
|
1361
|
+
)
|
|
1362
|
+
return _response.data
|
|
1363
|
+
|
|
1364
|
+
async def create_dataset_items_from_spans(
|
|
1365
|
+
self,
|
|
1366
|
+
dataset_id: str,
|
|
1367
|
+
*,
|
|
1368
|
+
span_ids: typing.Sequence[str],
|
|
1369
|
+
enrichment_options: SpanEnrichmentOptions,
|
|
1370
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1371
|
+
) -> None:
|
|
1372
|
+
"""
|
|
1373
|
+
Create dataset items from spans with enriched metadata
|
|
1374
|
+
|
|
1375
|
+
Parameters
|
|
1376
|
+
----------
|
|
1377
|
+
dataset_id : str
|
|
1378
|
+
|
|
1379
|
+
span_ids : typing.Sequence[str]
|
|
1380
|
+
Set of span IDs to add to the dataset
|
|
1381
|
+
|
|
1382
|
+
enrichment_options : SpanEnrichmentOptions
|
|
1383
|
+
|
|
1384
|
+
request_options : typing.Optional[RequestOptions]
|
|
1385
|
+
Request-specific configuration.
|
|
1386
|
+
|
|
1387
|
+
Returns
|
|
1388
|
+
-------
|
|
1389
|
+
None
|
|
1390
|
+
|
|
1391
|
+
Examples
|
|
1392
|
+
--------
|
|
1393
|
+
from Opik import AsyncOpikApi
|
|
1394
|
+
from Opik import SpanEnrichmentOptions
|
|
1395
|
+
import asyncio
|
|
1396
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1397
|
+
async def main() -> None:
|
|
1398
|
+
await client.datasets.create_dataset_items_from_spans(dataset_id='dataset_id', span_ids=['span_ids'], enrichment_options=SpanEnrichmentOptions(), )
|
|
1399
|
+
asyncio.run(main())
|
|
1400
|
+
"""
|
|
1401
|
+
_response = await self._raw_client.create_dataset_items_from_spans(
|
|
1402
|
+
dataset_id, span_ids=span_ids, enrichment_options=enrichment_options, request_options=request_options
|
|
1403
|
+
)
|
|
1404
|
+
return _response.data
|
|
1405
|
+
|
|
891
1406
|
async def create_dataset_items_from_traces(
|
|
892
1407
|
self,
|
|
893
1408
|
dataset_id: str,
|
|
@@ -1350,12 +1865,73 @@ class AsyncDatasetsClient:
|
|
|
1350
1865
|
_response = await self._raw_client.get_dataset_item_by_id(item_id, request_options=request_options)
|
|
1351
1866
|
return _response.data
|
|
1352
1867
|
|
|
1868
|
+
async def patch_dataset_item(
|
|
1869
|
+
self,
|
|
1870
|
+
item_id: str,
|
|
1871
|
+
*,
|
|
1872
|
+
source: DatasetItemWriteSource,
|
|
1873
|
+
data: JsonNode,
|
|
1874
|
+
id: typing.Optional[str] = OMIT,
|
|
1875
|
+
trace_id: typing.Optional[str] = OMIT,
|
|
1876
|
+
span_id: typing.Optional[str] = OMIT,
|
|
1877
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1878
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1879
|
+
) -> None:
|
|
1880
|
+
"""
|
|
1881
|
+
Partially update dataset item by id. Only provided fields will be updated.
|
|
1882
|
+
|
|
1883
|
+
Parameters
|
|
1884
|
+
----------
|
|
1885
|
+
item_id : str
|
|
1886
|
+
|
|
1887
|
+
source : DatasetItemWriteSource
|
|
1888
|
+
|
|
1889
|
+
data : JsonNode
|
|
1890
|
+
|
|
1891
|
+
id : typing.Optional[str]
|
|
1892
|
+
|
|
1893
|
+
trace_id : typing.Optional[str]
|
|
1894
|
+
|
|
1895
|
+
span_id : typing.Optional[str]
|
|
1896
|
+
|
|
1897
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
1898
|
+
|
|
1899
|
+
request_options : typing.Optional[RequestOptions]
|
|
1900
|
+
Request-specific configuration.
|
|
1901
|
+
|
|
1902
|
+
Returns
|
|
1903
|
+
-------
|
|
1904
|
+
None
|
|
1905
|
+
|
|
1906
|
+
Examples
|
|
1907
|
+
--------
|
|
1908
|
+
from Opik import AsyncOpikApi
|
|
1909
|
+
import asyncio
|
|
1910
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1911
|
+
async def main() -> None:
|
|
1912
|
+
await client.datasets.patch_dataset_item(item_id='itemId', source="manual", data={'key': 'value'
|
|
1913
|
+
}, )
|
|
1914
|
+
asyncio.run(main())
|
|
1915
|
+
"""
|
|
1916
|
+
_response = await self._raw_client.patch_dataset_item(
|
|
1917
|
+
item_id,
|
|
1918
|
+
source=source,
|
|
1919
|
+
data=data,
|
|
1920
|
+
id=id,
|
|
1921
|
+
trace_id=trace_id,
|
|
1922
|
+
span_id=span_id,
|
|
1923
|
+
tags=tags,
|
|
1924
|
+
request_options=request_options,
|
|
1925
|
+
)
|
|
1926
|
+
return _response.data
|
|
1927
|
+
|
|
1353
1928
|
async def get_dataset_items(
|
|
1354
1929
|
self,
|
|
1355
1930
|
id: str,
|
|
1356
1931
|
*,
|
|
1357
1932
|
page: typing.Optional[int] = None,
|
|
1358
1933
|
size: typing.Optional[int] = None,
|
|
1934
|
+
version: typing.Optional[str] = None,
|
|
1359
1935
|
filters: typing.Optional[str] = None,
|
|
1360
1936
|
truncate: typing.Optional[bool] = None,
|
|
1361
1937
|
request_options: typing.Optional[RequestOptions] = None,
|
|
@@ -1371,6 +1947,8 @@ class AsyncDatasetsClient:
|
|
|
1371
1947
|
|
|
1372
1948
|
size : typing.Optional[int]
|
|
1373
1949
|
|
|
1950
|
+
version : typing.Optional[str]
|
|
1951
|
+
|
|
1374
1952
|
filters : typing.Optional[str]
|
|
1375
1953
|
|
|
1376
1954
|
truncate : typing.Optional[bool]
|
|
@@ -1393,7 +1971,13 @@ class AsyncDatasetsClient:
|
|
|
1393
1971
|
asyncio.run(main())
|
|
1394
1972
|
"""
|
|
1395
1973
|
_response = await self._raw_client.get_dataset_items(
|
|
1396
|
-
id,
|
|
1974
|
+
id,
|
|
1975
|
+
page=page,
|
|
1976
|
+
size=size,
|
|
1977
|
+
version=version,
|
|
1978
|
+
filters=filters,
|
|
1979
|
+
truncate=truncate,
|
|
1980
|
+
request_options=request_options,
|
|
1397
1981
|
)
|
|
1398
1982
|
return _response.data
|
|
1399
1983
|
|
|
@@ -1470,3 +2054,223 @@ class AsyncDatasetsClient:
|
|
|
1470
2054
|
) as r:
|
|
1471
2055
|
async for data in r.data:
|
|
1472
2056
|
yield data
|
|
2057
|
+
|
|
2058
|
+
async def compare_dataset_versions(
|
|
2059
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
2060
|
+
) -> DatasetVersionDiff:
|
|
2061
|
+
"""
|
|
2062
|
+
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.
|
|
2063
|
+
|
|
2064
|
+
Parameters
|
|
2065
|
+
----------
|
|
2066
|
+
id : str
|
|
2067
|
+
|
|
2068
|
+
request_options : typing.Optional[RequestOptions]
|
|
2069
|
+
Request-specific configuration.
|
|
2070
|
+
|
|
2071
|
+
Returns
|
|
2072
|
+
-------
|
|
2073
|
+
DatasetVersionDiff
|
|
2074
|
+
Diff computed successfully
|
|
2075
|
+
|
|
2076
|
+
Examples
|
|
2077
|
+
--------
|
|
2078
|
+
from Opik import AsyncOpikApi
|
|
2079
|
+
import asyncio
|
|
2080
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2081
|
+
async def main() -> None:
|
|
2082
|
+
await client.datasets.compare_dataset_versions(id='id', )
|
|
2083
|
+
asyncio.run(main())
|
|
2084
|
+
"""
|
|
2085
|
+
_response = await self._raw_client.compare_dataset_versions(id, request_options=request_options)
|
|
2086
|
+
return _response.data
|
|
2087
|
+
|
|
2088
|
+
async def create_version_tag(
|
|
2089
|
+
self, version_hash: str, id: str, *, tag: str, request_options: typing.Optional[RequestOptions] = None
|
|
2090
|
+
) -> None:
|
|
2091
|
+
"""
|
|
2092
|
+
Add a tag to a specific dataset version for easy reference (e.g., 'baseline', 'v1.0', 'production')
|
|
2093
|
+
|
|
2094
|
+
Parameters
|
|
2095
|
+
----------
|
|
2096
|
+
version_hash : str
|
|
2097
|
+
|
|
2098
|
+
id : str
|
|
2099
|
+
|
|
2100
|
+
tag : str
|
|
2101
|
+
|
|
2102
|
+
request_options : typing.Optional[RequestOptions]
|
|
2103
|
+
Request-specific configuration.
|
|
2104
|
+
|
|
2105
|
+
Returns
|
|
2106
|
+
-------
|
|
2107
|
+
None
|
|
2108
|
+
|
|
2109
|
+
Examples
|
|
2110
|
+
--------
|
|
2111
|
+
from Opik import AsyncOpikApi
|
|
2112
|
+
import asyncio
|
|
2113
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2114
|
+
async def main() -> None:
|
|
2115
|
+
await client.datasets.create_version_tag(version_hash='versionHash', id='id', tag='tag', )
|
|
2116
|
+
asyncio.run(main())
|
|
2117
|
+
"""
|
|
2118
|
+
_response = await self._raw_client.create_version_tag(
|
|
2119
|
+
version_hash, id, tag=tag, request_options=request_options
|
|
2120
|
+
)
|
|
2121
|
+
return _response.data
|
|
2122
|
+
|
|
2123
|
+
async def list_dataset_versions(
|
|
2124
|
+
self,
|
|
2125
|
+
id: str,
|
|
2126
|
+
*,
|
|
2127
|
+
page: typing.Optional[int] = None,
|
|
2128
|
+
size: typing.Optional[int] = None,
|
|
2129
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2130
|
+
) -> DatasetVersionPagePublic:
|
|
2131
|
+
"""
|
|
2132
|
+
Get paginated list of versions for a dataset, ordered by creation time (newest first)
|
|
2133
|
+
|
|
2134
|
+
Parameters
|
|
2135
|
+
----------
|
|
2136
|
+
id : str
|
|
2137
|
+
|
|
2138
|
+
page : typing.Optional[int]
|
|
2139
|
+
|
|
2140
|
+
size : typing.Optional[int]
|
|
2141
|
+
|
|
2142
|
+
request_options : typing.Optional[RequestOptions]
|
|
2143
|
+
Request-specific configuration.
|
|
2144
|
+
|
|
2145
|
+
Returns
|
|
2146
|
+
-------
|
|
2147
|
+
DatasetVersionPagePublic
|
|
2148
|
+
Dataset versions
|
|
2149
|
+
|
|
2150
|
+
Examples
|
|
2151
|
+
--------
|
|
2152
|
+
from Opik import AsyncOpikApi
|
|
2153
|
+
import asyncio
|
|
2154
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2155
|
+
async def main() -> None:
|
|
2156
|
+
await client.datasets.list_dataset_versions(id='id', )
|
|
2157
|
+
asyncio.run(main())
|
|
2158
|
+
"""
|
|
2159
|
+
_response = await self._raw_client.list_dataset_versions(
|
|
2160
|
+
id, page=page, size=size, request_options=request_options
|
|
2161
|
+
)
|
|
2162
|
+
return _response.data
|
|
2163
|
+
|
|
2164
|
+
async def create_dataset_version(
|
|
2165
|
+
self,
|
|
2166
|
+
id: str,
|
|
2167
|
+
*,
|
|
2168
|
+
tag: typing.Optional[str] = OMIT,
|
|
2169
|
+
change_description: typing.Optional[str] = OMIT,
|
|
2170
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
2171
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2172
|
+
) -> None:
|
|
2173
|
+
"""
|
|
2174
|
+
Create a new immutable version of the dataset by snapshotting the current state
|
|
2175
|
+
|
|
2176
|
+
Parameters
|
|
2177
|
+
----------
|
|
2178
|
+
id : str
|
|
2179
|
+
|
|
2180
|
+
tag : typing.Optional[str]
|
|
2181
|
+
Optional tag for this version
|
|
2182
|
+
|
|
2183
|
+
change_description : typing.Optional[str]
|
|
2184
|
+
Optional description of changes in this version
|
|
2185
|
+
|
|
2186
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
2187
|
+
Optional user-defined metadata
|
|
2188
|
+
|
|
2189
|
+
request_options : typing.Optional[RequestOptions]
|
|
2190
|
+
Request-specific configuration.
|
|
2191
|
+
|
|
2192
|
+
Returns
|
|
2193
|
+
-------
|
|
2194
|
+
None
|
|
2195
|
+
|
|
2196
|
+
Examples
|
|
2197
|
+
--------
|
|
2198
|
+
from Opik import AsyncOpikApi
|
|
2199
|
+
import asyncio
|
|
2200
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2201
|
+
async def main() -> None:
|
|
2202
|
+
await client.datasets.create_dataset_version(id='id', )
|
|
2203
|
+
asyncio.run(main())
|
|
2204
|
+
"""
|
|
2205
|
+
_response = await self._raw_client.create_dataset_version(
|
|
2206
|
+
id, tag=tag, change_description=change_description, metadata=metadata, request_options=request_options
|
|
2207
|
+
)
|
|
2208
|
+
return _response.data
|
|
2209
|
+
|
|
2210
|
+
async def delete_version_tag(
|
|
2211
|
+
self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
2212
|
+
) -> None:
|
|
2213
|
+
"""
|
|
2214
|
+
Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
|
|
2215
|
+
|
|
2216
|
+
Parameters
|
|
2217
|
+
----------
|
|
2218
|
+
version_hash : str
|
|
2219
|
+
|
|
2220
|
+
tag : str
|
|
2221
|
+
|
|
2222
|
+
id : str
|
|
2223
|
+
|
|
2224
|
+
request_options : typing.Optional[RequestOptions]
|
|
2225
|
+
Request-specific configuration.
|
|
2226
|
+
|
|
2227
|
+
Returns
|
|
2228
|
+
-------
|
|
2229
|
+
None
|
|
2230
|
+
|
|
2231
|
+
Examples
|
|
2232
|
+
--------
|
|
2233
|
+
from Opik import AsyncOpikApi
|
|
2234
|
+
import asyncio
|
|
2235
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2236
|
+
async def main() -> None:
|
|
2237
|
+
await client.datasets.delete_version_tag(version_hash='versionHash', tag='tag', id='id', )
|
|
2238
|
+
asyncio.run(main())
|
|
2239
|
+
"""
|
|
2240
|
+
_response = await self._raw_client.delete_version_tag(version_hash, tag, id, request_options=request_options)
|
|
2241
|
+
return _response.data
|
|
2242
|
+
|
|
2243
|
+
async def restore_dataset_version(
|
|
2244
|
+
self, id: str, *, version_ref: str, request_options: typing.Optional[RequestOptions] = None
|
|
2245
|
+
) -> DatasetVersionPublic:
|
|
2246
|
+
"""
|
|
2247
|
+
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).
|
|
2248
|
+
|
|
2249
|
+
Parameters
|
|
2250
|
+
----------
|
|
2251
|
+
id : str
|
|
2252
|
+
|
|
2253
|
+
version_ref : str
|
|
2254
|
+
Version hash or tag to restore from
|
|
2255
|
+
|
|
2256
|
+
request_options : typing.Optional[RequestOptions]
|
|
2257
|
+
Request-specific configuration.
|
|
2258
|
+
|
|
2259
|
+
Returns
|
|
2260
|
+
-------
|
|
2261
|
+
DatasetVersionPublic
|
|
2262
|
+
Version restored successfully
|
|
2263
|
+
|
|
2264
|
+
Examples
|
|
2265
|
+
--------
|
|
2266
|
+
from Opik import AsyncOpikApi
|
|
2267
|
+
import asyncio
|
|
2268
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2269
|
+
async def main() -> None:
|
|
2270
|
+
await client.datasets.restore_dataset_version(id='id', version_ref='version_ref', )
|
|
2271
|
+
asyncio.run(main())
|
|
2272
|
+
"""
|
|
2273
|
+
_response = await self._raw_client.restore_dataset_version(
|
|
2274
|
+
id, version_ref=version_ref, request_options=request_options
|
|
2275
|
+
)
|
|
2276
|
+
return _response.data
|