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
@@ -1,39 +1,31 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing
4
- from ..core.client_wrapper import SyncClientWrapper
5
3
  import datetime as dt
4
+ import typing
5
+
6
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
7
  from ..core.request_options import RequestOptions
7
- from ..core.jsonable_encoder import jsonable_encoder
8
- from json.decoder import JSONDecodeError
9
- from ..core.api_error import ApiError
8
+ from ..types.comment import Comment
9
+ from ..types.error_info import ErrorInfo
10
+ from ..types.error_info_write import ErrorInfoWrite
11
+ from ..types.feedback_score_batch_item import FeedbackScoreBatchItem
10
12
  from ..types.feedback_score_source import FeedbackScoreSource
11
- from .types.get_spans_by_project_request_type import GetSpansByProjectRequestType
13
+ from ..types.json_list_string import JsonListString
14
+ from ..types.json_list_string_write import JsonListStringWrite
15
+ from ..types.project_stats_public import ProjectStatsPublic
16
+ from ..types.span_filter_public import SpanFilterPublic
12
17
  from ..types.span_page_public import SpanPagePublic
13
- from ..core.pydantic_utilities import parse_obj_as
14
- from ..types.span_write_type import SpanWriteType
15
- from ..types.json_node_write import JsonNodeWrite
16
- from ..types.error_info_write import ErrorInfoWrite
17
- from ..core.serialization import convert_and_respect_annotation_metadata
18
- from ..types.span_write import SpanWrite
19
18
  from ..types.span_public import SpanPublic
20
- from ..errors.not_found_error import NotFoundError
21
- from ..errors.not_implemented_error import NotImplementedError
22
- from ..types.json_node import JsonNode
23
- from ..types.error_info import ErrorInfo
24
- from .types.find_feedback_score_names_1_request_type import (
25
- FindFeedbackScoreNames1RequestType,
26
- )
27
- from ..types.comment import Comment
19
+ from ..types.span_update import SpanUpdate
20
+ from ..types.span_update_type import SpanUpdateType
21
+ from ..types.span_write import SpanWrite
22
+ from ..types.span_write_type import SpanWriteType
23
+ from ..types.value_entry import ValueEntry
24
+ from .raw_client import AsyncRawSpansClient, RawSpansClient
25
+ from .types.find_feedback_score_names_1_request_type import FindFeedbackScoreNames1RequestType
28
26
  from .types.get_span_stats_request_type import GetSpanStatsRequestType
29
- from ..types.project_stats_public import ProjectStatsPublic
30
- from ..types.feedback_score_batch_item import FeedbackScoreBatchItem
31
- from .types.span_search_stream_request_public_type import (
32
- SpanSearchStreamRequestPublicType,
33
- )
34
- from ..types.span_filter_public import SpanFilterPublic
35
- from ..errors.bad_request_error import BadRequestError
36
- from ..core.client_wrapper import AsyncClientWrapper
27
+ from .types.get_spans_by_project_request_type import GetSpansByProjectRequestType
28
+ from .types.span_search_stream_request_public_type import SpanSearchStreamRequestPublicType
37
29
 
38
30
  # this is used as the default value for optional parameters
39
31
  OMIT = typing.cast(typing.Any, ...)
@@ -41,7 +33,18 @@ OMIT = typing.cast(typing.Any, ...)
41
33
 
42
34
  class SpansClient:
43
35
  def __init__(self, *, client_wrapper: SyncClientWrapper):
44
- self._client_wrapper = client_wrapper
36
+ self._raw_client = RawSpansClient(client_wrapper=client_wrapper)
37
+
38
+ @property
39
+ def with_raw_response(self) -> RawSpansClient:
40
+ """
41
+ Retrieves a raw implementation of this client that returns raw responses.
42
+
43
+ Returns
44
+ -------
45
+ RawSpansClient
46
+ """
47
+ return self._raw_client
45
48
 
46
49
  def add_span_comment(
47
50
  self,
@@ -84,37 +87,20 @@ class SpansClient:
84
87
  Examples
85
88
  --------
86
89
  from Opik import OpikApi
87
-
88
- client = OpikApi(
89
- api_key="YOUR_API_KEY",
90
- workspace_name="YOUR_WORKSPACE_NAME",
91
- )
92
- client.spans.add_span_comment(
93
- id_="id",
94
- text="text",
95
- )
96
- """
97
- _response = self._client_wrapper.httpx_client.request(
98
- f"v1/private/spans/{jsonable_encoder(id_)}/comments",
99
- method="POST",
100
- json={
101
- "id": id,
102
- "text": text,
103
- "created_at": created_at,
104
- "last_updated_at": last_updated_at,
105
- "created_by": created_by,
106
- "last_updated_by": last_updated_by,
107
- },
90
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
91
+ client.spans.add_span_comment(id_='id', text='text', )
92
+ """
93
+ _response = self._raw_client.add_span_comment(
94
+ id_,
95
+ text=text,
96
+ id=id,
97
+ created_at=created_at,
98
+ last_updated_at=last_updated_at,
99
+ created_by=created_by,
100
+ last_updated_by=last_updated_by,
108
101
  request_options=request_options,
109
- omit=OMIT,
110
102
  )
111
- try:
112
- if 200 <= _response.status_code < 300:
113
- return
114
- _response_json = _response.json()
115
- except JSONDecodeError:
116
- raise ApiError(status_code=_response.status_code, body=_response.text)
117
- raise ApiError(status_code=_response.status_code, body=_response_json)
103
+ return _response.data
118
104
 
119
105
  def add_span_feedback_score(
120
106
  self,
@@ -129,6 +115,7 @@ class SpansClient:
129
115
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
130
116
  created_by: typing.Optional[str] = OMIT,
131
117
  last_updated_by: typing.Optional[str] = OMIT,
118
+ value_by_author: typing.Optional[typing.Dict[str, ValueEntry]] = OMIT,
132
119
  request_options: typing.Optional[RequestOptions] = None,
133
120
  ) -> None:
134
121
  """
@@ -156,6 +143,8 @@ class SpansClient:
156
143
 
157
144
  last_updated_by : typing.Optional[str]
158
145
 
146
+ value_by_author : typing.Optional[typing.Dict[str, ValueEntry]]
147
+
159
148
  request_options : typing.Optional[RequestOptions]
160
149
  Request-specific configuration.
161
150
 
@@ -166,42 +155,92 @@ class SpansClient:
166
155
  Examples
167
156
  --------
168
157
  from Opik import OpikApi
169
-
170
- client = OpikApi(
171
- api_key="YOUR_API_KEY",
172
- workspace_name="YOUR_WORKSPACE_NAME",
173
- )
174
- client.spans.add_span_feedback_score(
175
- id="id",
176
- name="name",
177
- value=1.1,
178
- source="ui",
158
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
159
+ client.spans.add_span_feedback_score(id='id', name='name', value=1.1, source="ui", )
160
+ """
161
+ _response = self._raw_client.add_span_feedback_score(
162
+ id,
163
+ name=name,
164
+ value=value,
165
+ source=source,
166
+ category_name=category_name,
167
+ reason=reason,
168
+ created_at=created_at,
169
+ last_updated_at=last_updated_at,
170
+ created_by=created_by,
171
+ last_updated_by=last_updated_by,
172
+ value_by_author=value_by_author,
173
+ request_options=request_options,
179
174
  )
175
+ return _response.data
176
+
177
+ def create_spans(
178
+ self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
179
+ ) -> None:
180
180
  """
181
- _response = self._client_wrapper.httpx_client.request(
182
- f"v1/private/spans/{jsonable_encoder(id)}/feedback-scores",
183
- method="PUT",
184
- json={
185
- "name": name,
186
- "category_name": category_name,
187
- "value": value,
188
- "reason": reason,
189
- "source": source,
190
- "created_at": created_at,
191
- "last_updated_at": last_updated_at,
192
- "created_by": created_by,
193
- "last_updated_by": last_updated_by,
194
- },
195
- request_options=request_options,
196
- omit=OMIT,
181
+ Create spans
182
+
183
+ Parameters
184
+ ----------
185
+ spans : typing.Sequence[SpanWrite]
186
+
187
+ request_options : typing.Optional[RequestOptions]
188
+ Request-specific configuration.
189
+
190
+ Returns
191
+ -------
192
+ None
193
+
194
+ Examples
195
+ --------
196
+ from Opik import OpikApi
197
+ from Opik import SpanWrite
198
+ import datetime
199
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
200
+ client.spans.create_spans(spans=[SpanWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
201
+ """
202
+ _response = self._raw_client.create_spans(spans=spans, request_options=request_options)
203
+ return _response.data
204
+
205
+ def batch_update_spans(
206
+ self,
207
+ *,
208
+ ids: typing.Sequence[str],
209
+ update: SpanUpdate,
210
+ merge_tags: typing.Optional[bool] = OMIT,
211
+ request_options: typing.Optional[RequestOptions] = None,
212
+ ) -> None:
213
+ """
214
+ Update multiple spans
215
+
216
+ Parameters
217
+ ----------
218
+ ids : typing.Sequence[str]
219
+ List of span IDs to update (max 1000)
220
+
221
+ update : SpanUpdate
222
+
223
+ merge_tags : typing.Optional[bool]
224
+ If true, merge tags with existing tags instead of replacing them. Default: false
225
+
226
+ request_options : typing.Optional[RequestOptions]
227
+ Request-specific configuration.
228
+
229
+ Returns
230
+ -------
231
+ None
232
+
233
+ Examples
234
+ --------
235
+ from Opik import OpikApi
236
+ from Opik import SpanUpdate
237
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
238
+ client.spans.batch_update_spans(ids=['ids'], update=SpanUpdate(trace_id='trace_id', ), )
239
+ """
240
+ _response = self._raw_client.batch_update_spans(
241
+ ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
197
242
  )
198
- try:
199
- if 200 <= _response.status_code < 300:
200
- return
201
- _response_json = _response.json()
202
- except JSONDecodeError:
203
- raise ApiError(status_code=_response.status_code, body=_response.text)
204
- raise ApiError(status_code=_response.status_code, body=_response_json)
243
+ return _response.data
205
244
 
206
245
  def get_spans_by_project(
207
246
  self,
@@ -214,6 +253,11 @@ class SpansClient:
214
253
  type: typing.Optional[GetSpansByProjectRequestType] = None,
215
254
  filters: typing.Optional[str] = None,
216
255
  truncate: typing.Optional[bool] = None,
256
+ strip_attachments: typing.Optional[bool] = None,
257
+ sorting: typing.Optional[str] = None,
258
+ exclude: typing.Optional[str] = None,
259
+ from_time: typing.Optional[dt.datetime] = None,
260
+ to_time: typing.Optional[dt.datetime] = None,
217
261
  request_options: typing.Optional[RequestOptions] = None,
218
262
  ) -> SpanPagePublic:
219
263
  """
@@ -237,6 +281,16 @@ class SpansClient:
237
281
 
238
282
  truncate : typing.Optional[bool]
239
283
 
284
+ strip_attachments : typing.Optional[bool]
285
+
286
+ sorting : typing.Optional[str]
287
+
288
+ exclude : typing.Optional[str]
289
+
290
+ from_time : typing.Optional[dt.datetime]
291
+
292
+ to_time : typing.Optional[dt.datetime]
293
+
240
294
  request_options : typing.Optional[RequestOptions]
241
295
  Request-specific configuration.
242
296
 
@@ -248,61 +302,47 @@ class SpansClient:
248
302
  Examples
249
303
  --------
250
304
  from Opik import OpikApi
251
-
252
- client = OpikApi(
253
- api_key="YOUR_API_KEY",
254
- workspace_name="YOUR_WORKSPACE_NAME",
255
- )
305
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
256
306
  client.spans.get_spans_by_project()
257
307
  """
258
- _response = self._client_wrapper.httpx_client.request(
259
- "v1/private/spans",
260
- method="GET",
261
- params={
262
- "page": page,
263
- "size": size,
264
- "project_name": project_name,
265
- "project_id": project_id,
266
- "trace_id": trace_id,
267
- "type": type,
268
- "filters": filters,
269
- "truncate": truncate,
270
- },
308
+ _response = self._raw_client.get_spans_by_project(
309
+ page=page,
310
+ size=size,
311
+ project_name=project_name,
312
+ project_id=project_id,
313
+ trace_id=trace_id,
314
+ type=type,
315
+ filters=filters,
316
+ truncate=truncate,
317
+ strip_attachments=strip_attachments,
318
+ sorting=sorting,
319
+ exclude=exclude,
320
+ from_time=from_time,
321
+ to_time=to_time,
271
322
  request_options=request_options,
272
323
  )
273
- try:
274
- if 200 <= _response.status_code < 300:
275
- return typing.cast(
276
- SpanPagePublic,
277
- parse_obj_as(
278
- type_=SpanPagePublic, # type: ignore
279
- object_=_response.json(),
280
- ),
281
- )
282
- _response_json = _response.json()
283
- except JSONDecodeError:
284
- raise ApiError(status_code=_response.status_code, body=_response.text)
285
- raise ApiError(status_code=_response.status_code, body=_response_json)
324
+ return _response.data
286
325
 
287
326
  def create_span(
288
327
  self,
289
328
  *,
290
- trace_id: str,
291
- name: str,
292
- type: SpanWriteType,
293
329
  start_time: dt.datetime,
294
330
  id: typing.Optional[str] = OMIT,
295
331
  project_name: typing.Optional[str] = OMIT,
332
+ trace_id: typing.Optional[str] = OMIT,
296
333
  parent_span_id: typing.Optional[str] = OMIT,
334
+ name: typing.Optional[str] = OMIT,
335
+ type: typing.Optional[SpanWriteType] = OMIT,
297
336
  end_time: typing.Optional[dt.datetime] = OMIT,
298
- input: typing.Optional[JsonNodeWrite] = OMIT,
299
- output: typing.Optional[JsonNodeWrite] = OMIT,
300
- metadata: typing.Optional[JsonNodeWrite] = OMIT,
337
+ input: typing.Optional[JsonListStringWrite] = OMIT,
338
+ output: typing.Optional[JsonListStringWrite] = OMIT,
339
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
301
340
  model: typing.Optional[str] = OMIT,
302
341
  provider: typing.Optional[str] = OMIT,
303
342
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
304
343
  usage: typing.Optional[typing.Dict[str, int]] = OMIT,
305
344
  error_info: typing.Optional[ErrorInfoWrite] = OMIT,
345
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
306
346
  total_estimated_cost: typing.Optional[float] = OMIT,
307
347
  total_estimated_cost_version: typing.Optional[str] = OMIT,
308
348
  request_options: typing.Optional[RequestOptions] = None,
@@ -312,12 +352,6 @@ class SpansClient:
312
352
 
313
353
  Parameters
314
354
  ----------
315
- trace_id : str
316
-
317
- name : str
318
-
319
- type : SpanWriteType
320
-
321
355
  start_time : dt.datetime
322
356
 
323
357
  id : typing.Optional[str]
@@ -325,15 +359,21 @@ class SpansClient:
325
359
  project_name : typing.Optional[str]
326
360
  If null, the default project is used
327
361
 
362
+ trace_id : typing.Optional[str]
363
+
328
364
  parent_span_id : typing.Optional[str]
329
365
 
366
+ name : typing.Optional[str]
367
+
368
+ type : typing.Optional[SpanWriteType]
369
+
330
370
  end_time : typing.Optional[dt.datetime]
331
371
 
332
- input : typing.Optional[JsonNodeWrite]
372
+ input : typing.Optional[JsonListStringWrite]
333
373
 
334
- output : typing.Optional[JsonNodeWrite]
374
+ output : typing.Optional[JsonListStringWrite]
335
375
 
336
- metadata : typing.Optional[JsonNodeWrite]
376
+ metadata : typing.Optional[JsonListStringWrite]
337
377
 
338
378
  model : typing.Optional[str]
339
379
 
@@ -345,6 +385,8 @@ class SpansClient:
345
385
 
346
386
  error_info : typing.Optional[ErrorInfoWrite]
347
387
 
388
+ last_updated_at : typing.Optional[dt.datetime]
389
+
348
390
  total_estimated_cost : typing.Optional[float]
349
391
 
350
392
  total_estimated_cost_version : typing.Optional[str]
@@ -358,128 +400,41 @@ class SpansClient:
358
400
 
359
401
  Examples
360
402
  --------
361
- import datetime
362
-
363
403
  from Opik import OpikApi
364
-
365
- client = OpikApi(
366
- api_key="YOUR_API_KEY",
367
- workspace_name="YOUR_WORKSPACE_NAME",
368
- )
369
- client.spans.create_span(
370
- trace_id="trace_id",
371
- name="name",
372
- type="general",
373
- start_time=datetime.datetime.fromisoformat(
374
- "2024-01-15 09:30:00+00:00",
375
- ),
376
- )
377
- """
378
- _response = self._client_wrapper.httpx_client.request(
379
- "v1/private/spans",
380
- method="POST",
381
- json={
382
- "id": id,
383
- "project_name": project_name,
384
- "trace_id": trace_id,
385
- "parent_span_id": parent_span_id,
386
- "name": name,
387
- "type": type,
388
- "start_time": start_time,
389
- "end_time": end_time,
390
- "input": input,
391
- "output": output,
392
- "metadata": metadata,
393
- "model": model,
394
- "provider": provider,
395
- "tags": tags,
396
- "usage": usage,
397
- "error_info": convert_and_respect_annotation_metadata(
398
- object_=error_info, annotation=ErrorInfoWrite, direction="write"
399
- ),
400
- "total_estimated_cost": total_estimated_cost,
401
- "total_estimated_cost_version": total_estimated_cost_version,
402
- },
404
+ import datetime
405
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
406
+ client.spans.create_span(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )
407
+ """
408
+ _response = self._raw_client.create_span(
409
+ start_time=start_time,
410
+ id=id,
411
+ project_name=project_name,
412
+ trace_id=trace_id,
413
+ parent_span_id=parent_span_id,
414
+ name=name,
415
+ type=type,
416
+ end_time=end_time,
417
+ input=input,
418
+ output=output,
419
+ metadata=metadata,
420
+ model=model,
421
+ provider=provider,
422
+ tags=tags,
423
+ usage=usage,
424
+ error_info=error_info,
425
+ last_updated_at=last_updated_at,
426
+ total_estimated_cost=total_estimated_cost,
427
+ total_estimated_cost_version=total_estimated_cost_version,
403
428
  request_options=request_options,
404
- omit=OMIT,
405
429
  )
406
- try:
407
- if 200 <= _response.status_code < 300:
408
- return
409
- _response_json = _response.json()
410
- except JSONDecodeError:
411
- raise ApiError(status_code=_response.status_code, body=_response.text)
412
- raise ApiError(status_code=_response.status_code, body=_response_json)
430
+ return _response.data
413
431
 
414
- def create_spans(
432
+ def get_span_by_id(
415
433
  self,
434
+ id: str,
416
435
  *,
417
- spans: typing.Sequence[SpanWrite],
436
+ strip_attachments: typing.Optional[bool] = None,
418
437
  request_options: typing.Optional[RequestOptions] = None,
419
- ) -> None:
420
- """
421
- Create spans
422
-
423
- Parameters
424
- ----------
425
- spans : typing.Sequence[SpanWrite]
426
-
427
- request_options : typing.Optional[RequestOptions]
428
- Request-specific configuration.
429
-
430
- Returns
431
- -------
432
- None
433
-
434
- Examples
435
- --------
436
- import datetime
437
-
438
- from Opik import OpikApi, SpanWrite
439
-
440
- client = OpikApi(
441
- api_key="YOUR_API_KEY",
442
- workspace_name="YOUR_WORKSPACE_NAME",
443
- )
444
- client.spans.create_spans(
445
- spans=[
446
- SpanWrite(
447
- trace_id="trace_id",
448
- name="name",
449
- type="general",
450
- start_time=datetime.datetime.fromisoformat(
451
- "2024-01-15 09:30:00+00:00",
452
- ),
453
- )
454
- ],
455
- )
456
- """
457
- _response = self._client_wrapper.httpx_client.request(
458
- "v1/private/spans/batch",
459
- method="POST",
460
- json={
461
- "spans": convert_and_respect_annotation_metadata(
462
- object_=spans,
463
- annotation=typing.Sequence[SpanWrite],
464
- direction="write",
465
- ),
466
- },
467
- headers={
468
- "content-type": "application/json",
469
- },
470
- request_options=request_options,
471
- omit=OMIT,
472
- )
473
- try:
474
- if 200 <= _response.status_code < 300:
475
- return
476
- _response_json = _response.json()
477
- except JSONDecodeError:
478
- raise ApiError(status_code=_response.status_code, body=_response.text)
479
- raise ApiError(status_code=_response.status_code, body=_response_json)
480
-
481
- def get_span_by_id(
482
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
483
438
  ) -> SpanPublic:
484
439
  """
485
440
  Get span by id
@@ -488,6 +443,8 @@ class SpansClient:
488
443
  ----------
489
444
  id : str
490
445
 
446
+ strip_attachments : typing.Optional[bool]
447
+
491
448
  request_options : typing.Optional[RequestOptions]
492
449
  Request-specific configuration.
493
450
 
@@ -499,47 +456,15 @@ class SpansClient:
499
456
  Examples
500
457
  --------
501
458
  from Opik import OpikApi
502
-
503
- client = OpikApi(
504
- api_key="YOUR_API_KEY",
505
- workspace_name="YOUR_WORKSPACE_NAME",
506
- )
507
- client.spans.get_span_by_id(
508
- id="id",
509
- )
459
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
460
+ client.spans.get_span_by_id(id='id', )
510
461
  """
511
- _response = self._client_wrapper.httpx_client.request(
512
- f"v1/private/spans/{jsonable_encoder(id)}",
513
- method="GET",
514
- request_options=request_options,
462
+ _response = self._raw_client.get_span_by_id(
463
+ id, strip_attachments=strip_attachments, request_options=request_options
515
464
  )
516
- try:
517
- if 200 <= _response.status_code < 300:
518
- return typing.cast(
519
- SpanPublic,
520
- parse_obj_as(
521
- type_=SpanPublic, # type: ignore
522
- object_=_response.json(),
523
- ),
524
- )
525
- if _response.status_code == 404:
526
- raise NotFoundError(
527
- typing.cast(
528
- typing.Optional[typing.Any],
529
- parse_obj_as(
530
- type_=typing.Optional[typing.Any], # type: ignore
531
- object_=_response.json(),
532
- ),
533
- )
534
- )
535
- _response_json = _response.json()
536
- except JSONDecodeError:
537
- raise ApiError(status_code=_response.status_code, body=_response.text)
538
- raise ApiError(status_code=_response.status_code, body=_response_json)
539
-
540
- def delete_span_by_id(
541
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
542
- ) -> None:
465
+ return _response.data
466
+
467
+ def delete_span_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
543
468
  """
544
469
  Delete span by id
545
470
 
@@ -557,37 +482,11 @@ class SpansClient:
557
482
  Examples
558
483
  --------
559
484
  from Opik import OpikApi
560
-
561
- client = OpikApi(
562
- api_key="YOUR_API_KEY",
563
- workspace_name="YOUR_WORKSPACE_NAME",
564
- )
565
- client.spans.delete_span_by_id(
566
- id="id",
567
- )
485
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
486
+ client.spans.delete_span_by_id(id='id', )
568
487
  """
569
- _response = self._client_wrapper.httpx_client.request(
570
- f"v1/private/spans/{jsonable_encoder(id)}",
571
- method="DELETE",
572
- request_options=request_options,
573
- )
574
- try:
575
- if 200 <= _response.status_code < 300:
576
- return
577
- if _response.status_code == 501:
578
- raise NotImplementedError(
579
- typing.cast(
580
- typing.Optional[typing.Any],
581
- parse_obj_as(
582
- type_=typing.Optional[typing.Any], # type: ignore
583
- object_=_response.json(),
584
- ),
585
- )
586
- )
587
- _response_json = _response.json()
588
- except JSONDecodeError:
589
- raise ApiError(status_code=_response.status_code, body=_response.text)
590
- raise ApiError(status_code=_response.status_code, body=_response_json)
488
+ _response = self._raw_client.delete_span_by_id(id, request_options=request_options)
489
+ return _response.data
591
490
 
592
491
  def update_span(
593
492
  self,
@@ -597,10 +496,12 @@ class SpansClient:
597
496
  project_name: typing.Optional[str] = OMIT,
598
497
  project_id: typing.Optional[str] = OMIT,
599
498
  parent_span_id: typing.Optional[str] = OMIT,
499
+ name: typing.Optional[str] = OMIT,
500
+ type: typing.Optional[SpanUpdateType] = OMIT,
600
501
  end_time: typing.Optional[dt.datetime] = OMIT,
601
- input: typing.Optional[JsonNode] = OMIT,
602
- output: typing.Optional[JsonNode] = OMIT,
603
- metadata: typing.Optional[JsonNode] = OMIT,
502
+ input: typing.Optional[JsonListString] = OMIT,
503
+ output: typing.Optional[JsonListString] = OMIT,
504
+ metadata: typing.Optional[JsonListString] = OMIT,
604
505
  model: typing.Optional[str] = OMIT,
605
506
  provider: typing.Optional[str] = OMIT,
606
507
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
@@ -626,13 +527,17 @@ class SpansClient:
626
527
 
627
528
  parent_span_id : typing.Optional[str]
628
529
 
530
+ name : typing.Optional[str]
531
+
532
+ type : typing.Optional[SpanUpdateType]
533
+
629
534
  end_time : typing.Optional[dt.datetime]
630
535
 
631
- input : typing.Optional[JsonNode]
536
+ input : typing.Optional[JsonListString]
632
537
 
633
- output : typing.Optional[JsonNode]
538
+ output : typing.Optional[JsonListString]
634
539
 
635
- metadata : typing.Optional[JsonNode]
540
+ metadata : typing.Optional[JsonListString]
636
541
 
637
542
  model : typing.Optional[str]
638
543
 
@@ -656,66 +561,33 @@ class SpansClient:
656
561
  Examples
657
562
  --------
658
563
  from Opik import OpikApi
659
-
660
- client = OpikApi(
661
- api_key="YOUR_API_KEY",
662
- workspace_name="YOUR_WORKSPACE_NAME",
663
- )
664
- client.spans.update_span(
665
- id="id",
666
- trace_id="trace_id",
667
- )
668
- """
669
- _response = self._client_wrapper.httpx_client.request(
670
- f"v1/private/spans/{jsonable_encoder(id)}",
671
- method="PATCH",
672
- json={
673
- "project_name": project_name,
674
- "project_id": project_id,
675
- "trace_id": trace_id,
676
- "parent_span_id": parent_span_id,
677
- "end_time": end_time,
678
- "input": input,
679
- "output": output,
680
- "metadata": metadata,
681
- "model": model,
682
- "provider": provider,
683
- "tags": tags,
684
- "usage": usage,
685
- "total_estimated_cost": total_estimated_cost,
686
- "error_info": convert_and_respect_annotation_metadata(
687
- object_=error_info, annotation=ErrorInfo, direction="write"
688
- ),
689
- },
690
- headers={
691
- "content-type": "application/json",
692
- },
564
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
565
+ client.spans.update_span(id='id', trace_id='trace_id', )
566
+ """
567
+ _response = self._raw_client.update_span(
568
+ id,
569
+ trace_id=trace_id,
570
+ project_name=project_name,
571
+ project_id=project_id,
572
+ parent_span_id=parent_span_id,
573
+ name=name,
574
+ type=type,
575
+ end_time=end_time,
576
+ input=input,
577
+ output=output,
578
+ metadata=metadata,
579
+ model=model,
580
+ provider=provider,
581
+ tags=tags,
582
+ usage=usage,
583
+ total_estimated_cost=total_estimated_cost,
584
+ error_info=error_info,
693
585
  request_options=request_options,
694
- omit=OMIT,
695
586
  )
696
- try:
697
- if 200 <= _response.status_code < 300:
698
- return
699
- if _response.status_code == 404:
700
- raise NotFoundError(
701
- typing.cast(
702
- typing.Optional[typing.Any],
703
- parse_obj_as(
704
- type_=typing.Optional[typing.Any], # type: ignore
705
- object_=_response.json(),
706
- ),
707
- )
708
- )
709
- _response_json = _response.json()
710
- except JSONDecodeError:
711
- raise ApiError(status_code=_response.status_code, body=_response.text)
712
- raise ApiError(status_code=_response.status_code, body=_response_json)
587
+ return _response.data
713
588
 
714
589
  def delete_span_comments(
715
- self,
716
- *,
717
- ids: typing.Sequence[str],
718
- request_options: typing.Optional[RequestOptions] = None,
590
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
719
591
  ) -> None:
720
592
  """
721
593
  Delete span comments
@@ -734,37 +606,18 @@ class SpansClient:
734
606
  Examples
735
607
  --------
736
608
  from Opik import OpikApi
737
-
738
- client = OpikApi(
739
- api_key="YOUR_API_KEY",
740
- workspace_name="YOUR_WORKSPACE_NAME",
741
- )
742
- client.spans.delete_span_comments(
743
- ids=["ids"],
744
- )
609
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
610
+ client.spans.delete_span_comments(ids=['ids'], )
745
611
  """
746
- _response = self._client_wrapper.httpx_client.request(
747
- "v1/private/spans/comments/delete",
748
- method="POST",
749
- json={
750
- "ids": ids,
751
- },
752
- request_options=request_options,
753
- omit=OMIT,
754
- )
755
- try:
756
- if 200 <= _response.status_code < 300:
757
- return
758
- _response_json = _response.json()
759
- except JSONDecodeError:
760
- raise ApiError(status_code=_response.status_code, body=_response.text)
761
- raise ApiError(status_code=_response.status_code, body=_response_json)
612
+ _response = self._raw_client.delete_span_comments(ids=ids, request_options=request_options)
613
+ return _response.data
762
614
 
763
615
  def delete_span_feedback_score(
764
616
  self,
765
617
  id: str,
766
618
  *,
767
619
  name: str,
620
+ author: typing.Optional[str] = OMIT,
768
621
  request_options: typing.Optional[RequestOptions] = None,
769
622
  ) -> None:
770
623
  """
@@ -776,6 +629,8 @@ class SpansClient:
776
629
 
777
630
  name : str
778
631
 
632
+ author : typing.Optional[str]
633
+
779
634
  request_options : typing.Optional[RequestOptions]
780
635
  Request-specific configuration.
781
636
 
@@ -786,32 +641,13 @@ class SpansClient:
786
641
  Examples
787
642
  --------
788
643
  from Opik import OpikApi
789
-
790
- client = OpikApi(
791
- api_key="YOUR_API_KEY",
792
- workspace_name="YOUR_WORKSPACE_NAME",
793
- )
794
- client.spans.delete_span_feedback_score(
795
- id="id",
796
- name="name",
797
- )
644
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
645
+ client.spans.delete_span_feedback_score(id='id', name='name', )
798
646
  """
799
- _response = self._client_wrapper.httpx_client.request(
800
- f"v1/private/spans/{jsonable_encoder(id)}/feedback-scores/delete",
801
- method="POST",
802
- json={
803
- "name": name,
804
- },
805
- request_options=request_options,
806
- omit=OMIT,
647
+ _response = self._raw_client.delete_span_feedback_score(
648
+ id, name=name, author=author, request_options=request_options
807
649
  )
808
- try:
809
- if 200 <= _response.status_code < 300:
810
- return
811
- _response_json = _response.json()
812
- except JSONDecodeError:
813
- raise ApiError(status_code=_response.status_code, body=_response.text)
814
- raise ApiError(status_code=_response.status_code, body=_response_json)
650
+ return _response.data
815
651
 
816
652
  def find_feedback_score_names_1(
817
653
  self,
@@ -840,42 +676,16 @@ class SpansClient:
840
676
  Examples
841
677
  --------
842
678
  from Opik import OpikApi
843
-
844
- client = OpikApi(
845
- api_key="YOUR_API_KEY",
846
- workspace_name="YOUR_WORKSPACE_NAME",
847
- )
679
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
848
680
  client.spans.find_feedback_score_names_1()
849
681
  """
850
- _response = self._client_wrapper.httpx_client.request(
851
- "v1/private/spans/feedback-scores/names",
852
- method="GET",
853
- params={
854
- "project_id": project_id,
855
- "type": type,
856
- },
857
- request_options=request_options,
682
+ _response = self._raw_client.find_feedback_score_names_1(
683
+ project_id=project_id, type=type, request_options=request_options
858
684
  )
859
- try:
860
- if 200 <= _response.status_code < 300:
861
- return typing.cast(
862
- typing.List[str],
863
- parse_obj_as(
864
- type_=typing.List[str], # type: ignore
865
- object_=_response.json(),
866
- ),
867
- )
868
- _response_json = _response.json()
869
- except JSONDecodeError:
870
- raise ApiError(status_code=_response.status_code, body=_response.text)
871
- raise ApiError(status_code=_response.status_code, body=_response_json)
685
+ return _response.data
872
686
 
873
687
  def get_span_comment(
874
- self,
875
- comment_id: str,
876
- span_id: str,
877
- *,
878
- request_options: typing.Optional[RequestOptions] = None,
688
+ self, comment_id: str, span_id: str, *, request_options: typing.Optional[RequestOptions] = None
879
689
  ) -> Comment:
880
690
  """
881
691
  Get span comment
@@ -897,44 +707,11 @@ class SpansClient:
897
707
  Examples
898
708
  --------
899
709
  from Opik import OpikApi
900
-
901
- client = OpikApi(
902
- api_key="YOUR_API_KEY",
903
- workspace_name="YOUR_WORKSPACE_NAME",
904
- )
905
- client.spans.get_span_comment(
906
- comment_id="commentId",
907
- span_id="spanId",
908
- )
710
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
711
+ client.spans.get_span_comment(comment_id='commentId', span_id='spanId', )
909
712
  """
910
- _response = self._client_wrapper.httpx_client.request(
911
- f"v1/private/spans/{jsonable_encoder(span_id)}/comments/{jsonable_encoder(comment_id)}",
912
- method="GET",
913
- request_options=request_options,
914
- )
915
- try:
916
- if 200 <= _response.status_code < 300:
917
- return typing.cast(
918
- Comment,
919
- parse_obj_as(
920
- type_=Comment, # type: ignore
921
- object_=_response.json(),
922
- ),
923
- )
924
- if _response.status_code == 404:
925
- raise NotFoundError(
926
- typing.cast(
927
- typing.Optional[typing.Any],
928
- parse_obj_as(
929
- type_=typing.Optional[typing.Any], # type: ignore
930
- object_=_response.json(),
931
- ),
932
- )
933
- )
934
- _response_json = _response.json()
935
- except JSONDecodeError:
936
- raise ApiError(status_code=_response.status_code, body=_response.text)
937
- raise ApiError(status_code=_response.status_code, body=_response_json)
713
+ _response = self._raw_client.get_span_comment(comment_id, span_id, request_options=request_options)
714
+ return _response.data
938
715
 
939
716
  def get_span_stats(
940
717
  self,
@@ -944,6 +721,8 @@ class SpansClient:
944
721
  trace_id: typing.Optional[str] = None,
945
722
  type: typing.Optional[GetSpanStatsRequestType] = None,
946
723
  filters: typing.Optional[str] = None,
724
+ from_time: typing.Optional[dt.datetime] = None,
725
+ to_time: typing.Optional[dt.datetime] = None,
947
726
  request_options: typing.Optional[RequestOptions] = None,
948
727
  ) -> ProjectStatsPublic:
949
728
  """
@@ -961,6 +740,10 @@ class SpansClient:
961
740
 
962
741
  filters : typing.Optional[str]
963
742
 
743
+ from_time : typing.Optional[dt.datetime]
744
+
745
+ to_time : typing.Optional[dt.datetime]
746
+
964
747
  request_options : typing.Optional[RequestOptions]
965
748
  Request-specific configuration.
966
749
 
@@ -972,38 +755,20 @@ class SpansClient:
972
755
  Examples
973
756
  --------
974
757
  from Opik import OpikApi
975
-
976
- client = OpikApi(
977
- api_key="YOUR_API_KEY",
978
- workspace_name="YOUR_WORKSPACE_NAME",
979
- )
758
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
980
759
  client.spans.get_span_stats()
981
760
  """
982
- _response = self._client_wrapper.httpx_client.request(
983
- "v1/private/spans/stats",
984
- method="GET",
985
- params={
986
- "project_id": project_id,
987
- "project_name": project_name,
988
- "trace_id": trace_id,
989
- "type": type,
990
- "filters": filters,
991
- },
761
+ _response = self._raw_client.get_span_stats(
762
+ project_id=project_id,
763
+ project_name=project_name,
764
+ trace_id=trace_id,
765
+ type=type,
766
+ filters=filters,
767
+ from_time=from_time,
768
+ to_time=to_time,
992
769
  request_options=request_options,
993
770
  )
994
- try:
995
- if 200 <= _response.status_code < 300:
996
- return typing.cast(
997
- ProjectStatsPublic,
998
- parse_obj_as(
999
- type_=ProjectStatsPublic, # type: ignore
1000
- object_=_response.json(),
1001
- ),
1002
- )
1003
- _response_json = _response.json()
1004
- except JSONDecodeError:
1005
- raise ApiError(status_code=_response.status_code, body=_response.text)
1006
- raise ApiError(status_code=_response.status_code, body=_response_json)
771
+ return _response.data
1007
772
 
1008
773
  def score_batch_of_spans(
1009
774
  self,
@@ -1027,43 +792,13 @@ class SpansClient:
1027
792
 
1028
793
  Examples
1029
794
  --------
1030
- from Opik import FeedbackScoreBatchItem, OpikApi
1031
-
1032
- client = OpikApi(
1033
- api_key="YOUR_API_KEY",
1034
- workspace_name="YOUR_WORKSPACE_NAME",
1035
- )
1036
- client.spans.score_batch_of_spans(
1037
- scores=[
1038
- FeedbackScoreBatchItem(
1039
- id="id",
1040
- name="name",
1041
- value=1.1,
1042
- source="ui",
1043
- )
1044
- ],
1045
- )
795
+ from Opik import OpikApi
796
+ from Opik import FeedbackScoreBatchItem
797
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
798
+ client.spans.score_batch_of_spans(scores=[FeedbackScoreBatchItem(name='name', value=1.1, source="ui", id='id', )], )
1046
799
  """
1047
- _response = self._client_wrapper.httpx_client.request(
1048
- "v1/private/spans/feedback-scores",
1049
- method="PUT",
1050
- json={
1051
- "scores": convert_and_respect_annotation_metadata(
1052
- object_=scores,
1053
- annotation=typing.Sequence[FeedbackScoreBatchItem],
1054
- direction="write",
1055
- ),
1056
- },
1057
- request_options=request_options,
1058
- omit=OMIT,
1059
- )
1060
- try:
1061
- if 200 <= _response.status_code < 300:
1062
- return
1063
- _response_json = _response.json()
1064
- except JSONDecodeError:
1065
- raise ApiError(status_code=_response.status_code, body=_response.text)
1066
- raise ApiError(status_code=_response.status_code, body=_response_json)
800
+ _response = self._raw_client.score_batch_of_spans(scores=scores, request_options=request_options)
801
+ return _response.data
1067
802
 
1068
803
  def search_spans(
1069
804
  self,
@@ -1076,6 +811,8 @@ class SpansClient:
1076
811
  limit: typing.Optional[int] = OMIT,
1077
812
  last_retrieved_id: typing.Optional[str] = OMIT,
1078
813
  truncate: typing.Optional[bool] = OMIT,
814
+ from_time: typing.Optional[dt.datetime] = OMIT,
815
+ to_time: typing.Optional[dt.datetime] = OMIT,
1079
816
  request_options: typing.Optional[RequestOptions] = None,
1080
817
  ) -> typing.Iterator[bytes]:
1081
818
  """
@@ -1094,68 +831,41 @@ class SpansClient:
1094
831
  filters : typing.Optional[typing.Sequence[SpanFilterPublic]]
1095
832
 
1096
833
  limit : typing.Optional[int]
834
+ Max number of spans to be streamed
1097
835
 
1098
836
  last_retrieved_id : typing.Optional[str]
1099
837
 
1100
838
  truncate : typing.Optional[bool]
1101
839
  Truncate image included in either input, output or metadata
1102
840
 
841
+ from_time : typing.Optional[dt.datetime]
842
+ Filter spans created from this time (ISO-8601 format).
843
+
844
+ to_time : typing.Optional[dt.datetime]
845
+ Filter spans created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
846
+
1103
847
  request_options : typing.Optional[RequestOptions]
1104
848
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
1105
849
 
1106
- Yields
1107
- ------
850
+ Returns
851
+ -------
1108
852
  typing.Iterator[bytes]
1109
853
  Spans stream or error during process
1110
854
  """
1111
- with self._client_wrapper.httpx_client.stream(
1112
- "v1/private/spans/search",
1113
- method="POST",
1114
- json={
1115
- "trace_id": trace_id,
1116
- "project_name": project_name,
1117
- "project_id": project_id,
1118
- "type": type,
1119
- "filters": convert_and_respect_annotation_metadata(
1120
- object_=filters,
1121
- annotation=typing.Sequence[SpanFilterPublic],
1122
- direction="write",
1123
- ),
1124
- "limit": limit,
1125
- "last_retrieved_id": last_retrieved_id,
1126
- "truncate": truncate,
1127
- },
1128
- headers={
1129
- "content-type": "application/json",
1130
- },
855
+ with self._raw_client.search_spans(
856
+ trace_id=trace_id,
857
+ project_name=project_name,
858
+ project_id=project_id,
859
+ type=type,
860
+ filters=filters,
861
+ limit=limit,
862
+ last_retrieved_id=last_retrieved_id,
863
+ truncate=truncate,
864
+ from_time=from_time,
865
+ to_time=to_time,
1131
866
  request_options=request_options,
1132
- omit=OMIT,
1133
- ) as _response:
1134
- try:
1135
- if 200 <= _response.status_code < 300:
1136
- _chunk_size = (
1137
- request_options.get("chunk_size", None)
1138
- if request_options is not None
1139
- else None
1140
- )
1141
- for _chunk in _response.iter_bytes(chunk_size=_chunk_size):
1142
- yield _chunk
1143
- return
1144
- _response.read()
1145
- if _response.status_code == 400:
1146
- raise BadRequestError(
1147
- typing.cast(
1148
- typing.Optional[typing.Any],
1149
- parse_obj_as(
1150
- type_=typing.Optional[typing.Any], # type: ignore
1151
- object_=_response.json(),
1152
- ),
1153
- )
1154
- )
1155
- _response_json = _response.json()
1156
- except JSONDecodeError:
1157
- raise ApiError(status_code=_response.status_code, body=_response.text)
1158
- raise ApiError(status_code=_response.status_code, body=_response_json)
867
+ ) as r:
868
+ yield from r.data
1159
869
 
1160
870
  def update_span_comment(
1161
871
  self,
@@ -1198,52 +908,36 @@ class SpansClient:
1198
908
  Examples
1199
909
  --------
1200
910
  from Opik import OpikApi
1201
-
1202
- client = OpikApi(
1203
- api_key="YOUR_API_KEY",
1204
- workspace_name="YOUR_WORKSPACE_NAME",
1205
- )
1206
- client.spans.update_span_comment(
1207
- comment_id="commentId",
1208
- text="text",
1209
- )
1210
- """
1211
- _response = self._client_wrapper.httpx_client.request(
1212
- f"v1/private/spans/comments/{jsonable_encoder(comment_id)}",
1213
- method="PATCH",
1214
- json={
1215
- "id": id,
1216
- "text": text,
1217
- "created_at": created_at,
1218
- "last_updated_at": last_updated_at,
1219
- "created_by": created_by,
1220
- "last_updated_by": last_updated_by,
1221
- },
911
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
912
+ client.spans.update_span_comment(comment_id='commentId', text='text', )
913
+ """
914
+ _response = self._raw_client.update_span_comment(
915
+ comment_id,
916
+ text=text,
917
+ id=id,
918
+ created_at=created_at,
919
+ last_updated_at=last_updated_at,
920
+ created_by=created_by,
921
+ last_updated_by=last_updated_by,
1222
922
  request_options=request_options,
1223
- omit=OMIT,
1224
923
  )
1225
- try:
1226
- if 200 <= _response.status_code < 300:
1227
- return
1228
- if _response.status_code == 404:
1229
- raise NotFoundError(
1230
- typing.cast(
1231
- typing.Optional[typing.Any],
1232
- parse_obj_as(
1233
- type_=typing.Optional[typing.Any], # type: ignore
1234
- object_=_response.json(),
1235
- ),
1236
- )
1237
- )
1238
- _response_json = _response.json()
1239
- except JSONDecodeError:
1240
- raise ApiError(status_code=_response.status_code, body=_response.text)
1241
- raise ApiError(status_code=_response.status_code, body=_response_json)
924
+ return _response.data
1242
925
 
1243
926
 
1244
927
  class AsyncSpansClient:
1245
928
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
1246
- self._client_wrapper = client_wrapper
929
+ self._raw_client = AsyncRawSpansClient(client_wrapper=client_wrapper)
930
+
931
+ @property
932
+ def with_raw_response(self) -> AsyncRawSpansClient:
933
+ """
934
+ Retrieves a raw implementation of this client that returns raw responses.
935
+
936
+ Returns
937
+ -------
938
+ AsyncRawSpansClient
939
+ """
940
+ return self._raw_client
1247
941
 
1248
942
  async def add_span_comment(
1249
943
  self,
@@ -1285,46 +979,24 @@ class AsyncSpansClient:
1285
979
 
1286
980
  Examples
1287
981
  --------
1288
- import asyncio
1289
-
1290
982
  from Opik import AsyncOpikApi
1291
-
1292
- client = AsyncOpikApi(
1293
- api_key="YOUR_API_KEY",
1294
- workspace_name="YOUR_WORKSPACE_NAME",
1295
- )
1296
-
1297
-
983
+ import asyncio
984
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1298
985
  async def main() -> None:
1299
- await client.spans.add_span_comment(
1300
- id_="id",
1301
- text="text",
1302
- )
1303
-
1304
-
986
+ await client.spans.add_span_comment(id_='id', text='text', )
1305
987
  asyncio.run(main())
1306
988
  """
1307
- _response = await self._client_wrapper.httpx_client.request(
1308
- f"v1/private/spans/{jsonable_encoder(id_)}/comments",
1309
- method="POST",
1310
- json={
1311
- "id": id,
1312
- "text": text,
1313
- "created_at": created_at,
1314
- "last_updated_at": last_updated_at,
1315
- "created_by": created_by,
1316
- "last_updated_by": last_updated_by,
1317
- },
989
+ _response = await self._raw_client.add_span_comment(
990
+ id_,
991
+ text=text,
992
+ id=id,
993
+ created_at=created_at,
994
+ last_updated_at=last_updated_at,
995
+ created_by=created_by,
996
+ last_updated_by=last_updated_by,
1318
997
  request_options=request_options,
1319
- omit=OMIT,
1320
998
  )
1321
- try:
1322
- if 200 <= _response.status_code < 300:
1323
- return
1324
- _response_json = _response.json()
1325
- except JSONDecodeError:
1326
- raise ApiError(status_code=_response.status_code, body=_response.text)
1327
- raise ApiError(status_code=_response.status_code, body=_response_json)
999
+ return _response.data
1328
1000
 
1329
1001
  async def add_span_feedback_score(
1330
1002
  self,
@@ -1339,6 +1011,7 @@ class AsyncSpansClient:
1339
1011
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
1340
1012
  created_by: typing.Optional[str] = OMIT,
1341
1013
  last_updated_by: typing.Optional[str] = OMIT,
1014
+ value_by_author: typing.Optional[typing.Dict[str, ValueEntry]] = OMIT,
1342
1015
  request_options: typing.Optional[RequestOptions] = None,
1343
1016
  ) -> None:
1344
1017
  """
@@ -1366,6 +1039,8 @@ class AsyncSpansClient:
1366
1039
 
1367
1040
  last_updated_by : typing.Optional[str]
1368
1041
 
1042
+ value_by_author : typing.Optional[typing.Dict[str, ValueEntry]]
1043
+
1369
1044
  request_options : typing.Optional[RequestOptions]
1370
1045
  Request-specific configuration.
1371
1046
 
@@ -1375,51 +1050,102 @@ class AsyncSpansClient:
1375
1050
 
1376
1051
  Examples
1377
1052
  --------
1053
+ from Opik import AsyncOpikApi
1378
1054
  import asyncio
1055
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1056
+ async def main() -> None:
1057
+ await client.spans.add_span_feedback_score(id='id', name='name', value=1.1, source="ui", )
1058
+ asyncio.run(main())
1059
+ """
1060
+ _response = await self._raw_client.add_span_feedback_score(
1061
+ id,
1062
+ name=name,
1063
+ value=value,
1064
+ source=source,
1065
+ category_name=category_name,
1066
+ reason=reason,
1067
+ created_at=created_at,
1068
+ last_updated_at=last_updated_at,
1069
+ created_by=created_by,
1070
+ last_updated_by=last_updated_by,
1071
+ value_by_author=value_by_author,
1072
+ request_options=request_options,
1073
+ )
1074
+ return _response.data
1379
1075
 
1380
- from Opik import AsyncOpikApi
1076
+ async def create_spans(
1077
+ self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
1078
+ ) -> None:
1079
+ """
1080
+ Create spans
1381
1081
 
1382
- client = AsyncOpikApi(
1383
- api_key="YOUR_API_KEY",
1384
- workspace_name="YOUR_WORKSPACE_NAME",
1385
- )
1082
+ Parameters
1083
+ ----------
1084
+ spans : typing.Sequence[SpanWrite]
1386
1085
 
1086
+ request_options : typing.Optional[RequestOptions]
1087
+ Request-specific configuration.
1088
+
1089
+ Returns
1090
+ -------
1091
+ None
1387
1092
 
1093
+ Examples
1094
+ --------
1095
+ from Opik import AsyncOpikApi
1096
+ from Opik import SpanWrite
1097
+ import datetime
1098
+ import asyncio
1099
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1388
1100
  async def main() -> None:
1389
- await client.spans.add_span_feedback_score(
1390
- id="id",
1391
- name="name",
1392
- value=1.1,
1393
- source="ui",
1394
- )
1101
+ await client.spans.create_spans(spans=[SpanWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
1102
+ asyncio.run(main())
1103
+ """
1104
+ _response = await self._raw_client.create_spans(spans=spans, request_options=request_options)
1105
+ return _response.data
1106
+
1107
+ async def batch_update_spans(
1108
+ self,
1109
+ *,
1110
+ ids: typing.Sequence[str],
1111
+ update: SpanUpdate,
1112
+ merge_tags: typing.Optional[bool] = OMIT,
1113
+ request_options: typing.Optional[RequestOptions] = None,
1114
+ ) -> None:
1115
+ """
1116
+ Update multiple spans
1395
1117
 
1118
+ Parameters
1119
+ ----------
1120
+ ids : typing.Sequence[str]
1121
+ List of span IDs to update (max 1000)
1396
1122
 
1123
+ update : SpanUpdate
1124
+
1125
+ merge_tags : typing.Optional[bool]
1126
+ If true, merge tags with existing tags instead of replacing them. Default: false
1127
+
1128
+ request_options : typing.Optional[RequestOptions]
1129
+ Request-specific configuration.
1130
+
1131
+ Returns
1132
+ -------
1133
+ None
1134
+
1135
+ Examples
1136
+ --------
1137
+ from Opik import AsyncOpikApi
1138
+ from Opik import SpanUpdate
1139
+ import asyncio
1140
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1141
+ async def main() -> None:
1142
+ await client.spans.batch_update_spans(ids=['ids'], update=SpanUpdate(trace_id='trace_id', ), )
1397
1143
  asyncio.run(main())
1398
1144
  """
1399
- _response = await self._client_wrapper.httpx_client.request(
1400
- f"v1/private/spans/{jsonable_encoder(id)}/feedback-scores",
1401
- method="PUT",
1402
- json={
1403
- "name": name,
1404
- "category_name": category_name,
1405
- "value": value,
1406
- "reason": reason,
1407
- "source": source,
1408
- "created_at": created_at,
1409
- "last_updated_at": last_updated_at,
1410
- "created_by": created_by,
1411
- "last_updated_by": last_updated_by,
1412
- },
1413
- request_options=request_options,
1414
- omit=OMIT,
1145
+ _response = await self._raw_client.batch_update_spans(
1146
+ ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
1415
1147
  )
1416
- try:
1417
- if 200 <= _response.status_code < 300:
1418
- return
1419
- _response_json = _response.json()
1420
- except JSONDecodeError:
1421
- raise ApiError(status_code=_response.status_code, body=_response.text)
1422
- raise ApiError(status_code=_response.status_code, body=_response_json)
1148
+ return _response.data
1423
1149
 
1424
1150
  async def get_spans_by_project(
1425
1151
  self,
@@ -1432,6 +1158,11 @@ class AsyncSpansClient:
1432
1158
  type: typing.Optional[GetSpansByProjectRequestType] = None,
1433
1159
  filters: typing.Optional[str] = None,
1434
1160
  truncate: typing.Optional[bool] = None,
1161
+ strip_attachments: typing.Optional[bool] = None,
1162
+ sorting: typing.Optional[str] = None,
1163
+ exclude: typing.Optional[str] = None,
1164
+ from_time: typing.Optional[dt.datetime] = None,
1165
+ to_time: typing.Optional[dt.datetime] = None,
1435
1166
  request_options: typing.Optional[RequestOptions] = None,
1436
1167
  ) -> SpanPagePublic:
1437
1168
  """
@@ -1455,6 +1186,16 @@ class AsyncSpansClient:
1455
1186
 
1456
1187
  truncate : typing.Optional[bool]
1457
1188
 
1189
+ strip_attachments : typing.Optional[bool]
1190
+
1191
+ sorting : typing.Optional[str]
1192
+
1193
+ exclude : typing.Optional[str]
1194
+
1195
+ from_time : typing.Optional[dt.datetime]
1196
+
1197
+ to_time : typing.Optional[dt.datetime]
1198
+
1458
1199
  request_options : typing.Optional[RequestOptions]
1459
1200
  Request-specific configuration.
1460
1201
 
@@ -1465,70 +1206,51 @@ class AsyncSpansClient:
1465
1206
 
1466
1207
  Examples
1467
1208
  --------
1468
- import asyncio
1469
-
1470
1209
  from Opik import AsyncOpikApi
1471
-
1472
- client = AsyncOpikApi(
1473
- api_key="YOUR_API_KEY",
1474
- workspace_name="YOUR_WORKSPACE_NAME",
1475
- )
1476
-
1477
-
1210
+ import asyncio
1211
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1478
1212
  async def main() -> None:
1479
1213
  await client.spans.get_spans_by_project()
1480
-
1481
-
1482
1214
  asyncio.run(main())
1483
1215
  """
1484
- _response = await self._client_wrapper.httpx_client.request(
1485
- "v1/private/spans",
1486
- method="GET",
1487
- params={
1488
- "page": page,
1489
- "size": size,
1490
- "project_name": project_name,
1491
- "project_id": project_id,
1492
- "trace_id": trace_id,
1493
- "type": type,
1494
- "filters": filters,
1495
- "truncate": truncate,
1496
- },
1216
+ _response = await self._raw_client.get_spans_by_project(
1217
+ page=page,
1218
+ size=size,
1219
+ project_name=project_name,
1220
+ project_id=project_id,
1221
+ trace_id=trace_id,
1222
+ type=type,
1223
+ filters=filters,
1224
+ truncate=truncate,
1225
+ strip_attachments=strip_attachments,
1226
+ sorting=sorting,
1227
+ exclude=exclude,
1228
+ from_time=from_time,
1229
+ to_time=to_time,
1497
1230
  request_options=request_options,
1498
1231
  )
1499
- try:
1500
- if 200 <= _response.status_code < 300:
1501
- return typing.cast(
1502
- SpanPagePublic,
1503
- parse_obj_as(
1504
- type_=SpanPagePublic, # type: ignore
1505
- object_=_response.json(),
1506
- ),
1507
- )
1508
- _response_json = _response.json()
1509
- except JSONDecodeError:
1510
- raise ApiError(status_code=_response.status_code, body=_response.text)
1511
- raise ApiError(status_code=_response.status_code, body=_response_json)
1232
+ return _response.data
1512
1233
 
1513
1234
  async def create_span(
1514
1235
  self,
1515
1236
  *,
1516
- trace_id: str,
1517
- name: str,
1518
- type: SpanWriteType,
1519
1237
  start_time: dt.datetime,
1520
1238
  id: typing.Optional[str] = OMIT,
1521
1239
  project_name: typing.Optional[str] = OMIT,
1240
+ trace_id: typing.Optional[str] = OMIT,
1522
1241
  parent_span_id: typing.Optional[str] = OMIT,
1242
+ name: typing.Optional[str] = OMIT,
1243
+ type: typing.Optional[SpanWriteType] = OMIT,
1523
1244
  end_time: typing.Optional[dt.datetime] = OMIT,
1524
- input: typing.Optional[JsonNodeWrite] = OMIT,
1525
- output: typing.Optional[JsonNodeWrite] = OMIT,
1526
- metadata: typing.Optional[JsonNodeWrite] = OMIT,
1245
+ input: typing.Optional[JsonListStringWrite] = OMIT,
1246
+ output: typing.Optional[JsonListStringWrite] = OMIT,
1247
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
1527
1248
  model: typing.Optional[str] = OMIT,
1528
1249
  provider: typing.Optional[str] = OMIT,
1529
1250
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
1530
1251
  usage: typing.Optional[typing.Dict[str, int]] = OMIT,
1531
1252
  error_info: typing.Optional[ErrorInfoWrite] = OMIT,
1253
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
1532
1254
  total_estimated_cost: typing.Optional[float] = OMIT,
1533
1255
  total_estimated_cost_version: typing.Optional[str] = OMIT,
1534
1256
  request_options: typing.Optional[RequestOptions] = None,
@@ -1538,12 +1260,6 @@ class AsyncSpansClient:
1538
1260
 
1539
1261
  Parameters
1540
1262
  ----------
1541
- trace_id : str
1542
-
1543
- name : str
1544
-
1545
- type : SpanWriteType
1546
-
1547
1263
  start_time : dt.datetime
1548
1264
 
1549
1265
  id : typing.Optional[str]
@@ -1551,15 +1267,21 @@ class AsyncSpansClient:
1551
1267
  project_name : typing.Optional[str]
1552
1268
  If null, the default project is used
1553
1269
 
1270
+ trace_id : typing.Optional[str]
1271
+
1554
1272
  parent_span_id : typing.Optional[str]
1555
1273
 
1274
+ name : typing.Optional[str]
1275
+
1276
+ type : typing.Optional[SpanWriteType]
1277
+
1556
1278
  end_time : typing.Optional[dt.datetime]
1557
1279
 
1558
- input : typing.Optional[JsonNodeWrite]
1280
+ input : typing.Optional[JsonListStringWrite]
1559
1281
 
1560
- output : typing.Optional[JsonNodeWrite]
1282
+ output : typing.Optional[JsonListStringWrite]
1561
1283
 
1562
- metadata : typing.Optional[JsonNodeWrite]
1284
+ metadata : typing.Optional[JsonListStringWrite]
1563
1285
 
1564
1286
  model : typing.Optional[str]
1565
1287
 
@@ -1571,6 +1293,8 @@ class AsyncSpansClient:
1571
1293
 
1572
1294
  error_info : typing.Optional[ErrorInfoWrite]
1573
1295
 
1296
+ last_updated_at : typing.Optional[dt.datetime]
1297
+
1574
1298
  total_estimated_cost : typing.Optional[float]
1575
1299
 
1576
1300
  total_estimated_cost_version : typing.Optional[str]
@@ -1584,142 +1308,44 @@ class AsyncSpansClient:
1584
1308
 
1585
1309
  Examples
1586
1310
  --------
1587
- import asyncio
1588
- import datetime
1589
-
1590
1311
  from Opik import AsyncOpikApi
1591
-
1592
- client = AsyncOpikApi(
1593
- api_key="YOUR_API_KEY",
1594
- workspace_name="YOUR_WORKSPACE_NAME",
1595
- )
1596
-
1597
-
1312
+ import datetime
1313
+ import asyncio
1314
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1598
1315
  async def main() -> None:
1599
- await client.spans.create_span(
1600
- trace_id="trace_id",
1601
- name="name",
1602
- type="general",
1603
- start_time=datetime.datetime.fromisoformat(
1604
- "2024-01-15 09:30:00+00:00",
1605
- ),
1606
- )
1607
-
1608
-
1316
+ await client.spans.create_span(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )
1609
1317
  asyncio.run(main())
1610
1318
  """
1611
- _response = await self._client_wrapper.httpx_client.request(
1612
- "v1/private/spans",
1613
- method="POST",
1614
- json={
1615
- "id": id,
1616
- "project_name": project_name,
1617
- "trace_id": trace_id,
1618
- "parent_span_id": parent_span_id,
1619
- "name": name,
1620
- "type": type,
1621
- "start_time": start_time,
1622
- "end_time": end_time,
1623
- "input": input,
1624
- "output": output,
1625
- "metadata": metadata,
1626
- "model": model,
1627
- "provider": provider,
1628
- "tags": tags,
1629
- "usage": usage,
1630
- "error_info": convert_and_respect_annotation_metadata(
1631
- object_=error_info, annotation=ErrorInfoWrite, direction="write"
1632
- ),
1633
- "total_estimated_cost": total_estimated_cost,
1634
- "total_estimated_cost_version": total_estimated_cost_version,
1635
- },
1319
+ _response = await self._raw_client.create_span(
1320
+ start_time=start_time,
1321
+ id=id,
1322
+ project_name=project_name,
1323
+ trace_id=trace_id,
1324
+ parent_span_id=parent_span_id,
1325
+ name=name,
1326
+ type=type,
1327
+ end_time=end_time,
1328
+ input=input,
1329
+ output=output,
1330
+ metadata=metadata,
1331
+ model=model,
1332
+ provider=provider,
1333
+ tags=tags,
1334
+ usage=usage,
1335
+ error_info=error_info,
1336
+ last_updated_at=last_updated_at,
1337
+ total_estimated_cost=total_estimated_cost,
1338
+ total_estimated_cost_version=total_estimated_cost_version,
1636
1339
  request_options=request_options,
1637
- omit=OMIT,
1638
1340
  )
1639
- try:
1640
- if 200 <= _response.status_code < 300:
1641
- return
1642
- _response_json = _response.json()
1643
- except JSONDecodeError:
1644
- raise ApiError(status_code=_response.status_code, body=_response.text)
1645
- raise ApiError(status_code=_response.status_code, body=_response_json)
1341
+ return _response.data
1646
1342
 
1647
- async def create_spans(
1343
+ async def get_span_by_id(
1648
1344
  self,
1345
+ id: str,
1649
1346
  *,
1650
- spans: typing.Sequence[SpanWrite],
1347
+ strip_attachments: typing.Optional[bool] = None,
1651
1348
  request_options: typing.Optional[RequestOptions] = None,
1652
- ) -> None:
1653
- """
1654
- Create spans
1655
-
1656
- Parameters
1657
- ----------
1658
- spans : typing.Sequence[SpanWrite]
1659
-
1660
- request_options : typing.Optional[RequestOptions]
1661
- Request-specific configuration.
1662
-
1663
- Returns
1664
- -------
1665
- None
1666
-
1667
- Examples
1668
- --------
1669
- import asyncio
1670
- import datetime
1671
-
1672
- from Opik import AsyncOpikApi, SpanWrite
1673
-
1674
- client = AsyncOpikApi(
1675
- api_key="YOUR_API_KEY",
1676
- workspace_name="YOUR_WORKSPACE_NAME",
1677
- )
1678
-
1679
-
1680
- async def main() -> None:
1681
- await client.spans.create_spans(
1682
- spans=[
1683
- SpanWrite(
1684
- trace_id="trace_id",
1685
- name="name",
1686
- type="general",
1687
- start_time=datetime.datetime.fromisoformat(
1688
- "2024-01-15 09:30:00+00:00",
1689
- ),
1690
- )
1691
- ],
1692
- )
1693
-
1694
-
1695
- asyncio.run(main())
1696
- """
1697
- _response = await self._client_wrapper.httpx_client.request(
1698
- "v1/private/spans/batch",
1699
- method="POST",
1700
- json={
1701
- "spans": convert_and_respect_annotation_metadata(
1702
- object_=spans,
1703
- annotation=typing.Sequence[SpanWrite],
1704
- direction="write",
1705
- ),
1706
- },
1707
- headers={
1708
- "content-type": "application/json",
1709
- },
1710
- request_options=request_options,
1711
- omit=OMIT,
1712
- )
1713
- try:
1714
- if 200 <= _response.status_code < 300:
1715
- return
1716
- _response_json = _response.json()
1717
- except JSONDecodeError:
1718
- raise ApiError(status_code=_response.status_code, body=_response.text)
1719
- raise ApiError(status_code=_response.status_code, body=_response_json)
1720
-
1721
- async def get_span_by_id(
1722
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1723
1349
  ) -> SpanPublic:
1724
1350
  """
1725
1351
  Get span by id
@@ -1728,6 +1354,8 @@ class AsyncSpansClient:
1728
1354
  ----------
1729
1355
  id : str
1730
1356
 
1357
+ strip_attachments : typing.Optional[bool]
1358
+
1731
1359
  request_options : typing.Optional[RequestOptions]
1732
1360
  Request-specific configuration.
1733
1361
 
@@ -1738,56 +1366,19 @@ class AsyncSpansClient:
1738
1366
 
1739
1367
  Examples
1740
1368
  --------
1741
- import asyncio
1742
-
1743
1369
  from Opik import AsyncOpikApi
1744
-
1745
- client = AsyncOpikApi(
1746
- api_key="YOUR_API_KEY",
1747
- workspace_name="YOUR_WORKSPACE_NAME",
1748
- )
1749
-
1750
-
1370
+ import asyncio
1371
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1751
1372
  async def main() -> None:
1752
- await client.spans.get_span_by_id(
1753
- id="id",
1754
- )
1755
-
1756
-
1373
+ await client.spans.get_span_by_id(id='id', )
1757
1374
  asyncio.run(main())
1758
1375
  """
1759
- _response = await self._client_wrapper.httpx_client.request(
1760
- f"v1/private/spans/{jsonable_encoder(id)}",
1761
- method="GET",
1762
- request_options=request_options,
1376
+ _response = await self._raw_client.get_span_by_id(
1377
+ id, strip_attachments=strip_attachments, request_options=request_options
1763
1378
  )
1764
- try:
1765
- if 200 <= _response.status_code < 300:
1766
- return typing.cast(
1767
- SpanPublic,
1768
- parse_obj_as(
1769
- type_=SpanPublic, # type: ignore
1770
- object_=_response.json(),
1771
- ),
1772
- )
1773
- if _response.status_code == 404:
1774
- raise NotFoundError(
1775
- typing.cast(
1776
- typing.Optional[typing.Any],
1777
- parse_obj_as(
1778
- type_=typing.Optional[typing.Any], # type: ignore
1779
- object_=_response.json(),
1780
- ),
1781
- )
1782
- )
1783
- _response_json = _response.json()
1784
- except JSONDecodeError:
1785
- raise ApiError(status_code=_response.status_code, body=_response.text)
1786
- raise ApiError(status_code=_response.status_code, body=_response_json)
1787
-
1788
- async def delete_span_by_id(
1789
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1790
- ) -> None:
1379
+ return _response.data
1380
+
1381
+ async def delete_span_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
1791
1382
  """
1792
1383
  Delete span by id
1793
1384
 
@@ -1804,46 +1395,15 @@ class AsyncSpansClient:
1804
1395
 
1805
1396
  Examples
1806
1397
  --------
1807
- import asyncio
1808
-
1809
1398
  from Opik import AsyncOpikApi
1810
-
1811
- client = AsyncOpikApi(
1812
- api_key="YOUR_API_KEY",
1813
- workspace_name="YOUR_WORKSPACE_NAME",
1814
- )
1815
-
1816
-
1399
+ import asyncio
1400
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1817
1401
  async def main() -> None:
1818
- await client.spans.delete_span_by_id(
1819
- id="id",
1820
- )
1821
-
1822
-
1402
+ await client.spans.delete_span_by_id(id='id', )
1823
1403
  asyncio.run(main())
1824
1404
  """
1825
- _response = await self._client_wrapper.httpx_client.request(
1826
- f"v1/private/spans/{jsonable_encoder(id)}",
1827
- method="DELETE",
1828
- request_options=request_options,
1829
- )
1830
- try:
1831
- if 200 <= _response.status_code < 300:
1832
- return
1833
- if _response.status_code == 501:
1834
- raise NotImplementedError(
1835
- typing.cast(
1836
- typing.Optional[typing.Any],
1837
- parse_obj_as(
1838
- type_=typing.Optional[typing.Any], # type: ignore
1839
- object_=_response.json(),
1840
- ),
1841
- )
1842
- )
1843
- _response_json = _response.json()
1844
- except JSONDecodeError:
1845
- raise ApiError(status_code=_response.status_code, body=_response.text)
1846
- raise ApiError(status_code=_response.status_code, body=_response_json)
1405
+ _response = await self._raw_client.delete_span_by_id(id, request_options=request_options)
1406
+ return _response.data
1847
1407
 
1848
1408
  async def update_span(
1849
1409
  self,
@@ -1853,10 +1413,12 @@ class AsyncSpansClient:
1853
1413
  project_name: typing.Optional[str] = OMIT,
1854
1414
  project_id: typing.Optional[str] = OMIT,
1855
1415
  parent_span_id: typing.Optional[str] = OMIT,
1416
+ name: typing.Optional[str] = OMIT,
1417
+ type: typing.Optional[SpanUpdateType] = OMIT,
1856
1418
  end_time: typing.Optional[dt.datetime] = OMIT,
1857
- input: typing.Optional[JsonNode] = OMIT,
1858
- output: typing.Optional[JsonNode] = OMIT,
1859
- metadata: typing.Optional[JsonNode] = OMIT,
1419
+ input: typing.Optional[JsonListString] = OMIT,
1420
+ output: typing.Optional[JsonListString] = OMIT,
1421
+ metadata: typing.Optional[JsonListString] = OMIT,
1860
1422
  model: typing.Optional[str] = OMIT,
1861
1423
  provider: typing.Optional[str] = OMIT,
1862
1424
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
@@ -1882,13 +1444,17 @@ class AsyncSpansClient:
1882
1444
 
1883
1445
  parent_span_id : typing.Optional[str]
1884
1446
 
1447
+ name : typing.Optional[str]
1448
+
1449
+ type : typing.Optional[SpanUpdateType]
1450
+
1885
1451
  end_time : typing.Optional[dt.datetime]
1886
1452
 
1887
- input : typing.Optional[JsonNode]
1453
+ input : typing.Optional[JsonListString]
1888
1454
 
1889
- output : typing.Optional[JsonNode]
1455
+ output : typing.Optional[JsonListString]
1890
1456
 
1891
- metadata : typing.Optional[JsonNode]
1457
+ metadata : typing.Optional[JsonListString]
1892
1458
 
1893
1459
  model : typing.Optional[str]
1894
1460
 
@@ -1911,75 +1477,37 @@ class AsyncSpansClient:
1911
1477
 
1912
1478
  Examples
1913
1479
  --------
1914
- import asyncio
1915
-
1916
1480
  from Opik import AsyncOpikApi
1917
-
1918
- client = AsyncOpikApi(
1919
- api_key="YOUR_API_KEY",
1920
- workspace_name="YOUR_WORKSPACE_NAME",
1921
- )
1922
-
1923
-
1481
+ import asyncio
1482
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1924
1483
  async def main() -> None:
1925
- await client.spans.update_span(
1926
- id="id",
1927
- trace_id="trace_id",
1928
- )
1929
-
1930
-
1484
+ await client.spans.update_span(id='id', trace_id='trace_id', )
1931
1485
  asyncio.run(main())
1932
1486
  """
1933
- _response = await self._client_wrapper.httpx_client.request(
1934
- f"v1/private/spans/{jsonable_encoder(id)}",
1935
- method="PATCH",
1936
- json={
1937
- "project_name": project_name,
1938
- "project_id": project_id,
1939
- "trace_id": trace_id,
1940
- "parent_span_id": parent_span_id,
1941
- "end_time": end_time,
1942
- "input": input,
1943
- "output": output,
1944
- "metadata": metadata,
1945
- "model": model,
1946
- "provider": provider,
1947
- "tags": tags,
1948
- "usage": usage,
1949
- "total_estimated_cost": total_estimated_cost,
1950
- "error_info": convert_and_respect_annotation_metadata(
1951
- object_=error_info, annotation=ErrorInfo, direction="write"
1952
- ),
1953
- },
1954
- headers={
1955
- "content-type": "application/json",
1956
- },
1487
+ _response = await self._raw_client.update_span(
1488
+ id,
1489
+ trace_id=trace_id,
1490
+ project_name=project_name,
1491
+ project_id=project_id,
1492
+ parent_span_id=parent_span_id,
1493
+ name=name,
1494
+ type=type,
1495
+ end_time=end_time,
1496
+ input=input,
1497
+ output=output,
1498
+ metadata=metadata,
1499
+ model=model,
1500
+ provider=provider,
1501
+ tags=tags,
1502
+ usage=usage,
1503
+ total_estimated_cost=total_estimated_cost,
1504
+ error_info=error_info,
1957
1505
  request_options=request_options,
1958
- omit=OMIT,
1959
1506
  )
1960
- try:
1961
- if 200 <= _response.status_code < 300:
1962
- return
1963
- if _response.status_code == 404:
1964
- raise NotFoundError(
1965
- typing.cast(
1966
- typing.Optional[typing.Any],
1967
- parse_obj_as(
1968
- type_=typing.Optional[typing.Any], # type: ignore
1969
- object_=_response.json(),
1970
- ),
1971
- )
1972
- )
1973
- _response_json = _response.json()
1974
- except JSONDecodeError:
1975
- raise ApiError(status_code=_response.status_code, body=_response.text)
1976
- raise ApiError(status_code=_response.status_code, body=_response_json)
1507
+ return _response.data
1977
1508
 
1978
1509
  async def delete_span_comments(
1979
- self,
1980
- *,
1981
- ids: typing.Sequence[str],
1982
- request_options: typing.Optional[RequestOptions] = None,
1510
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
1983
1511
  ) -> None:
1984
1512
  """
1985
1513
  Delete span comments
@@ -1997,46 +1525,22 @@ class AsyncSpansClient:
1997
1525
 
1998
1526
  Examples
1999
1527
  --------
2000
- import asyncio
2001
-
2002
1528
  from Opik import AsyncOpikApi
2003
-
2004
- client = AsyncOpikApi(
2005
- api_key="YOUR_API_KEY",
2006
- workspace_name="YOUR_WORKSPACE_NAME",
2007
- )
2008
-
2009
-
1529
+ import asyncio
1530
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2010
1531
  async def main() -> None:
2011
- await client.spans.delete_span_comments(
2012
- ids=["ids"],
2013
- )
2014
-
2015
-
1532
+ await client.spans.delete_span_comments(ids=['ids'], )
2016
1533
  asyncio.run(main())
2017
1534
  """
2018
- _response = await self._client_wrapper.httpx_client.request(
2019
- "v1/private/spans/comments/delete",
2020
- method="POST",
2021
- json={
2022
- "ids": ids,
2023
- },
2024
- request_options=request_options,
2025
- omit=OMIT,
2026
- )
2027
- try:
2028
- if 200 <= _response.status_code < 300:
2029
- return
2030
- _response_json = _response.json()
2031
- except JSONDecodeError:
2032
- raise ApiError(status_code=_response.status_code, body=_response.text)
2033
- raise ApiError(status_code=_response.status_code, body=_response_json)
1535
+ _response = await self._raw_client.delete_span_comments(ids=ids, request_options=request_options)
1536
+ return _response.data
2034
1537
 
2035
1538
  async def delete_span_feedback_score(
2036
1539
  self,
2037
1540
  id: str,
2038
1541
  *,
2039
1542
  name: str,
1543
+ author: typing.Optional[str] = OMIT,
2040
1544
  request_options: typing.Optional[RequestOptions] = None,
2041
1545
  ) -> None:
2042
1546
  """
@@ -2048,6 +1552,8 @@ class AsyncSpansClient:
2048
1552
 
2049
1553
  name : str
2050
1554
 
1555
+ author : typing.Optional[str]
1556
+
2051
1557
  request_options : typing.Optional[RequestOptions]
2052
1558
  Request-specific configuration.
2053
1559
 
@@ -2057,41 +1563,17 @@ class AsyncSpansClient:
2057
1563
 
2058
1564
  Examples
2059
1565
  --------
2060
- import asyncio
2061
-
2062
1566
  from Opik import AsyncOpikApi
2063
-
2064
- client = AsyncOpikApi(
2065
- api_key="YOUR_API_KEY",
2066
- workspace_name="YOUR_WORKSPACE_NAME",
2067
- )
2068
-
2069
-
1567
+ import asyncio
1568
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2070
1569
  async def main() -> None:
2071
- await client.spans.delete_span_feedback_score(
2072
- id="id",
2073
- name="name",
2074
- )
2075
-
2076
-
1570
+ await client.spans.delete_span_feedback_score(id='id', name='name', )
2077
1571
  asyncio.run(main())
2078
1572
  """
2079
- _response = await self._client_wrapper.httpx_client.request(
2080
- f"v1/private/spans/{jsonable_encoder(id)}/feedback-scores/delete",
2081
- method="POST",
2082
- json={
2083
- "name": name,
2084
- },
2085
- request_options=request_options,
2086
- omit=OMIT,
1573
+ _response = await self._raw_client.delete_span_feedback_score(
1574
+ id, name=name, author=author, request_options=request_options
2087
1575
  )
2088
- try:
2089
- if 200 <= _response.status_code < 300:
2090
- return
2091
- _response_json = _response.json()
2092
- except JSONDecodeError:
2093
- raise ApiError(status_code=_response.status_code, body=_response.text)
2094
- raise ApiError(status_code=_response.status_code, body=_response_json)
1576
+ return _response.data
2095
1577
 
2096
1578
  async def find_feedback_score_names_1(
2097
1579
  self,
@@ -2119,51 +1601,20 @@ class AsyncSpansClient:
2119
1601
 
2120
1602
  Examples
2121
1603
  --------
2122
- import asyncio
2123
-
2124
1604
  from Opik import AsyncOpikApi
2125
-
2126
- client = AsyncOpikApi(
2127
- api_key="YOUR_API_KEY",
2128
- workspace_name="YOUR_WORKSPACE_NAME",
2129
- )
2130
-
2131
-
1605
+ import asyncio
1606
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2132
1607
  async def main() -> None:
2133
1608
  await client.spans.find_feedback_score_names_1()
2134
-
2135
-
2136
1609
  asyncio.run(main())
2137
1610
  """
2138
- _response = await self._client_wrapper.httpx_client.request(
2139
- "v1/private/spans/feedback-scores/names",
2140
- method="GET",
2141
- params={
2142
- "project_id": project_id,
2143
- "type": type,
2144
- },
2145
- request_options=request_options,
1611
+ _response = await self._raw_client.find_feedback_score_names_1(
1612
+ project_id=project_id, type=type, request_options=request_options
2146
1613
  )
2147
- try:
2148
- if 200 <= _response.status_code < 300:
2149
- return typing.cast(
2150
- typing.List[str],
2151
- parse_obj_as(
2152
- type_=typing.List[str], # type: ignore
2153
- object_=_response.json(),
2154
- ),
2155
- )
2156
- _response_json = _response.json()
2157
- except JSONDecodeError:
2158
- raise ApiError(status_code=_response.status_code, body=_response.text)
2159
- raise ApiError(status_code=_response.status_code, body=_response_json)
1614
+ return _response.data
2160
1615
 
2161
1616
  async def get_span_comment(
2162
- self,
2163
- comment_id: str,
2164
- span_id: str,
2165
- *,
2166
- request_options: typing.Optional[RequestOptions] = None,
1617
+ self, comment_id: str, span_id: str, *, request_options: typing.Optional[RequestOptions] = None
2167
1618
  ) -> Comment:
2168
1619
  """
2169
1620
  Get span comment
@@ -2184,53 +1635,15 @@ class AsyncSpansClient:
2184
1635
 
2185
1636
  Examples
2186
1637
  --------
2187
- import asyncio
2188
-
2189
1638
  from Opik import AsyncOpikApi
2190
-
2191
- client = AsyncOpikApi(
2192
- api_key="YOUR_API_KEY",
2193
- workspace_name="YOUR_WORKSPACE_NAME",
2194
- )
2195
-
2196
-
1639
+ import asyncio
1640
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2197
1641
  async def main() -> None:
2198
- await client.spans.get_span_comment(
2199
- comment_id="commentId",
2200
- span_id="spanId",
2201
- )
2202
-
2203
-
1642
+ await client.spans.get_span_comment(comment_id='commentId', span_id='spanId', )
2204
1643
  asyncio.run(main())
2205
1644
  """
2206
- _response = await self._client_wrapper.httpx_client.request(
2207
- f"v1/private/spans/{jsonable_encoder(span_id)}/comments/{jsonable_encoder(comment_id)}",
2208
- method="GET",
2209
- request_options=request_options,
2210
- )
2211
- try:
2212
- if 200 <= _response.status_code < 300:
2213
- return typing.cast(
2214
- Comment,
2215
- parse_obj_as(
2216
- type_=Comment, # type: ignore
2217
- object_=_response.json(),
2218
- ),
2219
- )
2220
- if _response.status_code == 404:
2221
- raise NotFoundError(
2222
- typing.cast(
2223
- typing.Optional[typing.Any],
2224
- parse_obj_as(
2225
- type_=typing.Optional[typing.Any], # type: ignore
2226
- object_=_response.json(),
2227
- ),
2228
- )
2229
- )
2230
- _response_json = _response.json()
2231
- except JSONDecodeError:
2232
- raise ApiError(status_code=_response.status_code, body=_response.text)
2233
- raise ApiError(status_code=_response.status_code, body=_response_json)
1645
+ _response = await self._raw_client.get_span_comment(comment_id, span_id, request_options=request_options)
1646
+ return _response.data
2234
1647
 
2235
1648
  async def get_span_stats(
2236
1649
  self,
@@ -2240,6 +1653,8 @@ class AsyncSpansClient:
2240
1653
  trace_id: typing.Optional[str] = None,
2241
1654
  type: typing.Optional[GetSpanStatsRequestType] = None,
2242
1655
  filters: typing.Optional[str] = None,
1656
+ from_time: typing.Optional[dt.datetime] = None,
1657
+ to_time: typing.Optional[dt.datetime] = None,
2243
1658
  request_options: typing.Optional[RequestOptions] = None,
2244
1659
  ) -> ProjectStatsPublic:
2245
1660
  """
@@ -2257,6 +1672,10 @@ class AsyncSpansClient:
2257
1672
 
2258
1673
  filters : typing.Optional[str]
2259
1674
 
1675
+ from_time : typing.Optional[dt.datetime]
1676
+
1677
+ to_time : typing.Optional[dt.datetime]
1678
+
2260
1679
  request_options : typing.Optional[RequestOptions]
2261
1680
  Request-specific configuration.
2262
1681
 
@@ -2267,47 +1686,24 @@ class AsyncSpansClient:
2267
1686
 
2268
1687
  Examples
2269
1688
  --------
2270
- import asyncio
2271
-
2272
1689
  from Opik import AsyncOpikApi
2273
-
2274
- client = AsyncOpikApi(
2275
- api_key="YOUR_API_KEY",
2276
- workspace_name="YOUR_WORKSPACE_NAME",
2277
- )
2278
-
2279
-
1690
+ import asyncio
1691
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2280
1692
  async def main() -> None:
2281
1693
  await client.spans.get_span_stats()
2282
-
2283
-
2284
1694
  asyncio.run(main())
2285
1695
  """
2286
- _response = await self._client_wrapper.httpx_client.request(
2287
- "v1/private/spans/stats",
2288
- method="GET",
2289
- params={
2290
- "project_id": project_id,
2291
- "project_name": project_name,
2292
- "trace_id": trace_id,
2293
- "type": type,
2294
- "filters": filters,
2295
- },
1696
+ _response = await self._raw_client.get_span_stats(
1697
+ project_id=project_id,
1698
+ project_name=project_name,
1699
+ trace_id=trace_id,
1700
+ type=type,
1701
+ filters=filters,
1702
+ from_time=from_time,
1703
+ to_time=to_time,
2296
1704
  request_options=request_options,
2297
1705
  )
2298
- try:
2299
- if 200 <= _response.status_code < 300:
2300
- return typing.cast(
2301
- ProjectStatsPublic,
2302
- parse_obj_as(
2303
- type_=ProjectStatsPublic, # type: ignore
2304
- object_=_response.json(),
2305
- ),
2306
- )
2307
- _response_json = _response.json()
2308
- except JSONDecodeError:
2309
- raise ApiError(status_code=_response.status_code, body=_response.text)
2310
- raise ApiError(status_code=_response.status_code, body=_response_json)
1706
+ return _response.data
2311
1707
 
2312
1708
  async def score_batch_of_spans(
2313
1709
  self,
@@ -2331,51 +1727,16 @@ class AsyncSpansClient:
2331
1727
 
2332
1728
  Examples
2333
1729
  --------
1730
+ from Opik import AsyncOpikApi
1731
+ from Opik import FeedbackScoreBatchItem
2334
1732
  import asyncio
2335
-
2336
- from Opik import AsyncOpikApi, FeedbackScoreBatchItem
2337
-
2338
- client = AsyncOpikApi(
2339
- api_key="YOUR_API_KEY",
2340
- workspace_name="YOUR_WORKSPACE_NAME",
2341
- )
2342
-
2343
-
1733
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2344
1734
  async def main() -> None:
2345
- await client.spans.score_batch_of_spans(
2346
- scores=[
2347
- FeedbackScoreBatchItem(
2348
- id="id",
2349
- name="name",
2350
- value=1.1,
2351
- source="ui",
2352
- )
2353
- ],
2354
- )
2355
-
2356
-
1735
+ await client.spans.score_batch_of_spans(scores=[FeedbackScoreBatchItem(name='name', value=1.1, source="ui", id='id', )], )
2357
1736
  asyncio.run(main())
2358
1737
  """
2359
- _response = await self._client_wrapper.httpx_client.request(
2360
- "v1/private/spans/feedback-scores",
2361
- method="PUT",
2362
- json={
2363
- "scores": convert_and_respect_annotation_metadata(
2364
- object_=scores,
2365
- annotation=typing.Sequence[FeedbackScoreBatchItem],
2366
- direction="write",
2367
- ),
2368
- },
2369
- request_options=request_options,
2370
- omit=OMIT,
2371
- )
2372
- try:
2373
- if 200 <= _response.status_code < 300:
2374
- return
2375
- _response_json = _response.json()
2376
- except JSONDecodeError:
2377
- raise ApiError(status_code=_response.status_code, body=_response.text)
2378
- raise ApiError(status_code=_response.status_code, body=_response_json)
1738
+ _response = await self._raw_client.score_batch_of_spans(scores=scores, request_options=request_options)
1739
+ return _response.data
2379
1740
 
2380
1741
  async def search_spans(
2381
1742
  self,
@@ -2388,6 +1749,8 @@ class AsyncSpansClient:
2388
1749
  limit: typing.Optional[int] = OMIT,
2389
1750
  last_retrieved_id: typing.Optional[str] = OMIT,
2390
1751
  truncate: typing.Optional[bool] = OMIT,
1752
+ from_time: typing.Optional[dt.datetime] = OMIT,
1753
+ to_time: typing.Optional[dt.datetime] = OMIT,
2391
1754
  request_options: typing.Optional[RequestOptions] = None,
2392
1755
  ) -> typing.AsyncIterator[bytes]:
2393
1756
  """
@@ -2406,68 +1769,42 @@ class AsyncSpansClient:
2406
1769
  filters : typing.Optional[typing.Sequence[SpanFilterPublic]]
2407
1770
 
2408
1771
  limit : typing.Optional[int]
1772
+ Max number of spans to be streamed
2409
1773
 
2410
1774
  last_retrieved_id : typing.Optional[str]
2411
1775
 
2412
1776
  truncate : typing.Optional[bool]
2413
1777
  Truncate image included in either input, output or metadata
2414
1778
 
1779
+ from_time : typing.Optional[dt.datetime]
1780
+ Filter spans created from this time (ISO-8601 format).
1781
+
1782
+ to_time : typing.Optional[dt.datetime]
1783
+ Filter spans created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
1784
+
2415
1785
  request_options : typing.Optional[RequestOptions]
2416
1786
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
2417
1787
 
2418
- Yields
2419
- ------
1788
+ Returns
1789
+ -------
2420
1790
  typing.AsyncIterator[bytes]
2421
1791
  Spans stream or error during process
2422
1792
  """
2423
- async with self._client_wrapper.httpx_client.stream(
2424
- "v1/private/spans/search",
2425
- method="POST",
2426
- json={
2427
- "trace_id": trace_id,
2428
- "project_name": project_name,
2429
- "project_id": project_id,
2430
- "type": type,
2431
- "filters": convert_and_respect_annotation_metadata(
2432
- object_=filters,
2433
- annotation=typing.Sequence[SpanFilterPublic],
2434
- direction="write",
2435
- ),
2436
- "limit": limit,
2437
- "last_retrieved_id": last_retrieved_id,
2438
- "truncate": truncate,
2439
- },
2440
- headers={
2441
- "content-type": "application/json",
2442
- },
1793
+ async with self._raw_client.search_spans(
1794
+ trace_id=trace_id,
1795
+ project_name=project_name,
1796
+ project_id=project_id,
1797
+ type=type,
1798
+ filters=filters,
1799
+ limit=limit,
1800
+ last_retrieved_id=last_retrieved_id,
1801
+ truncate=truncate,
1802
+ from_time=from_time,
1803
+ to_time=to_time,
2443
1804
  request_options=request_options,
2444
- omit=OMIT,
2445
- ) as _response:
2446
- try:
2447
- if 200 <= _response.status_code < 300:
2448
- _chunk_size = (
2449
- request_options.get("chunk_size", None)
2450
- if request_options is not None
2451
- else None
2452
- )
2453
- async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size):
2454
- yield _chunk
2455
- return
2456
- await _response.aread()
2457
- if _response.status_code == 400:
2458
- raise BadRequestError(
2459
- typing.cast(
2460
- typing.Optional[typing.Any],
2461
- parse_obj_as(
2462
- type_=typing.Optional[typing.Any], # type: ignore
2463
- object_=_response.json(),
2464
- ),
2465
- )
2466
- )
2467
- _response_json = _response.json()
2468
- except JSONDecodeError:
2469
- raise ApiError(status_code=_response.status_code, body=_response.text)
2470
- raise ApiError(status_code=_response.status_code, body=_response_json)
1805
+ ) as r:
1806
+ async for data in r.data:
1807
+ yield data
2471
1808
 
2472
1809
  async def update_span_comment(
2473
1810
  self,
@@ -2509,53 +1846,21 @@ class AsyncSpansClient:
2509
1846
 
2510
1847
  Examples
2511
1848
  --------
2512
- import asyncio
2513
-
2514
1849
  from Opik import AsyncOpikApi
2515
-
2516
- client = AsyncOpikApi(
2517
- api_key="YOUR_API_KEY",
2518
- workspace_name="YOUR_WORKSPACE_NAME",
2519
- )
2520
-
2521
-
1850
+ import asyncio
1851
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2522
1852
  async def main() -> None:
2523
- await client.spans.update_span_comment(
2524
- comment_id="commentId",
2525
- text="text",
2526
- )
2527
-
2528
-
1853
+ await client.spans.update_span_comment(comment_id='commentId', text='text', )
2529
1854
  asyncio.run(main())
2530
1855
  """
2531
- _response = await self._client_wrapper.httpx_client.request(
2532
- f"v1/private/spans/comments/{jsonable_encoder(comment_id)}",
2533
- method="PATCH",
2534
- json={
2535
- "id": id,
2536
- "text": text,
2537
- "created_at": created_at,
2538
- "last_updated_at": last_updated_at,
2539
- "created_by": created_by,
2540
- "last_updated_by": last_updated_by,
2541
- },
1856
+ _response = await self._raw_client.update_span_comment(
1857
+ comment_id,
1858
+ text=text,
1859
+ id=id,
1860
+ created_at=created_at,
1861
+ last_updated_at=last_updated_at,
1862
+ created_by=created_by,
1863
+ last_updated_by=last_updated_by,
2542
1864
  request_options=request_options,
2543
- omit=OMIT,
2544
1865
  )
2545
- try:
2546
- if 200 <= _response.status_code < 300:
2547
- return
2548
- if _response.status_code == 404:
2549
- raise NotFoundError(
2550
- typing.cast(
2551
- typing.Optional[typing.Any],
2552
- parse_obj_as(
2553
- type_=typing.Optional[typing.Any], # type: ignore
2554
- object_=_response.json(),
2555
- ),
2556
- )
2557
- )
2558
- _response_json = _response.json()
2559
- except JSONDecodeError:
2560
- raise ApiError(status_code=_response.status_code, body=_response.text)
2561
- raise ApiError(status_code=_response.status_code, body=_response_json)
1866
+ return _response.data