opik 1.6.4__py3-none-any.whl → 1.9.71__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 +33 -2
- 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/attachment/__init__.py +5 -0
- opik/api_objects/attachment/attachment.py +20 -0
- opik/api_objects/attachment/attachment_context.py +36 -0
- opik/api_objects/attachment/attachments_extractor.py +153 -0
- opik/api_objects/attachment/client.py +220 -0
- opik/api_objects/attachment/converters.py +51 -0
- opik/api_objects/attachment/decoder.py +18 -0
- opik/api_objects/attachment/decoder_base64.py +83 -0
- opik/api_objects/attachment/decoder_helpers.py +137 -0
- opik/api_objects/conversation/__init__.py +0 -0
- opik/api_objects/conversation/conversation_factory.py +43 -0
- opik/api_objects/conversation/conversation_thread.py +49 -0
- opik/api_objects/data_helpers.py +79 -0
- opik/api_objects/dataset/dataset.py +107 -45
- opik/api_objects/dataset/rest_operations.py +12 -3
- opik/api_objects/experiment/experiment.py +81 -45
- opik/api_objects/experiment/experiment_item.py +2 -1
- opik/api_objects/experiment/experiments_client.py +64 -0
- opik/api_objects/experiment/helpers.py +35 -11
- opik/api_objects/experiment/rest_operations.py +88 -19
- opik/api_objects/helpers.py +104 -7
- opik/api_objects/local_recording.py +81 -0
- opik/api_objects/opik_client.py +872 -174
- opik/api_objects/opik_query_language.py +136 -18
- opik/api_objects/optimization/__init__.py +3 -0
- opik/api_objects/optimization/optimization.py +39 -0
- opik/api_objects/prompt/__init__.py +13 -1
- 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 +210 -0
- opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
- opik/api_objects/prompt/chat/content_renderer_registry.py +203 -0
- opik/api_objects/prompt/client.py +193 -41
- opik/api_objects/prompt/text/__init__.py +1 -0
- opik/api_objects/prompt/text/prompt.py +174 -0
- opik/api_objects/prompt/text/prompt_template.py +55 -0
- opik/api_objects/prompt/types.py +29 -0
- opik/api_objects/rest_stream_parser.py +98 -0
- opik/api_objects/search_helpers.py +89 -0
- opik/api_objects/span/span_client.py +165 -45
- opik/api_objects/span/span_data.py +136 -25
- opik/api_objects/threads/__init__.py +0 -0
- opik/api_objects/threads/threads_client.py +185 -0
- opik/api_objects/trace/trace_client.py +72 -36
- opik/api_objects/trace/trace_data.py +112 -26
- opik/api_objects/validation_helpers.py +3 -3
- opik/cli/__init__.py +5 -0
- opik/cli/__main__.py +6 -0
- opik/cli/configure.py +66 -0
- opik/cli/exports/__init__.py +131 -0
- opik/cli/exports/dataset.py +278 -0
- opik/cli/exports/experiment.py +784 -0
- opik/cli/exports/project.py +685 -0
- opik/cli/exports/prompt.py +578 -0
- opik/cli/exports/utils.py +406 -0
- opik/cli/harbor.py +39 -0
- opik/cli/healthcheck.py +21 -0
- opik/cli/imports/__init__.py +439 -0
- opik/cli/imports/dataset.py +143 -0
- opik/cli/imports/experiment.py +1192 -0
- opik/cli/imports/project.py +262 -0
- opik/cli/imports/prompt.py +177 -0
- opik/cli/imports/utils.py +280 -0
- opik/cli/main.py +49 -0
- opik/cli/proxy.py +93 -0
- opik/cli/usage_report/__init__.py +16 -0
- opik/cli/usage_report/charts.py +783 -0
- opik/cli/usage_report/cli.py +274 -0
- opik/cli/usage_report/constants.py +9 -0
- opik/cli/usage_report/extraction.py +749 -0
- opik/cli/usage_report/pdf.py +244 -0
- opik/cli/usage_report/statistics.py +78 -0
- opik/cli/usage_report/utils.py +235 -0
- opik/config.py +62 -4
- opik/configurator/configure.py +45 -6
- opik/configurator/opik_rest_helpers.py +4 -1
- opik/context_storage.py +164 -65
- opik/datetime_helpers.py +12 -0
- opik/decorator/arguments_helpers.py +9 -1
- opik/decorator/base_track_decorator.py +298 -146
- opik/decorator/context_manager/__init__.py +0 -0
- opik/decorator/context_manager/span_context_manager.py +123 -0
- opik/decorator/context_manager/trace_context_manager.py +84 -0
- opik/decorator/generator_wrappers.py +3 -2
- opik/decorator/inspect_helpers.py +11 -0
- opik/decorator/opik_args/__init__.py +13 -0
- opik/decorator/opik_args/api_classes.py +71 -0
- opik/decorator/opik_args/helpers.py +120 -0
- opik/decorator/span_creation_handler.py +49 -21
- opik/decorator/tracker.py +9 -1
- opik/dict_utils.py +3 -3
- opik/environment.py +13 -1
- opik/error_tracking/api.py +1 -1
- opik/error_tracking/before_send.py +6 -5
- opik/error_tracking/environment_details.py +29 -7
- opik/error_tracking/error_filtering/filter_by_response_status_code.py +42 -0
- opik/error_tracking/error_filtering/filter_chain_builder.py +14 -3
- opik/evaluation/__init__.py +14 -2
- opik/evaluation/engine/engine.py +280 -82
- opik/evaluation/engine/evaluation_tasks_executor.py +15 -10
- opik/evaluation/engine/helpers.py +34 -9
- opik/evaluation/engine/metrics_evaluator.py +237 -0
- opik/evaluation/engine/types.py +5 -4
- opik/evaluation/evaluation_result.py +169 -2
- opik/evaluation/evaluator.py +659 -58
- opik/evaluation/metrics/__init__.py +121 -6
- opik/evaluation/metrics/aggregated_metric.py +92 -0
- opik/evaluation/metrics/arguments_helpers.py +15 -21
- opik/evaluation/metrics/arguments_validator.py +38 -0
- opik/evaluation/metrics/base_metric.py +20 -10
- opik/evaluation/metrics/conversation/__init__.py +48 -0
- opik/evaluation/metrics/conversation/conversation_thread_metric.py +79 -0
- opik/evaluation/metrics/conversation/conversation_turns_factory.py +39 -0
- opik/evaluation/metrics/conversation/g_eval_wrappers.py +19 -0
- opik/evaluation/metrics/conversation/helpers.py +84 -0
- opik/evaluation/metrics/conversation/heuristics/__init__.py +14 -0
- opik/evaluation/metrics/conversation/heuristics/degeneration/__init__.py +3 -0
- opik/evaluation/metrics/conversation/heuristics/degeneration/metric.py +189 -0
- opik/evaluation/metrics/conversation/heuristics/degeneration/phrases.py +12 -0
- opik/evaluation/metrics/conversation/heuristics/knowledge_retention/__init__.py +3 -0
- opik/evaluation/metrics/conversation/heuristics/knowledge_retention/metric.py +172 -0
- opik/evaluation/metrics/conversation/llm_judges/__init__.py +32 -0
- opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/__init__.py +0 -0
- opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/metric.py +274 -0
- opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/schema.py +16 -0
- opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/templates.py +95 -0
- opik/evaluation/metrics/conversation/llm_judges/g_eval_wrappers.py +442 -0
- opik/evaluation/metrics/conversation/llm_judges/session_completeness/__init__.py +0 -0
- opik/evaluation/metrics/conversation/llm_judges/session_completeness/metric.py +295 -0
- opik/evaluation/metrics/conversation/llm_judges/session_completeness/schema.py +22 -0
- opik/evaluation/metrics/conversation/llm_judges/session_completeness/templates.py +139 -0
- opik/evaluation/metrics/conversation/llm_judges/user_frustration/__init__.py +0 -0
- opik/evaluation/metrics/conversation/llm_judges/user_frustration/metric.py +277 -0
- opik/evaluation/metrics/conversation/llm_judges/user_frustration/schema.py +16 -0
- opik/evaluation/metrics/conversation/llm_judges/user_frustration/templates.py +135 -0
- opik/evaluation/metrics/conversation/types.py +34 -0
- opik/evaluation/metrics/conversation_types.py +9 -0
- opik/evaluation/metrics/heuristics/bertscore.py +107 -0
- opik/evaluation/metrics/heuristics/bleu.py +43 -16
- opik/evaluation/metrics/heuristics/chrf.py +127 -0
- opik/evaluation/metrics/heuristics/contains.py +50 -11
- opik/evaluation/metrics/heuristics/distribution_metrics.py +331 -0
- opik/evaluation/metrics/heuristics/equals.py +4 -1
- opik/evaluation/metrics/heuristics/gleu.py +113 -0
- opik/evaluation/metrics/heuristics/is_json.py +9 -3
- opik/evaluation/metrics/heuristics/language_adherence.py +123 -0
- opik/evaluation/metrics/heuristics/levenshtein_ratio.py +6 -5
- opik/evaluation/metrics/heuristics/meteor.py +119 -0
- opik/evaluation/metrics/heuristics/prompt_injection.py +150 -0
- opik/evaluation/metrics/heuristics/readability.py +129 -0
- opik/evaluation/metrics/heuristics/regex_match.py +4 -1
- opik/evaluation/metrics/heuristics/rouge.py +148 -0
- opik/evaluation/metrics/heuristics/sentiment.py +98 -0
- opik/evaluation/metrics/heuristics/spearman.py +88 -0
- opik/evaluation/metrics/heuristics/tone.py +155 -0
- opik/evaluation/metrics/heuristics/vader_sentiment.py +77 -0
- opik/evaluation/metrics/llm_judges/answer_relevance/metric.py +27 -30
- opik/evaluation/metrics/llm_judges/answer_relevance/parser.py +27 -0
- opik/evaluation/metrics/llm_judges/answer_relevance/templates.py +10 -10
- opik/evaluation/metrics/llm_judges/context_precision/metric.py +28 -31
- opik/evaluation/metrics/llm_judges/context_precision/parser.py +27 -0
- opik/evaluation/metrics/llm_judges/context_precision/template.py +7 -7
- opik/evaluation/metrics/llm_judges/context_recall/metric.py +27 -31
- opik/evaluation/metrics/llm_judges/context_recall/parser.py +27 -0
- opik/evaluation/metrics/llm_judges/context_recall/template.py +7 -7
- opik/evaluation/metrics/llm_judges/factuality/metric.py +7 -26
- opik/evaluation/metrics/llm_judges/factuality/parser.py +35 -0
- opik/evaluation/metrics/llm_judges/factuality/template.py +1 -1
- opik/evaluation/metrics/llm_judges/g_eval/__init__.py +5 -0
- opik/evaluation/metrics/llm_judges/g_eval/metric.py +244 -113
- opik/evaluation/metrics/llm_judges/g_eval/parser.py +161 -0
- opik/evaluation/metrics/llm_judges/g_eval/presets.py +209 -0
- opik/evaluation/metrics/llm_judges/g_eval_presets/__init__.py +36 -0
- opik/evaluation/metrics/llm_judges/g_eval_presets/agent_assessment.py +77 -0
- opik/evaluation/metrics/llm_judges/g_eval_presets/bias_classifier.py +181 -0
- opik/evaluation/metrics/llm_judges/g_eval_presets/compliance_risk.py +41 -0
- opik/evaluation/metrics/llm_judges/g_eval_presets/prompt_uncertainty.py +41 -0
- opik/evaluation/metrics/llm_judges/g_eval_presets/qa_suite.py +146 -0
- opik/evaluation/metrics/llm_judges/hallucination/metric.py +23 -27
- opik/evaluation/metrics/llm_judges/hallucination/parser.py +29 -0
- opik/evaluation/metrics/llm_judges/hallucination/template.py +2 -4
- opik/evaluation/metrics/llm_judges/llm_juries/__init__.py +3 -0
- opik/evaluation/metrics/llm_judges/llm_juries/metric.py +76 -0
- opik/evaluation/metrics/llm_judges/moderation/metric.py +23 -28
- opik/evaluation/metrics/llm_judges/moderation/parser.py +27 -0
- opik/evaluation/metrics/llm_judges/moderation/template.py +2 -2
- opik/evaluation/metrics/llm_judges/parsing_helpers.py +26 -0
- opik/evaluation/metrics/llm_judges/structure_output_compliance/__init__.py +0 -0
- opik/evaluation/metrics/llm_judges/structure_output_compliance/metric.py +144 -0
- opik/evaluation/metrics/llm_judges/structure_output_compliance/parser.py +79 -0
- opik/evaluation/metrics/llm_judges/structure_output_compliance/schema.py +15 -0
- opik/evaluation/metrics/llm_judges/structure_output_compliance/template.py +50 -0
- opik/evaluation/metrics/llm_judges/syc_eval/__init__.py +0 -0
- opik/evaluation/metrics/llm_judges/syc_eval/metric.py +252 -0
- opik/evaluation/metrics/llm_judges/syc_eval/parser.py +82 -0
- opik/evaluation/metrics/llm_judges/syc_eval/template.py +155 -0
- opik/evaluation/metrics/llm_judges/trajectory_accuracy/__init__.py +3 -0
- opik/evaluation/metrics/llm_judges/trajectory_accuracy/metric.py +171 -0
- opik/evaluation/metrics/llm_judges/trajectory_accuracy/parser.py +38 -0
- opik/evaluation/metrics/llm_judges/trajectory_accuracy/templates.py +65 -0
- opik/evaluation/metrics/llm_judges/usefulness/metric.py +23 -32
- opik/evaluation/metrics/llm_judges/usefulness/parser.py +28 -0
- opik/evaluation/metrics/ragas_metric.py +112 -0
- opik/evaluation/models/__init__.py +10 -0
- opik/evaluation/models/base_model.py +140 -18
- opik/evaluation/models/langchain/__init__.py +3 -0
- opik/evaluation/models/langchain/langchain_chat_model.py +166 -0
- opik/evaluation/models/langchain/message_converters.py +106 -0
- opik/evaluation/models/langchain/opik_monitoring.py +23 -0
- opik/evaluation/models/litellm/litellm_chat_model.py +186 -40
- opik/evaluation/models/litellm/opik_monitor.py +24 -21
- opik/evaluation/models/litellm/util.py +125 -0
- opik/evaluation/models/litellm/warning_filters.py +16 -4
- opik/evaluation/models/model_capabilities.py +187 -0
- opik/evaluation/models/models_factory.py +25 -3
- opik/evaluation/preprocessing.py +92 -0
- opik/evaluation/report.py +70 -12
- opik/evaluation/rest_operations.py +49 -45
- opik/evaluation/samplers/__init__.py +4 -0
- opik/evaluation/samplers/base_dataset_sampler.py +40 -0
- opik/evaluation/samplers/random_dataset_sampler.py +48 -0
- opik/evaluation/score_statistics.py +66 -0
- opik/evaluation/scorers/__init__.py +4 -0
- opik/evaluation/scorers/scorer_function.py +55 -0
- opik/evaluation/scorers/scorer_wrapper_metric.py +130 -0
- opik/evaluation/test_case.py +3 -2
- opik/evaluation/test_result.py +1 -0
- opik/evaluation/threads/__init__.py +0 -0
- opik/evaluation/threads/context_helper.py +32 -0
- opik/evaluation/threads/evaluation_engine.py +181 -0
- opik/evaluation/threads/evaluation_result.py +18 -0
- opik/evaluation/threads/evaluator.py +120 -0
- opik/evaluation/threads/helpers.py +51 -0
- opik/evaluation/types.py +9 -1
- opik/exceptions.py +116 -3
- opik/file_upload/__init__.py +0 -0
- opik/file_upload/base_upload_manager.py +39 -0
- opik/file_upload/file_upload_monitor.py +14 -0
- opik/file_upload/file_uploader.py +141 -0
- opik/file_upload/mime_type.py +9 -0
- opik/file_upload/s3_multipart_upload/__init__.py +0 -0
- opik/file_upload/s3_multipart_upload/file_parts_strategy.py +89 -0
- opik/file_upload/s3_multipart_upload/s3_file_uploader.py +86 -0
- opik/file_upload/s3_multipart_upload/s3_upload_error.py +29 -0
- opik/file_upload/thread_pool.py +17 -0
- opik/file_upload/upload_client.py +114 -0
- opik/file_upload/upload_manager.py +255 -0
- opik/file_upload/upload_options.py +37 -0
- opik/format_helpers.py +17 -0
- opik/guardrails/__init__.py +4 -0
- opik/guardrails/guardrail.py +157 -0
- opik/guardrails/guards/__init__.py +5 -0
- opik/guardrails/guards/guard.py +17 -0
- opik/guardrails/guards/pii.py +47 -0
- opik/guardrails/guards/topic.py +76 -0
- opik/guardrails/rest_api_client.py +34 -0
- opik/guardrails/schemas.py +24 -0
- opik/guardrails/tracing.py +61 -0
- opik/healthcheck/__init__.py +2 -1
- opik/healthcheck/checks.py +2 -2
- opik/healthcheck/rich_representation.py +1 -1
- opik/hooks/__init__.py +23 -0
- opik/hooks/anonymizer_hook.py +36 -0
- opik/hooks/httpx_client_hook.py +112 -0
- opik/httpx_client.py +75 -4
- opik/id_helpers.py +18 -0
- opik/integrations/adk/__init__.py +14 -0
- opik/integrations/adk/callback_context_info_extractors.py +32 -0
- opik/integrations/adk/graph/__init__.py +0 -0
- opik/integrations/adk/graph/mermaid_graph_builder.py +128 -0
- opik/integrations/adk/graph/nodes.py +101 -0
- opik/integrations/adk/graph/subgraph_edges_builders.py +41 -0
- opik/integrations/adk/helpers.py +48 -0
- opik/integrations/adk/legacy_opik_tracer.py +381 -0
- opik/integrations/adk/opik_tracer.py +370 -0
- opik/integrations/adk/patchers/__init__.py +4 -0
- opik/integrations/adk/patchers/adk_otel_tracer/__init__.py +0 -0
- opik/integrations/adk/patchers/adk_otel_tracer/llm_span_helpers.py +30 -0
- opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +201 -0
- opik/integrations/adk/patchers/litellm_wrappers.py +91 -0
- opik/integrations/adk/patchers/llm_response_wrapper.py +105 -0
- opik/integrations/adk/patchers/patchers.py +64 -0
- opik/integrations/adk/recursive_callback_injector.py +126 -0
- opik/integrations/aisuite/aisuite_decorator.py +8 -3
- opik/integrations/aisuite/opik_tracker.py +1 -0
- opik/integrations/anthropic/messages_create_decorator.py +8 -3
- opik/integrations/anthropic/opik_tracker.py +0 -1
- opik/integrations/bedrock/converse/__init__.py +0 -0
- opik/integrations/bedrock/converse/chunks_aggregator.py +188 -0
- opik/integrations/bedrock/{converse_decorator.py → converse/converse_decorator.py} +18 -8
- opik/integrations/bedrock/invoke_agent_decorator.py +12 -7
- opik/integrations/bedrock/invoke_model/__init__.py +0 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/__init__.py +78 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/api.py +45 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/base.py +23 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/claude.py +121 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/format_detector.py +107 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/llama.py +108 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/mistral.py +118 -0
- opik/integrations/bedrock/invoke_model/chunks_aggregator/nova.py +99 -0
- opik/integrations/bedrock/invoke_model/invoke_model_decorator.py +178 -0
- opik/integrations/bedrock/invoke_model/response_types.py +34 -0
- opik/integrations/bedrock/invoke_model/stream_wrappers.py +122 -0
- opik/integrations/bedrock/invoke_model/usage_converters.py +87 -0
- opik/integrations/bedrock/invoke_model/usage_extraction.py +108 -0
- opik/integrations/bedrock/opik_tracker.py +43 -4
- opik/integrations/bedrock/types.py +19 -0
- opik/integrations/crewai/crewai_decorator.py +34 -56
- opik/integrations/crewai/opik_tracker.py +31 -10
- opik/integrations/crewai/patchers/__init__.py +5 -0
- opik/integrations/crewai/patchers/flow.py +118 -0
- opik/integrations/crewai/patchers/litellm_completion.py +30 -0
- opik/integrations/crewai/patchers/llm_client.py +207 -0
- opik/integrations/dspy/callback.py +246 -84
- opik/integrations/dspy/graph.py +88 -0
- opik/integrations/dspy/parsers.py +168 -0
- opik/integrations/genai/encoder_extension.py +2 -6
- opik/integrations/genai/generate_content_decorator.py +20 -13
- opik/integrations/guardrails/guardrails_decorator.py +4 -0
- opik/integrations/harbor/__init__.py +17 -0
- opik/integrations/harbor/experiment_service.py +269 -0
- opik/integrations/harbor/opik_tracker.py +528 -0
- opik/integrations/haystack/constants.py +35 -0
- opik/integrations/haystack/converters.py +1 -2
- opik/integrations/haystack/opik_connector.py +28 -6
- opik/integrations/haystack/opik_span_bridge.py +284 -0
- opik/integrations/haystack/opik_tracer.py +124 -222
- opik/integrations/langchain/__init__.py +3 -1
- opik/integrations/langchain/helpers.py +96 -0
- opik/integrations/langchain/langgraph_async_context_bridge.py +131 -0
- opik/integrations/langchain/langgraph_tracer_injector.py +88 -0
- opik/integrations/langchain/opik_encoder_extension.py +2 -2
- opik/integrations/langchain/opik_tracer.py +641 -206
- opik/integrations/langchain/provider_usage_extractors/__init__.py +5 -0
- opik/integrations/langchain/provider_usage_extractors/anthropic_usage_extractor.py +101 -0
- opik/integrations/langchain/provider_usage_extractors/anthropic_vertexai_usage_extractor.py +67 -0
- opik/integrations/langchain/provider_usage_extractors/bedrock_usage_extractor.py +94 -0
- opik/integrations/langchain/provider_usage_extractors/google_generative_ai_usage_extractor.py +109 -0
- opik/integrations/langchain/provider_usage_extractors/groq_usage_extractor.py +92 -0
- opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/__init__.py +15 -0
- opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/helpers.py +134 -0
- opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/langchain_usage.py +163 -0
- opik/integrations/langchain/provider_usage_extractors/openai_usage_extractor.py +124 -0
- opik/integrations/langchain/provider_usage_extractors/provider_usage_extractor_protocol.py +29 -0
- opik/integrations/langchain/provider_usage_extractors/usage_extractor.py +48 -0
- opik/integrations/langchain/provider_usage_extractors/vertexai_usage_extractor.py +109 -0
- opik/integrations/litellm/__init__.py +5 -0
- opik/integrations/litellm/completion_chunks_aggregator.py +115 -0
- opik/integrations/litellm/litellm_completion_decorator.py +242 -0
- opik/integrations/litellm/opik_tracker.py +43 -0
- opik/integrations/litellm/stream_patchers.py +151 -0
- opik/integrations/llama_index/callback.py +179 -78
- opik/integrations/llama_index/event_parsing_utils.py +29 -9
- opik/integrations/openai/agents/opik_tracing_processor.py +204 -32
- opik/integrations/openai/agents/span_data_parsers.py +15 -6
- opik/integrations/openai/chat_completion_chunks_aggregator.py +1 -1
- opik/integrations/openai/{openai_decorator.py → openai_chat_completions_decorator.py} +45 -35
- opik/integrations/openai/openai_responses_decorator.py +158 -0
- opik/integrations/openai/opik_tracker.py +94 -13
- opik/integrations/openai/response_events_aggregator.py +36 -0
- opik/integrations/openai/stream_patchers.py +125 -15
- opik/integrations/sagemaker/auth.py +5 -1
- opik/jsonable_encoder.py +29 -1
- opik/llm_usage/base_original_provider_usage.py +15 -8
- opik/llm_usage/bedrock_usage.py +8 -2
- opik/llm_usage/google_usage.py +6 -1
- opik/llm_usage/llm_usage_info.py +6 -0
- opik/llm_usage/{openai_usage.py → openai_chat_completions_usage.py} +2 -12
- opik/llm_usage/{openai_agent_usage.py → openai_responses_usage.py} +7 -15
- opik/llm_usage/opik_usage.py +36 -10
- opik/llm_usage/opik_usage_factory.py +35 -19
- opik/logging_messages.py +19 -7
- opik/message_processing/arguments_utils.py +22 -0
- opik/message_processing/batching/base_batcher.py +45 -17
- opik/message_processing/batching/batch_manager.py +22 -10
- opik/message_processing/batching/batch_manager_constuctors.py +36 -11
- opik/message_processing/batching/batchers.py +167 -44
- opik/message_processing/batching/flushing_thread.py +0 -3
- opik/message_processing/batching/sequence_splitter.py +50 -5
- opik/message_processing/emulation/__init__.py +0 -0
- opik/message_processing/emulation/emulator_message_processor.py +578 -0
- opik/message_processing/emulation/local_emulator_message_processor.py +140 -0
- opik/message_processing/emulation/models.py +162 -0
- opik/message_processing/encoder_helpers.py +79 -0
- opik/message_processing/message_queue.py +79 -0
- opik/message_processing/messages.py +154 -12
- opik/message_processing/preprocessing/__init__.py +0 -0
- opik/message_processing/preprocessing/attachments_preprocessor.py +70 -0
- opik/message_processing/preprocessing/batching_preprocessor.py +53 -0
- opik/message_processing/preprocessing/constants.py +1 -0
- opik/message_processing/preprocessing/file_upload_preprocessor.py +38 -0
- opik/message_processing/preprocessing/preprocessor.py +36 -0
- opik/message_processing/processors/__init__.py +0 -0
- opik/message_processing/processors/attachments_extraction_processor.py +146 -0
- opik/message_processing/processors/message_processors.py +92 -0
- opik/message_processing/processors/message_processors_chain.py +96 -0
- opik/message_processing/processors/online_message_processor.py +324 -0
- opik/message_processing/queue_consumer.py +61 -13
- opik/message_processing/streamer.py +102 -31
- opik/message_processing/streamer_constructors.py +67 -12
- opik/opik_context.py +103 -11
- opik/plugins/pytest/decorator.py +2 -2
- opik/plugins/pytest/experiment_runner.py +3 -2
- opik/plugins/pytest/hooks.py +6 -4
- opik/rate_limit/__init__.py +0 -0
- opik/rate_limit/rate_limit.py +25 -0
- opik/rest_api/__init__.py +643 -11
- opik/rest_api/alerts/__init__.py +7 -0
- opik/rest_api/alerts/client.py +667 -0
- opik/rest_api/alerts/raw_client.py +1015 -0
- opik/rest_api/alerts/types/__init__.py +7 -0
- opik/rest_api/alerts/types/get_webhook_examples_request_alert_type.py +5 -0
- opik/rest_api/annotation_queues/__init__.py +4 -0
- opik/rest_api/annotation_queues/client.py +668 -0
- opik/rest_api/annotation_queues/raw_client.py +1019 -0
- opik/rest_api/attachments/__init__.py +17 -0
- opik/rest_api/attachments/client.py +752 -0
- opik/rest_api/attachments/raw_client.py +1125 -0
- opik/rest_api/attachments/types/__init__.py +15 -0
- opik/rest_api/attachments/types/attachment_list_request_entity_type.py +5 -0
- opik/rest_api/attachments/types/download_attachment_request_entity_type.py +5 -0
- opik/rest_api/attachments/types/start_multipart_upload_request_entity_type.py +5 -0
- opik/rest_api/attachments/types/upload_attachment_request_entity_type.py +5 -0
- opik/rest_api/automation_rule_evaluators/__init__.py +2 -0
- opik/rest_api/automation_rule_evaluators/client.py +182 -1162
- opik/rest_api/automation_rule_evaluators/raw_client.py +598 -0
- opik/rest_api/chat_completions/__init__.py +2 -0
- opik/rest_api/chat_completions/client.py +115 -149
- opik/rest_api/chat_completions/raw_client.py +339 -0
- opik/rest_api/check/__init__.py +2 -0
- opik/rest_api/check/client.py +88 -106
- opik/rest_api/check/raw_client.py +258 -0
- opik/rest_api/client.py +112 -212
- opik/rest_api/core/__init__.py +5 -0
- opik/rest_api/core/api_error.py +12 -6
- opik/rest_api/core/client_wrapper.py +4 -14
- opik/rest_api/core/datetime_utils.py +1 -3
- opik/rest_api/core/file.py +2 -5
- opik/rest_api/core/http_client.py +42 -120
- opik/rest_api/core/http_response.py +55 -0
- opik/rest_api/core/jsonable_encoder.py +1 -4
- opik/rest_api/core/pydantic_utilities.py +79 -147
- opik/rest_api/core/query_encoder.py +1 -3
- opik/rest_api/core/serialization.py +10 -10
- 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/__init__.py +5 -0
- opik/rest_api/datasets/client.py +1638 -1091
- opik/rest_api/datasets/raw_client.py +3389 -0
- opik/rest_api/datasets/types/__init__.py +8 -0
- opik/rest_api/datasets/types/dataset_update_visibility.py +5 -0
- opik/rest_api/datasets/types/dataset_write_visibility.py +5 -0
- opik/rest_api/errors/__init__.py +2 -0
- opik/rest_api/errors/bad_request_error.py +4 -3
- opik/rest_api/errors/conflict_error.py +4 -3
- opik/rest_api/errors/forbidden_error.py +4 -2
- opik/rest_api/errors/not_found_error.py +4 -3
- opik/rest_api/errors/not_implemented_error.py +4 -3
- opik/rest_api/errors/unauthorized_error.py +4 -3
- opik/rest_api/errors/unprocessable_entity_error.py +4 -3
- opik/rest_api/experiments/__init__.py +5 -0
- opik/rest_api/experiments/client.py +676 -752
- opik/rest_api/experiments/raw_client.py +1872 -0
- opik/rest_api/experiments/types/__init__.py +10 -0
- opik/rest_api/experiments/types/experiment_update_status.py +5 -0
- opik/rest_api/experiments/types/experiment_update_type.py +5 -0
- opik/rest_api/experiments/types/experiment_write_status.py +5 -0
- opik/rest_api/experiments/types/experiment_write_type.py +5 -0
- opik/rest_api/feedback_definitions/__init__.py +2 -0
- opik/rest_api/feedback_definitions/client.py +96 -370
- opik/rest_api/feedback_definitions/raw_client.py +541 -0
- opik/rest_api/feedback_definitions/types/__init__.py +2 -0
- opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -3
- opik/rest_api/guardrails/__init__.py +4 -0
- opik/rest_api/guardrails/client.py +104 -0
- opik/rest_api/guardrails/raw_client.py +102 -0
- opik/rest_api/llm_provider_key/__init__.py +2 -0
- opik/rest_api/llm_provider_key/client.py +166 -440
- opik/rest_api/llm_provider_key/raw_client.py +643 -0
- opik/rest_api/llm_provider_key/types/__init__.py +2 -0
- opik/rest_api/llm_provider_key/types/provider_api_key_write_provider.py +1 -1
- opik/rest_api/manual_evaluation/__init__.py +4 -0
- opik/rest_api/manual_evaluation/client.py +347 -0
- opik/rest_api/manual_evaluation/raw_client.py +543 -0
- opik/rest_api/open_telemetry_ingestion/__init__.py +2 -0
- opik/rest_api/open_telemetry_ingestion/client.py +38 -63
- opik/rest_api/open_telemetry_ingestion/raw_client.py +88 -0
- opik/rest_api/optimizations/__init__.py +7 -0
- opik/rest_api/optimizations/client.py +704 -0
- opik/rest_api/optimizations/raw_client.py +920 -0
- opik/rest_api/optimizations/types/__init__.py +7 -0
- opik/rest_api/optimizations/types/optimization_update_status.py +7 -0
- opik/rest_api/projects/__init__.py +10 -1
- opik/rest_api/projects/client.py +180 -855
- opik/rest_api/projects/raw_client.py +1216 -0
- opik/rest_api/projects/types/__init__.py +11 -4
- opik/rest_api/projects/types/project_metric_request_public_interval.py +1 -3
- opik/rest_api/projects/types/project_metric_request_public_metric_type.py +11 -1
- opik/rest_api/projects/types/project_update_visibility.py +5 -0
- opik/rest_api/projects/types/project_write_visibility.py +5 -0
- opik/rest_api/prompts/__init__.py +4 -2
- opik/rest_api/prompts/client.py +381 -970
- opik/rest_api/prompts/raw_client.py +1634 -0
- opik/rest_api/prompts/types/__init__.py +5 -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/raw_client.py +156 -0
- opik/rest_api/redirect/__init__.py +4 -0
- opik/rest_api/redirect/client.py +375 -0
- opik/rest_api/redirect/raw_client.py +566 -0
- opik/rest_api/service_toggles/__init__.py +4 -0
- opik/rest_api/service_toggles/client.py +91 -0
- opik/rest_api/service_toggles/raw_client.py +93 -0
- opik/rest_api/spans/__init__.py +2 -0
- opik/rest_api/spans/client.py +659 -1354
- opik/rest_api/spans/raw_client.py +2383 -0
- opik/rest_api/spans/types/__init__.py +2 -0
- opik/rest_api/spans/types/find_feedback_score_names_1_request_type.py +1 -3
- opik/rest_api/spans/types/get_span_stats_request_type.py +1 -3
- opik/rest_api/spans/types/get_spans_by_project_request_type.py +1 -3
- opik/rest_api/spans/types/span_search_stream_request_public_type.py +1 -3
- opik/rest_api/system_usage/__init__.py +2 -0
- opik/rest_api/system_usage/client.py +157 -216
- opik/rest_api/system_usage/raw_client.py +455 -0
- opik/rest_api/traces/__init__.py +2 -0
- opik/rest_api/traces/client.py +2102 -1625
- opik/rest_api/traces/raw_client.py +4144 -0
- opik/rest_api/types/__init__.py +629 -24
- opik/rest_api/types/aggregation_data.py +27 -0
- opik/rest_api/types/alert.py +33 -0
- opik/rest_api/types/alert_alert_type.py +5 -0
- opik/rest_api/types/alert_page_public.py +24 -0
- opik/rest_api/types/alert_public.py +33 -0
- opik/rest_api/types/alert_public_alert_type.py +5 -0
- opik/rest_api/types/alert_trigger.py +27 -0
- opik/rest_api/types/alert_trigger_config.py +28 -0
- opik/rest_api/types/alert_trigger_config_public.py +28 -0
- opik/rest_api/types/alert_trigger_config_public_type.py +10 -0
- opik/rest_api/types/alert_trigger_config_type.py +10 -0
- opik/rest_api/types/alert_trigger_config_write.py +22 -0
- opik/rest_api/types/alert_trigger_config_write_type.py +10 -0
- opik/rest_api/types/alert_trigger_event_type.py +19 -0
- opik/rest_api/types/alert_trigger_public.py +27 -0
- opik/rest_api/types/alert_trigger_public_event_type.py +19 -0
- opik/rest_api/types/alert_trigger_write.py +23 -0
- opik/rest_api/types/alert_trigger_write_event_type.py +19 -0
- opik/rest_api/types/alert_write.py +28 -0
- opik/rest_api/types/alert_write_alert_type.py +5 -0
- opik/rest_api/types/annotation_queue.py +42 -0
- opik/rest_api/types/annotation_queue_batch.py +27 -0
- opik/rest_api/types/{json_schema_element.py → annotation_queue_item_ids.py} +5 -7
- opik/rest_api/types/annotation_queue_page_public.py +28 -0
- opik/rest_api/types/annotation_queue_public.py +38 -0
- opik/rest_api/types/annotation_queue_public_scope.py +5 -0
- opik/rest_api/types/{workspace_metadata.py → annotation_queue_reviewer.py} +6 -7
- opik/rest_api/types/annotation_queue_reviewer_public.py +20 -0
- opik/rest_api/types/annotation_queue_scope.py +5 -0
- opik/rest_api/types/annotation_queue_write.py +31 -0
- opik/rest_api/types/annotation_queue_write_scope.py +5 -0
- opik/rest_api/types/assistant_message.py +7 -8
- opik/rest_api/types/assistant_message_role.py +1 -3
- opik/rest_api/types/attachment.py +22 -0
- opik/rest_api/types/attachment_page.py +28 -0
- opik/rest_api/types/audio_url.py +19 -0
- opik/rest_api/types/audio_url_public.py +19 -0
- opik/rest_api/types/audio_url_write.py +19 -0
- opik/rest_api/types/automation_rule_evaluator.py +160 -0
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_object_object_public.py +155 -0
- opik/rest_api/types/automation_rule_evaluator_page_public.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_public.py +155 -0
- 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_span_user_defined_metric_python.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_public.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_write.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_update.py +143 -0
- opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_update_span_user_defined_metric_python.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +6 -6
- opik/rest_api/types/automation_rule_evaluator_write.py +143 -0
- opik/rest_api/types/avg_value_stat_public.py +3 -5
- opik/rest_api/types/batch_delete.py +3 -5
- opik/rest_api/types/batch_delete_by_project.py +20 -0
- opik/rest_api/types/bi_information.py +3 -5
- opik/rest_api/types/bi_information_response.py +4 -6
- 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/categorical_feedback_definition.py +5 -7
- opik/rest_api/types/categorical_feedback_definition_create.py +4 -6
- opik/rest_api/types/categorical_feedback_definition_public.py +5 -7
- opik/rest_api/types/categorical_feedback_definition_update.py +4 -6
- opik/rest_api/types/categorical_feedback_detail.py +3 -5
- opik/rest_api/types/categorical_feedback_detail_create.py +3 -5
- opik/rest_api/types/categorical_feedback_detail_public.py +3 -5
- opik/rest_api/types/categorical_feedback_detail_update.py +3 -5
- opik/rest_api/types/chat_completion_choice.py +4 -6
- opik/rest_api/types/chat_completion_response.py +5 -6
- opik/rest_api/types/check.py +22 -0
- opik/rest_api/types/{json_node_compare.py → check_name.py} +1 -1
- opik/rest_api/types/check_public.py +22 -0
- opik/rest_api/types/check_public_name.py +5 -0
- opik/rest_api/types/check_public_result.py +5 -0
- opik/rest_api/types/check_result.py +5 -0
- opik/rest_api/types/chunked_output_json_node.py +4 -6
- opik/rest_api/types/chunked_output_json_node_public.py +4 -6
- opik/rest_api/types/chunked_output_json_node_public_type.py +6 -10
- opik/rest_api/types/chunked_output_json_node_type.py +6 -10
- opik/rest_api/types/column.py +8 -10
- opik/rest_api/types/column_compare.py +8 -10
- opik/rest_api/types/column_public.py +8 -10
- opik/rest_api/types/column_types_item.py +1 -3
- opik/rest_api/types/comment.py +4 -6
- opik/rest_api/types/comment_compare.py +4 -6
- opik/rest_api/types/comment_public.py +4 -6
- opik/rest_api/types/complete_multipart_upload_request.py +33 -0
- opik/rest_api/types/complete_multipart_upload_request_entity_type.py +5 -0
- opik/rest_api/types/completion_tokens_details.py +3 -5
- opik/rest_api/types/count_value_stat_public.py +3 -5
- opik/rest_api/types/dashboard_page_public.py +24 -0
- opik/rest_api/types/dashboard_public.py +30 -0
- opik/rest_api/types/data_point_double.py +21 -0
- opik/rest_api/types/data_point_number_public.py +3 -5
- opik/rest_api/types/dataset.py +14 -6
- opik/rest_api/types/dataset_expansion.py +42 -0
- opik/rest_api/types/dataset_expansion_response.py +39 -0
- opik/rest_api/types/dataset_item.py +9 -8
- opik/rest_api/types/dataset_item_batch.py +3 -5
- opik/rest_api/types/dataset_item_changes_public.py +5 -0
- opik/rest_api/types/dataset_item_compare.py +9 -8
- opik/rest_api/types/dataset_item_compare_source.py +1 -3
- opik/rest_api/types/dataset_item_filter.py +27 -0
- opik/rest_api/types/dataset_item_filter_operator.py +21 -0
- opik/rest_api/types/dataset_item_page_compare.py +10 -7
- opik/rest_api/types/dataset_item_page_public.py +10 -7
- opik/rest_api/types/dataset_item_public.py +9 -8
- opik/rest_api/types/dataset_item_public_source.py +1 -3
- opik/rest_api/types/dataset_item_source.py +1 -3
- opik/rest_api/types/dataset_item_update.py +39 -0
- opik/rest_api/types/dataset_item_write.py +5 -6
- opik/rest_api/types/dataset_item_write_source.py +1 -3
- opik/rest_api/types/dataset_page_public.py +9 -6
- opik/rest_api/types/dataset_public.py +14 -6
- opik/rest_api/types/dataset_public_status.py +5 -0
- opik/rest_api/types/dataset_public_visibility.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 +59 -0
- opik/rest_api/types/dataset_version_summary.py +46 -0
- opik/rest_api/types/dataset_version_summary_public.py +46 -0
- opik/rest_api/types/dataset_visibility.py +5 -0
- opik/rest_api/types/delete_attachments_request.py +23 -0
- opik/rest_api/types/delete_attachments_request_entity_type.py +5 -0
- opik/rest_api/types/delete_feedback_score.py +4 -5
- opik/rest_api/types/delete_ids_holder.py +19 -0
- opik/rest_api/types/delta.py +7 -9
- opik/rest_api/types/error_count_with_deviation.py +21 -0
- opik/rest_api/types/error_count_with_deviation_detailed.py +21 -0
- opik/rest_api/types/error_info.py +3 -5
- opik/rest_api/types/error_info_experiment_item_bulk_write_view.py +21 -0
- opik/rest_api/types/error_info_public.py +3 -5
- opik/rest_api/types/error_info_write.py +3 -5
- opik/rest_api/types/error_message.py +3 -5
- opik/rest_api/types/error_message_detail.py +3 -5
- opik/rest_api/types/error_message_detailed.py +3 -5
- opik/rest_api/types/error_message_public.py +3 -5
- opik/rest_api/types/experiment.py +21 -10
- opik/rest_api/types/experiment_group_aggregations_response.py +20 -0
- opik/rest_api/types/experiment_group_response.py +22 -0
- opik/rest_api/types/experiment_item.py +14 -11
- opik/rest_api/types/experiment_item_bulk_record.py +27 -0
- opik/rest_api/types/experiment_item_bulk_record_experiment_item_bulk_write_view.py +27 -0
- opik/rest_api/types/experiment_item_bulk_upload.py +27 -0
- opik/rest_api/types/experiment_item_compare.py +14 -11
- opik/rest_api/types/experiment_item_compare_trace_visibility_mode.py +5 -0
- opik/rest_api/types/experiment_item_public.py +6 -6
- opik/rest_api/types/experiment_item_public_trace_visibility_mode.py +5 -0
- opik/rest_api/types/experiment_item_trace_visibility_mode.py +5 -0
- opik/rest_api/types/experiment_page_public.py +9 -6
- opik/rest_api/types/experiment_public.py +21 -10
- opik/rest_api/types/experiment_public_status.py +5 -0
- opik/rest_api/types/experiment_public_type.py +5 -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/experiment_status.py +5 -0
- opik/rest_api/types/experiment_type.py +5 -0
- opik/rest_api/types/export_trace_service_request.py +5 -0
- opik/rest_api/types/feedback.py +40 -27
- opik/rest_api/types/feedback_create.py +27 -13
- opik/rest_api/types/feedback_definition_page_public.py +4 -6
- opik/rest_api/types/feedback_object_public.py +40 -27
- opik/rest_api/types/feedback_public.py +40 -27
- opik/rest_api/types/feedback_score.py +7 -7
- opik/rest_api/types/feedback_score_average.py +3 -5
- opik/rest_api/types/feedback_score_average_detailed.py +3 -5
- opik/rest_api/types/feedback_score_average_public.py +3 -5
- opik/rest_api/types/feedback_score_batch.py +4 -6
- opik/rest_api/types/feedback_score_batch_item.py +6 -6
- opik/rest_api/types/feedback_score_batch_item_source.py +1 -3
- opik/rest_api/types/feedback_score_batch_item_thread.py +32 -0
- opik/rest_api/types/feedback_score_batch_item_thread_source.py +5 -0
- opik/rest_api/types/feedback_score_compare.py +7 -7
- opik/rest_api/types/feedback_score_compare_source.py +1 -3
- opik/rest_api/types/feedback_score_experiment_item_bulk_write_view.py +31 -0
- opik/rest_api/types/feedback_score_experiment_item_bulk_write_view_source.py +5 -0
- opik/rest_api/types/feedback_score_names.py +4 -6
- opik/rest_api/types/feedback_score_public.py +11 -7
- opik/rest_api/types/feedback_score_public_source.py +1 -3
- opik/rest_api/types/feedback_score_source.py +1 -3
- opik/rest_api/types/feedback_update.py +27 -13
- opik/rest_api/types/function.py +4 -7
- opik/rest_api/types/function_call.py +3 -5
- opik/rest_api/types/group_content.py +19 -0
- opik/rest_api/types/group_content_with_aggregations.py +21 -0
- opik/rest_api/types/group_detail.py +19 -0
- opik/rest_api/types/group_details.py +20 -0
- opik/rest_api/types/guardrail.py +34 -0
- opik/rest_api/types/guardrail_batch.py +20 -0
- opik/rest_api/types/guardrail_name.py +5 -0
- opik/rest_api/types/guardrail_result.py +5 -0
- opik/rest_api/types/guardrail_write.py +33 -0
- opik/rest_api/types/guardrail_write_name.py +5 -0
- opik/rest_api/types/guardrail_write_result.py +5 -0
- opik/rest_api/types/guardrails_validation.py +21 -0
- opik/rest_api/types/guardrails_validation_public.py +21 -0
- opik/rest_api/types/ids_holder.py +19 -0
- 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/json_list_string.py +7 -0
- opik/rest_api/types/json_list_string_compare.py +7 -0
- opik/rest_api/types/json_list_string_experiment_item_bulk_write_view.py +7 -0
- opik/rest_api/types/json_list_string_public.py +7 -0
- opik/rest_api/types/json_list_string_write.py +7 -0
- opik/rest_api/types/json_schema.py +5 -8
- opik/rest_api/types/llm_as_judge_code.py +8 -12
- opik/rest_api/types/llm_as_judge_code_public.py +8 -12
- opik/rest_api/types/llm_as_judge_code_write.py +8 -12
- opik/rest_api/types/llm_as_judge_message.py +9 -7
- opik/rest_api/types/llm_as_judge_message_content.py +26 -0
- opik/rest_api/types/llm_as_judge_message_content_public.py +26 -0
- opik/rest_api/types/llm_as_judge_message_content_write.py +26 -0
- opik/rest_api/types/llm_as_judge_message_public.py +9 -7
- opik/rest_api/types/llm_as_judge_message_public_role.py +1 -1
- opik/rest_api/types/llm_as_judge_message_role.py +1 -1
- opik/rest_api/types/llm_as_judge_message_write.py +9 -7
- opik/rest_api/types/llm_as_judge_message_write_role.py +1 -1
- opik/rest_api/types/llm_as_judge_model_parameters.py +6 -5
- opik/rest_api/types/llm_as_judge_model_parameters_public.py +6 -5
- opik/rest_api/types/llm_as_judge_model_parameters_write.py +6 -5
- opik/rest_api/types/llm_as_judge_output_schema.py +4 -6
- opik/rest_api/types/llm_as_judge_output_schema_public.py +4 -6
- opik/rest_api/types/llm_as_judge_output_schema_public_type.py +1 -3
- opik/rest_api/types/llm_as_judge_output_schema_type.py +1 -3
- opik/rest_api/types/llm_as_judge_output_schema_write.py +4 -6
- opik/rest_api/types/llm_as_judge_output_schema_write_type.py +1 -3
- opik/rest_api/types/log_item.py +5 -7
- opik/rest_api/types/log_item_level.py +1 -3
- opik/rest_api/types/log_page.py +4 -6
- opik/rest_api/types/manual_evaluation_request.py +38 -0
- opik/rest_api/types/manual_evaluation_request_entity_type.py +5 -0
- opik/rest_api/types/manual_evaluation_response.py +27 -0
- opik/rest_api/types/multipart_upload_part.py +20 -0
- opik/rest_api/types/numerical_feedback_definition.py +5 -7
- opik/rest_api/types/numerical_feedback_definition_create.py +4 -6
- opik/rest_api/types/numerical_feedback_definition_public.py +5 -7
- opik/rest_api/types/numerical_feedback_definition_update.py +4 -6
- opik/rest_api/types/numerical_feedback_detail.py +3 -5
- opik/rest_api/types/numerical_feedback_detail_create.py +3 -5
- opik/rest_api/types/numerical_feedback_detail_public.py +3 -5
- opik/rest_api/types/numerical_feedback_detail_update.py +3 -5
- opik/rest_api/types/optimization.py +37 -0
- opik/rest_api/types/optimization_page_public.py +28 -0
- opik/rest_api/types/optimization_public.py +37 -0
- opik/rest_api/types/optimization_public_status.py +7 -0
- opik/rest_api/types/optimization_status.py +7 -0
- 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 +30 -0
- opik/rest_api/types/optimization_write_status.py +7 -0
- opik/rest_api/types/page_columns.py +4 -6
- opik/rest_api/types/percentage_value_stat_public.py +4 -6
- opik/rest_api/types/percentage_values.py +8 -16
- opik/rest_api/types/percentage_values_detailed.py +8 -16
- opik/rest_api/types/percentage_values_public.py +8 -16
- opik/rest_api/types/project.py +12 -7
- opik/rest_api/types/project_detailed.py +12 -7
- opik/rest_api/types/project_detailed_visibility.py +5 -0
- opik/rest_api/types/project_metric_response_public.py +5 -9
- opik/rest_api/types/project_metric_response_public_interval.py +1 -3
- opik/rest_api/types/project_metric_response_public_metric_type.py +11 -1
- opik/rest_api/types/project_page_public.py +8 -10
- opik/rest_api/types/project_public.py +6 -6
- opik/rest_api/types/project_public_visibility.py +5 -0
- opik/rest_api/types/project_reference.py +31 -0
- opik/rest_api/types/project_reference_public.py +31 -0
- opik/rest_api/types/project_stat_item_object_public.py +8 -17
- opik/rest_api/types/project_stats_public.py +4 -6
- opik/rest_api/types/project_stats_summary.py +4 -6
- opik/rest_api/types/project_stats_summary_item.py +9 -6
- opik/rest_api/types/project_visibility.py +5 -0
- opik/rest_api/types/prompt.py +12 -7
- opik/rest_api/types/prompt_detail.py +12 -7
- opik/rest_api/types/prompt_detail_template_structure.py +5 -0
- opik/rest_api/types/prompt_page_public.py +9 -6
- opik/rest_api/types/prompt_public.py +11 -6
- 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_tokens_details.py +19 -0
- opik/rest_api/types/prompt_version.py +7 -6
- opik/rest_api/types/prompt_version_detail.py +7 -6
- opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
- opik/rest_api/types/prompt_version_link.py +4 -5
- opik/rest_api/types/prompt_version_link_public.py +4 -5
- opik/rest_api/types/prompt_version_link_write.py +3 -5
- opik/rest_api/types/prompt_version_page_public.py +9 -6
- opik/rest_api/types/prompt_version_public.py +7 -6
- 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/prompt_version_update.py +33 -0
- opik/rest_api/types/provider_api_key.py +18 -8
- opik/rest_api/types/provider_api_key_page_public.py +27 -0
- opik/rest_api/types/provider_api_key_provider.py +1 -1
- opik/rest_api/types/provider_api_key_public.py +18 -8
- opik/rest_api/types/provider_api_key_public_provider.py +1 -1
- opik/rest_api/types/response_format.py +5 -7
- opik/rest_api/types/response_format_type.py +1 -3
- opik/rest_api/types/result.py +21 -0
- opik/rest_api/types/results_number_public.py +4 -6
- opik/rest_api/types/score_name.py +4 -5
- opik/rest_api/types/service_toggles_config.py +44 -0
- opik/rest_api/types/span.py +13 -15
- opik/rest_api/types/span_batch.py +4 -6
- opik/rest_api/types/span_enrichment_options.py +31 -0
- opik/rest_api/types/span_experiment_item_bulk_write_view.py +39 -0
- opik/rest_api/types/span_experiment_item_bulk_write_view_type.py +5 -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_public.py +4 -6
- opik/rest_api/types/span_filter_public_operator.py +2 -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_page_public.py +9 -6
- opik/rest_api/types/span_public.py +19 -16
- opik/rest_api/types/span_public_type.py +1 -1
- opik/rest_api/types/span_type.py +1 -1
- opik/rest_api/types/span_update.py +46 -0
- opik/rest_api/types/span_update_type.py +5 -0
- opik/rest_api/types/span_user_defined_metric_python_code.py +20 -0
- opik/rest_api/types/span_user_defined_metric_python_code_public.py +20 -0
- opik/rest_api/types/span_user_defined_metric_python_code_write.py +20 -0
- opik/rest_api/types/span_write.py +13 -14
- opik/rest_api/types/span_write_type.py +1 -1
- opik/rest_api/types/spans_count_response.py +20 -0
- opik/rest_api/types/start_multipart_upload_response.py +20 -0
- opik/rest_api/types/stream_options.py +3 -5
- 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/tool.py +4 -6
- opik/rest_api/types/tool_call.py +4 -6
- opik/rest_api/types/trace.py +26 -12
- opik/rest_api/types/trace_batch.py +4 -6
- opik/rest_api/types/trace_count_response.py +4 -6
- opik/rest_api/types/trace_enrichment_options.py +32 -0
- opik/rest_api/types/trace_experiment_item_bulk_write_view.py +41 -0
- opik/rest_api/types/trace_filter.py +23 -0
- opik/rest_api/types/trace_filter_operator.py +21 -0
- opik/rest_api/types/trace_filter_public.py +23 -0
- opik/rest_api/types/trace_filter_public_operator.py +21 -0
- opik/rest_api/types/trace_filter_write.py +23 -0
- opik/rest_api/types/trace_filter_write_operator.py +21 -0
- opik/rest_api/types/trace_page_public.py +8 -10
- opik/rest_api/types/trace_public.py +27 -13
- opik/rest_api/types/trace_public_visibility_mode.py +5 -0
- opik/rest_api/types/trace_thread.py +18 -9
- opik/rest_api/types/trace_thread_filter.py +23 -0
- opik/rest_api/types/trace_thread_filter_operator.py +21 -0
- opik/rest_api/types/trace_thread_filter_public.py +23 -0
- opik/rest_api/types/trace_thread_filter_public_operator.py +21 -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_identifier.py +22 -0
- opik/rest_api/types/trace_thread_llm_as_judge_code.py +26 -0
- opik/rest_api/types/trace_thread_llm_as_judge_code_public.py +26 -0
- opik/rest_api/types/trace_thread_llm_as_judge_code_write.py +26 -0
- opik/rest_api/types/trace_thread_page.py +9 -6
- opik/rest_api/types/trace_thread_status.py +5 -0
- opik/rest_api/types/trace_thread_update.py +19 -0
- opik/rest_api/types/trace_thread_user_defined_metric_python_code.py +19 -0
- opik/rest_api/types/trace_thread_user_defined_metric_python_code_public.py +19 -0
- opik/rest_api/types/trace_thread_user_defined_metric_python_code_write.py +19 -0
- opik/rest_api/types/trace_update.py +39 -0
- opik/rest_api/types/trace_visibility_mode.py +5 -0
- opik/rest_api/types/trace_write.py +10 -11
- opik/rest_api/types/usage.py +6 -6
- opik/rest_api/types/user_defined_metric_python_code.py +3 -5
- opik/rest_api/types/user_defined_metric_python_code_public.py +3 -5
- opik/rest_api/types/user_defined_metric_python_code_write.py +3 -5
- opik/rest_api/types/value_entry.py +27 -0
- opik/rest_api/types/value_entry_compare.py +27 -0
- opik/rest_api/types/value_entry_compare_source.py +5 -0
- opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +27 -0
- opik/rest_api/types/value_entry_experiment_item_bulk_write_view_source.py +5 -0
- opik/rest_api/types/value_entry_public.py +27 -0
- opik/rest_api/types/value_entry_public_source.py +5 -0
- opik/rest_api/types/value_entry_source.py +5 -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/rest_api/types/webhook.py +28 -0
- opik/rest_api/types/webhook_examples.py +19 -0
- opik/rest_api/types/webhook_public.py +28 -0
- opik/rest_api/types/webhook_test_result.py +23 -0
- opik/rest_api/types/webhook_test_result_status.py +5 -0
- opik/rest_api/types/webhook_write.py +23 -0
- opik/rest_api/types/welcome_wizard_tracking.py +22 -0
- opik/rest_api/types/workspace_configuration.py +27 -0
- opik/rest_api/types/workspace_metric_request.py +24 -0
- opik/rest_api/types/workspace_metric_response.py +20 -0
- opik/rest_api/types/workspace_metrics_summary_request.py +23 -0
- opik/rest_api/types/workspace_metrics_summary_response.py +20 -0
- opik/rest_api/types/workspace_name_holder.py +19 -0
- opik/rest_api/types/workspace_spans_count.py +20 -0
- opik/rest_api/types/workspace_trace_count.py +3 -5
- opik/rest_api/welcome_wizard/__init__.py +4 -0
- opik/rest_api/welcome_wizard/client.py +195 -0
- opik/rest_api/welcome_wizard/raw_client.py +208 -0
- opik/rest_api/workspaces/__init__.py +2 -0
- opik/rest_api/workspaces/client.py +550 -77
- opik/rest_api/workspaces/raw_client.py +923 -0
- opik/rest_client_configurator/api.py +1 -0
- opik/rest_client_configurator/retry_decorator.py +1 -0
- opik/s3_httpx_client.py +67 -0
- opik/simulation/__init__.py +6 -0
- opik/simulation/simulated_user.py +99 -0
- opik/simulation/simulator.py +108 -0
- opik/synchronization.py +11 -24
- opik/tracing_runtime_config.py +48 -0
- opik/types.py +48 -2
- opik/url_helpers.py +13 -3
- opik/validation/chat_prompt_messages.py +241 -0
- opik/validation/feedback_score.py +4 -5
- opik/validation/parameter.py +122 -0
- opik/validation/parameters_validator.py +175 -0
- opik/validation/validator.py +30 -2
- opik/validation/validator_helpers.py +147 -0
- opik-1.9.71.dist-info/METADATA +370 -0
- opik-1.9.71.dist-info/RECORD +1110 -0
- {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/WHEEL +1 -1
- opik-1.9.71.dist-info/licenses/LICENSE +203 -0
- opik/api_objects/prompt/prompt.py +0 -107
- opik/api_objects/prompt/prompt_template.py +0 -35
- opik/cli.py +0 -193
- opik/evaluation/metrics/models.py +0 -8
- opik/hooks.py +0 -13
- opik/integrations/bedrock/chunks_aggregator.py +0 -55
- opik/integrations/bedrock/helpers.py +0 -8
- opik/integrations/langchain/google_run_helpers.py +0 -75
- opik/integrations/langchain/openai_run_helpers.py +0 -122
- opik/message_processing/message_processors.py +0 -203
- opik/rest_api/types/delta_role.py +0 -7
- opik/rest_api/types/json_object_schema.py +0 -34
- opik-1.6.4.dist-info/METADATA +0 -270
- opik-1.6.4.dist-info/RECORD +0 -507
- /opik/integrations/bedrock/{stream_wrappers.py → converse/stream_wrappers.py} +0 -0
- {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/entry_points.txt +0 -0
- {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/top_level.txt +0 -0
opik/rest_api/datasets/client.py
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
5
6
|
from ..core.request_options import RequestOptions
|
|
6
|
-
from ..types.
|
|
7
|
-
from ..
|
|
8
|
-
from
|
|
9
|
-
from ..core.api_error import ApiError
|
|
10
|
-
from ..types.dataset_item_write import DatasetItemWrite
|
|
11
|
-
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
12
|
-
from ..types.dataset_public import DatasetPublic
|
|
13
|
-
from ..core.jsonable_encoder import jsonable_encoder
|
|
7
|
+
from ..types.dataset_expansion_response import DatasetExpansionResponse
|
|
8
|
+
from ..types.dataset_item_changes_public import DatasetItemChangesPublic
|
|
9
|
+
from ..types.dataset_item_filter import DatasetItemFilter
|
|
14
10
|
from ..types.dataset_item_page_compare import DatasetItemPageCompare
|
|
15
|
-
from ..types.dataset_item_public import DatasetItemPublic
|
|
16
11
|
from ..types.dataset_item_page_public import DatasetItemPagePublic
|
|
12
|
+
from ..types.dataset_item_public import DatasetItemPublic
|
|
13
|
+
from ..types.dataset_item_update import DatasetItemUpdate
|
|
14
|
+
from ..types.dataset_item_write import DatasetItemWrite
|
|
15
|
+
from ..types.dataset_item_write_source import DatasetItemWriteSource
|
|
16
|
+
from ..types.dataset_page_public import DatasetPagePublic
|
|
17
|
+
from ..types.dataset_public import DatasetPublic
|
|
18
|
+
from ..types.dataset_version_diff import DatasetVersionDiff
|
|
19
|
+
from ..types.dataset_version_page_public import DatasetVersionPagePublic
|
|
20
|
+
from ..types.dataset_version_public import DatasetVersionPublic
|
|
21
|
+
from ..types.json_node import JsonNode
|
|
17
22
|
from ..types.page_columns import PageColumns
|
|
18
|
-
from ..
|
|
23
|
+
from ..types.project_stats_public import ProjectStatsPublic
|
|
24
|
+
from ..types.span_enrichment_options import SpanEnrichmentOptions
|
|
25
|
+
from ..types.trace_enrichment_options import TraceEnrichmentOptions
|
|
26
|
+
from .raw_client import AsyncRawDatasetsClient, RawDatasetsClient
|
|
27
|
+
from .types.dataset_update_visibility import DatasetUpdateVisibility
|
|
28
|
+
from .types.dataset_write_visibility import DatasetWriteVisibility
|
|
19
29
|
|
|
20
30
|
# this is used as the default value for optional parameters
|
|
21
31
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -23,7 +33,116 @@ OMIT = typing.cast(typing.Any, ...)
|
|
|
23
33
|
|
|
24
34
|
class DatasetsClient:
|
|
25
35
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
26
|
-
self.
|
|
36
|
+
self._raw_client = RawDatasetsClient(client_wrapper=client_wrapper)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def with_raw_response(self) -> RawDatasetsClient:
|
|
40
|
+
"""
|
|
41
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
RawDatasetsClient
|
|
46
|
+
"""
|
|
47
|
+
return self._raw_client
|
|
48
|
+
|
|
49
|
+
def apply_dataset_item_changes(
|
|
50
|
+
self,
|
|
51
|
+
id: str,
|
|
52
|
+
*,
|
|
53
|
+
request: DatasetItemChangesPublic,
|
|
54
|
+
override: typing.Optional[bool] = None,
|
|
55
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
56
|
+
) -> DatasetVersionPublic:
|
|
57
|
+
"""
|
|
58
|
+
Apply delta changes (add, edit, delete) to a dataset version with conflict detection.
|
|
59
|
+
|
|
60
|
+
This endpoint:
|
|
61
|
+
- Creates a new version with the applied changes
|
|
62
|
+
- Validates that baseVersion matches the latest version (unless override=true)
|
|
63
|
+
- Returns 409 Conflict if baseVersion is stale and override is not set
|
|
64
|
+
|
|
65
|
+
Use `override=true` query parameter to force version creation even with stale baseVersion.
|
|
66
|
+
|
|
67
|
+
Parameters
|
|
68
|
+
----------
|
|
69
|
+
id : str
|
|
70
|
+
|
|
71
|
+
request : DatasetItemChangesPublic
|
|
72
|
+
|
|
73
|
+
override : typing.Optional[bool]
|
|
74
|
+
|
|
75
|
+
request_options : typing.Optional[RequestOptions]
|
|
76
|
+
Request-specific configuration.
|
|
77
|
+
|
|
78
|
+
Returns
|
|
79
|
+
-------
|
|
80
|
+
DatasetVersionPublic
|
|
81
|
+
Version created successfully
|
|
82
|
+
|
|
83
|
+
Examples
|
|
84
|
+
--------
|
|
85
|
+
from Opik import OpikApi
|
|
86
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
87
|
+
client.datasets.apply_dataset_item_changes(id='id', request={'key': 'value'
|
|
88
|
+
}, )
|
|
89
|
+
"""
|
|
90
|
+
_response = self._raw_client.apply_dataset_item_changes(
|
|
91
|
+
id, request=request, override=override, request_options=request_options
|
|
92
|
+
)
|
|
93
|
+
return _response.data
|
|
94
|
+
|
|
95
|
+
def batch_update_dataset_items(
|
|
96
|
+
self,
|
|
97
|
+
*,
|
|
98
|
+
update: DatasetItemUpdate,
|
|
99
|
+
ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
100
|
+
filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
|
|
101
|
+
dataset_id: typing.Optional[str] = OMIT,
|
|
102
|
+
merge_tags: typing.Optional[bool] = OMIT,
|
|
103
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
104
|
+
) -> None:
|
|
105
|
+
"""
|
|
106
|
+
Update multiple dataset items
|
|
107
|
+
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
update : DatasetItemUpdate
|
|
111
|
+
|
|
112
|
+
ids : typing.Optional[typing.Sequence[str]]
|
|
113
|
+
List of dataset item IDs to update (max 1000). Mutually exclusive with 'filters'.
|
|
114
|
+
|
|
115
|
+
filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
|
|
116
|
+
|
|
117
|
+
dataset_id : typing.Optional[str]
|
|
118
|
+
Dataset ID. Required when using 'filters', optional when using 'ids'.
|
|
119
|
+
|
|
120
|
+
merge_tags : typing.Optional[bool]
|
|
121
|
+
If true, merge tags with existing tags instead of replacing them. Default: false. When using 'filters', this is automatically set to true.
|
|
122
|
+
|
|
123
|
+
request_options : typing.Optional[RequestOptions]
|
|
124
|
+
Request-specific configuration.
|
|
125
|
+
|
|
126
|
+
Returns
|
|
127
|
+
-------
|
|
128
|
+
None
|
|
129
|
+
|
|
130
|
+
Examples
|
|
131
|
+
--------
|
|
132
|
+
from Opik import OpikApi
|
|
133
|
+
from Opik import DatasetItemUpdate
|
|
134
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
135
|
+
client.datasets.batch_update_dataset_items(update=DatasetItemUpdate(), )
|
|
136
|
+
"""
|
|
137
|
+
_response = self._raw_client.batch_update_dataset_items(
|
|
138
|
+
update=update,
|
|
139
|
+
ids=ids,
|
|
140
|
+
filters=filters,
|
|
141
|
+
dataset_id=dataset_id,
|
|
142
|
+
merge_tags=merge_tags,
|
|
143
|
+
request_options=request_options,
|
|
144
|
+
)
|
|
145
|
+
return _response.data
|
|
27
146
|
|
|
28
147
|
def find_datasets(
|
|
29
148
|
self,
|
|
@@ -31,9 +150,11 @@ class DatasetsClient:
|
|
|
31
150
|
page: typing.Optional[int] = None,
|
|
32
151
|
size: typing.Optional[int] = None,
|
|
33
152
|
with_experiments_only: typing.Optional[bool] = None,
|
|
153
|
+
with_optimizations_only: typing.Optional[bool] = None,
|
|
34
154
|
prompt_id: typing.Optional[str] = None,
|
|
35
155
|
name: typing.Optional[str] = None,
|
|
36
156
|
sorting: typing.Optional[str] = None,
|
|
157
|
+
filters: typing.Optional[str] = None,
|
|
37
158
|
request_options: typing.Optional[RequestOptions] = None,
|
|
38
159
|
) -> DatasetPagePublic:
|
|
39
160
|
"""
|
|
@@ -47,12 +168,16 @@ class DatasetsClient:
|
|
|
47
168
|
|
|
48
169
|
with_experiments_only : typing.Optional[bool]
|
|
49
170
|
|
|
171
|
+
with_optimizations_only : typing.Optional[bool]
|
|
172
|
+
|
|
50
173
|
prompt_id : typing.Optional[str]
|
|
51
174
|
|
|
52
175
|
name : typing.Optional[str]
|
|
53
176
|
|
|
54
177
|
sorting : typing.Optional[str]
|
|
55
178
|
|
|
179
|
+
filters : typing.Optional[str]
|
|
180
|
+
|
|
56
181
|
request_options : typing.Optional[RequestOptions]
|
|
57
182
|
Request-specific configuration.
|
|
58
183
|
|
|
@@ -64,45 +189,29 @@ class DatasetsClient:
|
|
|
64
189
|
Examples
|
|
65
190
|
--------
|
|
66
191
|
from Opik import OpikApi
|
|
67
|
-
|
|
68
|
-
client = OpikApi(
|
|
69
|
-
api_key="YOUR_API_KEY",
|
|
70
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
71
|
-
)
|
|
192
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
72
193
|
client.datasets.find_datasets()
|
|
73
194
|
"""
|
|
74
|
-
_response = self.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"sorting": sorting,
|
|
84
|
-
},
|
|
195
|
+
_response = self._raw_client.find_datasets(
|
|
196
|
+
page=page,
|
|
197
|
+
size=size,
|
|
198
|
+
with_experiments_only=with_experiments_only,
|
|
199
|
+
with_optimizations_only=with_optimizations_only,
|
|
200
|
+
prompt_id=prompt_id,
|
|
201
|
+
name=name,
|
|
202
|
+
sorting=sorting,
|
|
203
|
+
filters=filters,
|
|
85
204
|
request_options=request_options,
|
|
86
205
|
)
|
|
87
|
-
|
|
88
|
-
if 200 <= _response.status_code < 300:
|
|
89
|
-
return typing.cast(
|
|
90
|
-
DatasetPagePublic,
|
|
91
|
-
parse_obj_as(
|
|
92
|
-
type_=DatasetPagePublic, # type: ignore
|
|
93
|
-
object_=_response.json(),
|
|
94
|
-
),
|
|
95
|
-
)
|
|
96
|
-
_response_json = _response.json()
|
|
97
|
-
except JSONDecodeError:
|
|
98
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
99
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
206
|
+
return _response.data
|
|
100
207
|
|
|
101
208
|
def create_dataset(
|
|
102
209
|
self,
|
|
103
210
|
*,
|
|
104
211
|
name: str,
|
|
105
212
|
id: typing.Optional[str] = OMIT,
|
|
213
|
+
visibility: typing.Optional[DatasetWriteVisibility] = OMIT,
|
|
214
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
106
215
|
description: typing.Optional[str] = OMIT,
|
|
107
216
|
request_options: typing.Optional[RequestOptions] = None,
|
|
108
217
|
) -> None:
|
|
@@ -115,6 +224,10 @@ class DatasetsClient:
|
|
|
115
224
|
|
|
116
225
|
id : typing.Optional[str]
|
|
117
226
|
|
|
227
|
+
visibility : typing.Optional[DatasetWriteVisibility]
|
|
228
|
+
|
|
229
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
230
|
+
|
|
118
231
|
description : typing.Optional[str]
|
|
119
232
|
|
|
120
233
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -127,36 +240,13 @@ class DatasetsClient:
|
|
|
127
240
|
Examples
|
|
128
241
|
--------
|
|
129
242
|
from Opik import OpikApi
|
|
130
|
-
|
|
131
|
-
client
|
|
132
|
-
api_key="YOUR_API_KEY",
|
|
133
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
134
|
-
)
|
|
135
|
-
client.datasets.create_dataset(
|
|
136
|
-
name="name",
|
|
137
|
-
)
|
|
243
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
244
|
+
client.datasets.create_dataset(name='name', )
|
|
138
245
|
"""
|
|
139
|
-
_response = self.
|
|
140
|
-
|
|
141
|
-
method="POST",
|
|
142
|
-
json={
|
|
143
|
-
"id": id,
|
|
144
|
-
"name": name,
|
|
145
|
-
"description": description,
|
|
146
|
-
},
|
|
147
|
-
headers={
|
|
148
|
-
"content-type": "application/json",
|
|
149
|
-
},
|
|
150
|
-
request_options=request_options,
|
|
151
|
-
omit=OMIT,
|
|
246
|
+
_response = self._raw_client.create_dataset(
|
|
247
|
+
name=name, id=id, visibility=visibility, tags=tags, description=description, request_options=request_options
|
|
152
248
|
)
|
|
153
|
-
|
|
154
|
-
if 200 <= _response.status_code < 300:
|
|
155
|
-
return
|
|
156
|
-
_response_json = _response.json()
|
|
157
|
-
except JSONDecodeError:
|
|
158
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
159
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
249
|
+
return _response.data
|
|
160
250
|
|
|
161
251
|
def create_or_update_dataset_items(
|
|
162
252
|
self,
|
|
@@ -188,50 +278,131 @@ class DatasetsClient:
|
|
|
188
278
|
|
|
189
279
|
Examples
|
|
190
280
|
--------
|
|
191
|
-
from Opik import
|
|
281
|
+
from Opik import OpikApi
|
|
282
|
+
from Opik import DatasetItemWrite
|
|
283
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
284
|
+
client.datasets.create_or_update_dataset_items(items=[DatasetItemWrite(source="manual", data={'key': 'value'
|
|
285
|
+
}, )], )
|
|
286
|
+
"""
|
|
287
|
+
_response = self._raw_client.create_or_update_dataset_items(
|
|
288
|
+
items=items, dataset_name=dataset_name, dataset_id=dataset_id, request_options=request_options
|
|
289
|
+
)
|
|
290
|
+
return _response.data
|
|
291
|
+
|
|
292
|
+
def create_dataset_items_from_csv(
|
|
293
|
+
self,
|
|
294
|
+
*,
|
|
295
|
+
file: typing.Dict[str, typing.Optional[typing.Any]],
|
|
296
|
+
dataset_id: str,
|
|
297
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
298
|
+
) -> None:
|
|
299
|
+
"""
|
|
300
|
+
Create dataset items from uploaded CSV file. CSV should have headers in the first row. Processing happens asynchronously in batches.
|
|
301
|
+
|
|
302
|
+
Parameters
|
|
303
|
+
----------
|
|
304
|
+
file : typing.Dict[str, typing.Optional[typing.Any]]
|
|
305
|
+
|
|
306
|
+
dataset_id : str
|
|
307
|
+
|
|
308
|
+
request_options : typing.Optional[RequestOptions]
|
|
309
|
+
Request-specific configuration.
|
|
310
|
+
|
|
311
|
+
Returns
|
|
312
|
+
-------
|
|
313
|
+
None
|
|
192
314
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
315
|
+
Examples
|
|
316
|
+
--------
|
|
317
|
+
from Opik import OpikApi
|
|
318
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
319
|
+
client.datasets.create_dataset_items_from_csv(file={'key': 'value'
|
|
320
|
+
}, dataset_id='dataset_id', )
|
|
321
|
+
"""
|
|
322
|
+
_response = self._raw_client.create_dataset_items_from_csv(
|
|
323
|
+
file=file, dataset_id=dataset_id, request_options=request_options
|
|
196
324
|
)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
325
|
+
return _response.data
|
|
326
|
+
|
|
327
|
+
def create_dataset_items_from_spans(
|
|
328
|
+
self,
|
|
329
|
+
dataset_id: str,
|
|
330
|
+
*,
|
|
331
|
+
span_ids: typing.Sequence[str],
|
|
332
|
+
enrichment_options: SpanEnrichmentOptions,
|
|
333
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
334
|
+
) -> None:
|
|
335
|
+
"""
|
|
336
|
+
Create dataset items from spans with enriched metadata
|
|
337
|
+
|
|
338
|
+
Parameters
|
|
339
|
+
----------
|
|
340
|
+
dataset_id : str
|
|
341
|
+
|
|
342
|
+
span_ids : typing.Sequence[str]
|
|
343
|
+
Set of span IDs to add to the dataset
|
|
344
|
+
|
|
345
|
+
enrichment_options : SpanEnrichmentOptions
|
|
346
|
+
|
|
347
|
+
request_options : typing.Optional[RequestOptions]
|
|
348
|
+
Request-specific configuration.
|
|
349
|
+
|
|
350
|
+
Returns
|
|
351
|
+
-------
|
|
352
|
+
None
|
|
353
|
+
|
|
354
|
+
Examples
|
|
355
|
+
--------
|
|
356
|
+
from Opik import OpikApi
|
|
357
|
+
from Opik import SpanEnrichmentOptions
|
|
358
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
359
|
+
client.datasets.create_dataset_items_from_spans(dataset_id='dataset_id', span_ids=['span_ids'], enrichment_options=SpanEnrichmentOptions(), )
|
|
360
|
+
"""
|
|
361
|
+
_response = self._raw_client.create_dataset_items_from_spans(
|
|
362
|
+
dataset_id, span_ids=span_ids, enrichment_options=enrichment_options, request_options=request_options
|
|
204
363
|
)
|
|
364
|
+
return _response.data
|
|
365
|
+
|
|
366
|
+
def create_dataset_items_from_traces(
|
|
367
|
+
self,
|
|
368
|
+
dataset_id: str,
|
|
369
|
+
*,
|
|
370
|
+
trace_ids: typing.Sequence[str],
|
|
371
|
+
enrichment_options: TraceEnrichmentOptions,
|
|
372
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
373
|
+
) -> None:
|
|
205
374
|
"""
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
375
|
+
Create dataset items from traces with enriched metadata
|
|
376
|
+
|
|
377
|
+
Parameters
|
|
378
|
+
----------
|
|
379
|
+
dataset_id : str
|
|
380
|
+
|
|
381
|
+
trace_ids : typing.Sequence[str]
|
|
382
|
+
Set of trace IDs to add to the dataset
|
|
383
|
+
|
|
384
|
+
enrichment_options : TraceEnrichmentOptions
|
|
385
|
+
|
|
386
|
+
request_options : typing.Optional[RequestOptions]
|
|
387
|
+
Request-specific configuration.
|
|
388
|
+
|
|
389
|
+
Returns
|
|
390
|
+
-------
|
|
391
|
+
None
|
|
392
|
+
|
|
393
|
+
Examples
|
|
394
|
+
--------
|
|
395
|
+
from Opik import OpikApi
|
|
396
|
+
from Opik import TraceEnrichmentOptions
|
|
397
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
398
|
+
client.datasets.create_dataset_items_from_traces(dataset_id='dataset_id', trace_ids=['trace_ids'], enrichment_options=TraceEnrichmentOptions(), )
|
|
399
|
+
"""
|
|
400
|
+
_response = self._raw_client.create_dataset_items_from_traces(
|
|
401
|
+
dataset_id, trace_ids=trace_ids, enrichment_options=enrichment_options, request_options=request_options
|
|
223
402
|
)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
_response_json = _response.json()
|
|
228
|
-
except JSONDecodeError:
|
|
229
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
230
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
231
|
-
|
|
232
|
-
def get_dataset_by_id(
|
|
233
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
234
|
-
) -> DatasetPublic:
|
|
403
|
+
return _response.data
|
|
404
|
+
|
|
405
|
+
def get_dataset_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DatasetPublic:
|
|
235
406
|
"""
|
|
236
407
|
Get dataset by id
|
|
237
408
|
|
|
@@ -250,33 +421,11 @@ class DatasetsClient:
|
|
|
250
421
|
Examples
|
|
251
422
|
--------
|
|
252
423
|
from Opik import OpikApi
|
|
253
|
-
|
|
254
|
-
client
|
|
255
|
-
api_key="YOUR_API_KEY",
|
|
256
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
257
|
-
)
|
|
258
|
-
client.datasets.get_dataset_by_id(
|
|
259
|
-
id="id",
|
|
260
|
-
)
|
|
424
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
425
|
+
client.datasets.get_dataset_by_id(id='id', )
|
|
261
426
|
"""
|
|
262
|
-
_response = self.
|
|
263
|
-
|
|
264
|
-
method="GET",
|
|
265
|
-
request_options=request_options,
|
|
266
|
-
)
|
|
267
|
-
try:
|
|
268
|
-
if 200 <= _response.status_code < 300:
|
|
269
|
-
return typing.cast(
|
|
270
|
-
DatasetPublic,
|
|
271
|
-
parse_obj_as(
|
|
272
|
-
type_=DatasetPublic, # type: ignore
|
|
273
|
-
object_=_response.json(),
|
|
274
|
-
),
|
|
275
|
-
)
|
|
276
|
-
_response_json = _response.json()
|
|
277
|
-
except JSONDecodeError:
|
|
278
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
279
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
427
|
+
_response = self._raw_client.get_dataset_by_id(id, request_options=request_options)
|
|
428
|
+
return _response.data
|
|
280
429
|
|
|
281
430
|
def update_dataset(
|
|
282
431
|
self,
|
|
@@ -284,6 +433,8 @@ class DatasetsClient:
|
|
|
284
433
|
*,
|
|
285
434
|
name: str,
|
|
286
435
|
description: typing.Optional[str] = OMIT,
|
|
436
|
+
visibility: typing.Optional[DatasetUpdateVisibility] = OMIT,
|
|
437
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
287
438
|
request_options: typing.Optional[RequestOptions] = None,
|
|
288
439
|
) -> None:
|
|
289
440
|
"""
|
|
@@ -297,6 +448,10 @@ class DatasetsClient:
|
|
|
297
448
|
|
|
298
449
|
description : typing.Optional[str]
|
|
299
450
|
|
|
451
|
+
visibility : typing.Optional[DatasetUpdateVisibility]
|
|
452
|
+
|
|
453
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
454
|
+
|
|
300
455
|
request_options : typing.Optional[RequestOptions]
|
|
301
456
|
Request-specific configuration.
|
|
302
457
|
|
|
@@ -307,40 +462,15 @@ class DatasetsClient:
|
|
|
307
462
|
Examples
|
|
308
463
|
--------
|
|
309
464
|
from Opik import OpikApi
|
|
310
|
-
|
|
311
|
-
client =
|
|
312
|
-
api_key="YOUR_API_KEY",
|
|
313
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
314
|
-
)
|
|
315
|
-
client.datasets.update_dataset(
|
|
316
|
-
id="id",
|
|
317
|
-
name="name",
|
|
318
|
-
)
|
|
465
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
466
|
+
client.datasets.update_dataset(id='id', name='name', )
|
|
319
467
|
"""
|
|
320
|
-
_response = self.
|
|
321
|
-
|
|
322
|
-
method="PUT",
|
|
323
|
-
json={
|
|
324
|
-
"name": name,
|
|
325
|
-
"description": description,
|
|
326
|
-
},
|
|
327
|
-
headers={
|
|
328
|
-
"content-type": "application/json",
|
|
329
|
-
},
|
|
330
|
-
request_options=request_options,
|
|
331
|
-
omit=OMIT,
|
|
468
|
+
_response = self._raw_client.update_dataset(
|
|
469
|
+
id, name=name, description=description, visibility=visibility, tags=tags, request_options=request_options
|
|
332
470
|
)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
_response_json = _response.json()
|
|
337
|
-
except JSONDecodeError:
|
|
338
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
339
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
340
|
-
|
|
341
|
-
def delete_dataset(
|
|
342
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
343
|
-
) -> None:
|
|
471
|
+
return _response.data
|
|
472
|
+
|
|
473
|
+
def delete_dataset(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
344
474
|
"""
|
|
345
475
|
Delete dataset by id
|
|
346
476
|
|
|
@@ -358,33 +488,14 @@ class DatasetsClient:
|
|
|
358
488
|
Examples
|
|
359
489
|
--------
|
|
360
490
|
from Opik import OpikApi
|
|
361
|
-
|
|
362
|
-
client
|
|
363
|
-
api_key="YOUR_API_KEY",
|
|
364
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
365
|
-
)
|
|
366
|
-
client.datasets.delete_dataset(
|
|
367
|
-
id="id",
|
|
368
|
-
)
|
|
491
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
492
|
+
client.datasets.delete_dataset(id='id', )
|
|
369
493
|
"""
|
|
370
|
-
_response = self.
|
|
371
|
-
|
|
372
|
-
method="DELETE",
|
|
373
|
-
request_options=request_options,
|
|
374
|
-
)
|
|
375
|
-
try:
|
|
376
|
-
if 200 <= _response.status_code < 300:
|
|
377
|
-
return
|
|
378
|
-
_response_json = _response.json()
|
|
379
|
-
except JSONDecodeError:
|
|
380
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
381
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
494
|
+
_response = self._raw_client.delete_dataset(id, request_options=request_options)
|
|
495
|
+
return _response.data
|
|
382
496
|
|
|
383
497
|
def delete_dataset_by_name(
|
|
384
|
-
self,
|
|
385
|
-
*,
|
|
386
|
-
dataset_name: str,
|
|
387
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
498
|
+
self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
|
|
388
499
|
) -> None:
|
|
389
500
|
"""
|
|
390
501
|
Delete dataset by name
|
|
@@ -403,47 +514,37 @@ class DatasetsClient:
|
|
|
403
514
|
Examples
|
|
404
515
|
--------
|
|
405
516
|
from Opik import OpikApi
|
|
406
|
-
|
|
407
|
-
client
|
|
408
|
-
api_key="YOUR_API_KEY",
|
|
409
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
410
|
-
)
|
|
411
|
-
client.datasets.delete_dataset_by_name(
|
|
412
|
-
dataset_name="dataset_name",
|
|
413
|
-
)
|
|
517
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
518
|
+
client.datasets.delete_dataset_by_name(dataset_name='dataset_name', )
|
|
414
519
|
"""
|
|
415
|
-
_response = self.
|
|
416
|
-
|
|
417
|
-
method="POST",
|
|
418
|
-
json={
|
|
419
|
-
"dataset_name": dataset_name,
|
|
420
|
-
},
|
|
421
|
-
headers={
|
|
422
|
-
"content-type": "application/json",
|
|
423
|
-
},
|
|
424
|
-
request_options=request_options,
|
|
425
|
-
omit=OMIT,
|
|
426
|
-
)
|
|
427
|
-
try:
|
|
428
|
-
if 200 <= _response.status_code < 300:
|
|
429
|
-
return
|
|
430
|
-
_response_json = _response.json()
|
|
431
|
-
except JSONDecodeError:
|
|
432
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
433
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
520
|
+
_response = self._raw_client.delete_dataset_by_name(dataset_name=dataset_name, request_options=request_options)
|
|
521
|
+
return _response.data
|
|
434
522
|
|
|
435
523
|
def delete_dataset_items(
|
|
436
524
|
self,
|
|
437
525
|
*,
|
|
438
|
-
item_ids: typing.Sequence[str],
|
|
526
|
+
item_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
527
|
+
dataset_id: typing.Optional[str] = OMIT,
|
|
528
|
+
filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
|
|
439
529
|
request_options: typing.Optional[RequestOptions] = None,
|
|
440
530
|
) -> None:
|
|
441
531
|
"""
|
|
442
|
-
Delete dataset items
|
|
532
|
+
Delete dataset items using one of two modes:
|
|
533
|
+
1. **Delete by IDs**: Provide 'item_ids' to delete specific items by their IDs
|
|
534
|
+
2. **Delete by filters**: Provide 'dataset_id' with optional 'filters' to delete items matching criteria
|
|
535
|
+
|
|
536
|
+
When using filters, an empty 'filters' array will delete all items in the specified dataset.
|
|
443
537
|
|
|
444
538
|
Parameters
|
|
445
539
|
----------
|
|
446
|
-
item_ids : typing.Sequence[str]
|
|
540
|
+
item_ids : typing.Optional[typing.Sequence[str]]
|
|
541
|
+
List of dataset item IDs to delete (max 1000). Use this to delete specific items by their IDs. Mutually exclusive with 'dataset_id' and 'filters'.
|
|
542
|
+
|
|
543
|
+
dataset_id : typing.Optional[str]
|
|
544
|
+
Dataset ID to scope the deletion. Required when using 'filters'. Mutually exclusive with 'item_ids'.
|
|
545
|
+
|
|
546
|
+
filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
|
|
547
|
+
Filters to select dataset items to delete within the specified dataset. Must be used with 'dataset_id'. Mutually exclusive with 'item_ids'. Empty array means 'delete all items in the dataset'.
|
|
447
548
|
|
|
448
549
|
request_options : typing.Optional[RequestOptions]
|
|
449
550
|
Request-specific configuration.
|
|
@@ -455,40 +556,16 @@ class DatasetsClient:
|
|
|
455
556
|
Examples
|
|
456
557
|
--------
|
|
457
558
|
from Opik import OpikApi
|
|
458
|
-
|
|
459
|
-
client
|
|
460
|
-
api_key="YOUR_API_KEY",
|
|
461
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
462
|
-
)
|
|
463
|
-
client.datasets.delete_dataset_items(
|
|
464
|
-
item_ids=["item_ids"],
|
|
465
|
-
)
|
|
559
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
560
|
+
client.datasets.delete_dataset_items()
|
|
466
561
|
"""
|
|
467
|
-
_response = self.
|
|
468
|
-
|
|
469
|
-
method="POST",
|
|
470
|
-
json={
|
|
471
|
-
"item_ids": item_ids,
|
|
472
|
-
},
|
|
473
|
-
headers={
|
|
474
|
-
"content-type": "application/json",
|
|
475
|
-
},
|
|
476
|
-
request_options=request_options,
|
|
477
|
-
omit=OMIT,
|
|
562
|
+
_response = self._raw_client.delete_dataset_items(
|
|
563
|
+
item_ids=item_ids, dataset_id=dataset_id, filters=filters, request_options=request_options
|
|
478
564
|
)
|
|
479
|
-
|
|
480
|
-
if 200 <= _response.status_code < 300:
|
|
481
|
-
return
|
|
482
|
-
_response_json = _response.json()
|
|
483
|
-
except JSONDecodeError:
|
|
484
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
485
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
565
|
+
return _response.data
|
|
486
566
|
|
|
487
567
|
def delete_datasets_batch(
|
|
488
|
-
self,
|
|
489
|
-
*,
|
|
490
|
-
ids: typing.Sequence[str],
|
|
491
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
568
|
+
self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
|
492
569
|
) -> None:
|
|
493
570
|
"""
|
|
494
571
|
Delete datasets batch
|
|
@@ -507,31 +584,69 @@ class DatasetsClient:
|
|
|
507
584
|
Examples
|
|
508
585
|
--------
|
|
509
586
|
from Opik import OpikApi
|
|
587
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
588
|
+
client.datasets.delete_datasets_batch(ids=['ids'], )
|
|
589
|
+
"""
|
|
590
|
+
_response = self._raw_client.delete_datasets_batch(ids=ids, request_options=request_options)
|
|
591
|
+
return _response.data
|
|
510
592
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
593
|
+
def expand_dataset(
|
|
594
|
+
self,
|
|
595
|
+
id: str,
|
|
596
|
+
*,
|
|
597
|
+
model: str,
|
|
598
|
+
sample_count: typing.Optional[int] = OMIT,
|
|
599
|
+
preserve_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
600
|
+
variation_instructions: typing.Optional[str] = OMIT,
|
|
601
|
+
custom_prompt: typing.Optional[str] = OMIT,
|
|
602
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
603
|
+
) -> DatasetExpansionResponse:
|
|
604
|
+
"""
|
|
605
|
+
Generate synthetic dataset samples using LLM based on existing data patterns
|
|
606
|
+
|
|
607
|
+
Parameters
|
|
608
|
+
----------
|
|
609
|
+
id : str
|
|
610
|
+
|
|
611
|
+
model : str
|
|
612
|
+
The model to use for synthetic data generation
|
|
613
|
+
|
|
614
|
+
sample_count : typing.Optional[int]
|
|
615
|
+
Number of synthetic samples to generate
|
|
616
|
+
|
|
617
|
+
preserve_fields : typing.Optional[typing.Sequence[str]]
|
|
618
|
+
Fields to preserve patterns from original data
|
|
619
|
+
|
|
620
|
+
variation_instructions : typing.Optional[str]
|
|
621
|
+
Additional instructions for data variation
|
|
622
|
+
|
|
623
|
+
custom_prompt : typing.Optional[str]
|
|
624
|
+
Custom prompt to use for generation instead of auto-generated one
|
|
625
|
+
|
|
626
|
+
request_options : typing.Optional[RequestOptions]
|
|
627
|
+
Request-specific configuration.
|
|
628
|
+
|
|
629
|
+
Returns
|
|
630
|
+
-------
|
|
631
|
+
DatasetExpansionResponse
|
|
632
|
+
Generated synthetic samples
|
|
633
|
+
|
|
634
|
+
Examples
|
|
635
|
+
--------
|
|
636
|
+
from Opik import OpikApi
|
|
637
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
638
|
+
client.datasets.expand_dataset(id='id', model='gpt-4', )
|
|
518
639
|
"""
|
|
519
|
-
_response = self.
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
640
|
+
_response = self._raw_client.expand_dataset(
|
|
641
|
+
id,
|
|
642
|
+
model=model,
|
|
643
|
+
sample_count=sample_count,
|
|
644
|
+
preserve_fields=preserve_fields,
|
|
645
|
+
variation_instructions=variation_instructions,
|
|
646
|
+
custom_prompt=custom_prompt,
|
|
525
647
|
request_options=request_options,
|
|
526
|
-
omit=OMIT,
|
|
527
648
|
)
|
|
528
|
-
|
|
529
|
-
if 200 <= _response.status_code < 300:
|
|
530
|
-
return
|
|
531
|
-
_response_json = _response.json()
|
|
532
|
-
except JSONDecodeError:
|
|
533
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
534
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
649
|
+
return _response.data
|
|
535
650
|
|
|
536
651
|
def find_dataset_items_with_experiment_items(
|
|
537
652
|
self,
|
|
@@ -541,6 +656,8 @@ class DatasetsClient:
|
|
|
541
656
|
page: typing.Optional[int] = None,
|
|
542
657
|
size: typing.Optional[int] = None,
|
|
543
658
|
filters: typing.Optional[str] = None,
|
|
659
|
+
sorting: typing.Optional[str] = None,
|
|
660
|
+
search: typing.Optional[str] = None,
|
|
544
661
|
truncate: typing.Optional[bool] = None,
|
|
545
662
|
request_options: typing.Optional[RequestOptions] = None,
|
|
546
663
|
) -> DatasetItemPageCompare:
|
|
@@ -559,6 +676,10 @@ class DatasetsClient:
|
|
|
559
676
|
|
|
560
677
|
filters : typing.Optional[str]
|
|
561
678
|
|
|
679
|
+
sorting : typing.Optional[str]
|
|
680
|
+
|
|
681
|
+
search : typing.Optional[str]
|
|
682
|
+
|
|
562
683
|
truncate : typing.Optional[bool]
|
|
563
684
|
|
|
564
685
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -572,47 +693,24 @@ class DatasetsClient:
|
|
|
572
693
|
Examples
|
|
573
694
|
--------
|
|
574
695
|
from Opik import OpikApi
|
|
575
|
-
|
|
576
|
-
client =
|
|
577
|
-
api_key="YOUR_API_KEY",
|
|
578
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
579
|
-
)
|
|
580
|
-
client.datasets.find_dataset_items_with_experiment_items(
|
|
581
|
-
id="id",
|
|
582
|
-
experiment_ids="experiment_ids",
|
|
583
|
-
)
|
|
696
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
697
|
+
client.datasets.find_dataset_items_with_experiment_items(id='id', experiment_ids='experiment_ids', )
|
|
584
698
|
"""
|
|
585
|
-
_response = self.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
},
|
|
699
|
+
_response = self._raw_client.find_dataset_items_with_experiment_items(
|
|
700
|
+
id,
|
|
701
|
+
experiment_ids=experiment_ids,
|
|
702
|
+
page=page,
|
|
703
|
+
size=size,
|
|
704
|
+
filters=filters,
|
|
705
|
+
sorting=sorting,
|
|
706
|
+
search=search,
|
|
707
|
+
truncate=truncate,
|
|
595
708
|
request_options=request_options,
|
|
596
709
|
)
|
|
597
|
-
|
|
598
|
-
if 200 <= _response.status_code < 300:
|
|
599
|
-
return typing.cast(
|
|
600
|
-
DatasetItemPageCompare,
|
|
601
|
-
parse_obj_as(
|
|
602
|
-
type_=DatasetItemPageCompare, # type: ignore
|
|
603
|
-
object_=_response.json(),
|
|
604
|
-
),
|
|
605
|
-
)
|
|
606
|
-
_response_json = _response.json()
|
|
607
|
-
except JSONDecodeError:
|
|
608
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
609
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
710
|
+
return _response.data
|
|
610
711
|
|
|
611
712
|
def get_dataset_by_identifier(
|
|
612
|
-
self,
|
|
613
|
-
*,
|
|
614
|
-
dataset_name: str,
|
|
615
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
713
|
+
self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
|
|
616
714
|
) -> DatasetPublic:
|
|
617
715
|
"""
|
|
618
716
|
Get dataset by name
|
|
@@ -632,89 +730,135 @@ class DatasetsClient:
|
|
|
632
730
|
Examples
|
|
633
731
|
--------
|
|
634
732
|
from Opik import OpikApi
|
|
635
|
-
|
|
636
|
-
client
|
|
637
|
-
api_key="YOUR_API_KEY",
|
|
638
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
639
|
-
)
|
|
640
|
-
client.datasets.get_dataset_by_identifier(
|
|
641
|
-
dataset_name="dataset_name",
|
|
642
|
-
)
|
|
733
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
734
|
+
client.datasets.get_dataset_by_identifier(dataset_name='dataset_name', )
|
|
643
735
|
"""
|
|
644
|
-
_response = self.
|
|
645
|
-
|
|
646
|
-
method="POST",
|
|
647
|
-
json={
|
|
648
|
-
"dataset_name": dataset_name,
|
|
649
|
-
},
|
|
650
|
-
headers={
|
|
651
|
-
"content-type": "application/json",
|
|
652
|
-
},
|
|
653
|
-
request_options=request_options,
|
|
654
|
-
omit=OMIT,
|
|
736
|
+
_response = self._raw_client.get_dataset_by_identifier(
|
|
737
|
+
dataset_name=dataset_name, request_options=request_options
|
|
655
738
|
)
|
|
656
|
-
|
|
657
|
-
if 200 <= _response.status_code < 300:
|
|
658
|
-
return typing.cast(
|
|
659
|
-
DatasetPublic,
|
|
660
|
-
parse_obj_as(
|
|
661
|
-
type_=DatasetPublic, # type: ignore
|
|
662
|
-
object_=_response.json(),
|
|
663
|
-
),
|
|
664
|
-
)
|
|
665
|
-
_response_json = _response.json()
|
|
666
|
-
except JSONDecodeError:
|
|
667
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
668
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
739
|
+
return _response.data
|
|
669
740
|
|
|
670
|
-
def
|
|
671
|
-
self,
|
|
672
|
-
|
|
741
|
+
def get_dataset_experiment_items_stats(
|
|
742
|
+
self,
|
|
743
|
+
id: str,
|
|
744
|
+
*,
|
|
745
|
+
experiment_ids: str,
|
|
746
|
+
filters: typing.Optional[str] = None,
|
|
747
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
748
|
+
) -> ProjectStatsPublic:
|
|
673
749
|
"""
|
|
674
|
-
Get
|
|
750
|
+
Get experiment items stats for dataset
|
|
675
751
|
|
|
676
752
|
Parameters
|
|
677
753
|
----------
|
|
678
|
-
|
|
754
|
+
id : str
|
|
755
|
+
|
|
756
|
+
experiment_ids : str
|
|
757
|
+
|
|
758
|
+
filters : typing.Optional[str]
|
|
679
759
|
|
|
680
760
|
request_options : typing.Optional[RequestOptions]
|
|
681
761
|
Request-specific configuration.
|
|
682
762
|
|
|
683
763
|
Returns
|
|
684
764
|
-------
|
|
685
|
-
|
|
686
|
-
|
|
765
|
+
ProjectStatsPublic
|
|
766
|
+
Experiment items stats resource
|
|
687
767
|
|
|
688
768
|
Examples
|
|
689
769
|
--------
|
|
690
770
|
from Opik import OpikApi
|
|
691
|
-
|
|
692
|
-
client =
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
client.datasets.get_dataset_item_by_id(
|
|
697
|
-
item_id="itemId",
|
|
771
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
772
|
+
client.datasets.get_dataset_experiment_items_stats(id='id', experiment_ids='experiment_ids', )
|
|
773
|
+
"""
|
|
774
|
+
_response = self._raw_client.get_dataset_experiment_items_stats(
|
|
775
|
+
id, experiment_ids=experiment_ids, filters=filters, request_options=request_options
|
|
698
776
|
)
|
|
777
|
+
return _response.data
|
|
778
|
+
|
|
779
|
+
def get_dataset_item_by_id(
|
|
780
|
+
self, item_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
781
|
+
) -> DatasetItemPublic:
|
|
782
|
+
"""
|
|
783
|
+
Get dataset item by id
|
|
784
|
+
|
|
785
|
+
Parameters
|
|
786
|
+
----------
|
|
787
|
+
item_id : str
|
|
788
|
+
|
|
789
|
+
request_options : typing.Optional[RequestOptions]
|
|
790
|
+
Request-specific configuration.
|
|
791
|
+
|
|
792
|
+
Returns
|
|
793
|
+
-------
|
|
794
|
+
DatasetItemPublic
|
|
795
|
+
Dataset item resource
|
|
796
|
+
|
|
797
|
+
Examples
|
|
798
|
+
--------
|
|
799
|
+
from Opik import OpikApi
|
|
800
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
801
|
+
client.datasets.get_dataset_item_by_id(item_id='itemId', )
|
|
802
|
+
"""
|
|
803
|
+
_response = self._raw_client.get_dataset_item_by_id(item_id, request_options=request_options)
|
|
804
|
+
return _response.data
|
|
805
|
+
|
|
806
|
+
def patch_dataset_item(
|
|
807
|
+
self,
|
|
808
|
+
item_id: str,
|
|
809
|
+
*,
|
|
810
|
+
source: DatasetItemWriteSource,
|
|
811
|
+
data: JsonNode,
|
|
812
|
+
id: typing.Optional[str] = OMIT,
|
|
813
|
+
trace_id: typing.Optional[str] = OMIT,
|
|
814
|
+
span_id: typing.Optional[str] = OMIT,
|
|
815
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
816
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
817
|
+
) -> None:
|
|
818
|
+
"""
|
|
819
|
+
Partially update dataset item by id. Only provided fields will be updated.
|
|
820
|
+
|
|
821
|
+
Parameters
|
|
822
|
+
----------
|
|
823
|
+
item_id : str
|
|
824
|
+
|
|
825
|
+
source : DatasetItemWriteSource
|
|
826
|
+
|
|
827
|
+
data : JsonNode
|
|
828
|
+
|
|
829
|
+
id : typing.Optional[str]
|
|
830
|
+
|
|
831
|
+
trace_id : typing.Optional[str]
|
|
832
|
+
|
|
833
|
+
span_id : typing.Optional[str]
|
|
834
|
+
|
|
835
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
836
|
+
|
|
837
|
+
request_options : typing.Optional[RequestOptions]
|
|
838
|
+
Request-specific configuration.
|
|
839
|
+
|
|
840
|
+
Returns
|
|
841
|
+
-------
|
|
842
|
+
None
|
|
843
|
+
|
|
844
|
+
Examples
|
|
845
|
+
--------
|
|
846
|
+
from Opik import OpikApi
|
|
847
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
848
|
+
client.datasets.patch_dataset_item(item_id='itemId', source="manual", data={'key': 'value'
|
|
849
|
+
}, )
|
|
699
850
|
"""
|
|
700
|
-
_response = self.
|
|
701
|
-
|
|
702
|
-
|
|
851
|
+
_response = self._raw_client.patch_dataset_item(
|
|
852
|
+
item_id,
|
|
853
|
+
source=source,
|
|
854
|
+
data=data,
|
|
855
|
+
id=id,
|
|
856
|
+
trace_id=trace_id,
|
|
857
|
+
span_id=span_id,
|
|
858
|
+
tags=tags,
|
|
703
859
|
request_options=request_options,
|
|
704
860
|
)
|
|
705
|
-
|
|
706
|
-
if 200 <= _response.status_code < 300:
|
|
707
|
-
return typing.cast(
|
|
708
|
-
DatasetItemPublic,
|
|
709
|
-
parse_obj_as(
|
|
710
|
-
type_=DatasetItemPublic, # type: ignore
|
|
711
|
-
object_=_response.json(),
|
|
712
|
-
),
|
|
713
|
-
)
|
|
714
|
-
_response_json = _response.json()
|
|
715
|
-
except JSONDecodeError:
|
|
716
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
717
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
861
|
+
return _response.data
|
|
718
862
|
|
|
719
863
|
def get_dataset_items(
|
|
720
864
|
self,
|
|
@@ -722,6 +866,8 @@ class DatasetsClient:
|
|
|
722
866
|
*,
|
|
723
867
|
page: typing.Optional[int] = None,
|
|
724
868
|
size: typing.Optional[int] = None,
|
|
869
|
+
version: typing.Optional[str] = None,
|
|
870
|
+
filters: typing.Optional[str] = None,
|
|
725
871
|
truncate: typing.Optional[bool] = None,
|
|
726
872
|
request_options: typing.Optional[RequestOptions] = None,
|
|
727
873
|
) -> DatasetItemPagePublic:
|
|
@@ -736,6 +882,10 @@ class DatasetsClient:
|
|
|
736
882
|
|
|
737
883
|
size : typing.Optional[int]
|
|
738
884
|
|
|
885
|
+
version : typing.Optional[str]
|
|
886
|
+
|
|
887
|
+
filters : typing.Optional[str]
|
|
888
|
+
|
|
739
889
|
truncate : typing.Optional[bool]
|
|
740
890
|
|
|
741
891
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -749,38 +899,19 @@ class DatasetsClient:
|
|
|
749
899
|
Examples
|
|
750
900
|
--------
|
|
751
901
|
from Opik import OpikApi
|
|
752
|
-
|
|
753
|
-
client
|
|
754
|
-
api_key="YOUR_API_KEY",
|
|
755
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
756
|
-
)
|
|
757
|
-
client.datasets.get_dataset_items(
|
|
758
|
-
id="id",
|
|
759
|
-
)
|
|
902
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
903
|
+
client.datasets.get_dataset_items(id='id', )
|
|
760
904
|
"""
|
|
761
|
-
_response = self.
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
},
|
|
905
|
+
_response = self._raw_client.get_dataset_items(
|
|
906
|
+
id,
|
|
907
|
+
page=page,
|
|
908
|
+
size=size,
|
|
909
|
+
version=version,
|
|
910
|
+
filters=filters,
|
|
911
|
+
truncate=truncate,
|
|
769
912
|
request_options=request_options,
|
|
770
913
|
)
|
|
771
|
-
|
|
772
|
-
if 200 <= _response.status_code < 300:
|
|
773
|
-
return typing.cast(
|
|
774
|
-
DatasetItemPagePublic,
|
|
775
|
-
parse_obj_as(
|
|
776
|
-
type_=DatasetItemPagePublic, # type: ignore
|
|
777
|
-
object_=_response.json(),
|
|
778
|
-
),
|
|
779
|
-
)
|
|
780
|
-
_response_json = _response.json()
|
|
781
|
-
except JSONDecodeError:
|
|
782
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
783
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
914
|
+
return _response.data
|
|
784
915
|
|
|
785
916
|
def get_dataset_items_output_columns(
|
|
786
917
|
self,
|
|
@@ -809,36 +940,13 @@ class DatasetsClient:
|
|
|
809
940
|
Examples
|
|
810
941
|
--------
|
|
811
942
|
from Opik import OpikApi
|
|
812
|
-
|
|
813
|
-
client
|
|
814
|
-
api_key="YOUR_API_KEY",
|
|
815
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
816
|
-
)
|
|
817
|
-
client.datasets.get_dataset_items_output_columns(
|
|
818
|
-
id="id",
|
|
819
|
-
)
|
|
943
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
944
|
+
client.datasets.get_dataset_items_output_columns(id='id', )
|
|
820
945
|
"""
|
|
821
|
-
_response = self.
|
|
822
|
-
|
|
823
|
-
method="GET",
|
|
824
|
-
params={
|
|
825
|
-
"experiment_ids": experiment_ids,
|
|
826
|
-
},
|
|
827
|
-
request_options=request_options,
|
|
946
|
+
_response = self._raw_client.get_dataset_items_output_columns(
|
|
947
|
+
id, experiment_ids=experiment_ids, request_options=request_options
|
|
828
948
|
)
|
|
829
|
-
|
|
830
|
-
if 200 <= _response.status_code < 300:
|
|
831
|
-
return typing.cast(
|
|
832
|
-
PageColumns,
|
|
833
|
-
parse_obj_as(
|
|
834
|
-
type_=PageColumns, # type: ignore
|
|
835
|
-
object_=_response.json(),
|
|
836
|
-
),
|
|
837
|
-
)
|
|
838
|
-
_response_json = _response.json()
|
|
839
|
-
except JSONDecodeError:
|
|
840
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
841
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
949
|
+
return _response.data
|
|
842
950
|
|
|
843
951
|
def stream_dataset_items(
|
|
844
952
|
self,
|
|
@@ -862,145 +970,59 @@ class DatasetsClient:
|
|
|
862
970
|
request_options : typing.Optional[RequestOptions]
|
|
863
971
|
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
864
972
|
|
|
865
|
-
|
|
866
|
-
|
|
973
|
+
Returns
|
|
974
|
+
-------
|
|
867
975
|
typing.Iterator[bytes]
|
|
868
976
|
Dataset items stream or error during process
|
|
869
977
|
"""
|
|
870
|
-
with self.
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
"dataset_name": dataset_name,
|
|
875
|
-
"last_retrieved_id": last_retrieved_id,
|
|
876
|
-
"steam_limit": steam_limit,
|
|
877
|
-
},
|
|
878
|
-
headers={
|
|
879
|
-
"content-type": "application/json",
|
|
880
|
-
},
|
|
978
|
+
with self._raw_client.stream_dataset_items(
|
|
979
|
+
dataset_name=dataset_name,
|
|
980
|
+
last_retrieved_id=last_retrieved_id,
|
|
981
|
+
steam_limit=steam_limit,
|
|
881
982
|
request_options=request_options,
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
try:
|
|
885
|
-
if 200 <= _response.status_code < 300:
|
|
886
|
-
_chunk_size = (
|
|
887
|
-
request_options.get("chunk_size", None)
|
|
888
|
-
if request_options is not None
|
|
889
|
-
else None
|
|
890
|
-
)
|
|
891
|
-
for _chunk in _response.iter_bytes(chunk_size=_chunk_size):
|
|
892
|
-
yield _chunk
|
|
893
|
-
return
|
|
894
|
-
_response.read()
|
|
895
|
-
_response_json = _response.json()
|
|
896
|
-
except JSONDecodeError:
|
|
897
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
898
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
899
|
-
|
|
983
|
+
) as r:
|
|
984
|
+
yield from r.data
|
|
900
985
|
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
async def find_datasets(
|
|
906
|
-
self,
|
|
907
|
-
*,
|
|
908
|
-
page: typing.Optional[int] = None,
|
|
909
|
-
size: typing.Optional[int] = None,
|
|
910
|
-
with_experiments_only: typing.Optional[bool] = None,
|
|
911
|
-
prompt_id: typing.Optional[str] = None,
|
|
912
|
-
name: typing.Optional[str] = None,
|
|
913
|
-
sorting: typing.Optional[str] = None,
|
|
914
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
915
|
-
) -> DatasetPagePublic:
|
|
986
|
+
def compare_dataset_versions(
|
|
987
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
988
|
+
) -> DatasetVersionDiff:
|
|
916
989
|
"""
|
|
917
|
-
|
|
990
|
+
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.
|
|
918
991
|
|
|
919
992
|
Parameters
|
|
920
993
|
----------
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
size : typing.Optional[int]
|
|
924
|
-
|
|
925
|
-
with_experiments_only : typing.Optional[bool]
|
|
926
|
-
|
|
927
|
-
prompt_id : typing.Optional[str]
|
|
928
|
-
|
|
929
|
-
name : typing.Optional[str]
|
|
930
|
-
|
|
931
|
-
sorting : typing.Optional[str]
|
|
994
|
+
id : str
|
|
932
995
|
|
|
933
996
|
request_options : typing.Optional[RequestOptions]
|
|
934
997
|
Request-specific configuration.
|
|
935
998
|
|
|
936
999
|
Returns
|
|
937
1000
|
-------
|
|
938
|
-
|
|
939
|
-
|
|
1001
|
+
DatasetVersionDiff
|
|
1002
|
+
Diff computed successfully
|
|
940
1003
|
|
|
941
1004
|
Examples
|
|
942
1005
|
--------
|
|
943
|
-
import
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
client = AsyncOpikApi(
|
|
948
|
-
api_key="YOUR_API_KEY",
|
|
949
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
950
|
-
)
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
async def main() -> None:
|
|
954
|
-
await client.datasets.find_datasets()
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
asyncio.run(main())
|
|
1006
|
+
from Opik import OpikApi
|
|
1007
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1008
|
+
client.datasets.compare_dataset_versions(id='id', )
|
|
958
1009
|
"""
|
|
959
|
-
_response =
|
|
960
|
-
|
|
961
|
-
method="GET",
|
|
962
|
-
params={
|
|
963
|
-
"page": page,
|
|
964
|
-
"size": size,
|
|
965
|
-
"with_experiments_only": with_experiments_only,
|
|
966
|
-
"prompt_id": prompt_id,
|
|
967
|
-
"name": name,
|
|
968
|
-
"sorting": sorting,
|
|
969
|
-
},
|
|
970
|
-
request_options=request_options,
|
|
971
|
-
)
|
|
972
|
-
try:
|
|
973
|
-
if 200 <= _response.status_code < 300:
|
|
974
|
-
return typing.cast(
|
|
975
|
-
DatasetPagePublic,
|
|
976
|
-
parse_obj_as(
|
|
977
|
-
type_=DatasetPagePublic, # type: ignore
|
|
978
|
-
object_=_response.json(),
|
|
979
|
-
),
|
|
980
|
-
)
|
|
981
|
-
_response_json = _response.json()
|
|
982
|
-
except JSONDecodeError:
|
|
983
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
984
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1010
|
+
_response = self._raw_client.compare_dataset_versions(id, request_options=request_options)
|
|
1011
|
+
return _response.data
|
|
985
1012
|
|
|
986
|
-
|
|
987
|
-
self,
|
|
988
|
-
*,
|
|
989
|
-
name: str,
|
|
990
|
-
id: typing.Optional[str] = OMIT,
|
|
991
|
-
description: typing.Optional[str] = OMIT,
|
|
992
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1013
|
+
def create_version_tag(
|
|
1014
|
+
self, version_hash: str, id: str, *, tag: str, request_options: typing.Optional[RequestOptions] = None
|
|
993
1015
|
) -> None:
|
|
994
1016
|
"""
|
|
995
|
-
|
|
1017
|
+
Add a tag to a specific dataset version for easy reference (e.g., 'baseline', 'v1.0', 'production')
|
|
996
1018
|
|
|
997
1019
|
Parameters
|
|
998
1020
|
----------
|
|
999
|
-
|
|
1021
|
+
version_hash : str
|
|
1000
1022
|
|
|
1001
|
-
id :
|
|
1023
|
+
id : str
|
|
1002
1024
|
|
|
1003
|
-
|
|
1025
|
+
tag : str
|
|
1004
1026
|
|
|
1005
1027
|
request_options : typing.Optional[RequestOptions]
|
|
1006
1028
|
Request-specific configuration.
|
|
@@ -1011,259 +1033,250 @@ class AsyncDatasetsClient:
|
|
|
1011
1033
|
|
|
1012
1034
|
Examples
|
|
1013
1035
|
--------
|
|
1014
|
-
import
|
|
1036
|
+
from Opik import OpikApi
|
|
1037
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1038
|
+
client.datasets.create_version_tag(version_hash='versionHash', id='id', tag='tag', )
|
|
1039
|
+
"""
|
|
1040
|
+
_response = self._raw_client.create_version_tag(version_hash, id, tag=tag, request_options=request_options)
|
|
1041
|
+
return _response.data
|
|
1015
1042
|
|
|
1016
|
-
|
|
1043
|
+
def delete_version_tag(
|
|
1044
|
+
self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1045
|
+
) -> None:
|
|
1046
|
+
"""
|
|
1047
|
+
Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
|
|
1017
1048
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
)
|
|
1049
|
+
Parameters
|
|
1050
|
+
----------
|
|
1051
|
+
version_hash : str
|
|
1022
1052
|
|
|
1053
|
+
tag : str
|
|
1023
1054
|
|
|
1024
|
-
|
|
1025
|
-
await client.datasets.create_dataset(
|
|
1026
|
-
name="name",
|
|
1027
|
-
)
|
|
1055
|
+
id : str
|
|
1028
1056
|
|
|
1057
|
+
request_options : typing.Optional[RequestOptions]
|
|
1058
|
+
Request-specific configuration.
|
|
1029
1059
|
|
|
1030
|
-
|
|
1060
|
+
Returns
|
|
1061
|
+
-------
|
|
1062
|
+
None
|
|
1063
|
+
|
|
1064
|
+
Examples
|
|
1065
|
+
--------
|
|
1066
|
+
from Opik import OpikApi
|
|
1067
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1068
|
+
client.datasets.delete_version_tag(version_hash='versionHash', tag='tag', id='id', )
|
|
1031
1069
|
"""
|
|
1032
|
-
_response =
|
|
1033
|
-
|
|
1034
|
-
method="POST",
|
|
1035
|
-
json={
|
|
1036
|
-
"id": id,
|
|
1037
|
-
"name": name,
|
|
1038
|
-
"description": description,
|
|
1039
|
-
},
|
|
1040
|
-
headers={
|
|
1041
|
-
"content-type": "application/json",
|
|
1042
|
-
},
|
|
1043
|
-
request_options=request_options,
|
|
1044
|
-
omit=OMIT,
|
|
1045
|
-
)
|
|
1046
|
-
try:
|
|
1047
|
-
if 200 <= _response.status_code < 300:
|
|
1048
|
-
return
|
|
1049
|
-
_response_json = _response.json()
|
|
1050
|
-
except JSONDecodeError:
|
|
1051
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1052
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1070
|
+
_response = self._raw_client.delete_version_tag(version_hash, tag, id, request_options=request_options)
|
|
1071
|
+
return _response.data
|
|
1053
1072
|
|
|
1054
|
-
|
|
1073
|
+
def list_dataset_versions(
|
|
1055
1074
|
self,
|
|
1075
|
+
id: str,
|
|
1056
1076
|
*,
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
dataset_id: typing.Optional[str] = OMIT,
|
|
1077
|
+
page: typing.Optional[int] = None,
|
|
1078
|
+
size: typing.Optional[int] = None,
|
|
1060
1079
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1061
|
-
) ->
|
|
1080
|
+
) -> DatasetVersionPagePublic:
|
|
1062
1081
|
"""
|
|
1063
|
-
|
|
1082
|
+
Get paginated list of versions for a dataset, ordered by creation time (newest first)
|
|
1064
1083
|
|
|
1065
1084
|
Parameters
|
|
1066
1085
|
----------
|
|
1067
|
-
|
|
1086
|
+
id : str
|
|
1068
1087
|
|
|
1069
|
-
|
|
1070
|
-
If null, dataset_id must be provided
|
|
1088
|
+
page : typing.Optional[int]
|
|
1071
1089
|
|
|
1072
|
-
|
|
1073
|
-
If null, dataset_name must be provided
|
|
1090
|
+
size : typing.Optional[int]
|
|
1074
1091
|
|
|
1075
1092
|
request_options : typing.Optional[RequestOptions]
|
|
1076
1093
|
Request-specific configuration.
|
|
1077
1094
|
|
|
1078
1095
|
Returns
|
|
1079
1096
|
-------
|
|
1080
|
-
|
|
1097
|
+
DatasetVersionPagePublic
|
|
1098
|
+
Dataset versions
|
|
1081
1099
|
|
|
1082
1100
|
Examples
|
|
1083
1101
|
--------
|
|
1084
|
-
import
|
|
1102
|
+
from Opik import OpikApi
|
|
1103
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1104
|
+
client.datasets.list_dataset_versions(id='id', )
|
|
1105
|
+
"""
|
|
1106
|
+
_response = self._raw_client.list_dataset_versions(id, page=page, size=size, request_options=request_options)
|
|
1107
|
+
return _response.data
|
|
1085
1108
|
|
|
1086
|
-
|
|
1109
|
+
def restore_dataset_version(
|
|
1110
|
+
self, id: str, *, version_ref: str, request_options: typing.Optional[RequestOptions] = None
|
|
1111
|
+
) -> DatasetVersionPublic:
|
|
1112
|
+
"""
|
|
1113
|
+
Restores the dataset to a previous version state by creating a new version with items copied from the specified version. If the version is already the latest, returns it as-is (no-op).
|
|
1087
1114
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
)
|
|
1115
|
+
Parameters
|
|
1116
|
+
----------
|
|
1117
|
+
id : str
|
|
1092
1118
|
|
|
1119
|
+
version_ref : str
|
|
1120
|
+
Version hash or tag to restore from
|
|
1093
1121
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
items=[
|
|
1097
|
-
DatasetItemWrite(
|
|
1098
|
-
source="manual",
|
|
1099
|
-
data={"key": "value"},
|
|
1100
|
-
)
|
|
1101
|
-
],
|
|
1102
|
-
)
|
|
1122
|
+
request_options : typing.Optional[RequestOptions]
|
|
1123
|
+
Request-specific configuration.
|
|
1103
1124
|
|
|
1125
|
+
Returns
|
|
1126
|
+
-------
|
|
1127
|
+
DatasetVersionPublic
|
|
1128
|
+
Version restored successfully
|
|
1104
1129
|
|
|
1105
|
-
|
|
1130
|
+
Examples
|
|
1131
|
+
--------
|
|
1132
|
+
from Opik import OpikApi
|
|
1133
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1134
|
+
client.datasets.restore_dataset_version(id='id', version_ref='version_ref', )
|
|
1106
1135
|
"""
|
|
1107
|
-
_response =
|
|
1108
|
-
|
|
1109
|
-
method="PUT",
|
|
1110
|
-
json={
|
|
1111
|
-
"dataset_name": dataset_name,
|
|
1112
|
-
"dataset_id": dataset_id,
|
|
1113
|
-
"items": convert_and_respect_annotation_metadata(
|
|
1114
|
-
object_=items,
|
|
1115
|
-
annotation=typing.Sequence[DatasetItemWrite],
|
|
1116
|
-
direction="write",
|
|
1117
|
-
),
|
|
1118
|
-
},
|
|
1119
|
-
headers={
|
|
1120
|
-
"content-type": "application/json",
|
|
1121
|
-
},
|
|
1122
|
-
request_options=request_options,
|
|
1123
|
-
omit=OMIT,
|
|
1136
|
+
_response = self._raw_client.restore_dataset_version(
|
|
1137
|
+
id, version_ref=version_ref, request_options=request_options
|
|
1124
1138
|
)
|
|
1125
|
-
|
|
1126
|
-
if 200 <= _response.status_code < 300:
|
|
1127
|
-
return
|
|
1128
|
-
_response_json = _response.json()
|
|
1129
|
-
except JSONDecodeError:
|
|
1130
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1131
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1139
|
+
return _response.data
|
|
1132
1140
|
|
|
1133
|
-
|
|
1134
|
-
self,
|
|
1135
|
-
|
|
1141
|
+
def update_dataset_version(
|
|
1142
|
+
self,
|
|
1143
|
+
version_hash: str,
|
|
1144
|
+
id: str,
|
|
1145
|
+
*,
|
|
1146
|
+
change_description: typing.Optional[str] = OMIT,
|
|
1147
|
+
tags_to_add: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1148
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1149
|
+
) -> DatasetVersionPublic:
|
|
1136
1150
|
"""
|
|
1137
|
-
|
|
1151
|
+
Update a dataset version's change_description and/or add new tags
|
|
1138
1152
|
|
|
1139
1153
|
Parameters
|
|
1140
1154
|
----------
|
|
1155
|
+
version_hash : str
|
|
1156
|
+
|
|
1141
1157
|
id : str
|
|
1142
1158
|
|
|
1159
|
+
change_description : typing.Optional[str]
|
|
1160
|
+
Optional description of changes in this version
|
|
1161
|
+
|
|
1162
|
+
tags_to_add : typing.Optional[typing.Sequence[str]]
|
|
1163
|
+
Optional list of tags to add to this version
|
|
1164
|
+
|
|
1143
1165
|
request_options : typing.Optional[RequestOptions]
|
|
1144
1166
|
Request-specific configuration.
|
|
1145
1167
|
|
|
1146
1168
|
Returns
|
|
1147
1169
|
-------
|
|
1148
|
-
|
|
1149
|
-
|
|
1170
|
+
DatasetVersionPublic
|
|
1171
|
+
Version updated successfully
|
|
1150
1172
|
|
|
1151
1173
|
Examples
|
|
1152
1174
|
--------
|
|
1153
|
-
import
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1175
|
+
from Opik import OpikApi
|
|
1176
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1177
|
+
client.datasets.update_dataset_version(version_hash='versionHash', id='id', )
|
|
1178
|
+
"""
|
|
1179
|
+
_response = self._raw_client.update_dataset_version(
|
|
1180
|
+
version_hash,
|
|
1181
|
+
id,
|
|
1182
|
+
change_description=change_description,
|
|
1183
|
+
tags_to_add=tags_to_add,
|
|
1184
|
+
request_options=request_options,
|
|
1160
1185
|
)
|
|
1186
|
+
return _response.data
|
|
1161
1187
|
|
|
1162
1188
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
)
|
|
1189
|
+
class AsyncDatasetsClient:
|
|
1190
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
1191
|
+
self._raw_client = AsyncRawDatasetsClient(client_wrapper=client_wrapper)
|
|
1167
1192
|
|
|
1193
|
+
@property
|
|
1194
|
+
def with_raw_response(self) -> AsyncRawDatasetsClient:
|
|
1195
|
+
"""
|
|
1196
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
1168
1197
|
|
|
1169
|
-
|
|
1198
|
+
Returns
|
|
1199
|
+
-------
|
|
1200
|
+
AsyncRawDatasetsClient
|
|
1170
1201
|
"""
|
|
1171
|
-
|
|
1172
|
-
f"v1/private/datasets/{jsonable_encoder(id)}",
|
|
1173
|
-
method="GET",
|
|
1174
|
-
request_options=request_options,
|
|
1175
|
-
)
|
|
1176
|
-
try:
|
|
1177
|
-
if 200 <= _response.status_code < 300:
|
|
1178
|
-
return typing.cast(
|
|
1179
|
-
DatasetPublic,
|
|
1180
|
-
parse_obj_as(
|
|
1181
|
-
type_=DatasetPublic, # type: ignore
|
|
1182
|
-
object_=_response.json(),
|
|
1183
|
-
),
|
|
1184
|
-
)
|
|
1185
|
-
_response_json = _response.json()
|
|
1186
|
-
except JSONDecodeError:
|
|
1187
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1188
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1202
|
+
return self._raw_client
|
|
1189
1203
|
|
|
1190
|
-
async def
|
|
1204
|
+
async def apply_dataset_item_changes(
|
|
1191
1205
|
self,
|
|
1192
1206
|
id: str,
|
|
1193
1207
|
*,
|
|
1194
|
-
|
|
1195
|
-
|
|
1208
|
+
request: DatasetItemChangesPublic,
|
|
1209
|
+
override: typing.Optional[bool] = None,
|
|
1196
1210
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1197
|
-
) ->
|
|
1211
|
+
) -> DatasetVersionPublic:
|
|
1198
1212
|
"""
|
|
1199
|
-
|
|
1213
|
+
Apply delta changes (add, edit, delete) to a dataset version with conflict detection.
|
|
1214
|
+
|
|
1215
|
+
This endpoint:
|
|
1216
|
+
- Creates a new version with the applied changes
|
|
1217
|
+
- Validates that baseVersion matches the latest version (unless override=true)
|
|
1218
|
+
- Returns 409 Conflict if baseVersion is stale and override is not set
|
|
1219
|
+
|
|
1220
|
+
Use `override=true` query parameter to force version creation even with stale baseVersion.
|
|
1200
1221
|
|
|
1201
1222
|
Parameters
|
|
1202
1223
|
----------
|
|
1203
1224
|
id : str
|
|
1204
1225
|
|
|
1205
|
-
|
|
1226
|
+
request : DatasetItemChangesPublic
|
|
1206
1227
|
|
|
1207
|
-
|
|
1228
|
+
override : typing.Optional[bool]
|
|
1208
1229
|
|
|
1209
1230
|
request_options : typing.Optional[RequestOptions]
|
|
1210
1231
|
Request-specific configuration.
|
|
1211
1232
|
|
|
1212
1233
|
Returns
|
|
1213
1234
|
-------
|
|
1214
|
-
|
|
1235
|
+
DatasetVersionPublic
|
|
1236
|
+
Version created successfully
|
|
1215
1237
|
|
|
1216
1238
|
Examples
|
|
1217
1239
|
--------
|
|
1218
|
-
import asyncio
|
|
1219
|
-
|
|
1220
1240
|
from Opik import AsyncOpikApi
|
|
1221
|
-
|
|
1222
|
-
client = AsyncOpikApi(
|
|
1223
|
-
api_key="YOUR_API_KEY",
|
|
1224
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1225
|
-
)
|
|
1226
|
-
|
|
1227
|
-
|
|
1241
|
+
import asyncio
|
|
1242
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1228
1243
|
async def main() -> None:
|
|
1229
|
-
await client.datasets.
|
|
1230
|
-
|
|
1231
|
-
name="name",
|
|
1232
|
-
)
|
|
1233
|
-
|
|
1234
|
-
|
|
1244
|
+
await client.datasets.apply_dataset_item_changes(id='id', request={'key': 'value'
|
|
1245
|
+
}, )
|
|
1235
1246
|
asyncio.run(main())
|
|
1236
1247
|
"""
|
|
1237
|
-
_response = await self.
|
|
1238
|
-
|
|
1239
|
-
method="PUT",
|
|
1240
|
-
json={
|
|
1241
|
-
"name": name,
|
|
1242
|
-
"description": description,
|
|
1243
|
-
},
|
|
1244
|
-
headers={
|
|
1245
|
-
"content-type": "application/json",
|
|
1246
|
-
},
|
|
1247
|
-
request_options=request_options,
|
|
1248
|
-
omit=OMIT,
|
|
1248
|
+
_response = await self._raw_client.apply_dataset_item_changes(
|
|
1249
|
+
id, request=request, override=override, request_options=request_options
|
|
1249
1250
|
)
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1251
|
+
return _response.data
|
|
1252
|
+
|
|
1253
|
+
async def batch_update_dataset_items(
|
|
1254
|
+
self,
|
|
1255
|
+
*,
|
|
1256
|
+
update: DatasetItemUpdate,
|
|
1257
|
+
ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1258
|
+
filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
|
|
1259
|
+
dataset_id: typing.Optional[str] = OMIT,
|
|
1260
|
+
merge_tags: typing.Optional[bool] = OMIT,
|
|
1261
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1260
1262
|
) -> None:
|
|
1261
1263
|
"""
|
|
1262
|
-
|
|
1264
|
+
Update multiple dataset items
|
|
1263
1265
|
|
|
1264
1266
|
Parameters
|
|
1265
1267
|
----------
|
|
1266
|
-
|
|
1268
|
+
update : DatasetItemUpdate
|
|
1269
|
+
|
|
1270
|
+
ids : typing.Optional[typing.Sequence[str]]
|
|
1271
|
+
List of dataset item IDs to update (max 1000). Mutually exclusive with 'filters'.
|
|
1272
|
+
|
|
1273
|
+
filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
|
|
1274
|
+
|
|
1275
|
+
dataset_id : typing.Optional[str]
|
|
1276
|
+
Dataset ID. Required when using 'filters', optional when using 'ids'.
|
|
1277
|
+
|
|
1278
|
+
merge_tags : typing.Optional[bool]
|
|
1279
|
+
If true, merge tags with existing tags instead of replacing them. Default: false. When using 'filters', this is automatically set to true.
|
|
1267
1280
|
|
|
1268
1281
|
request_options : typing.Optional[RequestOptions]
|
|
1269
1282
|
Request-specific configuration.
|
|
@@ -1274,169 +1287,768 @@ class AsyncDatasetsClient:
|
|
|
1274
1287
|
|
|
1275
1288
|
Examples
|
|
1276
1289
|
--------
|
|
1277
|
-
import asyncio
|
|
1278
|
-
|
|
1279
1290
|
from Opik import AsyncOpikApi
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1284
|
-
)
|
|
1285
|
-
|
|
1286
|
-
|
|
1291
|
+
from Opik import DatasetItemUpdate
|
|
1292
|
+
import asyncio
|
|
1293
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1287
1294
|
async def main() -> None:
|
|
1288
|
-
await client.datasets.
|
|
1289
|
-
id="id",
|
|
1290
|
-
)
|
|
1291
|
-
|
|
1292
|
-
|
|
1295
|
+
await client.datasets.batch_update_dataset_items(update=DatasetItemUpdate(), )
|
|
1293
1296
|
asyncio.run(main())
|
|
1294
1297
|
"""
|
|
1295
|
-
_response = await self.
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
+
_response = await self._raw_client.batch_update_dataset_items(
|
|
1299
|
+
update=update,
|
|
1300
|
+
ids=ids,
|
|
1301
|
+
filters=filters,
|
|
1302
|
+
dataset_id=dataset_id,
|
|
1303
|
+
merge_tags=merge_tags,
|
|
1298
1304
|
request_options=request_options,
|
|
1299
1305
|
)
|
|
1300
|
-
|
|
1301
|
-
if 200 <= _response.status_code < 300:
|
|
1302
|
-
return
|
|
1303
|
-
_response_json = _response.json()
|
|
1304
|
-
except JSONDecodeError:
|
|
1305
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1306
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1306
|
+
return _response.data
|
|
1307
1307
|
|
|
1308
|
-
async def
|
|
1308
|
+
async def find_datasets(
|
|
1309
1309
|
self,
|
|
1310
1310
|
*,
|
|
1311
|
-
|
|
1311
|
+
page: typing.Optional[int] = None,
|
|
1312
|
+
size: typing.Optional[int] = None,
|
|
1313
|
+
with_experiments_only: typing.Optional[bool] = None,
|
|
1314
|
+
with_optimizations_only: typing.Optional[bool] = None,
|
|
1315
|
+
prompt_id: typing.Optional[str] = None,
|
|
1316
|
+
name: typing.Optional[str] = None,
|
|
1317
|
+
sorting: typing.Optional[str] = None,
|
|
1318
|
+
filters: typing.Optional[str] = None,
|
|
1319
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1320
|
+
) -> DatasetPagePublic:
|
|
1321
|
+
"""
|
|
1322
|
+
Find datasets
|
|
1323
|
+
|
|
1324
|
+
Parameters
|
|
1325
|
+
----------
|
|
1326
|
+
page : typing.Optional[int]
|
|
1327
|
+
|
|
1328
|
+
size : typing.Optional[int]
|
|
1329
|
+
|
|
1330
|
+
with_experiments_only : typing.Optional[bool]
|
|
1331
|
+
|
|
1332
|
+
with_optimizations_only : typing.Optional[bool]
|
|
1333
|
+
|
|
1334
|
+
prompt_id : typing.Optional[str]
|
|
1335
|
+
|
|
1336
|
+
name : typing.Optional[str]
|
|
1337
|
+
|
|
1338
|
+
sorting : typing.Optional[str]
|
|
1339
|
+
|
|
1340
|
+
filters : typing.Optional[str]
|
|
1341
|
+
|
|
1342
|
+
request_options : typing.Optional[RequestOptions]
|
|
1343
|
+
Request-specific configuration.
|
|
1344
|
+
|
|
1345
|
+
Returns
|
|
1346
|
+
-------
|
|
1347
|
+
DatasetPagePublic
|
|
1348
|
+
Dataset resource
|
|
1349
|
+
|
|
1350
|
+
Examples
|
|
1351
|
+
--------
|
|
1352
|
+
from Opik import AsyncOpikApi
|
|
1353
|
+
import asyncio
|
|
1354
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1355
|
+
async def main() -> None:
|
|
1356
|
+
await client.datasets.find_datasets()
|
|
1357
|
+
asyncio.run(main())
|
|
1358
|
+
"""
|
|
1359
|
+
_response = await self._raw_client.find_datasets(
|
|
1360
|
+
page=page,
|
|
1361
|
+
size=size,
|
|
1362
|
+
with_experiments_only=with_experiments_only,
|
|
1363
|
+
with_optimizations_only=with_optimizations_only,
|
|
1364
|
+
prompt_id=prompt_id,
|
|
1365
|
+
name=name,
|
|
1366
|
+
sorting=sorting,
|
|
1367
|
+
filters=filters,
|
|
1368
|
+
request_options=request_options,
|
|
1369
|
+
)
|
|
1370
|
+
return _response.data
|
|
1371
|
+
|
|
1372
|
+
async def create_dataset(
|
|
1373
|
+
self,
|
|
1374
|
+
*,
|
|
1375
|
+
name: str,
|
|
1376
|
+
id: typing.Optional[str] = OMIT,
|
|
1377
|
+
visibility: typing.Optional[DatasetWriteVisibility] = OMIT,
|
|
1378
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1379
|
+
description: typing.Optional[str] = OMIT,
|
|
1380
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1381
|
+
) -> None:
|
|
1382
|
+
"""
|
|
1383
|
+
Create dataset
|
|
1384
|
+
|
|
1385
|
+
Parameters
|
|
1386
|
+
----------
|
|
1387
|
+
name : str
|
|
1388
|
+
|
|
1389
|
+
id : typing.Optional[str]
|
|
1390
|
+
|
|
1391
|
+
visibility : typing.Optional[DatasetWriteVisibility]
|
|
1392
|
+
|
|
1393
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
1394
|
+
|
|
1395
|
+
description : typing.Optional[str]
|
|
1396
|
+
|
|
1397
|
+
request_options : typing.Optional[RequestOptions]
|
|
1398
|
+
Request-specific configuration.
|
|
1399
|
+
|
|
1400
|
+
Returns
|
|
1401
|
+
-------
|
|
1402
|
+
None
|
|
1403
|
+
|
|
1404
|
+
Examples
|
|
1405
|
+
--------
|
|
1406
|
+
from Opik import AsyncOpikApi
|
|
1407
|
+
import asyncio
|
|
1408
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1409
|
+
async def main() -> None:
|
|
1410
|
+
await client.datasets.create_dataset(name='name', )
|
|
1411
|
+
asyncio.run(main())
|
|
1412
|
+
"""
|
|
1413
|
+
_response = await self._raw_client.create_dataset(
|
|
1414
|
+
name=name, id=id, visibility=visibility, tags=tags, description=description, request_options=request_options
|
|
1415
|
+
)
|
|
1416
|
+
return _response.data
|
|
1417
|
+
|
|
1418
|
+
async def create_or_update_dataset_items(
|
|
1419
|
+
self,
|
|
1420
|
+
*,
|
|
1421
|
+
items: typing.Sequence[DatasetItemWrite],
|
|
1422
|
+
dataset_name: typing.Optional[str] = OMIT,
|
|
1423
|
+
dataset_id: typing.Optional[str] = OMIT,
|
|
1424
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1425
|
+
) -> None:
|
|
1426
|
+
"""
|
|
1427
|
+
Create/update dataset items based on dataset item id
|
|
1428
|
+
|
|
1429
|
+
Parameters
|
|
1430
|
+
----------
|
|
1431
|
+
items : typing.Sequence[DatasetItemWrite]
|
|
1432
|
+
|
|
1433
|
+
dataset_name : typing.Optional[str]
|
|
1434
|
+
If null, dataset_id must be provided
|
|
1435
|
+
|
|
1436
|
+
dataset_id : typing.Optional[str]
|
|
1437
|
+
If null, dataset_name must be provided
|
|
1438
|
+
|
|
1439
|
+
request_options : typing.Optional[RequestOptions]
|
|
1440
|
+
Request-specific configuration.
|
|
1441
|
+
|
|
1442
|
+
Returns
|
|
1443
|
+
-------
|
|
1444
|
+
None
|
|
1445
|
+
|
|
1446
|
+
Examples
|
|
1447
|
+
--------
|
|
1448
|
+
from Opik import AsyncOpikApi
|
|
1449
|
+
from Opik import DatasetItemWrite
|
|
1450
|
+
import asyncio
|
|
1451
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1452
|
+
async def main() -> None:
|
|
1453
|
+
await client.datasets.create_or_update_dataset_items(items=[DatasetItemWrite(source="manual", data={'key': 'value'
|
|
1454
|
+
}, )], )
|
|
1455
|
+
asyncio.run(main())
|
|
1456
|
+
"""
|
|
1457
|
+
_response = await self._raw_client.create_or_update_dataset_items(
|
|
1458
|
+
items=items, dataset_name=dataset_name, dataset_id=dataset_id, request_options=request_options
|
|
1459
|
+
)
|
|
1460
|
+
return _response.data
|
|
1461
|
+
|
|
1462
|
+
async def create_dataset_items_from_csv(
|
|
1463
|
+
self,
|
|
1464
|
+
*,
|
|
1465
|
+
file: typing.Dict[str, typing.Optional[typing.Any]],
|
|
1466
|
+
dataset_id: str,
|
|
1467
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1468
|
+
) -> None:
|
|
1469
|
+
"""
|
|
1470
|
+
Create dataset items from uploaded CSV file. CSV should have headers in the first row. Processing happens asynchronously in batches.
|
|
1471
|
+
|
|
1472
|
+
Parameters
|
|
1473
|
+
----------
|
|
1474
|
+
file : typing.Dict[str, typing.Optional[typing.Any]]
|
|
1475
|
+
|
|
1476
|
+
dataset_id : str
|
|
1477
|
+
|
|
1478
|
+
request_options : typing.Optional[RequestOptions]
|
|
1479
|
+
Request-specific configuration.
|
|
1480
|
+
|
|
1481
|
+
Returns
|
|
1482
|
+
-------
|
|
1483
|
+
None
|
|
1484
|
+
|
|
1485
|
+
Examples
|
|
1486
|
+
--------
|
|
1487
|
+
from Opik import AsyncOpikApi
|
|
1488
|
+
import asyncio
|
|
1489
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1490
|
+
async def main() -> None:
|
|
1491
|
+
await client.datasets.create_dataset_items_from_csv(file={'key': 'value'
|
|
1492
|
+
}, dataset_id='dataset_id', )
|
|
1493
|
+
asyncio.run(main())
|
|
1494
|
+
"""
|
|
1495
|
+
_response = await self._raw_client.create_dataset_items_from_csv(
|
|
1496
|
+
file=file, dataset_id=dataset_id, request_options=request_options
|
|
1497
|
+
)
|
|
1498
|
+
return _response.data
|
|
1499
|
+
|
|
1500
|
+
async def create_dataset_items_from_spans(
|
|
1501
|
+
self,
|
|
1502
|
+
dataset_id: str,
|
|
1503
|
+
*,
|
|
1504
|
+
span_ids: typing.Sequence[str],
|
|
1505
|
+
enrichment_options: SpanEnrichmentOptions,
|
|
1506
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1507
|
+
) -> None:
|
|
1508
|
+
"""
|
|
1509
|
+
Create dataset items from spans with enriched metadata
|
|
1510
|
+
|
|
1511
|
+
Parameters
|
|
1512
|
+
----------
|
|
1513
|
+
dataset_id : str
|
|
1514
|
+
|
|
1515
|
+
span_ids : typing.Sequence[str]
|
|
1516
|
+
Set of span IDs to add to the dataset
|
|
1517
|
+
|
|
1518
|
+
enrichment_options : SpanEnrichmentOptions
|
|
1519
|
+
|
|
1520
|
+
request_options : typing.Optional[RequestOptions]
|
|
1521
|
+
Request-specific configuration.
|
|
1522
|
+
|
|
1523
|
+
Returns
|
|
1524
|
+
-------
|
|
1525
|
+
None
|
|
1526
|
+
|
|
1527
|
+
Examples
|
|
1528
|
+
--------
|
|
1529
|
+
from Opik import AsyncOpikApi
|
|
1530
|
+
from Opik import SpanEnrichmentOptions
|
|
1531
|
+
import asyncio
|
|
1532
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1533
|
+
async def main() -> None:
|
|
1534
|
+
await client.datasets.create_dataset_items_from_spans(dataset_id='dataset_id', span_ids=['span_ids'], enrichment_options=SpanEnrichmentOptions(), )
|
|
1535
|
+
asyncio.run(main())
|
|
1536
|
+
"""
|
|
1537
|
+
_response = await self._raw_client.create_dataset_items_from_spans(
|
|
1538
|
+
dataset_id, span_ids=span_ids, enrichment_options=enrichment_options, request_options=request_options
|
|
1539
|
+
)
|
|
1540
|
+
return _response.data
|
|
1541
|
+
|
|
1542
|
+
async def create_dataset_items_from_traces(
|
|
1543
|
+
self,
|
|
1544
|
+
dataset_id: str,
|
|
1545
|
+
*,
|
|
1546
|
+
trace_ids: typing.Sequence[str],
|
|
1547
|
+
enrichment_options: TraceEnrichmentOptions,
|
|
1548
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1549
|
+
) -> None:
|
|
1550
|
+
"""
|
|
1551
|
+
Create dataset items from traces with enriched metadata
|
|
1552
|
+
|
|
1553
|
+
Parameters
|
|
1554
|
+
----------
|
|
1555
|
+
dataset_id : str
|
|
1556
|
+
|
|
1557
|
+
trace_ids : typing.Sequence[str]
|
|
1558
|
+
Set of trace IDs to add to the dataset
|
|
1559
|
+
|
|
1560
|
+
enrichment_options : TraceEnrichmentOptions
|
|
1561
|
+
|
|
1562
|
+
request_options : typing.Optional[RequestOptions]
|
|
1563
|
+
Request-specific configuration.
|
|
1564
|
+
|
|
1565
|
+
Returns
|
|
1566
|
+
-------
|
|
1567
|
+
None
|
|
1568
|
+
|
|
1569
|
+
Examples
|
|
1570
|
+
--------
|
|
1571
|
+
from Opik import AsyncOpikApi
|
|
1572
|
+
from Opik import TraceEnrichmentOptions
|
|
1573
|
+
import asyncio
|
|
1574
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1575
|
+
async def main() -> None:
|
|
1576
|
+
await client.datasets.create_dataset_items_from_traces(dataset_id='dataset_id', trace_ids=['trace_ids'], enrichment_options=TraceEnrichmentOptions(), )
|
|
1577
|
+
asyncio.run(main())
|
|
1578
|
+
"""
|
|
1579
|
+
_response = await self._raw_client.create_dataset_items_from_traces(
|
|
1580
|
+
dataset_id, trace_ids=trace_ids, enrichment_options=enrichment_options, request_options=request_options
|
|
1581
|
+
)
|
|
1582
|
+
return _response.data
|
|
1583
|
+
|
|
1584
|
+
async def get_dataset_by_id(
|
|
1585
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1586
|
+
) -> DatasetPublic:
|
|
1587
|
+
"""
|
|
1588
|
+
Get dataset by id
|
|
1589
|
+
|
|
1590
|
+
Parameters
|
|
1591
|
+
----------
|
|
1592
|
+
id : str
|
|
1593
|
+
|
|
1594
|
+
request_options : typing.Optional[RequestOptions]
|
|
1595
|
+
Request-specific configuration.
|
|
1596
|
+
|
|
1597
|
+
Returns
|
|
1598
|
+
-------
|
|
1599
|
+
DatasetPublic
|
|
1600
|
+
Dataset resource
|
|
1601
|
+
|
|
1602
|
+
Examples
|
|
1603
|
+
--------
|
|
1604
|
+
from Opik import AsyncOpikApi
|
|
1605
|
+
import asyncio
|
|
1606
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1607
|
+
async def main() -> None:
|
|
1608
|
+
await client.datasets.get_dataset_by_id(id='id', )
|
|
1609
|
+
asyncio.run(main())
|
|
1610
|
+
"""
|
|
1611
|
+
_response = await self._raw_client.get_dataset_by_id(id, request_options=request_options)
|
|
1612
|
+
return _response.data
|
|
1613
|
+
|
|
1614
|
+
async def update_dataset(
|
|
1615
|
+
self,
|
|
1616
|
+
id: str,
|
|
1617
|
+
*,
|
|
1618
|
+
name: str,
|
|
1619
|
+
description: typing.Optional[str] = OMIT,
|
|
1620
|
+
visibility: typing.Optional[DatasetUpdateVisibility] = OMIT,
|
|
1621
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1622
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1623
|
+
) -> None:
|
|
1624
|
+
"""
|
|
1625
|
+
Update dataset by id
|
|
1626
|
+
|
|
1627
|
+
Parameters
|
|
1628
|
+
----------
|
|
1629
|
+
id : str
|
|
1630
|
+
|
|
1631
|
+
name : str
|
|
1632
|
+
|
|
1633
|
+
description : typing.Optional[str]
|
|
1634
|
+
|
|
1635
|
+
visibility : typing.Optional[DatasetUpdateVisibility]
|
|
1636
|
+
|
|
1637
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
1638
|
+
|
|
1639
|
+
request_options : typing.Optional[RequestOptions]
|
|
1640
|
+
Request-specific configuration.
|
|
1641
|
+
|
|
1642
|
+
Returns
|
|
1643
|
+
-------
|
|
1644
|
+
None
|
|
1645
|
+
|
|
1646
|
+
Examples
|
|
1647
|
+
--------
|
|
1648
|
+
from Opik import AsyncOpikApi
|
|
1649
|
+
import asyncio
|
|
1650
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1651
|
+
async def main() -> None:
|
|
1652
|
+
await client.datasets.update_dataset(id='id', name='name', )
|
|
1653
|
+
asyncio.run(main())
|
|
1654
|
+
"""
|
|
1655
|
+
_response = await self._raw_client.update_dataset(
|
|
1656
|
+
id, name=name, description=description, visibility=visibility, tags=tags, request_options=request_options
|
|
1657
|
+
)
|
|
1658
|
+
return _response.data
|
|
1659
|
+
|
|
1660
|
+
async def delete_dataset(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
1661
|
+
"""
|
|
1662
|
+
Delete dataset by id
|
|
1663
|
+
|
|
1664
|
+
Parameters
|
|
1665
|
+
----------
|
|
1666
|
+
id : str
|
|
1667
|
+
|
|
1668
|
+
request_options : typing.Optional[RequestOptions]
|
|
1669
|
+
Request-specific configuration.
|
|
1670
|
+
|
|
1671
|
+
Returns
|
|
1672
|
+
-------
|
|
1673
|
+
None
|
|
1674
|
+
|
|
1675
|
+
Examples
|
|
1676
|
+
--------
|
|
1677
|
+
from Opik import AsyncOpikApi
|
|
1678
|
+
import asyncio
|
|
1679
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1680
|
+
async def main() -> None:
|
|
1681
|
+
await client.datasets.delete_dataset(id='id', )
|
|
1682
|
+
asyncio.run(main())
|
|
1683
|
+
"""
|
|
1684
|
+
_response = await self._raw_client.delete_dataset(id, request_options=request_options)
|
|
1685
|
+
return _response.data
|
|
1686
|
+
|
|
1687
|
+
async def delete_dataset_by_name(
|
|
1688
|
+
self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
|
|
1689
|
+
) -> None:
|
|
1690
|
+
"""
|
|
1691
|
+
Delete dataset by name
|
|
1692
|
+
|
|
1693
|
+
Parameters
|
|
1694
|
+
----------
|
|
1695
|
+
dataset_name : str
|
|
1696
|
+
|
|
1697
|
+
request_options : typing.Optional[RequestOptions]
|
|
1698
|
+
Request-specific configuration.
|
|
1699
|
+
|
|
1700
|
+
Returns
|
|
1701
|
+
-------
|
|
1702
|
+
None
|
|
1703
|
+
|
|
1704
|
+
Examples
|
|
1705
|
+
--------
|
|
1706
|
+
from Opik import AsyncOpikApi
|
|
1707
|
+
import asyncio
|
|
1708
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1709
|
+
async def main() -> None:
|
|
1710
|
+
await client.datasets.delete_dataset_by_name(dataset_name='dataset_name', )
|
|
1711
|
+
asyncio.run(main())
|
|
1712
|
+
"""
|
|
1713
|
+
_response = await self._raw_client.delete_dataset_by_name(
|
|
1714
|
+
dataset_name=dataset_name, request_options=request_options
|
|
1715
|
+
)
|
|
1716
|
+
return _response.data
|
|
1717
|
+
|
|
1718
|
+
async def delete_dataset_items(
|
|
1719
|
+
self,
|
|
1720
|
+
*,
|
|
1721
|
+
item_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1722
|
+
dataset_id: typing.Optional[str] = OMIT,
|
|
1723
|
+
filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
|
|
1724
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1725
|
+
) -> None:
|
|
1726
|
+
"""
|
|
1727
|
+
Delete dataset items using one of two modes:
|
|
1728
|
+
1. **Delete by IDs**: Provide 'item_ids' to delete specific items by their IDs
|
|
1729
|
+
2. **Delete by filters**: Provide 'dataset_id' with optional 'filters' to delete items matching criteria
|
|
1730
|
+
|
|
1731
|
+
When using filters, an empty 'filters' array will delete all items in the specified dataset.
|
|
1732
|
+
|
|
1733
|
+
Parameters
|
|
1734
|
+
----------
|
|
1735
|
+
item_ids : typing.Optional[typing.Sequence[str]]
|
|
1736
|
+
List of dataset item IDs to delete (max 1000). Use this to delete specific items by their IDs. Mutually exclusive with 'dataset_id' and 'filters'.
|
|
1737
|
+
|
|
1738
|
+
dataset_id : typing.Optional[str]
|
|
1739
|
+
Dataset ID to scope the deletion. Required when using 'filters'. Mutually exclusive with 'item_ids'.
|
|
1740
|
+
|
|
1741
|
+
filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
|
|
1742
|
+
Filters to select dataset items to delete within the specified dataset. Must be used with 'dataset_id'. Mutually exclusive with 'item_ids'. Empty array means 'delete all items in the dataset'.
|
|
1743
|
+
|
|
1744
|
+
request_options : typing.Optional[RequestOptions]
|
|
1745
|
+
Request-specific configuration.
|
|
1746
|
+
|
|
1747
|
+
Returns
|
|
1748
|
+
-------
|
|
1749
|
+
None
|
|
1750
|
+
|
|
1751
|
+
Examples
|
|
1752
|
+
--------
|
|
1753
|
+
from Opik import AsyncOpikApi
|
|
1754
|
+
import asyncio
|
|
1755
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1756
|
+
async def main() -> None:
|
|
1757
|
+
await client.datasets.delete_dataset_items()
|
|
1758
|
+
asyncio.run(main())
|
|
1759
|
+
"""
|
|
1760
|
+
_response = await self._raw_client.delete_dataset_items(
|
|
1761
|
+
item_ids=item_ids, dataset_id=dataset_id, filters=filters, request_options=request_options
|
|
1762
|
+
)
|
|
1763
|
+
return _response.data
|
|
1764
|
+
|
|
1765
|
+
async def delete_datasets_batch(
|
|
1766
|
+
self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
|
1767
|
+
) -> None:
|
|
1768
|
+
"""
|
|
1769
|
+
Delete datasets batch
|
|
1770
|
+
|
|
1771
|
+
Parameters
|
|
1772
|
+
----------
|
|
1773
|
+
ids : typing.Sequence[str]
|
|
1774
|
+
|
|
1775
|
+
request_options : typing.Optional[RequestOptions]
|
|
1776
|
+
Request-specific configuration.
|
|
1777
|
+
|
|
1778
|
+
Returns
|
|
1779
|
+
-------
|
|
1780
|
+
None
|
|
1781
|
+
|
|
1782
|
+
Examples
|
|
1783
|
+
--------
|
|
1784
|
+
from Opik import AsyncOpikApi
|
|
1785
|
+
import asyncio
|
|
1786
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1787
|
+
async def main() -> None:
|
|
1788
|
+
await client.datasets.delete_datasets_batch(ids=['ids'], )
|
|
1789
|
+
asyncio.run(main())
|
|
1790
|
+
"""
|
|
1791
|
+
_response = await self._raw_client.delete_datasets_batch(ids=ids, request_options=request_options)
|
|
1792
|
+
return _response.data
|
|
1793
|
+
|
|
1794
|
+
async def expand_dataset(
|
|
1795
|
+
self,
|
|
1796
|
+
id: str,
|
|
1797
|
+
*,
|
|
1798
|
+
model: str,
|
|
1799
|
+
sample_count: typing.Optional[int] = OMIT,
|
|
1800
|
+
preserve_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1801
|
+
variation_instructions: typing.Optional[str] = OMIT,
|
|
1802
|
+
custom_prompt: typing.Optional[str] = OMIT,
|
|
1803
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1804
|
+
) -> DatasetExpansionResponse:
|
|
1805
|
+
"""
|
|
1806
|
+
Generate synthetic dataset samples using LLM based on existing data patterns
|
|
1807
|
+
|
|
1808
|
+
Parameters
|
|
1809
|
+
----------
|
|
1810
|
+
id : str
|
|
1811
|
+
|
|
1812
|
+
model : str
|
|
1813
|
+
The model to use for synthetic data generation
|
|
1814
|
+
|
|
1815
|
+
sample_count : typing.Optional[int]
|
|
1816
|
+
Number of synthetic samples to generate
|
|
1817
|
+
|
|
1818
|
+
preserve_fields : typing.Optional[typing.Sequence[str]]
|
|
1819
|
+
Fields to preserve patterns from original data
|
|
1820
|
+
|
|
1821
|
+
variation_instructions : typing.Optional[str]
|
|
1822
|
+
Additional instructions for data variation
|
|
1823
|
+
|
|
1824
|
+
custom_prompt : typing.Optional[str]
|
|
1825
|
+
Custom prompt to use for generation instead of auto-generated one
|
|
1826
|
+
|
|
1827
|
+
request_options : typing.Optional[RequestOptions]
|
|
1828
|
+
Request-specific configuration.
|
|
1829
|
+
|
|
1830
|
+
Returns
|
|
1831
|
+
-------
|
|
1832
|
+
DatasetExpansionResponse
|
|
1833
|
+
Generated synthetic samples
|
|
1834
|
+
|
|
1835
|
+
Examples
|
|
1836
|
+
--------
|
|
1837
|
+
from Opik import AsyncOpikApi
|
|
1838
|
+
import asyncio
|
|
1839
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1840
|
+
async def main() -> None:
|
|
1841
|
+
await client.datasets.expand_dataset(id='id', model='gpt-4', )
|
|
1842
|
+
asyncio.run(main())
|
|
1843
|
+
"""
|
|
1844
|
+
_response = await self._raw_client.expand_dataset(
|
|
1845
|
+
id,
|
|
1846
|
+
model=model,
|
|
1847
|
+
sample_count=sample_count,
|
|
1848
|
+
preserve_fields=preserve_fields,
|
|
1849
|
+
variation_instructions=variation_instructions,
|
|
1850
|
+
custom_prompt=custom_prompt,
|
|
1851
|
+
request_options=request_options,
|
|
1852
|
+
)
|
|
1853
|
+
return _response.data
|
|
1854
|
+
|
|
1855
|
+
async def find_dataset_items_with_experiment_items(
|
|
1856
|
+
self,
|
|
1857
|
+
id: str,
|
|
1858
|
+
*,
|
|
1859
|
+
experiment_ids: str,
|
|
1860
|
+
page: typing.Optional[int] = None,
|
|
1861
|
+
size: typing.Optional[int] = None,
|
|
1862
|
+
filters: typing.Optional[str] = None,
|
|
1863
|
+
sorting: typing.Optional[str] = None,
|
|
1864
|
+
search: typing.Optional[str] = None,
|
|
1865
|
+
truncate: typing.Optional[bool] = None,
|
|
1866
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1867
|
+
) -> DatasetItemPageCompare:
|
|
1868
|
+
"""
|
|
1869
|
+
Find dataset items with experiment items
|
|
1870
|
+
|
|
1871
|
+
Parameters
|
|
1872
|
+
----------
|
|
1873
|
+
id : str
|
|
1874
|
+
|
|
1875
|
+
experiment_ids : str
|
|
1876
|
+
|
|
1877
|
+
page : typing.Optional[int]
|
|
1878
|
+
|
|
1879
|
+
size : typing.Optional[int]
|
|
1880
|
+
|
|
1881
|
+
filters : typing.Optional[str]
|
|
1882
|
+
|
|
1883
|
+
sorting : typing.Optional[str]
|
|
1884
|
+
|
|
1885
|
+
search : typing.Optional[str]
|
|
1886
|
+
|
|
1887
|
+
truncate : typing.Optional[bool]
|
|
1888
|
+
|
|
1889
|
+
request_options : typing.Optional[RequestOptions]
|
|
1890
|
+
Request-specific configuration.
|
|
1891
|
+
|
|
1892
|
+
Returns
|
|
1893
|
+
-------
|
|
1894
|
+
DatasetItemPageCompare
|
|
1895
|
+
Dataset item resource
|
|
1896
|
+
|
|
1897
|
+
Examples
|
|
1898
|
+
--------
|
|
1899
|
+
from Opik import AsyncOpikApi
|
|
1900
|
+
import asyncio
|
|
1901
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1902
|
+
async def main() -> None:
|
|
1903
|
+
await client.datasets.find_dataset_items_with_experiment_items(id='id', experiment_ids='experiment_ids', )
|
|
1904
|
+
asyncio.run(main())
|
|
1905
|
+
"""
|
|
1906
|
+
_response = await self._raw_client.find_dataset_items_with_experiment_items(
|
|
1907
|
+
id,
|
|
1908
|
+
experiment_ids=experiment_ids,
|
|
1909
|
+
page=page,
|
|
1910
|
+
size=size,
|
|
1911
|
+
filters=filters,
|
|
1912
|
+
sorting=sorting,
|
|
1913
|
+
search=search,
|
|
1914
|
+
truncate=truncate,
|
|
1915
|
+
request_options=request_options,
|
|
1916
|
+
)
|
|
1917
|
+
return _response.data
|
|
1918
|
+
|
|
1919
|
+
async def get_dataset_by_identifier(
|
|
1920
|
+
self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
|
|
1921
|
+
) -> DatasetPublic:
|
|
1922
|
+
"""
|
|
1923
|
+
Get dataset by name
|
|
1924
|
+
|
|
1925
|
+
Parameters
|
|
1926
|
+
----------
|
|
1927
|
+
dataset_name : str
|
|
1928
|
+
|
|
1929
|
+
request_options : typing.Optional[RequestOptions]
|
|
1930
|
+
Request-specific configuration.
|
|
1931
|
+
|
|
1932
|
+
Returns
|
|
1933
|
+
-------
|
|
1934
|
+
DatasetPublic
|
|
1935
|
+
Dataset resource
|
|
1936
|
+
|
|
1937
|
+
Examples
|
|
1938
|
+
--------
|
|
1939
|
+
from Opik import AsyncOpikApi
|
|
1940
|
+
import asyncio
|
|
1941
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1942
|
+
async def main() -> None:
|
|
1943
|
+
await client.datasets.get_dataset_by_identifier(dataset_name='dataset_name', )
|
|
1944
|
+
asyncio.run(main())
|
|
1945
|
+
"""
|
|
1946
|
+
_response = await self._raw_client.get_dataset_by_identifier(
|
|
1947
|
+
dataset_name=dataset_name, request_options=request_options
|
|
1948
|
+
)
|
|
1949
|
+
return _response.data
|
|
1950
|
+
|
|
1951
|
+
async def get_dataset_experiment_items_stats(
|
|
1952
|
+
self,
|
|
1953
|
+
id: str,
|
|
1954
|
+
*,
|
|
1955
|
+
experiment_ids: str,
|
|
1956
|
+
filters: typing.Optional[str] = None,
|
|
1312
1957
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1313
|
-
) ->
|
|
1958
|
+
) -> ProjectStatsPublic:
|
|
1314
1959
|
"""
|
|
1315
|
-
|
|
1960
|
+
Get experiment items stats for dataset
|
|
1316
1961
|
|
|
1317
1962
|
Parameters
|
|
1318
1963
|
----------
|
|
1319
|
-
|
|
1964
|
+
id : str
|
|
1965
|
+
|
|
1966
|
+
experiment_ids : str
|
|
1967
|
+
|
|
1968
|
+
filters : typing.Optional[str]
|
|
1320
1969
|
|
|
1321
1970
|
request_options : typing.Optional[RequestOptions]
|
|
1322
1971
|
Request-specific configuration.
|
|
1323
1972
|
|
|
1324
1973
|
Returns
|
|
1325
1974
|
-------
|
|
1326
|
-
|
|
1975
|
+
ProjectStatsPublic
|
|
1976
|
+
Experiment items stats resource
|
|
1327
1977
|
|
|
1328
1978
|
Examples
|
|
1329
1979
|
--------
|
|
1330
|
-
import asyncio
|
|
1331
|
-
|
|
1332
1980
|
from Opik import AsyncOpikApi
|
|
1333
|
-
|
|
1334
|
-
client = AsyncOpikApi(
|
|
1335
|
-
api_key="YOUR_API_KEY",
|
|
1336
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1337
|
-
)
|
|
1338
|
-
|
|
1339
|
-
|
|
1981
|
+
import asyncio
|
|
1982
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1340
1983
|
async def main() -> None:
|
|
1341
|
-
await client.datasets.
|
|
1342
|
-
dataset_name="dataset_name",
|
|
1343
|
-
)
|
|
1344
|
-
|
|
1345
|
-
|
|
1984
|
+
await client.datasets.get_dataset_experiment_items_stats(id='id', experiment_ids='experiment_ids', )
|
|
1346
1985
|
asyncio.run(main())
|
|
1347
1986
|
"""
|
|
1348
|
-
_response = await self.
|
|
1349
|
-
|
|
1350
|
-
method="POST",
|
|
1351
|
-
json={
|
|
1352
|
-
"dataset_name": dataset_name,
|
|
1353
|
-
},
|
|
1354
|
-
headers={
|
|
1355
|
-
"content-type": "application/json",
|
|
1356
|
-
},
|
|
1357
|
-
request_options=request_options,
|
|
1358
|
-
omit=OMIT,
|
|
1987
|
+
_response = await self._raw_client.get_dataset_experiment_items_stats(
|
|
1988
|
+
id, experiment_ids=experiment_ids, filters=filters, request_options=request_options
|
|
1359
1989
|
)
|
|
1360
|
-
|
|
1361
|
-
if 200 <= _response.status_code < 300:
|
|
1362
|
-
return
|
|
1363
|
-
_response_json = _response.json()
|
|
1364
|
-
except JSONDecodeError:
|
|
1365
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1366
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1990
|
+
return _response.data
|
|
1367
1991
|
|
|
1368
|
-
async def
|
|
1369
|
-
self,
|
|
1370
|
-
|
|
1371
|
-
item_ids: typing.Sequence[str],
|
|
1372
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1373
|
-
) -> None:
|
|
1992
|
+
async def get_dataset_item_by_id(
|
|
1993
|
+
self, item_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1994
|
+
) -> DatasetItemPublic:
|
|
1374
1995
|
"""
|
|
1375
|
-
|
|
1996
|
+
Get dataset item by id
|
|
1376
1997
|
|
|
1377
1998
|
Parameters
|
|
1378
1999
|
----------
|
|
1379
|
-
|
|
2000
|
+
item_id : str
|
|
1380
2001
|
|
|
1381
2002
|
request_options : typing.Optional[RequestOptions]
|
|
1382
2003
|
Request-specific configuration.
|
|
1383
2004
|
|
|
1384
2005
|
Returns
|
|
1385
2006
|
-------
|
|
1386
|
-
|
|
2007
|
+
DatasetItemPublic
|
|
2008
|
+
Dataset item resource
|
|
1387
2009
|
|
|
1388
2010
|
Examples
|
|
1389
2011
|
--------
|
|
1390
|
-
import asyncio
|
|
1391
|
-
|
|
1392
2012
|
from Opik import AsyncOpikApi
|
|
1393
|
-
|
|
1394
|
-
client = AsyncOpikApi(
|
|
1395
|
-
api_key="YOUR_API_KEY",
|
|
1396
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1397
|
-
)
|
|
1398
|
-
|
|
1399
|
-
|
|
2013
|
+
import asyncio
|
|
2014
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1400
2015
|
async def main() -> None:
|
|
1401
|
-
await client.datasets.
|
|
1402
|
-
item_ids=["item_ids"],
|
|
1403
|
-
)
|
|
1404
|
-
|
|
1405
|
-
|
|
2016
|
+
await client.datasets.get_dataset_item_by_id(item_id='itemId', )
|
|
1406
2017
|
asyncio.run(main())
|
|
1407
2018
|
"""
|
|
1408
|
-
_response = await self.
|
|
1409
|
-
|
|
1410
|
-
method="POST",
|
|
1411
|
-
json={
|
|
1412
|
-
"item_ids": item_ids,
|
|
1413
|
-
},
|
|
1414
|
-
headers={
|
|
1415
|
-
"content-type": "application/json",
|
|
1416
|
-
},
|
|
1417
|
-
request_options=request_options,
|
|
1418
|
-
omit=OMIT,
|
|
1419
|
-
)
|
|
1420
|
-
try:
|
|
1421
|
-
if 200 <= _response.status_code < 300:
|
|
1422
|
-
return
|
|
1423
|
-
_response_json = _response.json()
|
|
1424
|
-
except JSONDecodeError:
|
|
1425
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1426
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2019
|
+
_response = await self._raw_client.get_dataset_item_by_id(item_id, request_options=request_options)
|
|
2020
|
+
return _response.data
|
|
1427
2021
|
|
|
1428
|
-
async def
|
|
2022
|
+
async def patch_dataset_item(
|
|
1429
2023
|
self,
|
|
2024
|
+
item_id: str,
|
|
1430
2025
|
*,
|
|
1431
|
-
|
|
2026
|
+
source: DatasetItemWriteSource,
|
|
2027
|
+
data: JsonNode,
|
|
2028
|
+
id: typing.Optional[str] = OMIT,
|
|
2029
|
+
trace_id: typing.Optional[str] = OMIT,
|
|
2030
|
+
span_id: typing.Optional[str] = OMIT,
|
|
2031
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1432
2032
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1433
2033
|
) -> None:
|
|
1434
2034
|
"""
|
|
1435
|
-
|
|
2035
|
+
Partially update dataset item by id. Only provided fields will be updated.
|
|
1436
2036
|
|
|
1437
2037
|
Parameters
|
|
1438
2038
|
----------
|
|
1439
|
-
|
|
2039
|
+
item_id : str
|
|
2040
|
+
|
|
2041
|
+
source : DatasetItemWriteSource
|
|
2042
|
+
|
|
2043
|
+
data : JsonNode
|
|
2044
|
+
|
|
2045
|
+
id : typing.Optional[str]
|
|
2046
|
+
|
|
2047
|
+
trace_id : typing.Optional[str]
|
|
2048
|
+
|
|
2049
|
+
span_id : typing.Optional[str]
|
|
2050
|
+
|
|
2051
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
1440
2052
|
|
|
1441
2053
|
request_options : typing.Optional[RequestOptions]
|
|
1442
2054
|
Request-specific configuration.
|
|
@@ -1447,65 +2059,50 @@ class AsyncDatasetsClient:
|
|
|
1447
2059
|
|
|
1448
2060
|
Examples
|
|
1449
2061
|
--------
|
|
1450
|
-
import asyncio
|
|
1451
|
-
|
|
1452
2062
|
from Opik import AsyncOpikApi
|
|
1453
|
-
|
|
1454
|
-
client = AsyncOpikApi(
|
|
1455
|
-
api_key="YOUR_API_KEY",
|
|
1456
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1457
|
-
)
|
|
1458
|
-
|
|
1459
|
-
|
|
2063
|
+
import asyncio
|
|
2064
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1460
2065
|
async def main() -> None:
|
|
1461
|
-
await client.datasets.
|
|
1462
|
-
|
|
1463
|
-
)
|
|
1464
|
-
|
|
1465
|
-
|
|
2066
|
+
await client.datasets.patch_dataset_item(item_id='itemId', source="manual", data={'key': 'value'
|
|
2067
|
+
}, )
|
|
1466
2068
|
asyncio.run(main())
|
|
1467
2069
|
"""
|
|
1468
|
-
_response = await self.
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
2070
|
+
_response = await self._raw_client.patch_dataset_item(
|
|
2071
|
+
item_id,
|
|
2072
|
+
source=source,
|
|
2073
|
+
data=data,
|
|
2074
|
+
id=id,
|
|
2075
|
+
trace_id=trace_id,
|
|
2076
|
+
span_id=span_id,
|
|
2077
|
+
tags=tags,
|
|
1474
2078
|
request_options=request_options,
|
|
1475
|
-
omit=OMIT,
|
|
1476
2079
|
)
|
|
1477
|
-
|
|
1478
|
-
if 200 <= _response.status_code < 300:
|
|
1479
|
-
return
|
|
1480
|
-
_response_json = _response.json()
|
|
1481
|
-
except JSONDecodeError:
|
|
1482
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1483
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2080
|
+
return _response.data
|
|
1484
2081
|
|
|
1485
|
-
async def
|
|
2082
|
+
async def get_dataset_items(
|
|
1486
2083
|
self,
|
|
1487
2084
|
id: str,
|
|
1488
2085
|
*,
|
|
1489
|
-
experiment_ids: str,
|
|
1490
2086
|
page: typing.Optional[int] = None,
|
|
1491
2087
|
size: typing.Optional[int] = None,
|
|
2088
|
+
version: typing.Optional[str] = None,
|
|
1492
2089
|
filters: typing.Optional[str] = None,
|
|
1493
2090
|
truncate: typing.Optional[bool] = None,
|
|
1494
2091
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1495
|
-
) ->
|
|
2092
|
+
) -> DatasetItemPagePublic:
|
|
1496
2093
|
"""
|
|
1497
|
-
|
|
2094
|
+
Get dataset items
|
|
1498
2095
|
|
|
1499
2096
|
Parameters
|
|
1500
2097
|
----------
|
|
1501
2098
|
id : str
|
|
1502
2099
|
|
|
1503
|
-
experiment_ids : str
|
|
1504
|
-
|
|
1505
2100
|
page : typing.Optional[int]
|
|
1506
2101
|
|
|
1507
2102
|
size : typing.Optional[int]
|
|
1508
2103
|
|
|
2104
|
+
version : typing.Optional[str]
|
|
2105
|
+
|
|
1509
2106
|
filters : typing.Optional[str]
|
|
1510
2107
|
|
|
1511
2108
|
truncate : typing.Optional[bool]
|
|
@@ -1515,191 +2112,211 @@ class AsyncDatasetsClient:
|
|
|
1515
2112
|
|
|
1516
2113
|
Returns
|
|
1517
2114
|
-------
|
|
1518
|
-
|
|
1519
|
-
Dataset
|
|
2115
|
+
DatasetItemPagePublic
|
|
2116
|
+
Dataset items resource
|
|
1520
2117
|
|
|
1521
2118
|
Examples
|
|
1522
2119
|
--------
|
|
2120
|
+
from Opik import AsyncOpikApi
|
|
1523
2121
|
import asyncio
|
|
2122
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2123
|
+
async def main() -> None:
|
|
2124
|
+
await client.datasets.get_dataset_items(id='id', )
|
|
2125
|
+
asyncio.run(main())
|
|
2126
|
+
"""
|
|
2127
|
+
_response = await self._raw_client.get_dataset_items(
|
|
2128
|
+
id,
|
|
2129
|
+
page=page,
|
|
2130
|
+
size=size,
|
|
2131
|
+
version=version,
|
|
2132
|
+
filters=filters,
|
|
2133
|
+
truncate=truncate,
|
|
2134
|
+
request_options=request_options,
|
|
2135
|
+
)
|
|
2136
|
+
return _response.data
|
|
1524
2137
|
|
|
1525
|
-
|
|
2138
|
+
async def get_dataset_items_output_columns(
|
|
2139
|
+
self,
|
|
2140
|
+
id: str,
|
|
2141
|
+
*,
|
|
2142
|
+
experiment_ids: typing.Optional[str] = None,
|
|
2143
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2144
|
+
) -> PageColumns:
|
|
2145
|
+
"""
|
|
2146
|
+
Get dataset items output columns
|
|
1526
2147
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
)
|
|
2148
|
+
Parameters
|
|
2149
|
+
----------
|
|
2150
|
+
id : str
|
|
1531
2151
|
|
|
2152
|
+
experiment_ids : typing.Optional[str]
|
|
1532
2153
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
id="id",
|
|
1536
|
-
experiment_ids="experiment_ids",
|
|
1537
|
-
)
|
|
2154
|
+
request_options : typing.Optional[RequestOptions]
|
|
2155
|
+
Request-specific configuration.
|
|
1538
2156
|
|
|
2157
|
+
Returns
|
|
2158
|
+
-------
|
|
2159
|
+
PageColumns
|
|
2160
|
+
Dataset item output columns
|
|
1539
2161
|
|
|
2162
|
+
Examples
|
|
2163
|
+
--------
|
|
2164
|
+
from Opik import AsyncOpikApi
|
|
2165
|
+
import asyncio
|
|
2166
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2167
|
+
async def main() -> None:
|
|
2168
|
+
await client.datasets.get_dataset_items_output_columns(id='id', )
|
|
1540
2169
|
asyncio.run(main())
|
|
1541
2170
|
"""
|
|
1542
|
-
_response = await self.
|
|
1543
|
-
|
|
1544
|
-
method="GET",
|
|
1545
|
-
params={
|
|
1546
|
-
"page": page,
|
|
1547
|
-
"size": size,
|
|
1548
|
-
"experiment_ids": experiment_ids,
|
|
1549
|
-
"filters": filters,
|
|
1550
|
-
"truncate": truncate,
|
|
1551
|
-
},
|
|
1552
|
-
request_options=request_options,
|
|
2171
|
+
_response = await self._raw_client.get_dataset_items_output_columns(
|
|
2172
|
+
id, experiment_ids=experiment_ids, request_options=request_options
|
|
1553
2173
|
)
|
|
1554
|
-
|
|
1555
|
-
if 200 <= _response.status_code < 300:
|
|
1556
|
-
return typing.cast(
|
|
1557
|
-
DatasetItemPageCompare,
|
|
1558
|
-
parse_obj_as(
|
|
1559
|
-
type_=DatasetItemPageCompare, # type: ignore
|
|
1560
|
-
object_=_response.json(),
|
|
1561
|
-
),
|
|
1562
|
-
)
|
|
1563
|
-
_response_json = _response.json()
|
|
1564
|
-
except JSONDecodeError:
|
|
1565
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1566
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2174
|
+
return _response.data
|
|
1567
2175
|
|
|
1568
|
-
async def
|
|
2176
|
+
async def stream_dataset_items(
|
|
1569
2177
|
self,
|
|
1570
2178
|
*,
|
|
1571
2179
|
dataset_name: str,
|
|
2180
|
+
last_retrieved_id: typing.Optional[str] = OMIT,
|
|
2181
|
+
steam_limit: typing.Optional[int] = OMIT,
|
|
1572
2182
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1573
|
-
) ->
|
|
2183
|
+
) -> typing.AsyncIterator[bytes]:
|
|
1574
2184
|
"""
|
|
1575
|
-
|
|
2185
|
+
Stream dataset items
|
|
1576
2186
|
|
|
1577
2187
|
Parameters
|
|
1578
2188
|
----------
|
|
1579
2189
|
dataset_name : str
|
|
1580
2190
|
|
|
2191
|
+
last_retrieved_id : typing.Optional[str]
|
|
2192
|
+
|
|
2193
|
+
steam_limit : typing.Optional[int]
|
|
2194
|
+
|
|
2195
|
+
request_options : typing.Optional[RequestOptions]
|
|
2196
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
2197
|
+
|
|
2198
|
+
Returns
|
|
2199
|
+
-------
|
|
2200
|
+
typing.AsyncIterator[bytes]
|
|
2201
|
+
Dataset items stream or error during process
|
|
2202
|
+
"""
|
|
2203
|
+
async with self._raw_client.stream_dataset_items(
|
|
2204
|
+
dataset_name=dataset_name,
|
|
2205
|
+
last_retrieved_id=last_retrieved_id,
|
|
2206
|
+
steam_limit=steam_limit,
|
|
2207
|
+
request_options=request_options,
|
|
2208
|
+
) as r:
|
|
2209
|
+
async for data in r.data:
|
|
2210
|
+
yield data
|
|
2211
|
+
|
|
2212
|
+
async def compare_dataset_versions(
|
|
2213
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
2214
|
+
) -> DatasetVersionDiff:
|
|
2215
|
+
"""
|
|
2216
|
+
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.
|
|
2217
|
+
|
|
2218
|
+
Parameters
|
|
2219
|
+
----------
|
|
2220
|
+
id : str
|
|
2221
|
+
|
|
1581
2222
|
request_options : typing.Optional[RequestOptions]
|
|
1582
2223
|
Request-specific configuration.
|
|
1583
2224
|
|
|
1584
2225
|
Returns
|
|
1585
2226
|
-------
|
|
1586
|
-
|
|
1587
|
-
|
|
2227
|
+
DatasetVersionDiff
|
|
2228
|
+
Diff computed successfully
|
|
1588
2229
|
|
|
1589
2230
|
Examples
|
|
1590
2231
|
--------
|
|
2232
|
+
from Opik import AsyncOpikApi
|
|
1591
2233
|
import asyncio
|
|
2234
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2235
|
+
async def main() -> None:
|
|
2236
|
+
await client.datasets.compare_dataset_versions(id='id', )
|
|
2237
|
+
asyncio.run(main())
|
|
2238
|
+
"""
|
|
2239
|
+
_response = await self._raw_client.compare_dataset_versions(id, request_options=request_options)
|
|
2240
|
+
return _response.data
|
|
1592
2241
|
|
|
1593
|
-
|
|
2242
|
+
async def create_version_tag(
|
|
2243
|
+
self, version_hash: str, id: str, *, tag: str, request_options: typing.Optional[RequestOptions] = None
|
|
2244
|
+
) -> None:
|
|
2245
|
+
"""
|
|
2246
|
+
Add a tag to a specific dataset version for easy reference (e.g., 'baseline', 'v1.0', 'production')
|
|
1594
2247
|
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
)
|
|
2248
|
+
Parameters
|
|
2249
|
+
----------
|
|
2250
|
+
version_hash : str
|
|
1599
2251
|
|
|
2252
|
+
id : str
|
|
1600
2253
|
|
|
1601
|
-
|
|
1602
|
-
await client.datasets.get_dataset_by_identifier(
|
|
1603
|
-
dataset_name="dataset_name",
|
|
1604
|
-
)
|
|
2254
|
+
tag : str
|
|
1605
2255
|
|
|
2256
|
+
request_options : typing.Optional[RequestOptions]
|
|
2257
|
+
Request-specific configuration.
|
|
2258
|
+
|
|
2259
|
+
Returns
|
|
2260
|
+
-------
|
|
2261
|
+
None
|
|
1606
2262
|
|
|
2263
|
+
Examples
|
|
2264
|
+
--------
|
|
2265
|
+
from Opik import AsyncOpikApi
|
|
2266
|
+
import asyncio
|
|
2267
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2268
|
+
async def main() -> None:
|
|
2269
|
+
await client.datasets.create_version_tag(version_hash='versionHash', id='id', tag='tag', )
|
|
1607
2270
|
asyncio.run(main())
|
|
1608
2271
|
"""
|
|
1609
|
-
_response = await self.
|
|
1610
|
-
|
|
1611
|
-
method="POST",
|
|
1612
|
-
json={
|
|
1613
|
-
"dataset_name": dataset_name,
|
|
1614
|
-
},
|
|
1615
|
-
headers={
|
|
1616
|
-
"content-type": "application/json",
|
|
1617
|
-
},
|
|
1618
|
-
request_options=request_options,
|
|
1619
|
-
omit=OMIT,
|
|
2272
|
+
_response = await self._raw_client.create_version_tag(
|
|
2273
|
+
version_hash, id, tag=tag, request_options=request_options
|
|
1620
2274
|
)
|
|
1621
|
-
|
|
1622
|
-
if 200 <= _response.status_code < 300:
|
|
1623
|
-
return typing.cast(
|
|
1624
|
-
DatasetPublic,
|
|
1625
|
-
parse_obj_as(
|
|
1626
|
-
type_=DatasetPublic, # type: ignore
|
|
1627
|
-
object_=_response.json(),
|
|
1628
|
-
),
|
|
1629
|
-
)
|
|
1630
|
-
_response_json = _response.json()
|
|
1631
|
-
except JSONDecodeError:
|
|
1632
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1633
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2275
|
+
return _response.data
|
|
1634
2276
|
|
|
1635
|
-
async def
|
|
1636
|
-
self,
|
|
1637
|
-
) ->
|
|
2277
|
+
async def delete_version_tag(
|
|
2278
|
+
self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
2279
|
+
) -> None:
|
|
1638
2280
|
"""
|
|
1639
|
-
|
|
2281
|
+
Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
|
|
1640
2282
|
|
|
1641
2283
|
Parameters
|
|
1642
2284
|
----------
|
|
1643
|
-
|
|
2285
|
+
version_hash : str
|
|
2286
|
+
|
|
2287
|
+
tag : str
|
|
2288
|
+
|
|
2289
|
+
id : str
|
|
1644
2290
|
|
|
1645
2291
|
request_options : typing.Optional[RequestOptions]
|
|
1646
2292
|
Request-specific configuration.
|
|
1647
2293
|
|
|
1648
2294
|
Returns
|
|
1649
2295
|
-------
|
|
1650
|
-
|
|
1651
|
-
Dataset item resource
|
|
2296
|
+
None
|
|
1652
2297
|
|
|
1653
2298
|
Examples
|
|
1654
2299
|
--------
|
|
1655
|
-
import asyncio
|
|
1656
|
-
|
|
1657
2300
|
from Opik import AsyncOpikApi
|
|
1658
|
-
|
|
1659
|
-
client = AsyncOpikApi(
|
|
1660
|
-
api_key="YOUR_API_KEY",
|
|
1661
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1662
|
-
)
|
|
1663
|
-
|
|
1664
|
-
|
|
2301
|
+
import asyncio
|
|
2302
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1665
2303
|
async def main() -> None:
|
|
1666
|
-
await client.datasets.
|
|
1667
|
-
item_id="itemId",
|
|
1668
|
-
)
|
|
1669
|
-
|
|
1670
|
-
|
|
2304
|
+
await client.datasets.delete_version_tag(version_hash='versionHash', tag='tag', id='id', )
|
|
1671
2305
|
asyncio.run(main())
|
|
1672
2306
|
"""
|
|
1673
|
-
_response = await self.
|
|
1674
|
-
|
|
1675
|
-
method="GET",
|
|
1676
|
-
request_options=request_options,
|
|
1677
|
-
)
|
|
1678
|
-
try:
|
|
1679
|
-
if 200 <= _response.status_code < 300:
|
|
1680
|
-
return typing.cast(
|
|
1681
|
-
DatasetItemPublic,
|
|
1682
|
-
parse_obj_as(
|
|
1683
|
-
type_=DatasetItemPublic, # type: ignore
|
|
1684
|
-
object_=_response.json(),
|
|
1685
|
-
),
|
|
1686
|
-
)
|
|
1687
|
-
_response_json = _response.json()
|
|
1688
|
-
except JSONDecodeError:
|
|
1689
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1690
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2307
|
+
_response = await self._raw_client.delete_version_tag(version_hash, tag, id, request_options=request_options)
|
|
2308
|
+
return _response.data
|
|
1691
2309
|
|
|
1692
|
-
async def
|
|
2310
|
+
async def list_dataset_versions(
|
|
1693
2311
|
self,
|
|
1694
2312
|
id: str,
|
|
1695
2313
|
*,
|
|
1696
2314
|
page: typing.Optional[int] = None,
|
|
1697
2315
|
size: typing.Optional[int] = None,
|
|
1698
|
-
truncate: typing.Optional[bool] = None,
|
|
1699
2316
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1700
|
-
) ->
|
|
2317
|
+
) -> DatasetVersionPagePublic:
|
|
1701
2318
|
"""
|
|
1702
|
-
Get dataset
|
|
2319
|
+
Get paginated list of versions for a dataset, ordered by creation time (newest first)
|
|
1703
2320
|
|
|
1704
2321
|
Parameters
|
|
1705
2322
|
----------
|
|
@@ -1709,179 +2326,109 @@ class AsyncDatasetsClient:
|
|
|
1709
2326
|
|
|
1710
2327
|
size : typing.Optional[int]
|
|
1711
2328
|
|
|
1712
|
-
truncate : typing.Optional[bool]
|
|
1713
|
-
|
|
1714
2329
|
request_options : typing.Optional[RequestOptions]
|
|
1715
2330
|
Request-specific configuration.
|
|
1716
2331
|
|
|
1717
2332
|
Returns
|
|
1718
2333
|
-------
|
|
1719
|
-
|
|
1720
|
-
Dataset
|
|
2334
|
+
DatasetVersionPagePublic
|
|
2335
|
+
Dataset versions
|
|
1721
2336
|
|
|
1722
2337
|
Examples
|
|
1723
2338
|
--------
|
|
1724
|
-
import asyncio
|
|
1725
|
-
|
|
1726
2339
|
from Opik import AsyncOpikApi
|
|
1727
|
-
|
|
1728
|
-
client = AsyncOpikApi(
|
|
1729
|
-
api_key="YOUR_API_KEY",
|
|
1730
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1731
|
-
)
|
|
1732
|
-
|
|
1733
|
-
|
|
2340
|
+
import asyncio
|
|
2341
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1734
2342
|
async def main() -> None:
|
|
1735
|
-
await client.datasets.
|
|
1736
|
-
id="id",
|
|
1737
|
-
)
|
|
1738
|
-
|
|
1739
|
-
|
|
2343
|
+
await client.datasets.list_dataset_versions(id='id', )
|
|
1740
2344
|
asyncio.run(main())
|
|
1741
2345
|
"""
|
|
1742
|
-
_response = await self.
|
|
1743
|
-
|
|
1744
|
-
method="GET",
|
|
1745
|
-
params={
|
|
1746
|
-
"page": page,
|
|
1747
|
-
"size": size,
|
|
1748
|
-
"truncate": truncate,
|
|
1749
|
-
},
|
|
1750
|
-
request_options=request_options,
|
|
2346
|
+
_response = await self._raw_client.list_dataset_versions(
|
|
2347
|
+
id, page=page, size=size, request_options=request_options
|
|
1751
2348
|
)
|
|
1752
|
-
|
|
1753
|
-
if 200 <= _response.status_code < 300:
|
|
1754
|
-
return typing.cast(
|
|
1755
|
-
DatasetItemPagePublic,
|
|
1756
|
-
parse_obj_as(
|
|
1757
|
-
type_=DatasetItemPagePublic, # type: ignore
|
|
1758
|
-
object_=_response.json(),
|
|
1759
|
-
),
|
|
1760
|
-
)
|
|
1761
|
-
_response_json = _response.json()
|
|
1762
|
-
except JSONDecodeError:
|
|
1763
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1764
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2349
|
+
return _response.data
|
|
1765
2350
|
|
|
1766
|
-
async def
|
|
1767
|
-
self,
|
|
1768
|
-
|
|
1769
|
-
*,
|
|
1770
|
-
experiment_ids: typing.Optional[str] = None,
|
|
1771
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1772
|
-
) -> PageColumns:
|
|
2351
|
+
async def restore_dataset_version(
|
|
2352
|
+
self, id: str, *, version_ref: str, request_options: typing.Optional[RequestOptions] = None
|
|
2353
|
+
) -> DatasetVersionPublic:
|
|
1773
2354
|
"""
|
|
1774
|
-
|
|
2355
|
+
Restores the dataset to a previous version state by creating a new version with items copied from the specified version. If the version is already the latest, returns it as-is (no-op).
|
|
1775
2356
|
|
|
1776
2357
|
Parameters
|
|
1777
2358
|
----------
|
|
1778
2359
|
id : str
|
|
1779
2360
|
|
|
1780
|
-
|
|
2361
|
+
version_ref : str
|
|
2362
|
+
Version hash or tag to restore from
|
|
1781
2363
|
|
|
1782
2364
|
request_options : typing.Optional[RequestOptions]
|
|
1783
2365
|
Request-specific configuration.
|
|
1784
2366
|
|
|
1785
2367
|
Returns
|
|
1786
2368
|
-------
|
|
1787
|
-
|
|
1788
|
-
|
|
2369
|
+
DatasetVersionPublic
|
|
2370
|
+
Version restored successfully
|
|
1789
2371
|
|
|
1790
2372
|
Examples
|
|
1791
2373
|
--------
|
|
1792
|
-
import asyncio
|
|
1793
|
-
|
|
1794
2374
|
from Opik import AsyncOpikApi
|
|
1795
|
-
|
|
1796
|
-
client = AsyncOpikApi(
|
|
1797
|
-
api_key="YOUR_API_KEY",
|
|
1798
|
-
workspace_name="YOUR_WORKSPACE_NAME",
|
|
1799
|
-
)
|
|
1800
|
-
|
|
1801
|
-
|
|
2375
|
+
import asyncio
|
|
2376
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1802
2377
|
async def main() -> None:
|
|
1803
|
-
await client.datasets.
|
|
1804
|
-
id="id",
|
|
1805
|
-
)
|
|
1806
|
-
|
|
1807
|
-
|
|
2378
|
+
await client.datasets.restore_dataset_version(id='id', version_ref='version_ref', )
|
|
1808
2379
|
asyncio.run(main())
|
|
1809
2380
|
"""
|
|
1810
|
-
_response = await self.
|
|
1811
|
-
|
|
1812
|
-
method="GET",
|
|
1813
|
-
params={
|
|
1814
|
-
"experiment_ids": experiment_ids,
|
|
1815
|
-
},
|
|
1816
|
-
request_options=request_options,
|
|
2381
|
+
_response = await self._raw_client.restore_dataset_version(
|
|
2382
|
+
id, version_ref=version_ref, request_options=request_options
|
|
1817
2383
|
)
|
|
1818
|
-
|
|
1819
|
-
if 200 <= _response.status_code < 300:
|
|
1820
|
-
return typing.cast(
|
|
1821
|
-
PageColumns,
|
|
1822
|
-
parse_obj_as(
|
|
1823
|
-
type_=PageColumns, # type: ignore
|
|
1824
|
-
object_=_response.json(),
|
|
1825
|
-
),
|
|
1826
|
-
)
|
|
1827
|
-
_response_json = _response.json()
|
|
1828
|
-
except JSONDecodeError:
|
|
1829
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1830
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2384
|
+
return _response.data
|
|
1831
2385
|
|
|
1832
|
-
async def
|
|
2386
|
+
async def update_dataset_version(
|
|
1833
2387
|
self,
|
|
2388
|
+
version_hash: str,
|
|
2389
|
+
id: str,
|
|
1834
2390
|
*,
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
steam_limit: typing.Optional[int] = OMIT,
|
|
2391
|
+
change_description: typing.Optional[str] = OMIT,
|
|
2392
|
+
tags_to_add: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1838
2393
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1839
|
-
) ->
|
|
2394
|
+
) -> DatasetVersionPublic:
|
|
1840
2395
|
"""
|
|
1841
|
-
|
|
2396
|
+
Update a dataset version's change_description and/or add new tags
|
|
1842
2397
|
|
|
1843
2398
|
Parameters
|
|
1844
2399
|
----------
|
|
1845
|
-
|
|
2400
|
+
version_hash : str
|
|
1846
2401
|
|
|
1847
|
-
|
|
2402
|
+
id : str
|
|
1848
2403
|
|
|
1849
|
-
|
|
2404
|
+
change_description : typing.Optional[str]
|
|
2405
|
+
Optional description of changes in this version
|
|
2406
|
+
|
|
2407
|
+
tags_to_add : typing.Optional[typing.Sequence[str]]
|
|
2408
|
+
Optional list of tags to add to this version
|
|
1850
2409
|
|
|
1851
2410
|
request_options : typing.Optional[RequestOptions]
|
|
1852
|
-
Request-specific configuration.
|
|
2411
|
+
Request-specific configuration.
|
|
1853
2412
|
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
2413
|
+
Returns
|
|
2414
|
+
-------
|
|
2415
|
+
DatasetVersionPublic
|
|
2416
|
+
Version updated successfully
|
|
2417
|
+
|
|
2418
|
+
Examples
|
|
2419
|
+
--------
|
|
2420
|
+
from Opik import AsyncOpikApi
|
|
2421
|
+
import asyncio
|
|
2422
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
2423
|
+
async def main() -> None:
|
|
2424
|
+
await client.datasets.update_dataset_version(version_hash='versionHash', id='id', )
|
|
2425
|
+
asyncio.run(main())
|
|
1858
2426
|
"""
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
"last_retrieved_id": last_retrieved_id,
|
|
1865
|
-
"steam_limit": steam_limit,
|
|
1866
|
-
},
|
|
1867
|
-
headers={
|
|
1868
|
-
"content-type": "application/json",
|
|
1869
|
-
},
|
|
2427
|
+
_response = await self._raw_client.update_dataset_version(
|
|
2428
|
+
version_hash,
|
|
2429
|
+
id,
|
|
2430
|
+
change_description=change_description,
|
|
2431
|
+
tags_to_add=tags_to_add,
|
|
1870
2432
|
request_options=request_options,
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
try:
|
|
1874
|
-
if 200 <= _response.status_code < 300:
|
|
1875
|
-
_chunk_size = (
|
|
1876
|
-
request_options.get("chunk_size", None)
|
|
1877
|
-
if request_options is not None
|
|
1878
|
-
else None
|
|
1879
|
-
)
|
|
1880
|
-
async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size):
|
|
1881
|
-
yield _chunk
|
|
1882
|
-
return
|
|
1883
|
-
await _response.aread()
|
|
1884
|
-
_response_json = _response.json()
|
|
1885
|
-
except JSONDecodeError:
|
|
1886
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1887
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2433
|
+
)
|
|
2434
|
+
return _response.data
|