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.
Files changed (1021) hide show
  1. opik/__init__.py +33 -2
  2. opik/anonymizer/__init__.py +5 -0
  3. opik/anonymizer/anonymizer.py +12 -0
  4. opik/anonymizer/factory.py +80 -0
  5. opik/anonymizer/recursive_anonymizer.py +64 -0
  6. opik/anonymizer/rules.py +56 -0
  7. opik/anonymizer/rules_anonymizer.py +35 -0
  8. opik/api_objects/attachment/__init__.py +5 -0
  9. opik/api_objects/attachment/attachment.py +20 -0
  10. opik/api_objects/attachment/attachment_context.py +36 -0
  11. opik/api_objects/attachment/attachments_extractor.py +153 -0
  12. opik/api_objects/attachment/client.py +220 -0
  13. opik/api_objects/attachment/converters.py +51 -0
  14. opik/api_objects/attachment/decoder.py +18 -0
  15. opik/api_objects/attachment/decoder_base64.py +83 -0
  16. opik/api_objects/attachment/decoder_helpers.py +137 -0
  17. opik/api_objects/conversation/__init__.py +0 -0
  18. opik/api_objects/conversation/conversation_factory.py +43 -0
  19. opik/api_objects/conversation/conversation_thread.py +49 -0
  20. opik/api_objects/data_helpers.py +79 -0
  21. opik/api_objects/dataset/dataset.py +107 -45
  22. opik/api_objects/dataset/rest_operations.py +12 -3
  23. opik/api_objects/experiment/experiment.py +81 -45
  24. opik/api_objects/experiment/experiment_item.py +2 -1
  25. opik/api_objects/experiment/experiments_client.py +64 -0
  26. opik/api_objects/experiment/helpers.py +35 -11
  27. opik/api_objects/experiment/rest_operations.py +88 -19
  28. opik/api_objects/helpers.py +104 -7
  29. opik/api_objects/local_recording.py +81 -0
  30. opik/api_objects/opik_client.py +872 -174
  31. opik/api_objects/opik_query_language.py +136 -18
  32. opik/api_objects/optimization/__init__.py +3 -0
  33. opik/api_objects/optimization/optimization.py +39 -0
  34. opik/api_objects/prompt/__init__.py +13 -1
  35. opik/api_objects/prompt/base_prompt.py +69 -0
  36. opik/api_objects/prompt/base_prompt_template.py +29 -0
  37. opik/api_objects/prompt/chat/__init__.py +1 -0
  38. opik/api_objects/prompt/chat/chat_prompt.py +210 -0
  39. opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
  40. opik/api_objects/prompt/chat/content_renderer_registry.py +203 -0
  41. opik/api_objects/prompt/client.py +193 -41
  42. opik/api_objects/prompt/text/__init__.py +1 -0
  43. opik/api_objects/prompt/text/prompt.py +174 -0
  44. opik/api_objects/prompt/text/prompt_template.py +55 -0
  45. opik/api_objects/prompt/types.py +29 -0
  46. opik/api_objects/rest_stream_parser.py +98 -0
  47. opik/api_objects/search_helpers.py +89 -0
  48. opik/api_objects/span/span_client.py +165 -45
  49. opik/api_objects/span/span_data.py +136 -25
  50. opik/api_objects/threads/__init__.py +0 -0
  51. opik/api_objects/threads/threads_client.py +185 -0
  52. opik/api_objects/trace/trace_client.py +72 -36
  53. opik/api_objects/trace/trace_data.py +112 -26
  54. opik/api_objects/validation_helpers.py +3 -3
  55. opik/cli/__init__.py +5 -0
  56. opik/cli/__main__.py +6 -0
  57. opik/cli/configure.py +66 -0
  58. opik/cli/exports/__init__.py +131 -0
  59. opik/cli/exports/dataset.py +278 -0
  60. opik/cli/exports/experiment.py +784 -0
  61. opik/cli/exports/project.py +685 -0
  62. opik/cli/exports/prompt.py +578 -0
  63. opik/cli/exports/utils.py +406 -0
  64. opik/cli/harbor.py +39 -0
  65. opik/cli/healthcheck.py +21 -0
  66. opik/cli/imports/__init__.py +439 -0
  67. opik/cli/imports/dataset.py +143 -0
  68. opik/cli/imports/experiment.py +1192 -0
  69. opik/cli/imports/project.py +262 -0
  70. opik/cli/imports/prompt.py +177 -0
  71. opik/cli/imports/utils.py +280 -0
  72. opik/cli/main.py +49 -0
  73. opik/cli/proxy.py +93 -0
  74. opik/cli/usage_report/__init__.py +16 -0
  75. opik/cli/usage_report/charts.py +783 -0
  76. opik/cli/usage_report/cli.py +274 -0
  77. opik/cli/usage_report/constants.py +9 -0
  78. opik/cli/usage_report/extraction.py +749 -0
  79. opik/cli/usage_report/pdf.py +244 -0
  80. opik/cli/usage_report/statistics.py +78 -0
  81. opik/cli/usage_report/utils.py +235 -0
  82. opik/config.py +62 -4
  83. opik/configurator/configure.py +45 -6
  84. opik/configurator/opik_rest_helpers.py +4 -1
  85. opik/context_storage.py +164 -65
  86. opik/datetime_helpers.py +12 -0
  87. opik/decorator/arguments_helpers.py +9 -1
  88. opik/decorator/base_track_decorator.py +298 -146
  89. opik/decorator/context_manager/__init__.py +0 -0
  90. opik/decorator/context_manager/span_context_manager.py +123 -0
  91. opik/decorator/context_manager/trace_context_manager.py +84 -0
  92. opik/decorator/generator_wrappers.py +3 -2
  93. opik/decorator/inspect_helpers.py +11 -0
  94. opik/decorator/opik_args/__init__.py +13 -0
  95. opik/decorator/opik_args/api_classes.py +71 -0
  96. opik/decorator/opik_args/helpers.py +120 -0
  97. opik/decorator/span_creation_handler.py +49 -21
  98. opik/decorator/tracker.py +9 -1
  99. opik/dict_utils.py +3 -3
  100. opik/environment.py +13 -1
  101. opik/error_tracking/api.py +1 -1
  102. opik/error_tracking/before_send.py +6 -5
  103. opik/error_tracking/environment_details.py +29 -7
  104. opik/error_tracking/error_filtering/filter_by_response_status_code.py +42 -0
  105. opik/error_tracking/error_filtering/filter_chain_builder.py +14 -3
  106. opik/evaluation/__init__.py +14 -2
  107. opik/evaluation/engine/engine.py +280 -82
  108. opik/evaluation/engine/evaluation_tasks_executor.py +15 -10
  109. opik/evaluation/engine/helpers.py +34 -9
  110. opik/evaluation/engine/metrics_evaluator.py +237 -0
  111. opik/evaluation/engine/types.py +5 -4
  112. opik/evaluation/evaluation_result.py +169 -2
  113. opik/evaluation/evaluator.py +659 -58
  114. opik/evaluation/metrics/__init__.py +121 -6
  115. opik/evaluation/metrics/aggregated_metric.py +92 -0
  116. opik/evaluation/metrics/arguments_helpers.py +15 -21
  117. opik/evaluation/metrics/arguments_validator.py +38 -0
  118. opik/evaluation/metrics/base_metric.py +20 -10
  119. opik/evaluation/metrics/conversation/__init__.py +48 -0
  120. opik/evaluation/metrics/conversation/conversation_thread_metric.py +79 -0
  121. opik/evaluation/metrics/conversation/conversation_turns_factory.py +39 -0
  122. opik/evaluation/metrics/conversation/g_eval_wrappers.py +19 -0
  123. opik/evaluation/metrics/conversation/helpers.py +84 -0
  124. opik/evaluation/metrics/conversation/heuristics/__init__.py +14 -0
  125. opik/evaluation/metrics/conversation/heuristics/degeneration/__init__.py +3 -0
  126. opik/evaluation/metrics/conversation/heuristics/degeneration/metric.py +189 -0
  127. opik/evaluation/metrics/conversation/heuristics/degeneration/phrases.py +12 -0
  128. opik/evaluation/metrics/conversation/heuristics/knowledge_retention/__init__.py +3 -0
  129. opik/evaluation/metrics/conversation/heuristics/knowledge_retention/metric.py +172 -0
  130. opik/evaluation/metrics/conversation/llm_judges/__init__.py +32 -0
  131. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/__init__.py +0 -0
  132. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/metric.py +274 -0
  133. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/schema.py +16 -0
  134. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/templates.py +95 -0
  135. opik/evaluation/metrics/conversation/llm_judges/g_eval_wrappers.py +442 -0
  136. opik/evaluation/metrics/conversation/llm_judges/session_completeness/__init__.py +0 -0
  137. opik/evaluation/metrics/conversation/llm_judges/session_completeness/metric.py +295 -0
  138. opik/evaluation/metrics/conversation/llm_judges/session_completeness/schema.py +22 -0
  139. opik/evaluation/metrics/conversation/llm_judges/session_completeness/templates.py +139 -0
  140. opik/evaluation/metrics/conversation/llm_judges/user_frustration/__init__.py +0 -0
  141. opik/evaluation/metrics/conversation/llm_judges/user_frustration/metric.py +277 -0
  142. opik/evaluation/metrics/conversation/llm_judges/user_frustration/schema.py +16 -0
  143. opik/evaluation/metrics/conversation/llm_judges/user_frustration/templates.py +135 -0
  144. opik/evaluation/metrics/conversation/types.py +34 -0
  145. opik/evaluation/metrics/conversation_types.py +9 -0
  146. opik/evaluation/metrics/heuristics/bertscore.py +107 -0
  147. opik/evaluation/metrics/heuristics/bleu.py +43 -16
  148. opik/evaluation/metrics/heuristics/chrf.py +127 -0
  149. opik/evaluation/metrics/heuristics/contains.py +50 -11
  150. opik/evaluation/metrics/heuristics/distribution_metrics.py +331 -0
  151. opik/evaluation/metrics/heuristics/equals.py +4 -1
  152. opik/evaluation/metrics/heuristics/gleu.py +113 -0
  153. opik/evaluation/metrics/heuristics/is_json.py +9 -3
  154. opik/evaluation/metrics/heuristics/language_adherence.py +123 -0
  155. opik/evaluation/metrics/heuristics/levenshtein_ratio.py +6 -5
  156. opik/evaluation/metrics/heuristics/meteor.py +119 -0
  157. opik/evaluation/metrics/heuristics/prompt_injection.py +150 -0
  158. opik/evaluation/metrics/heuristics/readability.py +129 -0
  159. opik/evaluation/metrics/heuristics/regex_match.py +4 -1
  160. opik/evaluation/metrics/heuristics/rouge.py +148 -0
  161. opik/evaluation/metrics/heuristics/sentiment.py +98 -0
  162. opik/evaluation/metrics/heuristics/spearman.py +88 -0
  163. opik/evaluation/metrics/heuristics/tone.py +155 -0
  164. opik/evaluation/metrics/heuristics/vader_sentiment.py +77 -0
  165. opik/evaluation/metrics/llm_judges/answer_relevance/metric.py +27 -30
  166. opik/evaluation/metrics/llm_judges/answer_relevance/parser.py +27 -0
  167. opik/evaluation/metrics/llm_judges/answer_relevance/templates.py +10 -10
  168. opik/evaluation/metrics/llm_judges/context_precision/metric.py +28 -31
  169. opik/evaluation/metrics/llm_judges/context_precision/parser.py +27 -0
  170. opik/evaluation/metrics/llm_judges/context_precision/template.py +7 -7
  171. opik/evaluation/metrics/llm_judges/context_recall/metric.py +27 -31
  172. opik/evaluation/metrics/llm_judges/context_recall/parser.py +27 -0
  173. opik/evaluation/metrics/llm_judges/context_recall/template.py +7 -7
  174. opik/evaluation/metrics/llm_judges/factuality/metric.py +7 -26
  175. opik/evaluation/metrics/llm_judges/factuality/parser.py +35 -0
  176. opik/evaluation/metrics/llm_judges/factuality/template.py +1 -1
  177. opik/evaluation/metrics/llm_judges/g_eval/__init__.py +5 -0
  178. opik/evaluation/metrics/llm_judges/g_eval/metric.py +244 -113
  179. opik/evaluation/metrics/llm_judges/g_eval/parser.py +161 -0
  180. opik/evaluation/metrics/llm_judges/g_eval/presets.py +209 -0
  181. opik/evaluation/metrics/llm_judges/g_eval_presets/__init__.py +36 -0
  182. opik/evaluation/metrics/llm_judges/g_eval_presets/agent_assessment.py +77 -0
  183. opik/evaluation/metrics/llm_judges/g_eval_presets/bias_classifier.py +181 -0
  184. opik/evaluation/metrics/llm_judges/g_eval_presets/compliance_risk.py +41 -0
  185. opik/evaluation/metrics/llm_judges/g_eval_presets/prompt_uncertainty.py +41 -0
  186. opik/evaluation/metrics/llm_judges/g_eval_presets/qa_suite.py +146 -0
  187. opik/evaluation/metrics/llm_judges/hallucination/metric.py +23 -27
  188. opik/evaluation/metrics/llm_judges/hallucination/parser.py +29 -0
  189. opik/evaluation/metrics/llm_judges/hallucination/template.py +2 -4
  190. opik/evaluation/metrics/llm_judges/llm_juries/__init__.py +3 -0
  191. opik/evaluation/metrics/llm_judges/llm_juries/metric.py +76 -0
  192. opik/evaluation/metrics/llm_judges/moderation/metric.py +23 -28
  193. opik/evaluation/metrics/llm_judges/moderation/parser.py +27 -0
  194. opik/evaluation/metrics/llm_judges/moderation/template.py +2 -2
  195. opik/evaluation/metrics/llm_judges/parsing_helpers.py +26 -0
  196. opik/evaluation/metrics/llm_judges/structure_output_compliance/__init__.py +0 -0
  197. opik/evaluation/metrics/llm_judges/structure_output_compliance/metric.py +144 -0
  198. opik/evaluation/metrics/llm_judges/structure_output_compliance/parser.py +79 -0
  199. opik/evaluation/metrics/llm_judges/structure_output_compliance/schema.py +15 -0
  200. opik/evaluation/metrics/llm_judges/structure_output_compliance/template.py +50 -0
  201. opik/evaluation/metrics/llm_judges/syc_eval/__init__.py +0 -0
  202. opik/evaluation/metrics/llm_judges/syc_eval/metric.py +252 -0
  203. opik/evaluation/metrics/llm_judges/syc_eval/parser.py +82 -0
  204. opik/evaluation/metrics/llm_judges/syc_eval/template.py +155 -0
  205. opik/evaluation/metrics/llm_judges/trajectory_accuracy/__init__.py +3 -0
  206. opik/evaluation/metrics/llm_judges/trajectory_accuracy/metric.py +171 -0
  207. opik/evaluation/metrics/llm_judges/trajectory_accuracy/parser.py +38 -0
  208. opik/evaluation/metrics/llm_judges/trajectory_accuracy/templates.py +65 -0
  209. opik/evaluation/metrics/llm_judges/usefulness/metric.py +23 -32
  210. opik/evaluation/metrics/llm_judges/usefulness/parser.py +28 -0
  211. opik/evaluation/metrics/ragas_metric.py +112 -0
  212. opik/evaluation/models/__init__.py +10 -0
  213. opik/evaluation/models/base_model.py +140 -18
  214. opik/evaluation/models/langchain/__init__.py +3 -0
  215. opik/evaluation/models/langchain/langchain_chat_model.py +166 -0
  216. opik/evaluation/models/langchain/message_converters.py +106 -0
  217. opik/evaluation/models/langchain/opik_monitoring.py +23 -0
  218. opik/evaluation/models/litellm/litellm_chat_model.py +186 -40
  219. opik/evaluation/models/litellm/opik_monitor.py +24 -21
  220. opik/evaluation/models/litellm/util.py +125 -0
  221. opik/evaluation/models/litellm/warning_filters.py +16 -4
  222. opik/evaluation/models/model_capabilities.py +187 -0
  223. opik/evaluation/models/models_factory.py +25 -3
  224. opik/evaluation/preprocessing.py +92 -0
  225. opik/evaluation/report.py +70 -12
  226. opik/evaluation/rest_operations.py +49 -45
  227. opik/evaluation/samplers/__init__.py +4 -0
  228. opik/evaluation/samplers/base_dataset_sampler.py +40 -0
  229. opik/evaluation/samplers/random_dataset_sampler.py +48 -0
  230. opik/evaluation/score_statistics.py +66 -0
  231. opik/evaluation/scorers/__init__.py +4 -0
  232. opik/evaluation/scorers/scorer_function.py +55 -0
  233. opik/evaluation/scorers/scorer_wrapper_metric.py +130 -0
  234. opik/evaluation/test_case.py +3 -2
  235. opik/evaluation/test_result.py +1 -0
  236. opik/evaluation/threads/__init__.py +0 -0
  237. opik/evaluation/threads/context_helper.py +32 -0
  238. opik/evaluation/threads/evaluation_engine.py +181 -0
  239. opik/evaluation/threads/evaluation_result.py +18 -0
  240. opik/evaluation/threads/evaluator.py +120 -0
  241. opik/evaluation/threads/helpers.py +51 -0
  242. opik/evaluation/types.py +9 -1
  243. opik/exceptions.py +116 -3
  244. opik/file_upload/__init__.py +0 -0
  245. opik/file_upload/base_upload_manager.py +39 -0
  246. opik/file_upload/file_upload_monitor.py +14 -0
  247. opik/file_upload/file_uploader.py +141 -0
  248. opik/file_upload/mime_type.py +9 -0
  249. opik/file_upload/s3_multipart_upload/__init__.py +0 -0
  250. opik/file_upload/s3_multipart_upload/file_parts_strategy.py +89 -0
  251. opik/file_upload/s3_multipart_upload/s3_file_uploader.py +86 -0
  252. opik/file_upload/s3_multipart_upload/s3_upload_error.py +29 -0
  253. opik/file_upload/thread_pool.py +17 -0
  254. opik/file_upload/upload_client.py +114 -0
  255. opik/file_upload/upload_manager.py +255 -0
  256. opik/file_upload/upload_options.py +37 -0
  257. opik/format_helpers.py +17 -0
  258. opik/guardrails/__init__.py +4 -0
  259. opik/guardrails/guardrail.py +157 -0
  260. opik/guardrails/guards/__init__.py +5 -0
  261. opik/guardrails/guards/guard.py +17 -0
  262. opik/guardrails/guards/pii.py +47 -0
  263. opik/guardrails/guards/topic.py +76 -0
  264. opik/guardrails/rest_api_client.py +34 -0
  265. opik/guardrails/schemas.py +24 -0
  266. opik/guardrails/tracing.py +61 -0
  267. opik/healthcheck/__init__.py +2 -1
  268. opik/healthcheck/checks.py +2 -2
  269. opik/healthcheck/rich_representation.py +1 -1
  270. opik/hooks/__init__.py +23 -0
  271. opik/hooks/anonymizer_hook.py +36 -0
  272. opik/hooks/httpx_client_hook.py +112 -0
  273. opik/httpx_client.py +75 -4
  274. opik/id_helpers.py +18 -0
  275. opik/integrations/adk/__init__.py +14 -0
  276. opik/integrations/adk/callback_context_info_extractors.py +32 -0
  277. opik/integrations/adk/graph/__init__.py +0 -0
  278. opik/integrations/adk/graph/mermaid_graph_builder.py +128 -0
  279. opik/integrations/adk/graph/nodes.py +101 -0
  280. opik/integrations/adk/graph/subgraph_edges_builders.py +41 -0
  281. opik/integrations/adk/helpers.py +48 -0
  282. opik/integrations/adk/legacy_opik_tracer.py +381 -0
  283. opik/integrations/adk/opik_tracer.py +370 -0
  284. opik/integrations/adk/patchers/__init__.py +4 -0
  285. opik/integrations/adk/patchers/adk_otel_tracer/__init__.py +0 -0
  286. opik/integrations/adk/patchers/adk_otel_tracer/llm_span_helpers.py +30 -0
  287. opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +201 -0
  288. opik/integrations/adk/patchers/litellm_wrappers.py +91 -0
  289. opik/integrations/adk/patchers/llm_response_wrapper.py +105 -0
  290. opik/integrations/adk/patchers/patchers.py +64 -0
  291. opik/integrations/adk/recursive_callback_injector.py +126 -0
  292. opik/integrations/aisuite/aisuite_decorator.py +8 -3
  293. opik/integrations/aisuite/opik_tracker.py +1 -0
  294. opik/integrations/anthropic/messages_create_decorator.py +8 -3
  295. opik/integrations/anthropic/opik_tracker.py +0 -1
  296. opik/integrations/bedrock/converse/__init__.py +0 -0
  297. opik/integrations/bedrock/converse/chunks_aggregator.py +188 -0
  298. opik/integrations/bedrock/{converse_decorator.py → converse/converse_decorator.py} +18 -8
  299. opik/integrations/bedrock/invoke_agent_decorator.py +12 -7
  300. opik/integrations/bedrock/invoke_model/__init__.py +0 -0
  301. opik/integrations/bedrock/invoke_model/chunks_aggregator/__init__.py +78 -0
  302. opik/integrations/bedrock/invoke_model/chunks_aggregator/api.py +45 -0
  303. opik/integrations/bedrock/invoke_model/chunks_aggregator/base.py +23 -0
  304. opik/integrations/bedrock/invoke_model/chunks_aggregator/claude.py +121 -0
  305. opik/integrations/bedrock/invoke_model/chunks_aggregator/format_detector.py +107 -0
  306. opik/integrations/bedrock/invoke_model/chunks_aggregator/llama.py +108 -0
  307. opik/integrations/bedrock/invoke_model/chunks_aggregator/mistral.py +118 -0
  308. opik/integrations/bedrock/invoke_model/chunks_aggregator/nova.py +99 -0
  309. opik/integrations/bedrock/invoke_model/invoke_model_decorator.py +178 -0
  310. opik/integrations/bedrock/invoke_model/response_types.py +34 -0
  311. opik/integrations/bedrock/invoke_model/stream_wrappers.py +122 -0
  312. opik/integrations/bedrock/invoke_model/usage_converters.py +87 -0
  313. opik/integrations/bedrock/invoke_model/usage_extraction.py +108 -0
  314. opik/integrations/bedrock/opik_tracker.py +43 -4
  315. opik/integrations/bedrock/types.py +19 -0
  316. opik/integrations/crewai/crewai_decorator.py +34 -56
  317. opik/integrations/crewai/opik_tracker.py +31 -10
  318. opik/integrations/crewai/patchers/__init__.py +5 -0
  319. opik/integrations/crewai/patchers/flow.py +118 -0
  320. opik/integrations/crewai/patchers/litellm_completion.py +30 -0
  321. opik/integrations/crewai/patchers/llm_client.py +207 -0
  322. opik/integrations/dspy/callback.py +246 -84
  323. opik/integrations/dspy/graph.py +88 -0
  324. opik/integrations/dspy/parsers.py +168 -0
  325. opik/integrations/genai/encoder_extension.py +2 -6
  326. opik/integrations/genai/generate_content_decorator.py +20 -13
  327. opik/integrations/guardrails/guardrails_decorator.py +4 -0
  328. opik/integrations/harbor/__init__.py +17 -0
  329. opik/integrations/harbor/experiment_service.py +269 -0
  330. opik/integrations/harbor/opik_tracker.py +528 -0
  331. opik/integrations/haystack/constants.py +35 -0
  332. opik/integrations/haystack/converters.py +1 -2
  333. opik/integrations/haystack/opik_connector.py +28 -6
  334. opik/integrations/haystack/opik_span_bridge.py +284 -0
  335. opik/integrations/haystack/opik_tracer.py +124 -222
  336. opik/integrations/langchain/__init__.py +3 -1
  337. opik/integrations/langchain/helpers.py +96 -0
  338. opik/integrations/langchain/langgraph_async_context_bridge.py +131 -0
  339. opik/integrations/langchain/langgraph_tracer_injector.py +88 -0
  340. opik/integrations/langchain/opik_encoder_extension.py +2 -2
  341. opik/integrations/langchain/opik_tracer.py +641 -206
  342. opik/integrations/langchain/provider_usage_extractors/__init__.py +5 -0
  343. opik/integrations/langchain/provider_usage_extractors/anthropic_usage_extractor.py +101 -0
  344. opik/integrations/langchain/provider_usage_extractors/anthropic_vertexai_usage_extractor.py +67 -0
  345. opik/integrations/langchain/provider_usage_extractors/bedrock_usage_extractor.py +94 -0
  346. opik/integrations/langchain/provider_usage_extractors/google_generative_ai_usage_extractor.py +109 -0
  347. opik/integrations/langchain/provider_usage_extractors/groq_usage_extractor.py +92 -0
  348. opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/__init__.py +15 -0
  349. opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/helpers.py +134 -0
  350. opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/langchain_usage.py +163 -0
  351. opik/integrations/langchain/provider_usage_extractors/openai_usage_extractor.py +124 -0
  352. opik/integrations/langchain/provider_usage_extractors/provider_usage_extractor_protocol.py +29 -0
  353. opik/integrations/langchain/provider_usage_extractors/usage_extractor.py +48 -0
  354. opik/integrations/langchain/provider_usage_extractors/vertexai_usage_extractor.py +109 -0
  355. opik/integrations/litellm/__init__.py +5 -0
  356. opik/integrations/litellm/completion_chunks_aggregator.py +115 -0
  357. opik/integrations/litellm/litellm_completion_decorator.py +242 -0
  358. opik/integrations/litellm/opik_tracker.py +43 -0
  359. opik/integrations/litellm/stream_patchers.py +151 -0
  360. opik/integrations/llama_index/callback.py +179 -78
  361. opik/integrations/llama_index/event_parsing_utils.py +29 -9
  362. opik/integrations/openai/agents/opik_tracing_processor.py +204 -32
  363. opik/integrations/openai/agents/span_data_parsers.py +15 -6
  364. opik/integrations/openai/chat_completion_chunks_aggregator.py +1 -1
  365. opik/integrations/openai/{openai_decorator.py → openai_chat_completions_decorator.py} +45 -35
  366. opik/integrations/openai/openai_responses_decorator.py +158 -0
  367. opik/integrations/openai/opik_tracker.py +94 -13
  368. opik/integrations/openai/response_events_aggregator.py +36 -0
  369. opik/integrations/openai/stream_patchers.py +125 -15
  370. opik/integrations/sagemaker/auth.py +5 -1
  371. opik/jsonable_encoder.py +29 -1
  372. opik/llm_usage/base_original_provider_usage.py +15 -8
  373. opik/llm_usage/bedrock_usage.py +8 -2
  374. opik/llm_usage/google_usage.py +6 -1
  375. opik/llm_usage/llm_usage_info.py +6 -0
  376. opik/llm_usage/{openai_usage.py → openai_chat_completions_usage.py} +2 -12
  377. opik/llm_usage/{openai_agent_usage.py → openai_responses_usage.py} +7 -15
  378. opik/llm_usage/opik_usage.py +36 -10
  379. opik/llm_usage/opik_usage_factory.py +35 -19
  380. opik/logging_messages.py +19 -7
  381. opik/message_processing/arguments_utils.py +22 -0
  382. opik/message_processing/batching/base_batcher.py +45 -17
  383. opik/message_processing/batching/batch_manager.py +22 -10
  384. opik/message_processing/batching/batch_manager_constuctors.py +36 -11
  385. opik/message_processing/batching/batchers.py +167 -44
  386. opik/message_processing/batching/flushing_thread.py +0 -3
  387. opik/message_processing/batching/sequence_splitter.py +50 -5
  388. opik/message_processing/emulation/__init__.py +0 -0
  389. opik/message_processing/emulation/emulator_message_processor.py +578 -0
  390. opik/message_processing/emulation/local_emulator_message_processor.py +140 -0
  391. opik/message_processing/emulation/models.py +162 -0
  392. opik/message_processing/encoder_helpers.py +79 -0
  393. opik/message_processing/message_queue.py +79 -0
  394. opik/message_processing/messages.py +154 -12
  395. opik/message_processing/preprocessing/__init__.py +0 -0
  396. opik/message_processing/preprocessing/attachments_preprocessor.py +70 -0
  397. opik/message_processing/preprocessing/batching_preprocessor.py +53 -0
  398. opik/message_processing/preprocessing/constants.py +1 -0
  399. opik/message_processing/preprocessing/file_upload_preprocessor.py +38 -0
  400. opik/message_processing/preprocessing/preprocessor.py +36 -0
  401. opik/message_processing/processors/__init__.py +0 -0
  402. opik/message_processing/processors/attachments_extraction_processor.py +146 -0
  403. opik/message_processing/processors/message_processors.py +92 -0
  404. opik/message_processing/processors/message_processors_chain.py +96 -0
  405. opik/message_processing/processors/online_message_processor.py +324 -0
  406. opik/message_processing/queue_consumer.py +61 -13
  407. opik/message_processing/streamer.py +102 -31
  408. opik/message_processing/streamer_constructors.py +67 -12
  409. opik/opik_context.py +103 -11
  410. opik/plugins/pytest/decorator.py +2 -2
  411. opik/plugins/pytest/experiment_runner.py +3 -2
  412. opik/plugins/pytest/hooks.py +6 -4
  413. opik/rate_limit/__init__.py +0 -0
  414. opik/rate_limit/rate_limit.py +25 -0
  415. opik/rest_api/__init__.py +643 -11
  416. opik/rest_api/alerts/__init__.py +7 -0
  417. opik/rest_api/alerts/client.py +667 -0
  418. opik/rest_api/alerts/raw_client.py +1015 -0
  419. opik/rest_api/alerts/types/__init__.py +7 -0
  420. opik/rest_api/alerts/types/get_webhook_examples_request_alert_type.py +5 -0
  421. opik/rest_api/annotation_queues/__init__.py +4 -0
  422. opik/rest_api/annotation_queues/client.py +668 -0
  423. opik/rest_api/annotation_queues/raw_client.py +1019 -0
  424. opik/rest_api/attachments/__init__.py +17 -0
  425. opik/rest_api/attachments/client.py +752 -0
  426. opik/rest_api/attachments/raw_client.py +1125 -0
  427. opik/rest_api/attachments/types/__init__.py +15 -0
  428. opik/rest_api/attachments/types/attachment_list_request_entity_type.py +5 -0
  429. opik/rest_api/attachments/types/download_attachment_request_entity_type.py +5 -0
  430. opik/rest_api/attachments/types/start_multipart_upload_request_entity_type.py +5 -0
  431. opik/rest_api/attachments/types/upload_attachment_request_entity_type.py +5 -0
  432. opik/rest_api/automation_rule_evaluators/__init__.py +2 -0
  433. opik/rest_api/automation_rule_evaluators/client.py +182 -1162
  434. opik/rest_api/automation_rule_evaluators/raw_client.py +598 -0
  435. opik/rest_api/chat_completions/__init__.py +2 -0
  436. opik/rest_api/chat_completions/client.py +115 -149
  437. opik/rest_api/chat_completions/raw_client.py +339 -0
  438. opik/rest_api/check/__init__.py +2 -0
  439. opik/rest_api/check/client.py +88 -106
  440. opik/rest_api/check/raw_client.py +258 -0
  441. opik/rest_api/client.py +112 -212
  442. opik/rest_api/core/__init__.py +5 -0
  443. opik/rest_api/core/api_error.py +12 -6
  444. opik/rest_api/core/client_wrapper.py +4 -14
  445. opik/rest_api/core/datetime_utils.py +1 -3
  446. opik/rest_api/core/file.py +2 -5
  447. opik/rest_api/core/http_client.py +42 -120
  448. opik/rest_api/core/http_response.py +55 -0
  449. opik/rest_api/core/jsonable_encoder.py +1 -4
  450. opik/rest_api/core/pydantic_utilities.py +79 -147
  451. opik/rest_api/core/query_encoder.py +1 -3
  452. opik/rest_api/core/serialization.py +10 -10
  453. opik/rest_api/dashboards/__init__.py +4 -0
  454. opik/rest_api/dashboards/client.py +462 -0
  455. opik/rest_api/dashboards/raw_client.py +648 -0
  456. opik/rest_api/datasets/__init__.py +5 -0
  457. opik/rest_api/datasets/client.py +1638 -1091
  458. opik/rest_api/datasets/raw_client.py +3389 -0
  459. opik/rest_api/datasets/types/__init__.py +8 -0
  460. opik/rest_api/datasets/types/dataset_update_visibility.py +5 -0
  461. opik/rest_api/datasets/types/dataset_write_visibility.py +5 -0
  462. opik/rest_api/errors/__init__.py +2 -0
  463. opik/rest_api/errors/bad_request_error.py +4 -3
  464. opik/rest_api/errors/conflict_error.py +4 -3
  465. opik/rest_api/errors/forbidden_error.py +4 -2
  466. opik/rest_api/errors/not_found_error.py +4 -3
  467. opik/rest_api/errors/not_implemented_error.py +4 -3
  468. opik/rest_api/errors/unauthorized_error.py +4 -3
  469. opik/rest_api/errors/unprocessable_entity_error.py +4 -3
  470. opik/rest_api/experiments/__init__.py +5 -0
  471. opik/rest_api/experiments/client.py +676 -752
  472. opik/rest_api/experiments/raw_client.py +1872 -0
  473. opik/rest_api/experiments/types/__init__.py +10 -0
  474. opik/rest_api/experiments/types/experiment_update_status.py +5 -0
  475. opik/rest_api/experiments/types/experiment_update_type.py +5 -0
  476. opik/rest_api/experiments/types/experiment_write_status.py +5 -0
  477. opik/rest_api/experiments/types/experiment_write_type.py +5 -0
  478. opik/rest_api/feedback_definitions/__init__.py +2 -0
  479. opik/rest_api/feedback_definitions/client.py +96 -370
  480. opik/rest_api/feedback_definitions/raw_client.py +541 -0
  481. opik/rest_api/feedback_definitions/types/__init__.py +2 -0
  482. opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -3
  483. opik/rest_api/guardrails/__init__.py +4 -0
  484. opik/rest_api/guardrails/client.py +104 -0
  485. opik/rest_api/guardrails/raw_client.py +102 -0
  486. opik/rest_api/llm_provider_key/__init__.py +2 -0
  487. opik/rest_api/llm_provider_key/client.py +166 -440
  488. opik/rest_api/llm_provider_key/raw_client.py +643 -0
  489. opik/rest_api/llm_provider_key/types/__init__.py +2 -0
  490. opik/rest_api/llm_provider_key/types/provider_api_key_write_provider.py +1 -1
  491. opik/rest_api/manual_evaluation/__init__.py +4 -0
  492. opik/rest_api/manual_evaluation/client.py +347 -0
  493. opik/rest_api/manual_evaluation/raw_client.py +543 -0
  494. opik/rest_api/open_telemetry_ingestion/__init__.py +2 -0
  495. opik/rest_api/open_telemetry_ingestion/client.py +38 -63
  496. opik/rest_api/open_telemetry_ingestion/raw_client.py +88 -0
  497. opik/rest_api/optimizations/__init__.py +7 -0
  498. opik/rest_api/optimizations/client.py +704 -0
  499. opik/rest_api/optimizations/raw_client.py +920 -0
  500. opik/rest_api/optimizations/types/__init__.py +7 -0
  501. opik/rest_api/optimizations/types/optimization_update_status.py +7 -0
  502. opik/rest_api/projects/__init__.py +10 -1
  503. opik/rest_api/projects/client.py +180 -855
  504. opik/rest_api/projects/raw_client.py +1216 -0
  505. opik/rest_api/projects/types/__init__.py +11 -4
  506. opik/rest_api/projects/types/project_metric_request_public_interval.py +1 -3
  507. opik/rest_api/projects/types/project_metric_request_public_metric_type.py +11 -1
  508. opik/rest_api/projects/types/project_update_visibility.py +5 -0
  509. opik/rest_api/projects/types/project_write_visibility.py +5 -0
  510. opik/rest_api/prompts/__init__.py +4 -2
  511. opik/rest_api/prompts/client.py +381 -970
  512. opik/rest_api/prompts/raw_client.py +1634 -0
  513. opik/rest_api/prompts/types/__init__.py +5 -1
  514. opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
  515. opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
  516. opik/rest_api/raw_client.py +156 -0
  517. opik/rest_api/redirect/__init__.py +4 -0
  518. opik/rest_api/redirect/client.py +375 -0
  519. opik/rest_api/redirect/raw_client.py +566 -0
  520. opik/rest_api/service_toggles/__init__.py +4 -0
  521. opik/rest_api/service_toggles/client.py +91 -0
  522. opik/rest_api/service_toggles/raw_client.py +93 -0
  523. opik/rest_api/spans/__init__.py +2 -0
  524. opik/rest_api/spans/client.py +659 -1354
  525. opik/rest_api/spans/raw_client.py +2383 -0
  526. opik/rest_api/spans/types/__init__.py +2 -0
  527. opik/rest_api/spans/types/find_feedback_score_names_1_request_type.py +1 -3
  528. opik/rest_api/spans/types/get_span_stats_request_type.py +1 -3
  529. opik/rest_api/spans/types/get_spans_by_project_request_type.py +1 -3
  530. opik/rest_api/spans/types/span_search_stream_request_public_type.py +1 -3
  531. opik/rest_api/system_usage/__init__.py +2 -0
  532. opik/rest_api/system_usage/client.py +157 -216
  533. opik/rest_api/system_usage/raw_client.py +455 -0
  534. opik/rest_api/traces/__init__.py +2 -0
  535. opik/rest_api/traces/client.py +2102 -1625
  536. opik/rest_api/traces/raw_client.py +4144 -0
  537. opik/rest_api/types/__init__.py +629 -24
  538. opik/rest_api/types/aggregation_data.py +27 -0
  539. opik/rest_api/types/alert.py +33 -0
  540. opik/rest_api/types/alert_alert_type.py +5 -0
  541. opik/rest_api/types/alert_page_public.py +24 -0
  542. opik/rest_api/types/alert_public.py +33 -0
  543. opik/rest_api/types/alert_public_alert_type.py +5 -0
  544. opik/rest_api/types/alert_trigger.py +27 -0
  545. opik/rest_api/types/alert_trigger_config.py +28 -0
  546. opik/rest_api/types/alert_trigger_config_public.py +28 -0
  547. opik/rest_api/types/alert_trigger_config_public_type.py +10 -0
  548. opik/rest_api/types/alert_trigger_config_type.py +10 -0
  549. opik/rest_api/types/alert_trigger_config_write.py +22 -0
  550. opik/rest_api/types/alert_trigger_config_write_type.py +10 -0
  551. opik/rest_api/types/alert_trigger_event_type.py +19 -0
  552. opik/rest_api/types/alert_trigger_public.py +27 -0
  553. opik/rest_api/types/alert_trigger_public_event_type.py +19 -0
  554. opik/rest_api/types/alert_trigger_write.py +23 -0
  555. opik/rest_api/types/alert_trigger_write_event_type.py +19 -0
  556. opik/rest_api/types/alert_write.py +28 -0
  557. opik/rest_api/types/alert_write_alert_type.py +5 -0
  558. opik/rest_api/types/annotation_queue.py +42 -0
  559. opik/rest_api/types/annotation_queue_batch.py +27 -0
  560. opik/rest_api/types/{json_schema_element.py → annotation_queue_item_ids.py} +5 -7
  561. opik/rest_api/types/annotation_queue_page_public.py +28 -0
  562. opik/rest_api/types/annotation_queue_public.py +38 -0
  563. opik/rest_api/types/annotation_queue_public_scope.py +5 -0
  564. opik/rest_api/types/{workspace_metadata.py → annotation_queue_reviewer.py} +6 -7
  565. opik/rest_api/types/annotation_queue_reviewer_public.py +20 -0
  566. opik/rest_api/types/annotation_queue_scope.py +5 -0
  567. opik/rest_api/types/annotation_queue_write.py +31 -0
  568. opik/rest_api/types/annotation_queue_write_scope.py +5 -0
  569. opik/rest_api/types/assistant_message.py +7 -8
  570. opik/rest_api/types/assistant_message_role.py +1 -3
  571. opik/rest_api/types/attachment.py +22 -0
  572. opik/rest_api/types/attachment_page.py +28 -0
  573. opik/rest_api/types/audio_url.py +19 -0
  574. opik/rest_api/types/audio_url_public.py +19 -0
  575. opik/rest_api/types/audio_url_write.py +19 -0
  576. opik/rest_api/types/automation_rule_evaluator.py +160 -0
  577. opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +6 -6
  578. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +6 -6
  579. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +6 -6
  580. opik/rest_api/types/automation_rule_evaluator_object_object_public.py +155 -0
  581. opik/rest_api/types/automation_rule_evaluator_page_public.py +6 -6
  582. opik/rest_api/types/automation_rule_evaluator_public.py +155 -0
  583. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
  584. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
  585. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
  586. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python.py +22 -0
  587. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_public.py +22 -0
  588. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_write.py +22 -0
  589. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +22 -0
  590. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +22 -0
  591. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +22 -0
  592. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +22 -0
  593. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +22 -0
  594. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +22 -0
  595. opik/rest_api/types/automation_rule_evaluator_update.py +143 -0
  596. opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +6 -6
  597. opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
  598. opik/rest_api/types/automation_rule_evaluator_update_span_user_defined_metric_python.py +22 -0
  599. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +22 -0
  600. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +22 -0
  601. opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +6 -6
  602. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +6 -6
  603. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +6 -6
  604. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +6 -6
  605. opik/rest_api/types/automation_rule_evaluator_write.py +143 -0
  606. opik/rest_api/types/avg_value_stat_public.py +3 -5
  607. opik/rest_api/types/batch_delete.py +3 -5
  608. opik/rest_api/types/batch_delete_by_project.py +20 -0
  609. opik/rest_api/types/bi_information.py +3 -5
  610. opik/rest_api/types/bi_information_response.py +4 -6
  611. opik/rest_api/types/boolean_feedback_definition.py +25 -0
  612. opik/rest_api/types/boolean_feedback_definition_create.py +20 -0
  613. opik/rest_api/types/boolean_feedback_definition_public.py +25 -0
  614. opik/rest_api/types/boolean_feedback_definition_update.py +20 -0
  615. opik/rest_api/types/boolean_feedback_detail.py +29 -0
  616. opik/rest_api/types/boolean_feedback_detail_create.py +29 -0
  617. opik/rest_api/types/boolean_feedback_detail_public.py +29 -0
  618. opik/rest_api/types/boolean_feedback_detail_update.py +29 -0
  619. opik/rest_api/types/categorical_feedback_definition.py +5 -7
  620. opik/rest_api/types/categorical_feedback_definition_create.py +4 -6
  621. opik/rest_api/types/categorical_feedback_definition_public.py +5 -7
  622. opik/rest_api/types/categorical_feedback_definition_update.py +4 -6
  623. opik/rest_api/types/categorical_feedback_detail.py +3 -5
  624. opik/rest_api/types/categorical_feedback_detail_create.py +3 -5
  625. opik/rest_api/types/categorical_feedback_detail_public.py +3 -5
  626. opik/rest_api/types/categorical_feedback_detail_update.py +3 -5
  627. opik/rest_api/types/chat_completion_choice.py +4 -6
  628. opik/rest_api/types/chat_completion_response.py +5 -6
  629. opik/rest_api/types/check.py +22 -0
  630. opik/rest_api/types/{json_node_compare.py → check_name.py} +1 -1
  631. opik/rest_api/types/check_public.py +22 -0
  632. opik/rest_api/types/check_public_name.py +5 -0
  633. opik/rest_api/types/check_public_result.py +5 -0
  634. opik/rest_api/types/check_result.py +5 -0
  635. opik/rest_api/types/chunked_output_json_node.py +4 -6
  636. opik/rest_api/types/chunked_output_json_node_public.py +4 -6
  637. opik/rest_api/types/chunked_output_json_node_public_type.py +6 -10
  638. opik/rest_api/types/chunked_output_json_node_type.py +6 -10
  639. opik/rest_api/types/column.py +8 -10
  640. opik/rest_api/types/column_compare.py +8 -10
  641. opik/rest_api/types/column_public.py +8 -10
  642. opik/rest_api/types/column_types_item.py +1 -3
  643. opik/rest_api/types/comment.py +4 -6
  644. opik/rest_api/types/comment_compare.py +4 -6
  645. opik/rest_api/types/comment_public.py +4 -6
  646. opik/rest_api/types/complete_multipart_upload_request.py +33 -0
  647. opik/rest_api/types/complete_multipart_upload_request_entity_type.py +5 -0
  648. opik/rest_api/types/completion_tokens_details.py +3 -5
  649. opik/rest_api/types/count_value_stat_public.py +3 -5
  650. opik/rest_api/types/dashboard_page_public.py +24 -0
  651. opik/rest_api/types/dashboard_public.py +30 -0
  652. opik/rest_api/types/data_point_double.py +21 -0
  653. opik/rest_api/types/data_point_number_public.py +3 -5
  654. opik/rest_api/types/dataset.py +14 -6
  655. opik/rest_api/types/dataset_expansion.py +42 -0
  656. opik/rest_api/types/dataset_expansion_response.py +39 -0
  657. opik/rest_api/types/dataset_item.py +9 -8
  658. opik/rest_api/types/dataset_item_batch.py +3 -5
  659. opik/rest_api/types/dataset_item_changes_public.py +5 -0
  660. opik/rest_api/types/dataset_item_compare.py +9 -8
  661. opik/rest_api/types/dataset_item_compare_source.py +1 -3
  662. opik/rest_api/types/dataset_item_filter.py +27 -0
  663. opik/rest_api/types/dataset_item_filter_operator.py +21 -0
  664. opik/rest_api/types/dataset_item_page_compare.py +10 -7
  665. opik/rest_api/types/dataset_item_page_public.py +10 -7
  666. opik/rest_api/types/dataset_item_public.py +9 -8
  667. opik/rest_api/types/dataset_item_public_source.py +1 -3
  668. opik/rest_api/types/dataset_item_source.py +1 -3
  669. opik/rest_api/types/dataset_item_update.py +39 -0
  670. opik/rest_api/types/dataset_item_write.py +5 -6
  671. opik/rest_api/types/dataset_item_write_source.py +1 -3
  672. opik/rest_api/types/dataset_page_public.py +9 -6
  673. opik/rest_api/types/dataset_public.py +14 -6
  674. opik/rest_api/types/dataset_public_status.py +5 -0
  675. opik/rest_api/types/dataset_public_visibility.py +5 -0
  676. opik/rest_api/types/dataset_status.py +5 -0
  677. opik/rest_api/types/dataset_version_diff.py +22 -0
  678. opik/rest_api/types/dataset_version_diff_stats.py +24 -0
  679. opik/rest_api/types/dataset_version_page_public.py +23 -0
  680. opik/rest_api/types/dataset_version_public.py +59 -0
  681. opik/rest_api/types/dataset_version_summary.py +46 -0
  682. opik/rest_api/types/dataset_version_summary_public.py +46 -0
  683. opik/rest_api/types/dataset_visibility.py +5 -0
  684. opik/rest_api/types/delete_attachments_request.py +23 -0
  685. opik/rest_api/types/delete_attachments_request_entity_type.py +5 -0
  686. opik/rest_api/types/delete_feedback_score.py +4 -5
  687. opik/rest_api/types/delete_ids_holder.py +19 -0
  688. opik/rest_api/types/delta.py +7 -9
  689. opik/rest_api/types/error_count_with_deviation.py +21 -0
  690. opik/rest_api/types/error_count_with_deviation_detailed.py +21 -0
  691. opik/rest_api/types/error_info.py +3 -5
  692. opik/rest_api/types/error_info_experiment_item_bulk_write_view.py +21 -0
  693. opik/rest_api/types/error_info_public.py +3 -5
  694. opik/rest_api/types/error_info_write.py +3 -5
  695. opik/rest_api/types/error_message.py +3 -5
  696. opik/rest_api/types/error_message_detail.py +3 -5
  697. opik/rest_api/types/error_message_detailed.py +3 -5
  698. opik/rest_api/types/error_message_public.py +3 -5
  699. opik/rest_api/types/experiment.py +21 -10
  700. opik/rest_api/types/experiment_group_aggregations_response.py +20 -0
  701. opik/rest_api/types/experiment_group_response.py +22 -0
  702. opik/rest_api/types/experiment_item.py +14 -11
  703. opik/rest_api/types/experiment_item_bulk_record.py +27 -0
  704. opik/rest_api/types/experiment_item_bulk_record_experiment_item_bulk_write_view.py +27 -0
  705. opik/rest_api/types/experiment_item_bulk_upload.py +27 -0
  706. opik/rest_api/types/experiment_item_compare.py +14 -11
  707. opik/rest_api/types/experiment_item_compare_trace_visibility_mode.py +5 -0
  708. opik/rest_api/types/experiment_item_public.py +6 -6
  709. opik/rest_api/types/experiment_item_public_trace_visibility_mode.py +5 -0
  710. opik/rest_api/types/experiment_item_trace_visibility_mode.py +5 -0
  711. opik/rest_api/types/experiment_page_public.py +9 -6
  712. opik/rest_api/types/experiment_public.py +21 -10
  713. opik/rest_api/types/experiment_public_status.py +5 -0
  714. opik/rest_api/types/experiment_public_type.py +5 -0
  715. opik/rest_api/types/experiment_score.py +20 -0
  716. opik/rest_api/types/experiment_score_public.py +20 -0
  717. opik/rest_api/types/experiment_score_write.py +20 -0
  718. opik/rest_api/types/experiment_status.py +5 -0
  719. opik/rest_api/types/experiment_type.py +5 -0
  720. opik/rest_api/types/export_trace_service_request.py +5 -0
  721. opik/rest_api/types/feedback.py +40 -27
  722. opik/rest_api/types/feedback_create.py +27 -13
  723. opik/rest_api/types/feedback_definition_page_public.py +4 -6
  724. opik/rest_api/types/feedback_object_public.py +40 -27
  725. opik/rest_api/types/feedback_public.py +40 -27
  726. opik/rest_api/types/feedback_score.py +7 -7
  727. opik/rest_api/types/feedback_score_average.py +3 -5
  728. opik/rest_api/types/feedback_score_average_detailed.py +3 -5
  729. opik/rest_api/types/feedback_score_average_public.py +3 -5
  730. opik/rest_api/types/feedback_score_batch.py +4 -6
  731. opik/rest_api/types/feedback_score_batch_item.py +6 -6
  732. opik/rest_api/types/feedback_score_batch_item_source.py +1 -3
  733. opik/rest_api/types/feedback_score_batch_item_thread.py +32 -0
  734. opik/rest_api/types/feedback_score_batch_item_thread_source.py +5 -0
  735. opik/rest_api/types/feedback_score_compare.py +7 -7
  736. opik/rest_api/types/feedback_score_compare_source.py +1 -3
  737. opik/rest_api/types/feedback_score_experiment_item_bulk_write_view.py +31 -0
  738. opik/rest_api/types/feedback_score_experiment_item_bulk_write_view_source.py +5 -0
  739. opik/rest_api/types/feedback_score_names.py +4 -6
  740. opik/rest_api/types/feedback_score_public.py +11 -7
  741. opik/rest_api/types/feedback_score_public_source.py +1 -3
  742. opik/rest_api/types/feedback_score_source.py +1 -3
  743. opik/rest_api/types/feedback_update.py +27 -13
  744. opik/rest_api/types/function.py +4 -7
  745. opik/rest_api/types/function_call.py +3 -5
  746. opik/rest_api/types/group_content.py +19 -0
  747. opik/rest_api/types/group_content_with_aggregations.py +21 -0
  748. opik/rest_api/types/group_detail.py +19 -0
  749. opik/rest_api/types/group_details.py +20 -0
  750. opik/rest_api/types/guardrail.py +34 -0
  751. opik/rest_api/types/guardrail_batch.py +20 -0
  752. opik/rest_api/types/guardrail_name.py +5 -0
  753. opik/rest_api/types/guardrail_result.py +5 -0
  754. opik/rest_api/types/guardrail_write.py +33 -0
  755. opik/rest_api/types/guardrail_write_name.py +5 -0
  756. opik/rest_api/types/guardrail_write_result.py +5 -0
  757. opik/rest_api/types/guardrails_validation.py +21 -0
  758. opik/rest_api/types/guardrails_validation_public.py +21 -0
  759. opik/rest_api/types/ids_holder.py +19 -0
  760. opik/rest_api/types/image_url.py +20 -0
  761. opik/rest_api/types/image_url_public.py +20 -0
  762. opik/rest_api/types/image_url_write.py +20 -0
  763. opik/rest_api/types/json_list_string.py +7 -0
  764. opik/rest_api/types/json_list_string_compare.py +7 -0
  765. opik/rest_api/types/json_list_string_experiment_item_bulk_write_view.py +7 -0
  766. opik/rest_api/types/json_list_string_public.py +7 -0
  767. opik/rest_api/types/json_list_string_write.py +7 -0
  768. opik/rest_api/types/json_schema.py +5 -8
  769. opik/rest_api/types/llm_as_judge_code.py +8 -12
  770. opik/rest_api/types/llm_as_judge_code_public.py +8 -12
  771. opik/rest_api/types/llm_as_judge_code_write.py +8 -12
  772. opik/rest_api/types/llm_as_judge_message.py +9 -7
  773. opik/rest_api/types/llm_as_judge_message_content.py +26 -0
  774. opik/rest_api/types/llm_as_judge_message_content_public.py +26 -0
  775. opik/rest_api/types/llm_as_judge_message_content_write.py +26 -0
  776. opik/rest_api/types/llm_as_judge_message_public.py +9 -7
  777. opik/rest_api/types/llm_as_judge_message_public_role.py +1 -1
  778. opik/rest_api/types/llm_as_judge_message_role.py +1 -1
  779. opik/rest_api/types/llm_as_judge_message_write.py +9 -7
  780. opik/rest_api/types/llm_as_judge_message_write_role.py +1 -1
  781. opik/rest_api/types/llm_as_judge_model_parameters.py +6 -5
  782. opik/rest_api/types/llm_as_judge_model_parameters_public.py +6 -5
  783. opik/rest_api/types/llm_as_judge_model_parameters_write.py +6 -5
  784. opik/rest_api/types/llm_as_judge_output_schema.py +4 -6
  785. opik/rest_api/types/llm_as_judge_output_schema_public.py +4 -6
  786. opik/rest_api/types/llm_as_judge_output_schema_public_type.py +1 -3
  787. opik/rest_api/types/llm_as_judge_output_schema_type.py +1 -3
  788. opik/rest_api/types/llm_as_judge_output_schema_write.py +4 -6
  789. opik/rest_api/types/llm_as_judge_output_schema_write_type.py +1 -3
  790. opik/rest_api/types/log_item.py +5 -7
  791. opik/rest_api/types/log_item_level.py +1 -3
  792. opik/rest_api/types/log_page.py +4 -6
  793. opik/rest_api/types/manual_evaluation_request.py +38 -0
  794. opik/rest_api/types/manual_evaluation_request_entity_type.py +5 -0
  795. opik/rest_api/types/manual_evaluation_response.py +27 -0
  796. opik/rest_api/types/multipart_upload_part.py +20 -0
  797. opik/rest_api/types/numerical_feedback_definition.py +5 -7
  798. opik/rest_api/types/numerical_feedback_definition_create.py +4 -6
  799. opik/rest_api/types/numerical_feedback_definition_public.py +5 -7
  800. opik/rest_api/types/numerical_feedback_definition_update.py +4 -6
  801. opik/rest_api/types/numerical_feedback_detail.py +3 -5
  802. opik/rest_api/types/numerical_feedback_detail_create.py +3 -5
  803. opik/rest_api/types/numerical_feedback_detail_public.py +3 -5
  804. opik/rest_api/types/numerical_feedback_detail_update.py +3 -5
  805. opik/rest_api/types/optimization.py +37 -0
  806. opik/rest_api/types/optimization_page_public.py +28 -0
  807. opik/rest_api/types/optimization_public.py +37 -0
  808. opik/rest_api/types/optimization_public_status.py +7 -0
  809. opik/rest_api/types/optimization_status.py +7 -0
  810. opik/rest_api/types/optimization_studio_config.py +27 -0
  811. opik/rest_api/types/optimization_studio_config_public.py +27 -0
  812. opik/rest_api/types/optimization_studio_config_write.py +27 -0
  813. opik/rest_api/types/optimization_studio_log.py +22 -0
  814. opik/rest_api/types/optimization_write.py +30 -0
  815. opik/rest_api/types/optimization_write_status.py +7 -0
  816. opik/rest_api/types/page_columns.py +4 -6
  817. opik/rest_api/types/percentage_value_stat_public.py +4 -6
  818. opik/rest_api/types/percentage_values.py +8 -16
  819. opik/rest_api/types/percentage_values_detailed.py +8 -16
  820. opik/rest_api/types/percentage_values_public.py +8 -16
  821. opik/rest_api/types/project.py +12 -7
  822. opik/rest_api/types/project_detailed.py +12 -7
  823. opik/rest_api/types/project_detailed_visibility.py +5 -0
  824. opik/rest_api/types/project_metric_response_public.py +5 -9
  825. opik/rest_api/types/project_metric_response_public_interval.py +1 -3
  826. opik/rest_api/types/project_metric_response_public_metric_type.py +11 -1
  827. opik/rest_api/types/project_page_public.py +8 -10
  828. opik/rest_api/types/project_public.py +6 -6
  829. opik/rest_api/types/project_public_visibility.py +5 -0
  830. opik/rest_api/types/project_reference.py +31 -0
  831. opik/rest_api/types/project_reference_public.py +31 -0
  832. opik/rest_api/types/project_stat_item_object_public.py +8 -17
  833. opik/rest_api/types/project_stats_public.py +4 -6
  834. opik/rest_api/types/project_stats_summary.py +4 -6
  835. opik/rest_api/types/project_stats_summary_item.py +9 -6
  836. opik/rest_api/types/project_visibility.py +5 -0
  837. opik/rest_api/types/prompt.py +12 -7
  838. opik/rest_api/types/prompt_detail.py +12 -7
  839. opik/rest_api/types/prompt_detail_template_structure.py +5 -0
  840. opik/rest_api/types/prompt_page_public.py +9 -6
  841. opik/rest_api/types/prompt_public.py +11 -6
  842. opik/rest_api/types/prompt_public_template_structure.py +5 -0
  843. opik/rest_api/types/prompt_template_structure.py +5 -0
  844. opik/rest_api/types/prompt_tokens_details.py +19 -0
  845. opik/rest_api/types/prompt_version.py +7 -6
  846. opik/rest_api/types/prompt_version_detail.py +7 -6
  847. opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
  848. opik/rest_api/types/prompt_version_link.py +4 -5
  849. opik/rest_api/types/prompt_version_link_public.py +4 -5
  850. opik/rest_api/types/prompt_version_link_write.py +3 -5
  851. opik/rest_api/types/prompt_version_page_public.py +9 -6
  852. opik/rest_api/types/prompt_version_public.py +7 -6
  853. opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
  854. opik/rest_api/types/prompt_version_template_structure.py +5 -0
  855. opik/rest_api/types/prompt_version_update.py +33 -0
  856. opik/rest_api/types/provider_api_key.py +18 -8
  857. opik/rest_api/types/provider_api_key_page_public.py +27 -0
  858. opik/rest_api/types/provider_api_key_provider.py +1 -1
  859. opik/rest_api/types/provider_api_key_public.py +18 -8
  860. opik/rest_api/types/provider_api_key_public_provider.py +1 -1
  861. opik/rest_api/types/response_format.py +5 -7
  862. opik/rest_api/types/response_format_type.py +1 -3
  863. opik/rest_api/types/result.py +21 -0
  864. opik/rest_api/types/results_number_public.py +4 -6
  865. opik/rest_api/types/score_name.py +4 -5
  866. opik/rest_api/types/service_toggles_config.py +44 -0
  867. opik/rest_api/types/span.py +13 -15
  868. opik/rest_api/types/span_batch.py +4 -6
  869. opik/rest_api/types/span_enrichment_options.py +31 -0
  870. opik/rest_api/types/span_experiment_item_bulk_write_view.py +39 -0
  871. opik/rest_api/types/span_experiment_item_bulk_write_view_type.py +5 -0
  872. opik/rest_api/types/span_filter.py +23 -0
  873. opik/rest_api/types/span_filter_operator.py +21 -0
  874. opik/rest_api/types/span_filter_public.py +4 -6
  875. opik/rest_api/types/span_filter_public_operator.py +2 -0
  876. opik/rest_api/types/span_filter_write.py +23 -0
  877. opik/rest_api/types/span_filter_write_operator.py +21 -0
  878. opik/rest_api/types/span_llm_as_judge_code.py +27 -0
  879. opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
  880. opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
  881. opik/rest_api/types/span_page_public.py +9 -6
  882. opik/rest_api/types/span_public.py +19 -16
  883. opik/rest_api/types/span_public_type.py +1 -1
  884. opik/rest_api/types/span_type.py +1 -1
  885. opik/rest_api/types/span_update.py +46 -0
  886. opik/rest_api/types/span_update_type.py +5 -0
  887. opik/rest_api/types/span_user_defined_metric_python_code.py +20 -0
  888. opik/rest_api/types/span_user_defined_metric_python_code_public.py +20 -0
  889. opik/rest_api/types/span_user_defined_metric_python_code_write.py +20 -0
  890. opik/rest_api/types/span_write.py +13 -14
  891. opik/rest_api/types/span_write_type.py +1 -1
  892. opik/rest_api/types/spans_count_response.py +20 -0
  893. opik/rest_api/types/start_multipart_upload_response.py +20 -0
  894. opik/rest_api/types/stream_options.py +3 -5
  895. opik/rest_api/types/studio_evaluation.py +20 -0
  896. opik/rest_api/types/studio_evaluation_public.py +20 -0
  897. opik/rest_api/types/studio_evaluation_write.py +20 -0
  898. opik/rest_api/types/studio_llm_model.py +21 -0
  899. opik/rest_api/types/studio_llm_model_public.py +21 -0
  900. opik/rest_api/types/studio_llm_model_write.py +21 -0
  901. opik/rest_api/types/studio_message.py +20 -0
  902. opik/rest_api/types/studio_message_public.py +20 -0
  903. opik/rest_api/types/studio_message_write.py +20 -0
  904. opik/rest_api/types/studio_metric.py +21 -0
  905. opik/rest_api/types/studio_metric_public.py +21 -0
  906. opik/rest_api/types/studio_metric_write.py +21 -0
  907. opik/rest_api/types/studio_optimizer.py +21 -0
  908. opik/rest_api/types/studio_optimizer_public.py +21 -0
  909. opik/rest_api/types/studio_optimizer_write.py +21 -0
  910. opik/rest_api/types/studio_prompt.py +20 -0
  911. opik/rest_api/types/studio_prompt_public.py +20 -0
  912. opik/rest_api/types/studio_prompt_write.py +20 -0
  913. opik/rest_api/types/tool.py +4 -6
  914. opik/rest_api/types/tool_call.py +4 -6
  915. opik/rest_api/types/trace.py +26 -12
  916. opik/rest_api/types/trace_batch.py +4 -6
  917. opik/rest_api/types/trace_count_response.py +4 -6
  918. opik/rest_api/types/trace_enrichment_options.py +32 -0
  919. opik/rest_api/types/trace_experiment_item_bulk_write_view.py +41 -0
  920. opik/rest_api/types/trace_filter.py +23 -0
  921. opik/rest_api/types/trace_filter_operator.py +21 -0
  922. opik/rest_api/types/trace_filter_public.py +23 -0
  923. opik/rest_api/types/trace_filter_public_operator.py +21 -0
  924. opik/rest_api/types/trace_filter_write.py +23 -0
  925. opik/rest_api/types/trace_filter_write_operator.py +21 -0
  926. opik/rest_api/types/trace_page_public.py +8 -10
  927. opik/rest_api/types/trace_public.py +27 -13
  928. opik/rest_api/types/trace_public_visibility_mode.py +5 -0
  929. opik/rest_api/types/trace_thread.py +18 -9
  930. opik/rest_api/types/trace_thread_filter.py +23 -0
  931. opik/rest_api/types/trace_thread_filter_operator.py +21 -0
  932. opik/rest_api/types/trace_thread_filter_public.py +23 -0
  933. opik/rest_api/types/trace_thread_filter_public_operator.py +21 -0
  934. opik/rest_api/types/trace_thread_filter_write.py +23 -0
  935. opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
  936. opik/rest_api/types/trace_thread_identifier.py +22 -0
  937. opik/rest_api/types/trace_thread_llm_as_judge_code.py +26 -0
  938. opik/rest_api/types/trace_thread_llm_as_judge_code_public.py +26 -0
  939. opik/rest_api/types/trace_thread_llm_as_judge_code_write.py +26 -0
  940. opik/rest_api/types/trace_thread_page.py +9 -6
  941. opik/rest_api/types/trace_thread_status.py +5 -0
  942. opik/rest_api/types/trace_thread_update.py +19 -0
  943. opik/rest_api/types/trace_thread_user_defined_metric_python_code.py +19 -0
  944. opik/rest_api/types/trace_thread_user_defined_metric_python_code_public.py +19 -0
  945. opik/rest_api/types/trace_thread_user_defined_metric_python_code_write.py +19 -0
  946. opik/rest_api/types/trace_update.py +39 -0
  947. opik/rest_api/types/trace_visibility_mode.py +5 -0
  948. opik/rest_api/types/trace_write.py +10 -11
  949. opik/rest_api/types/usage.py +6 -6
  950. opik/rest_api/types/user_defined_metric_python_code.py +3 -5
  951. opik/rest_api/types/user_defined_metric_python_code_public.py +3 -5
  952. opik/rest_api/types/user_defined_metric_python_code_write.py +3 -5
  953. opik/rest_api/types/value_entry.py +27 -0
  954. opik/rest_api/types/value_entry_compare.py +27 -0
  955. opik/rest_api/types/value_entry_compare_source.py +5 -0
  956. opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +27 -0
  957. opik/rest_api/types/value_entry_experiment_item_bulk_write_view_source.py +5 -0
  958. opik/rest_api/types/value_entry_public.py +27 -0
  959. opik/rest_api/types/value_entry_public_source.py +5 -0
  960. opik/rest_api/types/value_entry_source.py +5 -0
  961. opik/rest_api/types/video_url.py +19 -0
  962. opik/rest_api/types/video_url_public.py +19 -0
  963. opik/rest_api/types/video_url_write.py +19 -0
  964. opik/rest_api/types/webhook.py +28 -0
  965. opik/rest_api/types/webhook_examples.py +19 -0
  966. opik/rest_api/types/webhook_public.py +28 -0
  967. opik/rest_api/types/webhook_test_result.py +23 -0
  968. opik/rest_api/types/webhook_test_result_status.py +5 -0
  969. opik/rest_api/types/webhook_write.py +23 -0
  970. opik/rest_api/types/welcome_wizard_tracking.py +22 -0
  971. opik/rest_api/types/workspace_configuration.py +27 -0
  972. opik/rest_api/types/workspace_metric_request.py +24 -0
  973. opik/rest_api/types/workspace_metric_response.py +20 -0
  974. opik/rest_api/types/workspace_metrics_summary_request.py +23 -0
  975. opik/rest_api/types/workspace_metrics_summary_response.py +20 -0
  976. opik/rest_api/types/workspace_name_holder.py +19 -0
  977. opik/rest_api/types/workspace_spans_count.py +20 -0
  978. opik/rest_api/types/workspace_trace_count.py +3 -5
  979. opik/rest_api/welcome_wizard/__init__.py +4 -0
  980. opik/rest_api/welcome_wizard/client.py +195 -0
  981. opik/rest_api/welcome_wizard/raw_client.py +208 -0
  982. opik/rest_api/workspaces/__init__.py +2 -0
  983. opik/rest_api/workspaces/client.py +550 -77
  984. opik/rest_api/workspaces/raw_client.py +923 -0
  985. opik/rest_client_configurator/api.py +1 -0
  986. opik/rest_client_configurator/retry_decorator.py +1 -0
  987. opik/s3_httpx_client.py +67 -0
  988. opik/simulation/__init__.py +6 -0
  989. opik/simulation/simulated_user.py +99 -0
  990. opik/simulation/simulator.py +108 -0
  991. opik/synchronization.py +11 -24
  992. opik/tracing_runtime_config.py +48 -0
  993. opik/types.py +48 -2
  994. opik/url_helpers.py +13 -3
  995. opik/validation/chat_prompt_messages.py +241 -0
  996. opik/validation/feedback_score.py +4 -5
  997. opik/validation/parameter.py +122 -0
  998. opik/validation/parameters_validator.py +175 -0
  999. opik/validation/validator.py +30 -2
  1000. opik/validation/validator_helpers.py +147 -0
  1001. opik-1.9.71.dist-info/METADATA +370 -0
  1002. opik-1.9.71.dist-info/RECORD +1110 -0
  1003. {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/WHEEL +1 -1
  1004. opik-1.9.71.dist-info/licenses/LICENSE +203 -0
  1005. opik/api_objects/prompt/prompt.py +0 -107
  1006. opik/api_objects/prompt/prompt_template.py +0 -35
  1007. opik/cli.py +0 -193
  1008. opik/evaluation/metrics/models.py +0 -8
  1009. opik/hooks.py +0 -13
  1010. opik/integrations/bedrock/chunks_aggregator.py +0 -55
  1011. opik/integrations/bedrock/helpers.py +0 -8
  1012. opik/integrations/langchain/google_run_helpers.py +0 -75
  1013. opik/integrations/langchain/openai_run_helpers.py +0 -122
  1014. opik/message_processing/message_processors.py +0 -203
  1015. opik/rest_api/types/delta_role.py +0 -7
  1016. opik/rest_api/types/json_object_schema.py +0 -34
  1017. opik-1.6.4.dist-info/METADATA +0 -270
  1018. opik-1.6.4.dist-info/RECORD +0 -507
  1019. /opik/integrations/bedrock/{stream_wrappers.py → converse/stream_wrappers.py} +0 -0
  1020. {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/entry_points.txt +0 -0
  1021. {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,3389 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import contextlib
4
+ import typing
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ..core.api_error import ApiError
8
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
10
+ from ..core.jsonable_encoder import jsonable_encoder
11
+ from ..core.pydantic_utilities import parse_obj_as
12
+ from ..core.request_options import RequestOptions
13
+ from ..core.serialization import convert_and_respect_annotation_metadata
14
+ from ..errors.bad_request_error import BadRequestError
15
+ from ..errors.conflict_error import ConflictError
16
+ from ..errors.not_found_error import NotFoundError
17
+ from ..types.dataset_expansion_response import DatasetExpansionResponse
18
+ from ..types.dataset_item_changes_public import DatasetItemChangesPublic
19
+ from ..types.dataset_item_filter import DatasetItemFilter
20
+ from ..types.dataset_item_page_compare import DatasetItemPageCompare
21
+ from ..types.dataset_item_page_public import DatasetItemPagePublic
22
+ from ..types.dataset_item_public import DatasetItemPublic
23
+ from ..types.dataset_item_update import DatasetItemUpdate
24
+ from ..types.dataset_item_write import DatasetItemWrite
25
+ from ..types.dataset_item_write_source import DatasetItemWriteSource
26
+ from ..types.dataset_page_public import DatasetPagePublic
27
+ from ..types.dataset_public import DatasetPublic
28
+ from ..types.dataset_version_diff import DatasetVersionDiff
29
+ from ..types.dataset_version_page_public import DatasetVersionPagePublic
30
+ from ..types.dataset_version_public import DatasetVersionPublic
31
+ from ..types.json_node import JsonNode
32
+ from ..types.page_columns import PageColumns
33
+ from ..types.project_stats_public import ProjectStatsPublic
34
+ from ..types.span_enrichment_options import SpanEnrichmentOptions
35
+ from ..types.trace_enrichment_options import TraceEnrichmentOptions
36
+ from .types.dataset_update_visibility import DatasetUpdateVisibility
37
+ from .types.dataset_write_visibility import DatasetWriteVisibility
38
+
39
+ # this is used as the default value for optional parameters
40
+ OMIT = typing.cast(typing.Any, ...)
41
+
42
+
43
+ class RawDatasetsClient:
44
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
45
+ self._client_wrapper = client_wrapper
46
+
47
+ def apply_dataset_item_changes(
48
+ self,
49
+ id: str,
50
+ *,
51
+ request: DatasetItemChangesPublic,
52
+ override: typing.Optional[bool] = None,
53
+ request_options: typing.Optional[RequestOptions] = None,
54
+ ) -> HttpResponse[DatasetVersionPublic]:
55
+ """
56
+ Apply delta changes (add, edit, delete) to a dataset version with conflict detection.
57
+
58
+ This endpoint:
59
+ - Creates a new version with the applied changes
60
+ - Validates that baseVersion matches the latest version (unless override=true)
61
+ - Returns 409 Conflict if baseVersion is stale and override is not set
62
+
63
+ Use `override=true` query parameter to force version creation even with stale baseVersion.
64
+
65
+ Parameters
66
+ ----------
67
+ id : str
68
+
69
+ request : DatasetItemChangesPublic
70
+
71
+ override : typing.Optional[bool]
72
+
73
+ request_options : typing.Optional[RequestOptions]
74
+ Request-specific configuration.
75
+
76
+ Returns
77
+ -------
78
+ HttpResponse[DatasetVersionPublic]
79
+ Version created successfully
80
+ """
81
+ _response = self._client_wrapper.httpx_client.request(
82
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/changes",
83
+ method="POST",
84
+ params={
85
+ "override": override,
86
+ },
87
+ json=request,
88
+ headers={
89
+ "content-type": "application/json",
90
+ },
91
+ request_options=request_options,
92
+ omit=OMIT,
93
+ )
94
+ try:
95
+ if 200 <= _response.status_code < 300:
96
+ _data = typing.cast(
97
+ DatasetVersionPublic,
98
+ parse_obj_as(
99
+ type_=DatasetVersionPublic, # type: ignore
100
+ object_=_response.json(),
101
+ ),
102
+ )
103
+ return HttpResponse(response=_response, data=_data)
104
+ if _response.status_code == 400:
105
+ raise BadRequestError(
106
+ headers=dict(_response.headers),
107
+ body=typing.cast(
108
+ typing.Optional[typing.Any],
109
+ parse_obj_as(
110
+ type_=typing.Optional[typing.Any], # type: ignore
111
+ object_=_response.json(),
112
+ ),
113
+ ),
114
+ )
115
+ if _response.status_code == 404:
116
+ raise NotFoundError(
117
+ headers=dict(_response.headers),
118
+ body=typing.cast(
119
+ typing.Optional[typing.Any],
120
+ parse_obj_as(
121
+ type_=typing.Optional[typing.Any], # type: ignore
122
+ object_=_response.json(),
123
+ ),
124
+ ),
125
+ )
126
+ if _response.status_code == 409:
127
+ raise ConflictError(
128
+ headers=dict(_response.headers),
129
+ body=typing.cast(
130
+ typing.Optional[typing.Any],
131
+ parse_obj_as(
132
+ type_=typing.Optional[typing.Any], # type: ignore
133
+ object_=_response.json(),
134
+ ),
135
+ ),
136
+ )
137
+ _response_json = _response.json()
138
+ except JSONDecodeError:
139
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
140
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
141
+
142
+ def batch_update_dataset_items(
143
+ self,
144
+ *,
145
+ update: DatasetItemUpdate,
146
+ ids: typing.Optional[typing.Sequence[str]] = OMIT,
147
+ filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
148
+ dataset_id: typing.Optional[str] = OMIT,
149
+ merge_tags: typing.Optional[bool] = OMIT,
150
+ request_options: typing.Optional[RequestOptions] = None,
151
+ ) -> HttpResponse[None]:
152
+ """
153
+ Update multiple dataset items
154
+
155
+ Parameters
156
+ ----------
157
+ update : DatasetItemUpdate
158
+
159
+ ids : typing.Optional[typing.Sequence[str]]
160
+ List of dataset item IDs to update (max 1000). Mutually exclusive with 'filters'.
161
+
162
+ filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
163
+
164
+ dataset_id : typing.Optional[str]
165
+ Dataset ID. Required when using 'filters', optional when using 'ids'.
166
+
167
+ merge_tags : typing.Optional[bool]
168
+ If true, merge tags with existing tags instead of replacing them. Default: false. When using 'filters', this is automatically set to true.
169
+
170
+ request_options : typing.Optional[RequestOptions]
171
+ Request-specific configuration.
172
+
173
+ Returns
174
+ -------
175
+ HttpResponse[None]
176
+ """
177
+ _response = self._client_wrapper.httpx_client.request(
178
+ "v1/private/datasets/items/batch",
179
+ method="PATCH",
180
+ json={
181
+ "ids": ids,
182
+ "filters": convert_and_respect_annotation_metadata(
183
+ object_=filters, annotation=typing.Sequence[DatasetItemFilter], direction="write"
184
+ ),
185
+ "dataset_id": dataset_id,
186
+ "update": convert_and_respect_annotation_metadata(
187
+ object_=update, annotation=DatasetItemUpdate, direction="write"
188
+ ),
189
+ "merge_tags": merge_tags,
190
+ },
191
+ headers={
192
+ "content-type": "application/json",
193
+ },
194
+ request_options=request_options,
195
+ omit=OMIT,
196
+ )
197
+ try:
198
+ if 200 <= _response.status_code < 300:
199
+ return HttpResponse(response=_response, data=None)
200
+ if _response.status_code == 400:
201
+ raise BadRequestError(
202
+ headers=dict(_response.headers),
203
+ body=typing.cast(
204
+ typing.Optional[typing.Any],
205
+ parse_obj_as(
206
+ type_=typing.Optional[typing.Any], # type: ignore
207
+ object_=_response.json(),
208
+ ),
209
+ ),
210
+ )
211
+ _response_json = _response.json()
212
+ except JSONDecodeError:
213
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
214
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
215
+
216
+ def find_datasets(
217
+ self,
218
+ *,
219
+ page: typing.Optional[int] = None,
220
+ size: typing.Optional[int] = None,
221
+ with_experiments_only: typing.Optional[bool] = None,
222
+ with_optimizations_only: typing.Optional[bool] = None,
223
+ prompt_id: typing.Optional[str] = None,
224
+ name: typing.Optional[str] = None,
225
+ sorting: typing.Optional[str] = None,
226
+ filters: typing.Optional[str] = None,
227
+ request_options: typing.Optional[RequestOptions] = None,
228
+ ) -> HttpResponse[DatasetPagePublic]:
229
+ """
230
+ Find datasets
231
+
232
+ Parameters
233
+ ----------
234
+ page : typing.Optional[int]
235
+
236
+ size : typing.Optional[int]
237
+
238
+ with_experiments_only : typing.Optional[bool]
239
+
240
+ with_optimizations_only : typing.Optional[bool]
241
+
242
+ prompt_id : typing.Optional[str]
243
+
244
+ name : typing.Optional[str]
245
+
246
+ sorting : typing.Optional[str]
247
+
248
+ filters : typing.Optional[str]
249
+
250
+ request_options : typing.Optional[RequestOptions]
251
+ Request-specific configuration.
252
+
253
+ Returns
254
+ -------
255
+ HttpResponse[DatasetPagePublic]
256
+ Dataset resource
257
+ """
258
+ _response = self._client_wrapper.httpx_client.request(
259
+ "v1/private/datasets",
260
+ method="GET",
261
+ params={
262
+ "page": page,
263
+ "size": size,
264
+ "with_experiments_only": with_experiments_only,
265
+ "with_optimizations_only": with_optimizations_only,
266
+ "prompt_id": prompt_id,
267
+ "name": name,
268
+ "sorting": sorting,
269
+ "filters": filters,
270
+ },
271
+ request_options=request_options,
272
+ )
273
+ try:
274
+ if 200 <= _response.status_code < 300:
275
+ _data = typing.cast(
276
+ DatasetPagePublic,
277
+ parse_obj_as(
278
+ type_=DatasetPagePublic, # type: ignore
279
+ object_=_response.json(),
280
+ ),
281
+ )
282
+ return HttpResponse(response=_response, data=_data)
283
+ _response_json = _response.json()
284
+ except JSONDecodeError:
285
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
286
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
287
+
288
+ def create_dataset(
289
+ self,
290
+ *,
291
+ name: str,
292
+ id: typing.Optional[str] = OMIT,
293
+ visibility: typing.Optional[DatasetWriteVisibility] = OMIT,
294
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
295
+ description: typing.Optional[str] = OMIT,
296
+ request_options: typing.Optional[RequestOptions] = None,
297
+ ) -> HttpResponse[None]:
298
+ """
299
+ Create dataset
300
+
301
+ Parameters
302
+ ----------
303
+ name : str
304
+
305
+ id : typing.Optional[str]
306
+
307
+ visibility : typing.Optional[DatasetWriteVisibility]
308
+
309
+ tags : typing.Optional[typing.Sequence[str]]
310
+
311
+ description : typing.Optional[str]
312
+
313
+ request_options : typing.Optional[RequestOptions]
314
+ Request-specific configuration.
315
+
316
+ Returns
317
+ -------
318
+ HttpResponse[None]
319
+ """
320
+ _response = self._client_wrapper.httpx_client.request(
321
+ "v1/private/datasets",
322
+ method="POST",
323
+ json={
324
+ "id": id,
325
+ "name": name,
326
+ "visibility": visibility,
327
+ "tags": tags,
328
+ "description": description,
329
+ },
330
+ headers={
331
+ "content-type": "application/json",
332
+ },
333
+ request_options=request_options,
334
+ omit=OMIT,
335
+ )
336
+ try:
337
+ if 200 <= _response.status_code < 300:
338
+ return HttpResponse(response=_response, data=None)
339
+ _response_json = _response.json()
340
+ except JSONDecodeError:
341
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
342
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
343
+
344
+ def create_or_update_dataset_items(
345
+ self,
346
+ *,
347
+ items: typing.Sequence[DatasetItemWrite],
348
+ dataset_name: typing.Optional[str] = OMIT,
349
+ dataset_id: typing.Optional[str] = OMIT,
350
+ request_options: typing.Optional[RequestOptions] = None,
351
+ ) -> HttpResponse[None]:
352
+ """
353
+ Create/update dataset items based on dataset item id
354
+
355
+ Parameters
356
+ ----------
357
+ items : typing.Sequence[DatasetItemWrite]
358
+
359
+ dataset_name : typing.Optional[str]
360
+ If null, dataset_id must be provided
361
+
362
+ dataset_id : typing.Optional[str]
363
+ If null, dataset_name must be provided
364
+
365
+ request_options : typing.Optional[RequestOptions]
366
+ Request-specific configuration.
367
+
368
+ Returns
369
+ -------
370
+ HttpResponse[None]
371
+ """
372
+ _response = self._client_wrapper.httpx_client.request(
373
+ "v1/private/datasets/items",
374
+ method="PUT",
375
+ json={
376
+ "dataset_name": dataset_name,
377
+ "dataset_id": dataset_id,
378
+ "items": convert_and_respect_annotation_metadata(
379
+ object_=items, annotation=typing.Sequence[DatasetItemWrite], direction="write"
380
+ ),
381
+ },
382
+ headers={
383
+ "content-type": "application/json",
384
+ },
385
+ request_options=request_options,
386
+ omit=OMIT,
387
+ )
388
+ try:
389
+ if 200 <= _response.status_code < 300:
390
+ return HttpResponse(response=_response, data=None)
391
+ _response_json = _response.json()
392
+ except JSONDecodeError:
393
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
394
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
395
+
396
+ def create_dataset_items_from_csv(
397
+ self,
398
+ *,
399
+ file: typing.Dict[str, typing.Optional[typing.Any]],
400
+ dataset_id: str,
401
+ request_options: typing.Optional[RequestOptions] = None,
402
+ ) -> HttpResponse[None]:
403
+ """
404
+ Create dataset items from uploaded CSV file. CSV should have headers in the first row. Processing happens asynchronously in batches.
405
+
406
+ Parameters
407
+ ----------
408
+ file : typing.Dict[str, typing.Optional[typing.Any]]
409
+
410
+ dataset_id : str
411
+
412
+ request_options : typing.Optional[RequestOptions]
413
+ Request-specific configuration.
414
+
415
+ Returns
416
+ -------
417
+ HttpResponse[None]
418
+ """
419
+ _response = self._client_wrapper.httpx_client.request(
420
+ "v1/private/datasets/items/from-csv",
421
+ method="POST",
422
+ data={
423
+ "file": file,
424
+ "dataset_id": dataset_id,
425
+ },
426
+ files={},
427
+ request_options=request_options,
428
+ omit=OMIT,
429
+ )
430
+ try:
431
+ if 200 <= _response.status_code < 300:
432
+ return HttpResponse(response=_response, data=None)
433
+ if _response.status_code == 400:
434
+ raise BadRequestError(
435
+ headers=dict(_response.headers),
436
+ body=typing.cast(
437
+ typing.Optional[typing.Any],
438
+ parse_obj_as(
439
+ type_=typing.Optional[typing.Any], # type: ignore
440
+ object_=_response.json(),
441
+ ),
442
+ ),
443
+ )
444
+ if _response.status_code == 404:
445
+ raise NotFoundError(
446
+ headers=dict(_response.headers),
447
+ body=typing.cast(
448
+ typing.Optional[typing.Any],
449
+ parse_obj_as(
450
+ type_=typing.Optional[typing.Any], # type: ignore
451
+ object_=_response.json(),
452
+ ),
453
+ ),
454
+ )
455
+ _response_json = _response.json()
456
+ except JSONDecodeError:
457
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
458
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
459
+
460
+ def create_dataset_items_from_spans(
461
+ self,
462
+ dataset_id: str,
463
+ *,
464
+ span_ids: typing.Sequence[str],
465
+ enrichment_options: SpanEnrichmentOptions,
466
+ request_options: typing.Optional[RequestOptions] = None,
467
+ ) -> HttpResponse[None]:
468
+ """
469
+ Create dataset items from spans with enriched metadata
470
+
471
+ Parameters
472
+ ----------
473
+ dataset_id : str
474
+
475
+ span_ids : typing.Sequence[str]
476
+ Set of span IDs to add to the dataset
477
+
478
+ enrichment_options : SpanEnrichmentOptions
479
+
480
+ request_options : typing.Optional[RequestOptions]
481
+ Request-specific configuration.
482
+
483
+ Returns
484
+ -------
485
+ HttpResponse[None]
486
+ """
487
+ _response = self._client_wrapper.httpx_client.request(
488
+ f"v1/private/datasets/{jsonable_encoder(dataset_id)}/items/from-spans",
489
+ method="POST",
490
+ json={
491
+ "span_ids": span_ids,
492
+ "enrichment_options": convert_and_respect_annotation_metadata(
493
+ object_=enrichment_options, annotation=SpanEnrichmentOptions, direction="write"
494
+ ),
495
+ },
496
+ headers={
497
+ "content-type": "application/json",
498
+ },
499
+ request_options=request_options,
500
+ omit=OMIT,
501
+ )
502
+ try:
503
+ if 200 <= _response.status_code < 300:
504
+ return HttpResponse(response=_response, data=None)
505
+ _response_json = _response.json()
506
+ except JSONDecodeError:
507
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
508
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
509
+
510
+ def create_dataset_items_from_traces(
511
+ self,
512
+ dataset_id: str,
513
+ *,
514
+ trace_ids: typing.Sequence[str],
515
+ enrichment_options: TraceEnrichmentOptions,
516
+ request_options: typing.Optional[RequestOptions] = None,
517
+ ) -> HttpResponse[None]:
518
+ """
519
+ Create dataset items from traces with enriched metadata
520
+
521
+ Parameters
522
+ ----------
523
+ dataset_id : str
524
+
525
+ trace_ids : typing.Sequence[str]
526
+ Set of trace IDs to add to the dataset
527
+
528
+ enrichment_options : TraceEnrichmentOptions
529
+
530
+ request_options : typing.Optional[RequestOptions]
531
+ Request-specific configuration.
532
+
533
+ Returns
534
+ -------
535
+ HttpResponse[None]
536
+ """
537
+ _response = self._client_wrapper.httpx_client.request(
538
+ f"v1/private/datasets/{jsonable_encoder(dataset_id)}/items/from-traces",
539
+ method="POST",
540
+ json={
541
+ "trace_ids": trace_ids,
542
+ "enrichment_options": convert_and_respect_annotation_metadata(
543
+ object_=enrichment_options, annotation=TraceEnrichmentOptions, direction="write"
544
+ ),
545
+ },
546
+ headers={
547
+ "content-type": "application/json",
548
+ },
549
+ request_options=request_options,
550
+ omit=OMIT,
551
+ )
552
+ try:
553
+ if 200 <= _response.status_code < 300:
554
+ return HttpResponse(response=_response, data=None)
555
+ _response_json = _response.json()
556
+ except JSONDecodeError:
557
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
558
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
559
+
560
+ def get_dataset_by_id(
561
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
562
+ ) -> HttpResponse[DatasetPublic]:
563
+ """
564
+ Get dataset by id
565
+
566
+ Parameters
567
+ ----------
568
+ id : str
569
+
570
+ request_options : typing.Optional[RequestOptions]
571
+ Request-specific configuration.
572
+
573
+ Returns
574
+ -------
575
+ HttpResponse[DatasetPublic]
576
+ Dataset resource
577
+ """
578
+ _response = self._client_wrapper.httpx_client.request(
579
+ f"v1/private/datasets/{jsonable_encoder(id)}",
580
+ method="GET",
581
+ request_options=request_options,
582
+ )
583
+ try:
584
+ if 200 <= _response.status_code < 300:
585
+ _data = typing.cast(
586
+ DatasetPublic,
587
+ parse_obj_as(
588
+ type_=DatasetPublic, # type: ignore
589
+ object_=_response.json(),
590
+ ),
591
+ )
592
+ return HttpResponse(response=_response, data=_data)
593
+ _response_json = _response.json()
594
+ except JSONDecodeError:
595
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
596
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
597
+
598
+ def update_dataset(
599
+ self,
600
+ id: str,
601
+ *,
602
+ name: str,
603
+ description: typing.Optional[str] = OMIT,
604
+ visibility: typing.Optional[DatasetUpdateVisibility] = OMIT,
605
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
606
+ request_options: typing.Optional[RequestOptions] = None,
607
+ ) -> HttpResponse[None]:
608
+ """
609
+ Update dataset by id
610
+
611
+ Parameters
612
+ ----------
613
+ id : str
614
+
615
+ name : str
616
+
617
+ description : typing.Optional[str]
618
+
619
+ visibility : typing.Optional[DatasetUpdateVisibility]
620
+
621
+ tags : typing.Optional[typing.Sequence[str]]
622
+
623
+ request_options : typing.Optional[RequestOptions]
624
+ Request-specific configuration.
625
+
626
+ Returns
627
+ -------
628
+ HttpResponse[None]
629
+ """
630
+ _response = self._client_wrapper.httpx_client.request(
631
+ f"v1/private/datasets/{jsonable_encoder(id)}",
632
+ method="PUT",
633
+ json={
634
+ "name": name,
635
+ "description": description,
636
+ "visibility": visibility,
637
+ "tags": tags,
638
+ },
639
+ headers={
640
+ "content-type": "application/json",
641
+ },
642
+ request_options=request_options,
643
+ omit=OMIT,
644
+ )
645
+ try:
646
+ if 200 <= _response.status_code < 300:
647
+ return HttpResponse(response=_response, data=None)
648
+ _response_json = _response.json()
649
+ except JSONDecodeError:
650
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
651
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
652
+
653
+ def delete_dataset(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
654
+ """
655
+ Delete dataset by id
656
+
657
+ Parameters
658
+ ----------
659
+ id : str
660
+
661
+ request_options : typing.Optional[RequestOptions]
662
+ Request-specific configuration.
663
+
664
+ Returns
665
+ -------
666
+ HttpResponse[None]
667
+ """
668
+ _response = self._client_wrapper.httpx_client.request(
669
+ f"v1/private/datasets/{jsonable_encoder(id)}",
670
+ method="DELETE",
671
+ request_options=request_options,
672
+ )
673
+ try:
674
+ if 200 <= _response.status_code < 300:
675
+ return HttpResponse(response=_response, data=None)
676
+ _response_json = _response.json()
677
+ except JSONDecodeError:
678
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
679
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
680
+
681
+ def delete_dataset_by_name(
682
+ self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
683
+ ) -> HttpResponse[None]:
684
+ """
685
+ Delete dataset by name
686
+
687
+ Parameters
688
+ ----------
689
+ dataset_name : str
690
+
691
+ request_options : typing.Optional[RequestOptions]
692
+ Request-specific configuration.
693
+
694
+ Returns
695
+ -------
696
+ HttpResponse[None]
697
+ """
698
+ _response = self._client_wrapper.httpx_client.request(
699
+ "v1/private/datasets/delete",
700
+ method="POST",
701
+ json={
702
+ "dataset_name": dataset_name,
703
+ },
704
+ headers={
705
+ "content-type": "application/json",
706
+ },
707
+ request_options=request_options,
708
+ omit=OMIT,
709
+ )
710
+ try:
711
+ if 200 <= _response.status_code < 300:
712
+ return HttpResponse(response=_response, data=None)
713
+ _response_json = _response.json()
714
+ except JSONDecodeError:
715
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
716
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
717
+
718
+ def delete_dataset_items(
719
+ self,
720
+ *,
721
+ item_ids: typing.Optional[typing.Sequence[str]] = OMIT,
722
+ dataset_id: typing.Optional[str] = OMIT,
723
+ filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
724
+ request_options: typing.Optional[RequestOptions] = None,
725
+ ) -> HttpResponse[None]:
726
+ """
727
+ Delete dataset items using one of two modes:
728
+ 1. **Delete by IDs**: Provide 'item_ids' to delete specific items by their IDs
729
+ 2. **Delete by filters**: Provide 'dataset_id' with optional 'filters' to delete items matching criteria
730
+
731
+ When using filters, an empty 'filters' array will delete all items in the specified dataset.
732
+
733
+ Parameters
734
+ ----------
735
+ item_ids : typing.Optional[typing.Sequence[str]]
736
+ 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'.
737
+
738
+ dataset_id : typing.Optional[str]
739
+ Dataset ID to scope the deletion. Required when using 'filters'. Mutually exclusive with 'item_ids'.
740
+
741
+ filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
742
+ 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'.
743
+
744
+ request_options : typing.Optional[RequestOptions]
745
+ Request-specific configuration.
746
+
747
+ Returns
748
+ -------
749
+ HttpResponse[None]
750
+ """
751
+ _response = self._client_wrapper.httpx_client.request(
752
+ "v1/private/datasets/items/delete",
753
+ method="POST",
754
+ json={
755
+ "item_ids": item_ids,
756
+ "dataset_id": dataset_id,
757
+ "filters": convert_and_respect_annotation_metadata(
758
+ object_=filters, annotation=typing.Sequence[DatasetItemFilter], direction="write"
759
+ ),
760
+ },
761
+ headers={
762
+ "content-type": "application/json",
763
+ },
764
+ request_options=request_options,
765
+ omit=OMIT,
766
+ )
767
+ try:
768
+ if 200 <= _response.status_code < 300:
769
+ return HttpResponse(response=_response, data=None)
770
+ if _response.status_code == 400:
771
+ raise BadRequestError(
772
+ headers=dict(_response.headers),
773
+ body=typing.cast(
774
+ typing.Optional[typing.Any],
775
+ parse_obj_as(
776
+ type_=typing.Optional[typing.Any], # type: ignore
777
+ object_=_response.json(),
778
+ ),
779
+ ),
780
+ )
781
+ _response_json = _response.json()
782
+ except JSONDecodeError:
783
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
784
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
785
+
786
+ def delete_datasets_batch(
787
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
788
+ ) -> HttpResponse[None]:
789
+ """
790
+ Delete datasets batch
791
+
792
+ Parameters
793
+ ----------
794
+ ids : typing.Sequence[str]
795
+
796
+ request_options : typing.Optional[RequestOptions]
797
+ Request-specific configuration.
798
+
799
+ Returns
800
+ -------
801
+ HttpResponse[None]
802
+ """
803
+ _response = self._client_wrapper.httpx_client.request(
804
+ "v1/private/datasets/delete-batch",
805
+ method="POST",
806
+ json={
807
+ "ids": ids,
808
+ },
809
+ headers={
810
+ "content-type": "application/json",
811
+ },
812
+ request_options=request_options,
813
+ omit=OMIT,
814
+ )
815
+ try:
816
+ if 200 <= _response.status_code < 300:
817
+ return HttpResponse(response=_response, data=None)
818
+ _response_json = _response.json()
819
+ except JSONDecodeError:
820
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
821
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
822
+
823
+ def expand_dataset(
824
+ self,
825
+ id: str,
826
+ *,
827
+ model: str,
828
+ sample_count: typing.Optional[int] = OMIT,
829
+ preserve_fields: typing.Optional[typing.Sequence[str]] = OMIT,
830
+ variation_instructions: typing.Optional[str] = OMIT,
831
+ custom_prompt: typing.Optional[str] = OMIT,
832
+ request_options: typing.Optional[RequestOptions] = None,
833
+ ) -> HttpResponse[DatasetExpansionResponse]:
834
+ """
835
+ Generate synthetic dataset samples using LLM based on existing data patterns
836
+
837
+ Parameters
838
+ ----------
839
+ id : str
840
+
841
+ model : str
842
+ The model to use for synthetic data generation
843
+
844
+ sample_count : typing.Optional[int]
845
+ Number of synthetic samples to generate
846
+
847
+ preserve_fields : typing.Optional[typing.Sequence[str]]
848
+ Fields to preserve patterns from original data
849
+
850
+ variation_instructions : typing.Optional[str]
851
+ Additional instructions for data variation
852
+
853
+ custom_prompt : typing.Optional[str]
854
+ Custom prompt to use for generation instead of auto-generated one
855
+
856
+ request_options : typing.Optional[RequestOptions]
857
+ Request-specific configuration.
858
+
859
+ Returns
860
+ -------
861
+ HttpResponse[DatasetExpansionResponse]
862
+ Generated synthetic samples
863
+ """
864
+ _response = self._client_wrapper.httpx_client.request(
865
+ f"v1/private/datasets/{jsonable_encoder(id)}/expansions",
866
+ method="POST",
867
+ json={
868
+ "model": model,
869
+ "sample_count": sample_count,
870
+ "preserve_fields": preserve_fields,
871
+ "variation_instructions": variation_instructions,
872
+ "custom_prompt": custom_prompt,
873
+ },
874
+ headers={
875
+ "content-type": "application/json",
876
+ },
877
+ request_options=request_options,
878
+ omit=OMIT,
879
+ )
880
+ try:
881
+ if 200 <= _response.status_code < 300:
882
+ _data = typing.cast(
883
+ DatasetExpansionResponse,
884
+ parse_obj_as(
885
+ type_=DatasetExpansionResponse, # type: ignore
886
+ object_=_response.json(),
887
+ ),
888
+ )
889
+ return HttpResponse(response=_response, data=_data)
890
+ _response_json = _response.json()
891
+ except JSONDecodeError:
892
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
893
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
894
+
895
+ def find_dataset_items_with_experiment_items(
896
+ self,
897
+ id: str,
898
+ *,
899
+ experiment_ids: str,
900
+ page: typing.Optional[int] = None,
901
+ size: typing.Optional[int] = None,
902
+ filters: typing.Optional[str] = None,
903
+ sorting: typing.Optional[str] = None,
904
+ search: typing.Optional[str] = None,
905
+ truncate: typing.Optional[bool] = None,
906
+ request_options: typing.Optional[RequestOptions] = None,
907
+ ) -> HttpResponse[DatasetItemPageCompare]:
908
+ """
909
+ Find dataset items with experiment items
910
+
911
+ Parameters
912
+ ----------
913
+ id : str
914
+
915
+ experiment_ids : str
916
+
917
+ page : typing.Optional[int]
918
+
919
+ size : typing.Optional[int]
920
+
921
+ filters : typing.Optional[str]
922
+
923
+ sorting : typing.Optional[str]
924
+
925
+ search : typing.Optional[str]
926
+
927
+ truncate : typing.Optional[bool]
928
+
929
+ request_options : typing.Optional[RequestOptions]
930
+ Request-specific configuration.
931
+
932
+ Returns
933
+ -------
934
+ HttpResponse[DatasetItemPageCompare]
935
+ Dataset item resource
936
+ """
937
+ _response = self._client_wrapper.httpx_client.request(
938
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/experiments/items",
939
+ method="GET",
940
+ params={
941
+ "page": page,
942
+ "size": size,
943
+ "experiment_ids": experiment_ids,
944
+ "filters": filters,
945
+ "sorting": sorting,
946
+ "search": search,
947
+ "truncate": truncate,
948
+ },
949
+ request_options=request_options,
950
+ )
951
+ try:
952
+ if 200 <= _response.status_code < 300:
953
+ _data = typing.cast(
954
+ DatasetItemPageCompare,
955
+ parse_obj_as(
956
+ type_=DatasetItemPageCompare, # type: ignore
957
+ object_=_response.json(),
958
+ ),
959
+ )
960
+ return HttpResponse(response=_response, data=_data)
961
+ _response_json = _response.json()
962
+ except JSONDecodeError:
963
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
964
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
965
+
966
+ def get_dataset_by_identifier(
967
+ self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
968
+ ) -> HttpResponse[DatasetPublic]:
969
+ """
970
+ Get dataset by name
971
+
972
+ Parameters
973
+ ----------
974
+ dataset_name : str
975
+
976
+ request_options : typing.Optional[RequestOptions]
977
+ Request-specific configuration.
978
+
979
+ Returns
980
+ -------
981
+ HttpResponse[DatasetPublic]
982
+ Dataset resource
983
+ """
984
+ _response = self._client_wrapper.httpx_client.request(
985
+ "v1/private/datasets/retrieve",
986
+ method="POST",
987
+ json={
988
+ "dataset_name": dataset_name,
989
+ },
990
+ headers={
991
+ "content-type": "application/json",
992
+ },
993
+ request_options=request_options,
994
+ omit=OMIT,
995
+ )
996
+ try:
997
+ if 200 <= _response.status_code < 300:
998
+ _data = typing.cast(
999
+ DatasetPublic,
1000
+ parse_obj_as(
1001
+ type_=DatasetPublic, # type: ignore
1002
+ object_=_response.json(),
1003
+ ),
1004
+ )
1005
+ return HttpResponse(response=_response, data=_data)
1006
+ _response_json = _response.json()
1007
+ except JSONDecodeError:
1008
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1009
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1010
+
1011
+ def get_dataset_experiment_items_stats(
1012
+ self,
1013
+ id: str,
1014
+ *,
1015
+ experiment_ids: str,
1016
+ filters: typing.Optional[str] = None,
1017
+ request_options: typing.Optional[RequestOptions] = None,
1018
+ ) -> HttpResponse[ProjectStatsPublic]:
1019
+ """
1020
+ Get experiment items stats for dataset
1021
+
1022
+ Parameters
1023
+ ----------
1024
+ id : str
1025
+
1026
+ experiment_ids : str
1027
+
1028
+ filters : typing.Optional[str]
1029
+
1030
+ request_options : typing.Optional[RequestOptions]
1031
+ Request-specific configuration.
1032
+
1033
+ Returns
1034
+ -------
1035
+ HttpResponse[ProjectStatsPublic]
1036
+ Experiment items stats resource
1037
+ """
1038
+ _response = self._client_wrapper.httpx_client.request(
1039
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/experiments/items/stats",
1040
+ method="GET",
1041
+ params={
1042
+ "experiment_ids": experiment_ids,
1043
+ "filters": filters,
1044
+ },
1045
+ request_options=request_options,
1046
+ )
1047
+ try:
1048
+ if 200 <= _response.status_code < 300:
1049
+ _data = typing.cast(
1050
+ ProjectStatsPublic,
1051
+ parse_obj_as(
1052
+ type_=ProjectStatsPublic, # type: ignore
1053
+ object_=_response.json(),
1054
+ ),
1055
+ )
1056
+ return HttpResponse(response=_response, data=_data)
1057
+ _response_json = _response.json()
1058
+ except JSONDecodeError:
1059
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1060
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1061
+
1062
+ def get_dataset_item_by_id(
1063
+ self, item_id: str, *, request_options: typing.Optional[RequestOptions] = None
1064
+ ) -> HttpResponse[DatasetItemPublic]:
1065
+ """
1066
+ Get dataset item by id
1067
+
1068
+ Parameters
1069
+ ----------
1070
+ item_id : str
1071
+
1072
+ request_options : typing.Optional[RequestOptions]
1073
+ Request-specific configuration.
1074
+
1075
+ Returns
1076
+ -------
1077
+ HttpResponse[DatasetItemPublic]
1078
+ Dataset item resource
1079
+ """
1080
+ _response = self._client_wrapper.httpx_client.request(
1081
+ f"v1/private/datasets/items/{jsonable_encoder(item_id)}",
1082
+ method="GET",
1083
+ request_options=request_options,
1084
+ )
1085
+ try:
1086
+ if 200 <= _response.status_code < 300:
1087
+ _data = typing.cast(
1088
+ DatasetItemPublic,
1089
+ parse_obj_as(
1090
+ type_=DatasetItemPublic, # type: ignore
1091
+ object_=_response.json(),
1092
+ ),
1093
+ )
1094
+ return HttpResponse(response=_response, data=_data)
1095
+ _response_json = _response.json()
1096
+ except JSONDecodeError:
1097
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1098
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1099
+
1100
+ def patch_dataset_item(
1101
+ self,
1102
+ item_id: str,
1103
+ *,
1104
+ source: DatasetItemWriteSource,
1105
+ data: JsonNode,
1106
+ id: typing.Optional[str] = OMIT,
1107
+ trace_id: typing.Optional[str] = OMIT,
1108
+ span_id: typing.Optional[str] = OMIT,
1109
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1110
+ request_options: typing.Optional[RequestOptions] = None,
1111
+ ) -> HttpResponse[None]:
1112
+ """
1113
+ Partially update dataset item by id. Only provided fields will be updated.
1114
+
1115
+ Parameters
1116
+ ----------
1117
+ item_id : str
1118
+
1119
+ source : DatasetItemWriteSource
1120
+
1121
+ data : JsonNode
1122
+
1123
+ id : typing.Optional[str]
1124
+
1125
+ trace_id : typing.Optional[str]
1126
+
1127
+ span_id : typing.Optional[str]
1128
+
1129
+ tags : typing.Optional[typing.Sequence[str]]
1130
+
1131
+ request_options : typing.Optional[RequestOptions]
1132
+ Request-specific configuration.
1133
+
1134
+ Returns
1135
+ -------
1136
+ HttpResponse[None]
1137
+ """
1138
+ _response = self._client_wrapper.httpx_client.request(
1139
+ f"v1/private/datasets/items/{jsonable_encoder(item_id)}",
1140
+ method="PATCH",
1141
+ json={
1142
+ "id": id,
1143
+ "trace_id": trace_id,
1144
+ "span_id": span_id,
1145
+ "source": source,
1146
+ "data": data,
1147
+ "tags": tags,
1148
+ },
1149
+ headers={
1150
+ "content-type": "application/json",
1151
+ },
1152
+ request_options=request_options,
1153
+ omit=OMIT,
1154
+ )
1155
+ try:
1156
+ if 200 <= _response.status_code < 300:
1157
+ return HttpResponse(response=_response, data=None)
1158
+ if _response.status_code == 404:
1159
+ raise NotFoundError(
1160
+ headers=dict(_response.headers),
1161
+ body=typing.cast(
1162
+ typing.Optional[typing.Any],
1163
+ parse_obj_as(
1164
+ type_=typing.Optional[typing.Any], # type: ignore
1165
+ object_=_response.json(),
1166
+ ),
1167
+ ),
1168
+ )
1169
+ _response_json = _response.json()
1170
+ except JSONDecodeError:
1171
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1172
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1173
+
1174
+ def get_dataset_items(
1175
+ self,
1176
+ id: str,
1177
+ *,
1178
+ page: typing.Optional[int] = None,
1179
+ size: typing.Optional[int] = None,
1180
+ version: typing.Optional[str] = None,
1181
+ filters: typing.Optional[str] = None,
1182
+ truncate: typing.Optional[bool] = None,
1183
+ request_options: typing.Optional[RequestOptions] = None,
1184
+ ) -> HttpResponse[DatasetItemPagePublic]:
1185
+ """
1186
+ Get dataset items
1187
+
1188
+ Parameters
1189
+ ----------
1190
+ id : str
1191
+
1192
+ page : typing.Optional[int]
1193
+
1194
+ size : typing.Optional[int]
1195
+
1196
+ version : typing.Optional[str]
1197
+
1198
+ filters : typing.Optional[str]
1199
+
1200
+ truncate : typing.Optional[bool]
1201
+
1202
+ request_options : typing.Optional[RequestOptions]
1203
+ Request-specific configuration.
1204
+
1205
+ Returns
1206
+ -------
1207
+ HttpResponse[DatasetItemPagePublic]
1208
+ Dataset items resource
1209
+ """
1210
+ _response = self._client_wrapper.httpx_client.request(
1211
+ f"v1/private/datasets/{jsonable_encoder(id)}/items",
1212
+ method="GET",
1213
+ params={
1214
+ "page": page,
1215
+ "size": size,
1216
+ "version": version,
1217
+ "filters": filters,
1218
+ "truncate": truncate,
1219
+ },
1220
+ request_options=request_options,
1221
+ )
1222
+ try:
1223
+ if 200 <= _response.status_code < 300:
1224
+ _data = typing.cast(
1225
+ DatasetItemPagePublic,
1226
+ parse_obj_as(
1227
+ type_=DatasetItemPagePublic, # type: ignore
1228
+ object_=_response.json(),
1229
+ ),
1230
+ )
1231
+ return HttpResponse(response=_response, data=_data)
1232
+ _response_json = _response.json()
1233
+ except JSONDecodeError:
1234
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1235
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1236
+
1237
+ def get_dataset_items_output_columns(
1238
+ self,
1239
+ id: str,
1240
+ *,
1241
+ experiment_ids: typing.Optional[str] = None,
1242
+ request_options: typing.Optional[RequestOptions] = None,
1243
+ ) -> HttpResponse[PageColumns]:
1244
+ """
1245
+ Get dataset items output columns
1246
+
1247
+ Parameters
1248
+ ----------
1249
+ id : str
1250
+
1251
+ experiment_ids : typing.Optional[str]
1252
+
1253
+ request_options : typing.Optional[RequestOptions]
1254
+ Request-specific configuration.
1255
+
1256
+ Returns
1257
+ -------
1258
+ HttpResponse[PageColumns]
1259
+ Dataset item output columns
1260
+ """
1261
+ _response = self._client_wrapper.httpx_client.request(
1262
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/experiments/items/output/columns",
1263
+ method="GET",
1264
+ params={
1265
+ "experiment_ids": experiment_ids,
1266
+ },
1267
+ request_options=request_options,
1268
+ )
1269
+ try:
1270
+ if 200 <= _response.status_code < 300:
1271
+ _data = typing.cast(
1272
+ PageColumns,
1273
+ parse_obj_as(
1274
+ type_=PageColumns, # type: ignore
1275
+ object_=_response.json(),
1276
+ ),
1277
+ )
1278
+ return HttpResponse(response=_response, data=_data)
1279
+ _response_json = _response.json()
1280
+ except JSONDecodeError:
1281
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1282
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1283
+
1284
+ @contextlib.contextmanager
1285
+ def stream_dataset_items(
1286
+ self,
1287
+ *,
1288
+ dataset_name: str,
1289
+ last_retrieved_id: typing.Optional[str] = OMIT,
1290
+ steam_limit: typing.Optional[int] = OMIT,
1291
+ request_options: typing.Optional[RequestOptions] = None,
1292
+ ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
1293
+ """
1294
+ Stream dataset items
1295
+
1296
+ Parameters
1297
+ ----------
1298
+ dataset_name : str
1299
+
1300
+ last_retrieved_id : typing.Optional[str]
1301
+
1302
+ steam_limit : typing.Optional[int]
1303
+
1304
+ request_options : typing.Optional[RequestOptions]
1305
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
1306
+
1307
+ Returns
1308
+ -------
1309
+ typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
1310
+ Dataset items stream or error during process
1311
+ """
1312
+ with self._client_wrapper.httpx_client.stream(
1313
+ "v1/private/datasets/items/stream",
1314
+ method="POST",
1315
+ json={
1316
+ "dataset_name": dataset_name,
1317
+ "last_retrieved_id": last_retrieved_id,
1318
+ "steam_limit": steam_limit,
1319
+ },
1320
+ headers={
1321
+ "content-type": "application/json",
1322
+ },
1323
+ request_options=request_options,
1324
+ omit=OMIT,
1325
+ ) as _response:
1326
+
1327
+ def stream() -> HttpResponse[typing.Iterator[bytes]]:
1328
+ try:
1329
+ if 200 <= _response.status_code < 300:
1330
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
1331
+ return HttpResponse(
1332
+ response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
1333
+ )
1334
+ _response.read()
1335
+ _response_json = _response.json()
1336
+ except JSONDecodeError:
1337
+ raise ApiError(
1338
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
1339
+ )
1340
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1341
+
1342
+ yield stream()
1343
+
1344
+ def compare_dataset_versions(
1345
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1346
+ ) -> HttpResponse[DatasetVersionDiff]:
1347
+ """
1348
+ 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.
1349
+
1350
+ Parameters
1351
+ ----------
1352
+ id : str
1353
+
1354
+ request_options : typing.Optional[RequestOptions]
1355
+ Request-specific configuration.
1356
+
1357
+ Returns
1358
+ -------
1359
+ HttpResponse[DatasetVersionDiff]
1360
+ Diff computed successfully
1361
+ """
1362
+ _response = self._client_wrapper.httpx_client.request(
1363
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/diff",
1364
+ method="GET",
1365
+ request_options=request_options,
1366
+ )
1367
+ try:
1368
+ if 200 <= _response.status_code < 300:
1369
+ _data = typing.cast(
1370
+ DatasetVersionDiff,
1371
+ parse_obj_as(
1372
+ type_=DatasetVersionDiff, # type: ignore
1373
+ object_=_response.json(),
1374
+ ),
1375
+ )
1376
+ return HttpResponse(response=_response, data=_data)
1377
+ if _response.status_code == 404:
1378
+ raise NotFoundError(
1379
+ headers=dict(_response.headers),
1380
+ body=typing.cast(
1381
+ typing.Optional[typing.Any],
1382
+ parse_obj_as(
1383
+ type_=typing.Optional[typing.Any], # type: ignore
1384
+ object_=_response.json(),
1385
+ ),
1386
+ ),
1387
+ )
1388
+ _response_json = _response.json()
1389
+ except JSONDecodeError:
1390
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1391
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1392
+
1393
+ def create_version_tag(
1394
+ self, version_hash: str, id: str, *, tag: str, request_options: typing.Optional[RequestOptions] = None
1395
+ ) -> HttpResponse[None]:
1396
+ """
1397
+ Add a tag to a specific dataset version for easy reference (e.g., 'baseline', 'v1.0', 'production')
1398
+
1399
+ Parameters
1400
+ ----------
1401
+ version_hash : str
1402
+
1403
+ id : str
1404
+
1405
+ tag : str
1406
+
1407
+ request_options : typing.Optional[RequestOptions]
1408
+ Request-specific configuration.
1409
+
1410
+ Returns
1411
+ -------
1412
+ HttpResponse[None]
1413
+ """
1414
+ _response = self._client_wrapper.httpx_client.request(
1415
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/hash/{jsonable_encoder(version_hash)}/tags",
1416
+ method="POST",
1417
+ json={
1418
+ "tag": tag,
1419
+ },
1420
+ headers={
1421
+ "content-type": "application/json",
1422
+ },
1423
+ request_options=request_options,
1424
+ omit=OMIT,
1425
+ )
1426
+ try:
1427
+ if 200 <= _response.status_code < 300:
1428
+ return HttpResponse(response=_response, data=None)
1429
+ if _response.status_code == 400:
1430
+ raise BadRequestError(
1431
+ headers=dict(_response.headers),
1432
+ body=typing.cast(
1433
+ typing.Optional[typing.Any],
1434
+ parse_obj_as(
1435
+ type_=typing.Optional[typing.Any], # type: ignore
1436
+ object_=_response.json(),
1437
+ ),
1438
+ ),
1439
+ )
1440
+ if _response.status_code == 404:
1441
+ raise NotFoundError(
1442
+ headers=dict(_response.headers),
1443
+ body=typing.cast(
1444
+ typing.Optional[typing.Any],
1445
+ parse_obj_as(
1446
+ type_=typing.Optional[typing.Any], # type: ignore
1447
+ object_=_response.json(),
1448
+ ),
1449
+ ),
1450
+ )
1451
+ if _response.status_code == 409:
1452
+ raise ConflictError(
1453
+ headers=dict(_response.headers),
1454
+ body=typing.cast(
1455
+ typing.Optional[typing.Any],
1456
+ parse_obj_as(
1457
+ type_=typing.Optional[typing.Any], # type: ignore
1458
+ object_=_response.json(),
1459
+ ),
1460
+ ),
1461
+ )
1462
+ _response_json = _response.json()
1463
+ except JSONDecodeError:
1464
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1465
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1466
+
1467
+ def delete_version_tag(
1468
+ self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
1469
+ ) -> HttpResponse[None]:
1470
+ """
1471
+ Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
1472
+
1473
+ Parameters
1474
+ ----------
1475
+ version_hash : str
1476
+
1477
+ tag : str
1478
+
1479
+ id : str
1480
+
1481
+ request_options : typing.Optional[RequestOptions]
1482
+ Request-specific configuration.
1483
+
1484
+ Returns
1485
+ -------
1486
+ HttpResponse[None]
1487
+ """
1488
+ _response = self._client_wrapper.httpx_client.request(
1489
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_hash)}/tags/{jsonable_encoder(tag)}",
1490
+ method="DELETE",
1491
+ request_options=request_options,
1492
+ )
1493
+ try:
1494
+ if 200 <= _response.status_code < 300:
1495
+ return HttpResponse(response=_response, data=None)
1496
+ _response_json = _response.json()
1497
+ except JSONDecodeError:
1498
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1499
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1500
+
1501
+ def list_dataset_versions(
1502
+ self,
1503
+ id: str,
1504
+ *,
1505
+ page: typing.Optional[int] = None,
1506
+ size: typing.Optional[int] = None,
1507
+ request_options: typing.Optional[RequestOptions] = None,
1508
+ ) -> HttpResponse[DatasetVersionPagePublic]:
1509
+ """
1510
+ Get paginated list of versions for a dataset, ordered by creation time (newest first)
1511
+
1512
+ Parameters
1513
+ ----------
1514
+ id : str
1515
+
1516
+ page : typing.Optional[int]
1517
+
1518
+ size : typing.Optional[int]
1519
+
1520
+ request_options : typing.Optional[RequestOptions]
1521
+ Request-specific configuration.
1522
+
1523
+ Returns
1524
+ -------
1525
+ HttpResponse[DatasetVersionPagePublic]
1526
+ Dataset versions
1527
+ """
1528
+ _response = self._client_wrapper.httpx_client.request(
1529
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions",
1530
+ method="GET",
1531
+ params={
1532
+ "page": page,
1533
+ "size": size,
1534
+ },
1535
+ request_options=request_options,
1536
+ )
1537
+ try:
1538
+ if 200 <= _response.status_code < 300:
1539
+ _data = typing.cast(
1540
+ DatasetVersionPagePublic,
1541
+ parse_obj_as(
1542
+ type_=DatasetVersionPagePublic, # type: ignore
1543
+ object_=_response.json(),
1544
+ ),
1545
+ )
1546
+ return HttpResponse(response=_response, data=_data)
1547
+ if _response.status_code == 400:
1548
+ raise BadRequestError(
1549
+ headers=dict(_response.headers),
1550
+ body=typing.cast(
1551
+ typing.Optional[typing.Any],
1552
+ parse_obj_as(
1553
+ type_=typing.Optional[typing.Any], # type: ignore
1554
+ object_=_response.json(),
1555
+ ),
1556
+ ),
1557
+ )
1558
+ _response_json = _response.json()
1559
+ except JSONDecodeError:
1560
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1561
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1562
+
1563
+ def restore_dataset_version(
1564
+ self, id: str, *, version_ref: str, request_options: typing.Optional[RequestOptions] = None
1565
+ ) -> HttpResponse[DatasetVersionPublic]:
1566
+ """
1567
+ 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).
1568
+
1569
+ Parameters
1570
+ ----------
1571
+ id : str
1572
+
1573
+ version_ref : str
1574
+ Version hash or tag to restore from
1575
+
1576
+ request_options : typing.Optional[RequestOptions]
1577
+ Request-specific configuration.
1578
+
1579
+ Returns
1580
+ -------
1581
+ HttpResponse[DatasetVersionPublic]
1582
+ Version restored successfully
1583
+ """
1584
+ _response = self._client_wrapper.httpx_client.request(
1585
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/restore",
1586
+ method="POST",
1587
+ json={
1588
+ "version_ref": version_ref,
1589
+ },
1590
+ headers={
1591
+ "content-type": "application/json",
1592
+ },
1593
+ request_options=request_options,
1594
+ omit=OMIT,
1595
+ )
1596
+ try:
1597
+ if 200 <= _response.status_code < 300:
1598
+ _data = typing.cast(
1599
+ DatasetVersionPublic,
1600
+ parse_obj_as(
1601
+ type_=DatasetVersionPublic, # type: ignore
1602
+ object_=_response.json(),
1603
+ ),
1604
+ )
1605
+ return HttpResponse(response=_response, data=_data)
1606
+ if _response.status_code == 404:
1607
+ raise NotFoundError(
1608
+ headers=dict(_response.headers),
1609
+ body=typing.cast(
1610
+ typing.Optional[typing.Any],
1611
+ parse_obj_as(
1612
+ type_=typing.Optional[typing.Any], # type: ignore
1613
+ object_=_response.json(),
1614
+ ),
1615
+ ),
1616
+ )
1617
+ _response_json = _response.json()
1618
+ except JSONDecodeError:
1619
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1620
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1621
+
1622
+ def update_dataset_version(
1623
+ self,
1624
+ version_hash: str,
1625
+ id: str,
1626
+ *,
1627
+ change_description: typing.Optional[str] = OMIT,
1628
+ tags_to_add: typing.Optional[typing.Sequence[str]] = OMIT,
1629
+ request_options: typing.Optional[RequestOptions] = None,
1630
+ ) -> HttpResponse[DatasetVersionPublic]:
1631
+ """
1632
+ Update a dataset version's change_description and/or add new tags
1633
+
1634
+ Parameters
1635
+ ----------
1636
+ version_hash : str
1637
+
1638
+ id : str
1639
+
1640
+ change_description : typing.Optional[str]
1641
+ Optional description of changes in this version
1642
+
1643
+ tags_to_add : typing.Optional[typing.Sequence[str]]
1644
+ Optional list of tags to add to this version
1645
+
1646
+ request_options : typing.Optional[RequestOptions]
1647
+ Request-specific configuration.
1648
+
1649
+ Returns
1650
+ -------
1651
+ HttpResponse[DatasetVersionPublic]
1652
+ Version updated successfully
1653
+ """
1654
+ _response = self._client_wrapper.httpx_client.request(
1655
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/hash/{jsonable_encoder(version_hash)}",
1656
+ method="PATCH",
1657
+ json={
1658
+ "change_description": change_description,
1659
+ "tags_to_add": tags_to_add,
1660
+ },
1661
+ headers={
1662
+ "content-type": "application/json",
1663
+ },
1664
+ request_options=request_options,
1665
+ omit=OMIT,
1666
+ )
1667
+ try:
1668
+ if 200 <= _response.status_code < 300:
1669
+ _data = typing.cast(
1670
+ DatasetVersionPublic,
1671
+ parse_obj_as(
1672
+ type_=DatasetVersionPublic, # type: ignore
1673
+ object_=_response.json(),
1674
+ ),
1675
+ )
1676
+ return HttpResponse(response=_response, data=_data)
1677
+ if _response.status_code == 400:
1678
+ raise BadRequestError(
1679
+ headers=dict(_response.headers),
1680
+ body=typing.cast(
1681
+ typing.Optional[typing.Any],
1682
+ parse_obj_as(
1683
+ type_=typing.Optional[typing.Any], # type: ignore
1684
+ object_=_response.json(),
1685
+ ),
1686
+ ),
1687
+ )
1688
+ if _response.status_code == 404:
1689
+ raise NotFoundError(
1690
+ headers=dict(_response.headers),
1691
+ body=typing.cast(
1692
+ typing.Optional[typing.Any],
1693
+ parse_obj_as(
1694
+ type_=typing.Optional[typing.Any], # type: ignore
1695
+ object_=_response.json(),
1696
+ ),
1697
+ ),
1698
+ )
1699
+ if _response.status_code == 409:
1700
+ raise ConflictError(
1701
+ headers=dict(_response.headers),
1702
+ body=typing.cast(
1703
+ typing.Optional[typing.Any],
1704
+ parse_obj_as(
1705
+ type_=typing.Optional[typing.Any], # type: ignore
1706
+ object_=_response.json(),
1707
+ ),
1708
+ ),
1709
+ )
1710
+ _response_json = _response.json()
1711
+ except JSONDecodeError:
1712
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1713
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1714
+
1715
+
1716
+ class AsyncRawDatasetsClient:
1717
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
1718
+ self._client_wrapper = client_wrapper
1719
+
1720
+ async def apply_dataset_item_changes(
1721
+ self,
1722
+ id: str,
1723
+ *,
1724
+ request: DatasetItemChangesPublic,
1725
+ override: typing.Optional[bool] = None,
1726
+ request_options: typing.Optional[RequestOptions] = None,
1727
+ ) -> AsyncHttpResponse[DatasetVersionPublic]:
1728
+ """
1729
+ Apply delta changes (add, edit, delete) to a dataset version with conflict detection.
1730
+
1731
+ This endpoint:
1732
+ - Creates a new version with the applied changes
1733
+ - Validates that baseVersion matches the latest version (unless override=true)
1734
+ - Returns 409 Conflict if baseVersion is stale and override is not set
1735
+
1736
+ Use `override=true` query parameter to force version creation even with stale baseVersion.
1737
+
1738
+ Parameters
1739
+ ----------
1740
+ id : str
1741
+
1742
+ request : DatasetItemChangesPublic
1743
+
1744
+ override : typing.Optional[bool]
1745
+
1746
+ request_options : typing.Optional[RequestOptions]
1747
+ Request-specific configuration.
1748
+
1749
+ Returns
1750
+ -------
1751
+ AsyncHttpResponse[DatasetVersionPublic]
1752
+ Version created successfully
1753
+ """
1754
+ _response = await self._client_wrapper.httpx_client.request(
1755
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/changes",
1756
+ method="POST",
1757
+ params={
1758
+ "override": override,
1759
+ },
1760
+ json=request,
1761
+ headers={
1762
+ "content-type": "application/json",
1763
+ },
1764
+ request_options=request_options,
1765
+ omit=OMIT,
1766
+ )
1767
+ try:
1768
+ if 200 <= _response.status_code < 300:
1769
+ _data = typing.cast(
1770
+ DatasetVersionPublic,
1771
+ parse_obj_as(
1772
+ type_=DatasetVersionPublic, # type: ignore
1773
+ object_=_response.json(),
1774
+ ),
1775
+ )
1776
+ return AsyncHttpResponse(response=_response, data=_data)
1777
+ if _response.status_code == 400:
1778
+ raise BadRequestError(
1779
+ headers=dict(_response.headers),
1780
+ body=typing.cast(
1781
+ typing.Optional[typing.Any],
1782
+ parse_obj_as(
1783
+ type_=typing.Optional[typing.Any], # type: ignore
1784
+ object_=_response.json(),
1785
+ ),
1786
+ ),
1787
+ )
1788
+ if _response.status_code == 404:
1789
+ raise NotFoundError(
1790
+ headers=dict(_response.headers),
1791
+ body=typing.cast(
1792
+ typing.Optional[typing.Any],
1793
+ parse_obj_as(
1794
+ type_=typing.Optional[typing.Any], # type: ignore
1795
+ object_=_response.json(),
1796
+ ),
1797
+ ),
1798
+ )
1799
+ if _response.status_code == 409:
1800
+ raise ConflictError(
1801
+ headers=dict(_response.headers),
1802
+ body=typing.cast(
1803
+ typing.Optional[typing.Any],
1804
+ parse_obj_as(
1805
+ type_=typing.Optional[typing.Any], # type: ignore
1806
+ object_=_response.json(),
1807
+ ),
1808
+ ),
1809
+ )
1810
+ _response_json = _response.json()
1811
+ except JSONDecodeError:
1812
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1813
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1814
+
1815
+ async def batch_update_dataset_items(
1816
+ self,
1817
+ *,
1818
+ update: DatasetItemUpdate,
1819
+ ids: typing.Optional[typing.Sequence[str]] = OMIT,
1820
+ filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
1821
+ dataset_id: typing.Optional[str] = OMIT,
1822
+ merge_tags: typing.Optional[bool] = OMIT,
1823
+ request_options: typing.Optional[RequestOptions] = None,
1824
+ ) -> AsyncHttpResponse[None]:
1825
+ """
1826
+ Update multiple dataset items
1827
+
1828
+ Parameters
1829
+ ----------
1830
+ update : DatasetItemUpdate
1831
+
1832
+ ids : typing.Optional[typing.Sequence[str]]
1833
+ List of dataset item IDs to update (max 1000). Mutually exclusive with 'filters'.
1834
+
1835
+ filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
1836
+
1837
+ dataset_id : typing.Optional[str]
1838
+ Dataset ID. Required when using 'filters', optional when using 'ids'.
1839
+
1840
+ merge_tags : typing.Optional[bool]
1841
+ If true, merge tags with existing tags instead of replacing them. Default: false. When using 'filters', this is automatically set to true.
1842
+
1843
+ request_options : typing.Optional[RequestOptions]
1844
+ Request-specific configuration.
1845
+
1846
+ Returns
1847
+ -------
1848
+ AsyncHttpResponse[None]
1849
+ """
1850
+ _response = await self._client_wrapper.httpx_client.request(
1851
+ "v1/private/datasets/items/batch",
1852
+ method="PATCH",
1853
+ json={
1854
+ "ids": ids,
1855
+ "filters": convert_and_respect_annotation_metadata(
1856
+ object_=filters, annotation=typing.Sequence[DatasetItemFilter], direction="write"
1857
+ ),
1858
+ "dataset_id": dataset_id,
1859
+ "update": convert_and_respect_annotation_metadata(
1860
+ object_=update, annotation=DatasetItemUpdate, direction="write"
1861
+ ),
1862
+ "merge_tags": merge_tags,
1863
+ },
1864
+ headers={
1865
+ "content-type": "application/json",
1866
+ },
1867
+ request_options=request_options,
1868
+ omit=OMIT,
1869
+ )
1870
+ try:
1871
+ if 200 <= _response.status_code < 300:
1872
+ return AsyncHttpResponse(response=_response, data=None)
1873
+ if _response.status_code == 400:
1874
+ raise BadRequestError(
1875
+ headers=dict(_response.headers),
1876
+ body=typing.cast(
1877
+ typing.Optional[typing.Any],
1878
+ parse_obj_as(
1879
+ type_=typing.Optional[typing.Any], # type: ignore
1880
+ object_=_response.json(),
1881
+ ),
1882
+ ),
1883
+ )
1884
+ _response_json = _response.json()
1885
+ except JSONDecodeError:
1886
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1887
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1888
+
1889
+ async def find_datasets(
1890
+ self,
1891
+ *,
1892
+ page: typing.Optional[int] = None,
1893
+ size: typing.Optional[int] = None,
1894
+ with_experiments_only: typing.Optional[bool] = None,
1895
+ with_optimizations_only: typing.Optional[bool] = None,
1896
+ prompt_id: typing.Optional[str] = None,
1897
+ name: typing.Optional[str] = None,
1898
+ sorting: typing.Optional[str] = None,
1899
+ filters: typing.Optional[str] = None,
1900
+ request_options: typing.Optional[RequestOptions] = None,
1901
+ ) -> AsyncHttpResponse[DatasetPagePublic]:
1902
+ """
1903
+ Find datasets
1904
+
1905
+ Parameters
1906
+ ----------
1907
+ page : typing.Optional[int]
1908
+
1909
+ size : typing.Optional[int]
1910
+
1911
+ with_experiments_only : typing.Optional[bool]
1912
+
1913
+ with_optimizations_only : typing.Optional[bool]
1914
+
1915
+ prompt_id : typing.Optional[str]
1916
+
1917
+ name : typing.Optional[str]
1918
+
1919
+ sorting : typing.Optional[str]
1920
+
1921
+ filters : typing.Optional[str]
1922
+
1923
+ request_options : typing.Optional[RequestOptions]
1924
+ Request-specific configuration.
1925
+
1926
+ Returns
1927
+ -------
1928
+ AsyncHttpResponse[DatasetPagePublic]
1929
+ Dataset resource
1930
+ """
1931
+ _response = await self._client_wrapper.httpx_client.request(
1932
+ "v1/private/datasets",
1933
+ method="GET",
1934
+ params={
1935
+ "page": page,
1936
+ "size": size,
1937
+ "with_experiments_only": with_experiments_only,
1938
+ "with_optimizations_only": with_optimizations_only,
1939
+ "prompt_id": prompt_id,
1940
+ "name": name,
1941
+ "sorting": sorting,
1942
+ "filters": filters,
1943
+ },
1944
+ request_options=request_options,
1945
+ )
1946
+ try:
1947
+ if 200 <= _response.status_code < 300:
1948
+ _data = typing.cast(
1949
+ DatasetPagePublic,
1950
+ parse_obj_as(
1951
+ type_=DatasetPagePublic, # type: ignore
1952
+ object_=_response.json(),
1953
+ ),
1954
+ )
1955
+ return AsyncHttpResponse(response=_response, data=_data)
1956
+ _response_json = _response.json()
1957
+ except JSONDecodeError:
1958
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1959
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1960
+
1961
+ async def create_dataset(
1962
+ self,
1963
+ *,
1964
+ name: str,
1965
+ id: typing.Optional[str] = OMIT,
1966
+ visibility: typing.Optional[DatasetWriteVisibility] = OMIT,
1967
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1968
+ description: typing.Optional[str] = OMIT,
1969
+ request_options: typing.Optional[RequestOptions] = None,
1970
+ ) -> AsyncHttpResponse[None]:
1971
+ """
1972
+ Create dataset
1973
+
1974
+ Parameters
1975
+ ----------
1976
+ name : str
1977
+
1978
+ id : typing.Optional[str]
1979
+
1980
+ visibility : typing.Optional[DatasetWriteVisibility]
1981
+
1982
+ tags : typing.Optional[typing.Sequence[str]]
1983
+
1984
+ description : typing.Optional[str]
1985
+
1986
+ request_options : typing.Optional[RequestOptions]
1987
+ Request-specific configuration.
1988
+
1989
+ Returns
1990
+ -------
1991
+ AsyncHttpResponse[None]
1992
+ """
1993
+ _response = await self._client_wrapper.httpx_client.request(
1994
+ "v1/private/datasets",
1995
+ method="POST",
1996
+ json={
1997
+ "id": id,
1998
+ "name": name,
1999
+ "visibility": visibility,
2000
+ "tags": tags,
2001
+ "description": description,
2002
+ },
2003
+ headers={
2004
+ "content-type": "application/json",
2005
+ },
2006
+ request_options=request_options,
2007
+ omit=OMIT,
2008
+ )
2009
+ try:
2010
+ if 200 <= _response.status_code < 300:
2011
+ return AsyncHttpResponse(response=_response, data=None)
2012
+ _response_json = _response.json()
2013
+ except JSONDecodeError:
2014
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2015
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2016
+
2017
+ async def create_or_update_dataset_items(
2018
+ self,
2019
+ *,
2020
+ items: typing.Sequence[DatasetItemWrite],
2021
+ dataset_name: typing.Optional[str] = OMIT,
2022
+ dataset_id: typing.Optional[str] = OMIT,
2023
+ request_options: typing.Optional[RequestOptions] = None,
2024
+ ) -> AsyncHttpResponse[None]:
2025
+ """
2026
+ Create/update dataset items based on dataset item id
2027
+
2028
+ Parameters
2029
+ ----------
2030
+ items : typing.Sequence[DatasetItemWrite]
2031
+
2032
+ dataset_name : typing.Optional[str]
2033
+ If null, dataset_id must be provided
2034
+
2035
+ dataset_id : typing.Optional[str]
2036
+ If null, dataset_name must be provided
2037
+
2038
+ request_options : typing.Optional[RequestOptions]
2039
+ Request-specific configuration.
2040
+
2041
+ Returns
2042
+ -------
2043
+ AsyncHttpResponse[None]
2044
+ """
2045
+ _response = await self._client_wrapper.httpx_client.request(
2046
+ "v1/private/datasets/items",
2047
+ method="PUT",
2048
+ json={
2049
+ "dataset_name": dataset_name,
2050
+ "dataset_id": dataset_id,
2051
+ "items": convert_and_respect_annotation_metadata(
2052
+ object_=items, annotation=typing.Sequence[DatasetItemWrite], direction="write"
2053
+ ),
2054
+ },
2055
+ headers={
2056
+ "content-type": "application/json",
2057
+ },
2058
+ request_options=request_options,
2059
+ omit=OMIT,
2060
+ )
2061
+ try:
2062
+ if 200 <= _response.status_code < 300:
2063
+ return AsyncHttpResponse(response=_response, data=None)
2064
+ _response_json = _response.json()
2065
+ except JSONDecodeError:
2066
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2067
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2068
+
2069
+ async def create_dataset_items_from_csv(
2070
+ self,
2071
+ *,
2072
+ file: typing.Dict[str, typing.Optional[typing.Any]],
2073
+ dataset_id: str,
2074
+ request_options: typing.Optional[RequestOptions] = None,
2075
+ ) -> AsyncHttpResponse[None]:
2076
+ """
2077
+ Create dataset items from uploaded CSV file. CSV should have headers in the first row. Processing happens asynchronously in batches.
2078
+
2079
+ Parameters
2080
+ ----------
2081
+ file : typing.Dict[str, typing.Optional[typing.Any]]
2082
+
2083
+ dataset_id : str
2084
+
2085
+ request_options : typing.Optional[RequestOptions]
2086
+ Request-specific configuration.
2087
+
2088
+ Returns
2089
+ -------
2090
+ AsyncHttpResponse[None]
2091
+ """
2092
+ _response = await self._client_wrapper.httpx_client.request(
2093
+ "v1/private/datasets/items/from-csv",
2094
+ method="POST",
2095
+ data={
2096
+ "file": file,
2097
+ "dataset_id": dataset_id,
2098
+ },
2099
+ files={},
2100
+ request_options=request_options,
2101
+ omit=OMIT,
2102
+ )
2103
+ try:
2104
+ if 200 <= _response.status_code < 300:
2105
+ return AsyncHttpResponse(response=_response, data=None)
2106
+ if _response.status_code == 400:
2107
+ raise BadRequestError(
2108
+ headers=dict(_response.headers),
2109
+ body=typing.cast(
2110
+ typing.Optional[typing.Any],
2111
+ parse_obj_as(
2112
+ type_=typing.Optional[typing.Any], # type: ignore
2113
+ object_=_response.json(),
2114
+ ),
2115
+ ),
2116
+ )
2117
+ if _response.status_code == 404:
2118
+ raise NotFoundError(
2119
+ headers=dict(_response.headers),
2120
+ body=typing.cast(
2121
+ typing.Optional[typing.Any],
2122
+ parse_obj_as(
2123
+ type_=typing.Optional[typing.Any], # type: ignore
2124
+ object_=_response.json(),
2125
+ ),
2126
+ ),
2127
+ )
2128
+ _response_json = _response.json()
2129
+ except JSONDecodeError:
2130
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2131
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2132
+
2133
+ async def create_dataset_items_from_spans(
2134
+ self,
2135
+ dataset_id: str,
2136
+ *,
2137
+ span_ids: typing.Sequence[str],
2138
+ enrichment_options: SpanEnrichmentOptions,
2139
+ request_options: typing.Optional[RequestOptions] = None,
2140
+ ) -> AsyncHttpResponse[None]:
2141
+ """
2142
+ Create dataset items from spans with enriched metadata
2143
+
2144
+ Parameters
2145
+ ----------
2146
+ dataset_id : str
2147
+
2148
+ span_ids : typing.Sequence[str]
2149
+ Set of span IDs to add to the dataset
2150
+
2151
+ enrichment_options : SpanEnrichmentOptions
2152
+
2153
+ request_options : typing.Optional[RequestOptions]
2154
+ Request-specific configuration.
2155
+
2156
+ Returns
2157
+ -------
2158
+ AsyncHttpResponse[None]
2159
+ """
2160
+ _response = await self._client_wrapper.httpx_client.request(
2161
+ f"v1/private/datasets/{jsonable_encoder(dataset_id)}/items/from-spans",
2162
+ method="POST",
2163
+ json={
2164
+ "span_ids": span_ids,
2165
+ "enrichment_options": convert_and_respect_annotation_metadata(
2166
+ object_=enrichment_options, annotation=SpanEnrichmentOptions, direction="write"
2167
+ ),
2168
+ },
2169
+ headers={
2170
+ "content-type": "application/json",
2171
+ },
2172
+ request_options=request_options,
2173
+ omit=OMIT,
2174
+ )
2175
+ try:
2176
+ if 200 <= _response.status_code < 300:
2177
+ return AsyncHttpResponse(response=_response, data=None)
2178
+ _response_json = _response.json()
2179
+ except JSONDecodeError:
2180
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2181
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2182
+
2183
+ async def create_dataset_items_from_traces(
2184
+ self,
2185
+ dataset_id: str,
2186
+ *,
2187
+ trace_ids: typing.Sequence[str],
2188
+ enrichment_options: TraceEnrichmentOptions,
2189
+ request_options: typing.Optional[RequestOptions] = None,
2190
+ ) -> AsyncHttpResponse[None]:
2191
+ """
2192
+ Create dataset items from traces with enriched metadata
2193
+
2194
+ Parameters
2195
+ ----------
2196
+ dataset_id : str
2197
+
2198
+ trace_ids : typing.Sequence[str]
2199
+ Set of trace IDs to add to the dataset
2200
+
2201
+ enrichment_options : TraceEnrichmentOptions
2202
+
2203
+ request_options : typing.Optional[RequestOptions]
2204
+ Request-specific configuration.
2205
+
2206
+ Returns
2207
+ -------
2208
+ AsyncHttpResponse[None]
2209
+ """
2210
+ _response = await self._client_wrapper.httpx_client.request(
2211
+ f"v1/private/datasets/{jsonable_encoder(dataset_id)}/items/from-traces",
2212
+ method="POST",
2213
+ json={
2214
+ "trace_ids": trace_ids,
2215
+ "enrichment_options": convert_and_respect_annotation_metadata(
2216
+ object_=enrichment_options, annotation=TraceEnrichmentOptions, direction="write"
2217
+ ),
2218
+ },
2219
+ headers={
2220
+ "content-type": "application/json",
2221
+ },
2222
+ request_options=request_options,
2223
+ omit=OMIT,
2224
+ )
2225
+ try:
2226
+ if 200 <= _response.status_code < 300:
2227
+ return AsyncHttpResponse(response=_response, data=None)
2228
+ _response_json = _response.json()
2229
+ except JSONDecodeError:
2230
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2231
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2232
+
2233
+ async def get_dataset_by_id(
2234
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2235
+ ) -> AsyncHttpResponse[DatasetPublic]:
2236
+ """
2237
+ Get dataset by id
2238
+
2239
+ Parameters
2240
+ ----------
2241
+ id : str
2242
+
2243
+ request_options : typing.Optional[RequestOptions]
2244
+ Request-specific configuration.
2245
+
2246
+ Returns
2247
+ -------
2248
+ AsyncHttpResponse[DatasetPublic]
2249
+ Dataset resource
2250
+ """
2251
+ _response = await self._client_wrapper.httpx_client.request(
2252
+ f"v1/private/datasets/{jsonable_encoder(id)}",
2253
+ method="GET",
2254
+ request_options=request_options,
2255
+ )
2256
+ try:
2257
+ if 200 <= _response.status_code < 300:
2258
+ _data = typing.cast(
2259
+ DatasetPublic,
2260
+ parse_obj_as(
2261
+ type_=DatasetPublic, # type: ignore
2262
+ object_=_response.json(),
2263
+ ),
2264
+ )
2265
+ return AsyncHttpResponse(response=_response, data=_data)
2266
+ _response_json = _response.json()
2267
+ except JSONDecodeError:
2268
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2269
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2270
+
2271
+ async def update_dataset(
2272
+ self,
2273
+ id: str,
2274
+ *,
2275
+ name: str,
2276
+ description: typing.Optional[str] = OMIT,
2277
+ visibility: typing.Optional[DatasetUpdateVisibility] = OMIT,
2278
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2279
+ request_options: typing.Optional[RequestOptions] = None,
2280
+ ) -> AsyncHttpResponse[None]:
2281
+ """
2282
+ Update dataset by id
2283
+
2284
+ Parameters
2285
+ ----------
2286
+ id : str
2287
+
2288
+ name : str
2289
+
2290
+ description : typing.Optional[str]
2291
+
2292
+ visibility : typing.Optional[DatasetUpdateVisibility]
2293
+
2294
+ tags : typing.Optional[typing.Sequence[str]]
2295
+
2296
+ request_options : typing.Optional[RequestOptions]
2297
+ Request-specific configuration.
2298
+
2299
+ Returns
2300
+ -------
2301
+ AsyncHttpResponse[None]
2302
+ """
2303
+ _response = await self._client_wrapper.httpx_client.request(
2304
+ f"v1/private/datasets/{jsonable_encoder(id)}",
2305
+ method="PUT",
2306
+ json={
2307
+ "name": name,
2308
+ "description": description,
2309
+ "visibility": visibility,
2310
+ "tags": tags,
2311
+ },
2312
+ headers={
2313
+ "content-type": "application/json",
2314
+ },
2315
+ request_options=request_options,
2316
+ omit=OMIT,
2317
+ )
2318
+ try:
2319
+ if 200 <= _response.status_code < 300:
2320
+ return AsyncHttpResponse(response=_response, data=None)
2321
+ _response_json = _response.json()
2322
+ except JSONDecodeError:
2323
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2324
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2325
+
2326
+ async def delete_dataset(
2327
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2328
+ ) -> AsyncHttpResponse[None]:
2329
+ """
2330
+ Delete dataset by id
2331
+
2332
+ Parameters
2333
+ ----------
2334
+ id : str
2335
+
2336
+ request_options : typing.Optional[RequestOptions]
2337
+ Request-specific configuration.
2338
+
2339
+ Returns
2340
+ -------
2341
+ AsyncHttpResponse[None]
2342
+ """
2343
+ _response = await self._client_wrapper.httpx_client.request(
2344
+ f"v1/private/datasets/{jsonable_encoder(id)}",
2345
+ method="DELETE",
2346
+ request_options=request_options,
2347
+ )
2348
+ try:
2349
+ if 200 <= _response.status_code < 300:
2350
+ return AsyncHttpResponse(response=_response, data=None)
2351
+ _response_json = _response.json()
2352
+ except JSONDecodeError:
2353
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2354
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2355
+
2356
+ async def delete_dataset_by_name(
2357
+ self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
2358
+ ) -> AsyncHttpResponse[None]:
2359
+ """
2360
+ Delete dataset by name
2361
+
2362
+ Parameters
2363
+ ----------
2364
+ dataset_name : str
2365
+
2366
+ request_options : typing.Optional[RequestOptions]
2367
+ Request-specific configuration.
2368
+
2369
+ Returns
2370
+ -------
2371
+ AsyncHttpResponse[None]
2372
+ """
2373
+ _response = await self._client_wrapper.httpx_client.request(
2374
+ "v1/private/datasets/delete",
2375
+ method="POST",
2376
+ json={
2377
+ "dataset_name": dataset_name,
2378
+ },
2379
+ headers={
2380
+ "content-type": "application/json",
2381
+ },
2382
+ request_options=request_options,
2383
+ omit=OMIT,
2384
+ )
2385
+ try:
2386
+ if 200 <= _response.status_code < 300:
2387
+ return AsyncHttpResponse(response=_response, data=None)
2388
+ _response_json = _response.json()
2389
+ except JSONDecodeError:
2390
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2391
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2392
+
2393
+ async def delete_dataset_items(
2394
+ self,
2395
+ *,
2396
+ item_ids: typing.Optional[typing.Sequence[str]] = OMIT,
2397
+ dataset_id: typing.Optional[str] = OMIT,
2398
+ filters: typing.Optional[typing.Sequence[DatasetItemFilter]] = OMIT,
2399
+ request_options: typing.Optional[RequestOptions] = None,
2400
+ ) -> AsyncHttpResponse[None]:
2401
+ """
2402
+ Delete dataset items using one of two modes:
2403
+ 1. **Delete by IDs**: Provide 'item_ids' to delete specific items by their IDs
2404
+ 2. **Delete by filters**: Provide 'dataset_id' with optional 'filters' to delete items matching criteria
2405
+
2406
+ When using filters, an empty 'filters' array will delete all items in the specified dataset.
2407
+
2408
+ Parameters
2409
+ ----------
2410
+ item_ids : typing.Optional[typing.Sequence[str]]
2411
+ 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'.
2412
+
2413
+ dataset_id : typing.Optional[str]
2414
+ Dataset ID to scope the deletion. Required when using 'filters'. Mutually exclusive with 'item_ids'.
2415
+
2416
+ filters : typing.Optional[typing.Sequence[DatasetItemFilter]]
2417
+ 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'.
2418
+
2419
+ request_options : typing.Optional[RequestOptions]
2420
+ Request-specific configuration.
2421
+
2422
+ Returns
2423
+ -------
2424
+ AsyncHttpResponse[None]
2425
+ """
2426
+ _response = await self._client_wrapper.httpx_client.request(
2427
+ "v1/private/datasets/items/delete",
2428
+ method="POST",
2429
+ json={
2430
+ "item_ids": item_ids,
2431
+ "dataset_id": dataset_id,
2432
+ "filters": convert_and_respect_annotation_metadata(
2433
+ object_=filters, annotation=typing.Sequence[DatasetItemFilter], direction="write"
2434
+ ),
2435
+ },
2436
+ headers={
2437
+ "content-type": "application/json",
2438
+ },
2439
+ request_options=request_options,
2440
+ omit=OMIT,
2441
+ )
2442
+ try:
2443
+ if 200 <= _response.status_code < 300:
2444
+ return AsyncHttpResponse(response=_response, data=None)
2445
+ if _response.status_code == 400:
2446
+ raise BadRequestError(
2447
+ headers=dict(_response.headers),
2448
+ body=typing.cast(
2449
+ typing.Optional[typing.Any],
2450
+ parse_obj_as(
2451
+ type_=typing.Optional[typing.Any], # type: ignore
2452
+ object_=_response.json(),
2453
+ ),
2454
+ ),
2455
+ )
2456
+ _response_json = _response.json()
2457
+ except JSONDecodeError:
2458
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2459
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2460
+
2461
+ async def delete_datasets_batch(
2462
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
2463
+ ) -> AsyncHttpResponse[None]:
2464
+ """
2465
+ Delete datasets batch
2466
+
2467
+ Parameters
2468
+ ----------
2469
+ ids : typing.Sequence[str]
2470
+
2471
+ request_options : typing.Optional[RequestOptions]
2472
+ Request-specific configuration.
2473
+
2474
+ Returns
2475
+ -------
2476
+ AsyncHttpResponse[None]
2477
+ """
2478
+ _response = await self._client_wrapper.httpx_client.request(
2479
+ "v1/private/datasets/delete-batch",
2480
+ method="POST",
2481
+ json={
2482
+ "ids": ids,
2483
+ },
2484
+ headers={
2485
+ "content-type": "application/json",
2486
+ },
2487
+ request_options=request_options,
2488
+ omit=OMIT,
2489
+ )
2490
+ try:
2491
+ if 200 <= _response.status_code < 300:
2492
+ return AsyncHttpResponse(response=_response, data=None)
2493
+ _response_json = _response.json()
2494
+ except JSONDecodeError:
2495
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2496
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2497
+
2498
+ async def expand_dataset(
2499
+ self,
2500
+ id: str,
2501
+ *,
2502
+ model: str,
2503
+ sample_count: typing.Optional[int] = OMIT,
2504
+ preserve_fields: typing.Optional[typing.Sequence[str]] = OMIT,
2505
+ variation_instructions: typing.Optional[str] = OMIT,
2506
+ custom_prompt: typing.Optional[str] = OMIT,
2507
+ request_options: typing.Optional[RequestOptions] = None,
2508
+ ) -> AsyncHttpResponse[DatasetExpansionResponse]:
2509
+ """
2510
+ Generate synthetic dataset samples using LLM based on existing data patterns
2511
+
2512
+ Parameters
2513
+ ----------
2514
+ id : str
2515
+
2516
+ model : str
2517
+ The model to use for synthetic data generation
2518
+
2519
+ sample_count : typing.Optional[int]
2520
+ Number of synthetic samples to generate
2521
+
2522
+ preserve_fields : typing.Optional[typing.Sequence[str]]
2523
+ Fields to preserve patterns from original data
2524
+
2525
+ variation_instructions : typing.Optional[str]
2526
+ Additional instructions for data variation
2527
+
2528
+ custom_prompt : typing.Optional[str]
2529
+ Custom prompt to use for generation instead of auto-generated one
2530
+
2531
+ request_options : typing.Optional[RequestOptions]
2532
+ Request-specific configuration.
2533
+
2534
+ Returns
2535
+ -------
2536
+ AsyncHttpResponse[DatasetExpansionResponse]
2537
+ Generated synthetic samples
2538
+ """
2539
+ _response = await self._client_wrapper.httpx_client.request(
2540
+ f"v1/private/datasets/{jsonable_encoder(id)}/expansions",
2541
+ method="POST",
2542
+ json={
2543
+ "model": model,
2544
+ "sample_count": sample_count,
2545
+ "preserve_fields": preserve_fields,
2546
+ "variation_instructions": variation_instructions,
2547
+ "custom_prompt": custom_prompt,
2548
+ },
2549
+ headers={
2550
+ "content-type": "application/json",
2551
+ },
2552
+ request_options=request_options,
2553
+ omit=OMIT,
2554
+ )
2555
+ try:
2556
+ if 200 <= _response.status_code < 300:
2557
+ _data = typing.cast(
2558
+ DatasetExpansionResponse,
2559
+ parse_obj_as(
2560
+ type_=DatasetExpansionResponse, # type: ignore
2561
+ object_=_response.json(),
2562
+ ),
2563
+ )
2564
+ return AsyncHttpResponse(response=_response, data=_data)
2565
+ _response_json = _response.json()
2566
+ except JSONDecodeError:
2567
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2568
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2569
+
2570
+ async def find_dataset_items_with_experiment_items(
2571
+ self,
2572
+ id: str,
2573
+ *,
2574
+ experiment_ids: str,
2575
+ page: typing.Optional[int] = None,
2576
+ size: typing.Optional[int] = None,
2577
+ filters: typing.Optional[str] = None,
2578
+ sorting: typing.Optional[str] = None,
2579
+ search: typing.Optional[str] = None,
2580
+ truncate: typing.Optional[bool] = None,
2581
+ request_options: typing.Optional[RequestOptions] = None,
2582
+ ) -> AsyncHttpResponse[DatasetItemPageCompare]:
2583
+ """
2584
+ Find dataset items with experiment items
2585
+
2586
+ Parameters
2587
+ ----------
2588
+ id : str
2589
+
2590
+ experiment_ids : str
2591
+
2592
+ page : typing.Optional[int]
2593
+
2594
+ size : typing.Optional[int]
2595
+
2596
+ filters : typing.Optional[str]
2597
+
2598
+ sorting : typing.Optional[str]
2599
+
2600
+ search : typing.Optional[str]
2601
+
2602
+ truncate : typing.Optional[bool]
2603
+
2604
+ request_options : typing.Optional[RequestOptions]
2605
+ Request-specific configuration.
2606
+
2607
+ Returns
2608
+ -------
2609
+ AsyncHttpResponse[DatasetItemPageCompare]
2610
+ Dataset item resource
2611
+ """
2612
+ _response = await self._client_wrapper.httpx_client.request(
2613
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/experiments/items",
2614
+ method="GET",
2615
+ params={
2616
+ "page": page,
2617
+ "size": size,
2618
+ "experiment_ids": experiment_ids,
2619
+ "filters": filters,
2620
+ "sorting": sorting,
2621
+ "search": search,
2622
+ "truncate": truncate,
2623
+ },
2624
+ request_options=request_options,
2625
+ )
2626
+ try:
2627
+ if 200 <= _response.status_code < 300:
2628
+ _data = typing.cast(
2629
+ DatasetItemPageCompare,
2630
+ parse_obj_as(
2631
+ type_=DatasetItemPageCompare, # type: ignore
2632
+ object_=_response.json(),
2633
+ ),
2634
+ )
2635
+ return AsyncHttpResponse(response=_response, data=_data)
2636
+ _response_json = _response.json()
2637
+ except JSONDecodeError:
2638
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2639
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2640
+
2641
+ async def get_dataset_by_identifier(
2642
+ self, *, dataset_name: str, request_options: typing.Optional[RequestOptions] = None
2643
+ ) -> AsyncHttpResponse[DatasetPublic]:
2644
+ """
2645
+ Get dataset by name
2646
+
2647
+ Parameters
2648
+ ----------
2649
+ dataset_name : str
2650
+
2651
+ request_options : typing.Optional[RequestOptions]
2652
+ Request-specific configuration.
2653
+
2654
+ Returns
2655
+ -------
2656
+ AsyncHttpResponse[DatasetPublic]
2657
+ Dataset resource
2658
+ """
2659
+ _response = await self._client_wrapper.httpx_client.request(
2660
+ "v1/private/datasets/retrieve",
2661
+ method="POST",
2662
+ json={
2663
+ "dataset_name": dataset_name,
2664
+ },
2665
+ headers={
2666
+ "content-type": "application/json",
2667
+ },
2668
+ request_options=request_options,
2669
+ omit=OMIT,
2670
+ )
2671
+ try:
2672
+ if 200 <= _response.status_code < 300:
2673
+ _data = typing.cast(
2674
+ DatasetPublic,
2675
+ parse_obj_as(
2676
+ type_=DatasetPublic, # type: ignore
2677
+ object_=_response.json(),
2678
+ ),
2679
+ )
2680
+ return AsyncHttpResponse(response=_response, data=_data)
2681
+ _response_json = _response.json()
2682
+ except JSONDecodeError:
2683
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2684
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2685
+
2686
+ async def get_dataset_experiment_items_stats(
2687
+ self,
2688
+ id: str,
2689
+ *,
2690
+ experiment_ids: str,
2691
+ filters: typing.Optional[str] = None,
2692
+ request_options: typing.Optional[RequestOptions] = None,
2693
+ ) -> AsyncHttpResponse[ProjectStatsPublic]:
2694
+ """
2695
+ Get experiment items stats for dataset
2696
+
2697
+ Parameters
2698
+ ----------
2699
+ id : str
2700
+
2701
+ experiment_ids : str
2702
+
2703
+ filters : typing.Optional[str]
2704
+
2705
+ request_options : typing.Optional[RequestOptions]
2706
+ Request-specific configuration.
2707
+
2708
+ Returns
2709
+ -------
2710
+ AsyncHttpResponse[ProjectStatsPublic]
2711
+ Experiment items stats resource
2712
+ """
2713
+ _response = await self._client_wrapper.httpx_client.request(
2714
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/experiments/items/stats",
2715
+ method="GET",
2716
+ params={
2717
+ "experiment_ids": experiment_ids,
2718
+ "filters": filters,
2719
+ },
2720
+ request_options=request_options,
2721
+ )
2722
+ try:
2723
+ if 200 <= _response.status_code < 300:
2724
+ _data = typing.cast(
2725
+ ProjectStatsPublic,
2726
+ parse_obj_as(
2727
+ type_=ProjectStatsPublic, # type: ignore
2728
+ object_=_response.json(),
2729
+ ),
2730
+ )
2731
+ return AsyncHttpResponse(response=_response, data=_data)
2732
+ _response_json = _response.json()
2733
+ except JSONDecodeError:
2734
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2735
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2736
+
2737
+ async def get_dataset_item_by_id(
2738
+ self, item_id: str, *, request_options: typing.Optional[RequestOptions] = None
2739
+ ) -> AsyncHttpResponse[DatasetItemPublic]:
2740
+ """
2741
+ Get dataset item by id
2742
+
2743
+ Parameters
2744
+ ----------
2745
+ item_id : str
2746
+
2747
+ request_options : typing.Optional[RequestOptions]
2748
+ Request-specific configuration.
2749
+
2750
+ Returns
2751
+ -------
2752
+ AsyncHttpResponse[DatasetItemPublic]
2753
+ Dataset item resource
2754
+ """
2755
+ _response = await self._client_wrapper.httpx_client.request(
2756
+ f"v1/private/datasets/items/{jsonable_encoder(item_id)}",
2757
+ method="GET",
2758
+ request_options=request_options,
2759
+ )
2760
+ try:
2761
+ if 200 <= _response.status_code < 300:
2762
+ _data = typing.cast(
2763
+ DatasetItemPublic,
2764
+ parse_obj_as(
2765
+ type_=DatasetItemPublic, # type: ignore
2766
+ object_=_response.json(),
2767
+ ),
2768
+ )
2769
+ return AsyncHttpResponse(response=_response, data=_data)
2770
+ _response_json = _response.json()
2771
+ except JSONDecodeError:
2772
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2773
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2774
+
2775
+ async def patch_dataset_item(
2776
+ self,
2777
+ item_id: str,
2778
+ *,
2779
+ source: DatasetItemWriteSource,
2780
+ data: JsonNode,
2781
+ id: typing.Optional[str] = OMIT,
2782
+ trace_id: typing.Optional[str] = OMIT,
2783
+ span_id: typing.Optional[str] = OMIT,
2784
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2785
+ request_options: typing.Optional[RequestOptions] = None,
2786
+ ) -> AsyncHttpResponse[None]:
2787
+ """
2788
+ Partially update dataset item by id. Only provided fields will be updated.
2789
+
2790
+ Parameters
2791
+ ----------
2792
+ item_id : str
2793
+
2794
+ source : DatasetItemWriteSource
2795
+
2796
+ data : JsonNode
2797
+
2798
+ id : typing.Optional[str]
2799
+
2800
+ trace_id : typing.Optional[str]
2801
+
2802
+ span_id : typing.Optional[str]
2803
+
2804
+ tags : typing.Optional[typing.Sequence[str]]
2805
+
2806
+ request_options : typing.Optional[RequestOptions]
2807
+ Request-specific configuration.
2808
+
2809
+ Returns
2810
+ -------
2811
+ AsyncHttpResponse[None]
2812
+ """
2813
+ _response = await self._client_wrapper.httpx_client.request(
2814
+ f"v1/private/datasets/items/{jsonable_encoder(item_id)}",
2815
+ method="PATCH",
2816
+ json={
2817
+ "id": id,
2818
+ "trace_id": trace_id,
2819
+ "span_id": span_id,
2820
+ "source": source,
2821
+ "data": data,
2822
+ "tags": tags,
2823
+ },
2824
+ headers={
2825
+ "content-type": "application/json",
2826
+ },
2827
+ request_options=request_options,
2828
+ omit=OMIT,
2829
+ )
2830
+ try:
2831
+ if 200 <= _response.status_code < 300:
2832
+ return AsyncHttpResponse(response=_response, data=None)
2833
+ if _response.status_code == 404:
2834
+ raise NotFoundError(
2835
+ headers=dict(_response.headers),
2836
+ body=typing.cast(
2837
+ typing.Optional[typing.Any],
2838
+ parse_obj_as(
2839
+ type_=typing.Optional[typing.Any], # type: ignore
2840
+ object_=_response.json(),
2841
+ ),
2842
+ ),
2843
+ )
2844
+ _response_json = _response.json()
2845
+ except JSONDecodeError:
2846
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2847
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2848
+
2849
+ async def get_dataset_items(
2850
+ self,
2851
+ id: str,
2852
+ *,
2853
+ page: typing.Optional[int] = None,
2854
+ size: typing.Optional[int] = None,
2855
+ version: typing.Optional[str] = None,
2856
+ filters: typing.Optional[str] = None,
2857
+ truncate: typing.Optional[bool] = None,
2858
+ request_options: typing.Optional[RequestOptions] = None,
2859
+ ) -> AsyncHttpResponse[DatasetItemPagePublic]:
2860
+ """
2861
+ Get dataset items
2862
+
2863
+ Parameters
2864
+ ----------
2865
+ id : str
2866
+
2867
+ page : typing.Optional[int]
2868
+
2869
+ size : typing.Optional[int]
2870
+
2871
+ version : typing.Optional[str]
2872
+
2873
+ filters : typing.Optional[str]
2874
+
2875
+ truncate : typing.Optional[bool]
2876
+
2877
+ request_options : typing.Optional[RequestOptions]
2878
+ Request-specific configuration.
2879
+
2880
+ Returns
2881
+ -------
2882
+ AsyncHttpResponse[DatasetItemPagePublic]
2883
+ Dataset items resource
2884
+ """
2885
+ _response = await self._client_wrapper.httpx_client.request(
2886
+ f"v1/private/datasets/{jsonable_encoder(id)}/items",
2887
+ method="GET",
2888
+ params={
2889
+ "page": page,
2890
+ "size": size,
2891
+ "version": version,
2892
+ "filters": filters,
2893
+ "truncate": truncate,
2894
+ },
2895
+ request_options=request_options,
2896
+ )
2897
+ try:
2898
+ if 200 <= _response.status_code < 300:
2899
+ _data = typing.cast(
2900
+ DatasetItemPagePublic,
2901
+ parse_obj_as(
2902
+ type_=DatasetItemPagePublic, # type: ignore
2903
+ object_=_response.json(),
2904
+ ),
2905
+ )
2906
+ return AsyncHttpResponse(response=_response, data=_data)
2907
+ _response_json = _response.json()
2908
+ except JSONDecodeError:
2909
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2910
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2911
+
2912
+ async def get_dataset_items_output_columns(
2913
+ self,
2914
+ id: str,
2915
+ *,
2916
+ experiment_ids: typing.Optional[str] = None,
2917
+ request_options: typing.Optional[RequestOptions] = None,
2918
+ ) -> AsyncHttpResponse[PageColumns]:
2919
+ """
2920
+ Get dataset items output columns
2921
+
2922
+ Parameters
2923
+ ----------
2924
+ id : str
2925
+
2926
+ experiment_ids : typing.Optional[str]
2927
+
2928
+ request_options : typing.Optional[RequestOptions]
2929
+ Request-specific configuration.
2930
+
2931
+ Returns
2932
+ -------
2933
+ AsyncHttpResponse[PageColumns]
2934
+ Dataset item output columns
2935
+ """
2936
+ _response = await self._client_wrapper.httpx_client.request(
2937
+ f"v1/private/datasets/{jsonable_encoder(id)}/items/experiments/items/output/columns",
2938
+ method="GET",
2939
+ params={
2940
+ "experiment_ids": experiment_ids,
2941
+ },
2942
+ request_options=request_options,
2943
+ )
2944
+ try:
2945
+ if 200 <= _response.status_code < 300:
2946
+ _data = typing.cast(
2947
+ PageColumns,
2948
+ parse_obj_as(
2949
+ type_=PageColumns, # type: ignore
2950
+ object_=_response.json(),
2951
+ ),
2952
+ )
2953
+ return AsyncHttpResponse(response=_response, data=_data)
2954
+ _response_json = _response.json()
2955
+ except JSONDecodeError:
2956
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2957
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2958
+
2959
+ @contextlib.asynccontextmanager
2960
+ async def stream_dataset_items(
2961
+ self,
2962
+ *,
2963
+ dataset_name: str,
2964
+ last_retrieved_id: typing.Optional[str] = OMIT,
2965
+ steam_limit: typing.Optional[int] = OMIT,
2966
+ request_options: typing.Optional[RequestOptions] = None,
2967
+ ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
2968
+ """
2969
+ Stream dataset items
2970
+
2971
+ Parameters
2972
+ ----------
2973
+ dataset_name : str
2974
+
2975
+ last_retrieved_id : typing.Optional[str]
2976
+
2977
+ steam_limit : typing.Optional[int]
2978
+
2979
+ request_options : typing.Optional[RequestOptions]
2980
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
2981
+
2982
+ Returns
2983
+ -------
2984
+ typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
2985
+ Dataset items stream or error during process
2986
+ """
2987
+ async with self._client_wrapper.httpx_client.stream(
2988
+ "v1/private/datasets/items/stream",
2989
+ method="POST",
2990
+ json={
2991
+ "dataset_name": dataset_name,
2992
+ "last_retrieved_id": last_retrieved_id,
2993
+ "steam_limit": steam_limit,
2994
+ },
2995
+ headers={
2996
+ "content-type": "application/json",
2997
+ },
2998
+ request_options=request_options,
2999
+ omit=OMIT,
3000
+ ) as _response:
3001
+
3002
+ async def stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
3003
+ try:
3004
+ if 200 <= _response.status_code < 300:
3005
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
3006
+ return AsyncHttpResponse(
3007
+ response=_response,
3008
+ data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
3009
+ )
3010
+ await _response.aread()
3011
+ _response_json = _response.json()
3012
+ except JSONDecodeError:
3013
+ raise ApiError(
3014
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
3015
+ )
3016
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3017
+
3018
+ yield await stream()
3019
+
3020
+ async def compare_dataset_versions(
3021
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
3022
+ ) -> AsyncHttpResponse[DatasetVersionDiff]:
3023
+ """
3024
+ 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.
3025
+
3026
+ Parameters
3027
+ ----------
3028
+ id : str
3029
+
3030
+ request_options : typing.Optional[RequestOptions]
3031
+ Request-specific configuration.
3032
+
3033
+ Returns
3034
+ -------
3035
+ AsyncHttpResponse[DatasetVersionDiff]
3036
+ Diff computed successfully
3037
+ """
3038
+ _response = await self._client_wrapper.httpx_client.request(
3039
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/diff",
3040
+ method="GET",
3041
+ request_options=request_options,
3042
+ )
3043
+ try:
3044
+ if 200 <= _response.status_code < 300:
3045
+ _data = typing.cast(
3046
+ DatasetVersionDiff,
3047
+ parse_obj_as(
3048
+ type_=DatasetVersionDiff, # type: ignore
3049
+ object_=_response.json(),
3050
+ ),
3051
+ )
3052
+ return AsyncHttpResponse(response=_response, data=_data)
3053
+ if _response.status_code == 404:
3054
+ raise NotFoundError(
3055
+ headers=dict(_response.headers),
3056
+ body=typing.cast(
3057
+ typing.Optional[typing.Any],
3058
+ parse_obj_as(
3059
+ type_=typing.Optional[typing.Any], # type: ignore
3060
+ object_=_response.json(),
3061
+ ),
3062
+ ),
3063
+ )
3064
+ _response_json = _response.json()
3065
+ except JSONDecodeError:
3066
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3067
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3068
+
3069
+ async def create_version_tag(
3070
+ self, version_hash: str, id: str, *, tag: str, request_options: typing.Optional[RequestOptions] = None
3071
+ ) -> AsyncHttpResponse[None]:
3072
+ """
3073
+ Add a tag to a specific dataset version for easy reference (e.g., 'baseline', 'v1.0', 'production')
3074
+
3075
+ Parameters
3076
+ ----------
3077
+ version_hash : str
3078
+
3079
+ id : str
3080
+
3081
+ tag : str
3082
+
3083
+ request_options : typing.Optional[RequestOptions]
3084
+ Request-specific configuration.
3085
+
3086
+ Returns
3087
+ -------
3088
+ AsyncHttpResponse[None]
3089
+ """
3090
+ _response = await self._client_wrapper.httpx_client.request(
3091
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/hash/{jsonable_encoder(version_hash)}/tags",
3092
+ method="POST",
3093
+ json={
3094
+ "tag": tag,
3095
+ },
3096
+ headers={
3097
+ "content-type": "application/json",
3098
+ },
3099
+ request_options=request_options,
3100
+ omit=OMIT,
3101
+ )
3102
+ try:
3103
+ if 200 <= _response.status_code < 300:
3104
+ return AsyncHttpResponse(response=_response, data=None)
3105
+ if _response.status_code == 400:
3106
+ raise BadRequestError(
3107
+ headers=dict(_response.headers),
3108
+ body=typing.cast(
3109
+ typing.Optional[typing.Any],
3110
+ parse_obj_as(
3111
+ type_=typing.Optional[typing.Any], # type: ignore
3112
+ object_=_response.json(),
3113
+ ),
3114
+ ),
3115
+ )
3116
+ if _response.status_code == 404:
3117
+ raise NotFoundError(
3118
+ headers=dict(_response.headers),
3119
+ body=typing.cast(
3120
+ typing.Optional[typing.Any],
3121
+ parse_obj_as(
3122
+ type_=typing.Optional[typing.Any], # type: ignore
3123
+ object_=_response.json(),
3124
+ ),
3125
+ ),
3126
+ )
3127
+ if _response.status_code == 409:
3128
+ raise ConflictError(
3129
+ headers=dict(_response.headers),
3130
+ body=typing.cast(
3131
+ typing.Optional[typing.Any],
3132
+ parse_obj_as(
3133
+ type_=typing.Optional[typing.Any], # type: ignore
3134
+ object_=_response.json(),
3135
+ ),
3136
+ ),
3137
+ )
3138
+ _response_json = _response.json()
3139
+ except JSONDecodeError:
3140
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3141
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3142
+
3143
+ async def delete_version_tag(
3144
+ self, version_hash: str, tag: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
3145
+ ) -> AsyncHttpResponse[None]:
3146
+ """
3147
+ Remove a tag from a dataset version. The version itself is not deleted, only the tag reference.
3148
+
3149
+ Parameters
3150
+ ----------
3151
+ version_hash : str
3152
+
3153
+ tag : str
3154
+
3155
+ id : str
3156
+
3157
+ request_options : typing.Optional[RequestOptions]
3158
+ Request-specific configuration.
3159
+
3160
+ Returns
3161
+ -------
3162
+ AsyncHttpResponse[None]
3163
+ """
3164
+ _response = await self._client_wrapper.httpx_client.request(
3165
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_hash)}/tags/{jsonable_encoder(tag)}",
3166
+ method="DELETE",
3167
+ request_options=request_options,
3168
+ )
3169
+ try:
3170
+ if 200 <= _response.status_code < 300:
3171
+ return AsyncHttpResponse(response=_response, data=None)
3172
+ _response_json = _response.json()
3173
+ except JSONDecodeError:
3174
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3175
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3176
+
3177
+ async def list_dataset_versions(
3178
+ self,
3179
+ id: str,
3180
+ *,
3181
+ page: typing.Optional[int] = None,
3182
+ size: typing.Optional[int] = None,
3183
+ request_options: typing.Optional[RequestOptions] = None,
3184
+ ) -> AsyncHttpResponse[DatasetVersionPagePublic]:
3185
+ """
3186
+ Get paginated list of versions for a dataset, ordered by creation time (newest first)
3187
+
3188
+ Parameters
3189
+ ----------
3190
+ id : str
3191
+
3192
+ page : typing.Optional[int]
3193
+
3194
+ size : typing.Optional[int]
3195
+
3196
+ request_options : typing.Optional[RequestOptions]
3197
+ Request-specific configuration.
3198
+
3199
+ Returns
3200
+ -------
3201
+ AsyncHttpResponse[DatasetVersionPagePublic]
3202
+ Dataset versions
3203
+ """
3204
+ _response = await self._client_wrapper.httpx_client.request(
3205
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions",
3206
+ method="GET",
3207
+ params={
3208
+ "page": page,
3209
+ "size": size,
3210
+ },
3211
+ request_options=request_options,
3212
+ )
3213
+ try:
3214
+ if 200 <= _response.status_code < 300:
3215
+ _data = typing.cast(
3216
+ DatasetVersionPagePublic,
3217
+ parse_obj_as(
3218
+ type_=DatasetVersionPagePublic, # type: ignore
3219
+ object_=_response.json(),
3220
+ ),
3221
+ )
3222
+ return AsyncHttpResponse(response=_response, data=_data)
3223
+ if _response.status_code == 400:
3224
+ raise BadRequestError(
3225
+ headers=dict(_response.headers),
3226
+ body=typing.cast(
3227
+ typing.Optional[typing.Any],
3228
+ parse_obj_as(
3229
+ type_=typing.Optional[typing.Any], # type: ignore
3230
+ object_=_response.json(),
3231
+ ),
3232
+ ),
3233
+ )
3234
+ _response_json = _response.json()
3235
+ except JSONDecodeError:
3236
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3237
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3238
+
3239
+ async def restore_dataset_version(
3240
+ self, id: str, *, version_ref: str, request_options: typing.Optional[RequestOptions] = None
3241
+ ) -> AsyncHttpResponse[DatasetVersionPublic]:
3242
+ """
3243
+ 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).
3244
+
3245
+ Parameters
3246
+ ----------
3247
+ id : str
3248
+
3249
+ version_ref : str
3250
+ Version hash or tag to restore from
3251
+
3252
+ request_options : typing.Optional[RequestOptions]
3253
+ Request-specific configuration.
3254
+
3255
+ Returns
3256
+ -------
3257
+ AsyncHttpResponse[DatasetVersionPublic]
3258
+ Version restored successfully
3259
+ """
3260
+ _response = await self._client_wrapper.httpx_client.request(
3261
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/restore",
3262
+ method="POST",
3263
+ json={
3264
+ "version_ref": version_ref,
3265
+ },
3266
+ headers={
3267
+ "content-type": "application/json",
3268
+ },
3269
+ request_options=request_options,
3270
+ omit=OMIT,
3271
+ )
3272
+ try:
3273
+ if 200 <= _response.status_code < 300:
3274
+ _data = typing.cast(
3275
+ DatasetVersionPublic,
3276
+ parse_obj_as(
3277
+ type_=DatasetVersionPublic, # type: ignore
3278
+ object_=_response.json(),
3279
+ ),
3280
+ )
3281
+ return AsyncHttpResponse(response=_response, data=_data)
3282
+ if _response.status_code == 404:
3283
+ raise NotFoundError(
3284
+ headers=dict(_response.headers),
3285
+ body=typing.cast(
3286
+ typing.Optional[typing.Any],
3287
+ parse_obj_as(
3288
+ type_=typing.Optional[typing.Any], # type: ignore
3289
+ object_=_response.json(),
3290
+ ),
3291
+ ),
3292
+ )
3293
+ _response_json = _response.json()
3294
+ except JSONDecodeError:
3295
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3296
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3297
+
3298
+ async def update_dataset_version(
3299
+ self,
3300
+ version_hash: str,
3301
+ id: str,
3302
+ *,
3303
+ change_description: typing.Optional[str] = OMIT,
3304
+ tags_to_add: typing.Optional[typing.Sequence[str]] = OMIT,
3305
+ request_options: typing.Optional[RequestOptions] = None,
3306
+ ) -> AsyncHttpResponse[DatasetVersionPublic]:
3307
+ """
3308
+ Update a dataset version's change_description and/or add new tags
3309
+
3310
+ Parameters
3311
+ ----------
3312
+ version_hash : str
3313
+
3314
+ id : str
3315
+
3316
+ change_description : typing.Optional[str]
3317
+ Optional description of changes in this version
3318
+
3319
+ tags_to_add : typing.Optional[typing.Sequence[str]]
3320
+ Optional list of tags to add to this version
3321
+
3322
+ request_options : typing.Optional[RequestOptions]
3323
+ Request-specific configuration.
3324
+
3325
+ Returns
3326
+ -------
3327
+ AsyncHttpResponse[DatasetVersionPublic]
3328
+ Version updated successfully
3329
+ """
3330
+ _response = await self._client_wrapper.httpx_client.request(
3331
+ f"v1/private/datasets/{jsonable_encoder(id)}/versions/hash/{jsonable_encoder(version_hash)}",
3332
+ method="PATCH",
3333
+ json={
3334
+ "change_description": change_description,
3335
+ "tags_to_add": tags_to_add,
3336
+ },
3337
+ headers={
3338
+ "content-type": "application/json",
3339
+ },
3340
+ request_options=request_options,
3341
+ omit=OMIT,
3342
+ )
3343
+ try:
3344
+ if 200 <= _response.status_code < 300:
3345
+ _data = typing.cast(
3346
+ DatasetVersionPublic,
3347
+ parse_obj_as(
3348
+ type_=DatasetVersionPublic, # type: ignore
3349
+ object_=_response.json(),
3350
+ ),
3351
+ )
3352
+ return AsyncHttpResponse(response=_response, data=_data)
3353
+ if _response.status_code == 400:
3354
+ raise BadRequestError(
3355
+ headers=dict(_response.headers),
3356
+ body=typing.cast(
3357
+ typing.Optional[typing.Any],
3358
+ parse_obj_as(
3359
+ type_=typing.Optional[typing.Any], # type: ignore
3360
+ object_=_response.json(),
3361
+ ),
3362
+ ),
3363
+ )
3364
+ if _response.status_code == 404:
3365
+ raise NotFoundError(
3366
+ headers=dict(_response.headers),
3367
+ body=typing.cast(
3368
+ typing.Optional[typing.Any],
3369
+ parse_obj_as(
3370
+ type_=typing.Optional[typing.Any], # type: ignore
3371
+ object_=_response.json(),
3372
+ ),
3373
+ ),
3374
+ )
3375
+ if _response.status_code == 409:
3376
+ raise ConflictError(
3377
+ headers=dict(_response.headers),
3378
+ body=typing.cast(
3379
+ typing.Optional[typing.Any],
3380
+ parse_obj_as(
3381
+ type_=typing.Optional[typing.Any], # type: ignore
3382
+ object_=_response.json(),
3383
+ ),
3384
+ ),
3385
+ )
3386
+ _response_json = _response.json()
3387
+ except JSONDecodeError:
3388
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3389
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)