opik 1.9.5__py3-none-any.whl → 1.9.39__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. opik/__init__.py +10 -3
  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/dataset/rest_operations.py +5 -0
  9. opik/api_objects/experiment/experiment.py +46 -49
  10. opik/api_objects/experiment/helpers.py +34 -10
  11. opik/api_objects/local_recording.py +8 -3
  12. opik/api_objects/opik_client.py +230 -48
  13. opik/api_objects/opik_query_language.py +9 -0
  14. opik/api_objects/prompt/__init__.py +11 -3
  15. opik/api_objects/prompt/base_prompt.py +69 -0
  16. opik/api_objects/prompt/base_prompt_template.py +29 -0
  17. opik/api_objects/prompt/chat/__init__.py +1 -0
  18. opik/api_objects/prompt/chat/chat_prompt.py +193 -0
  19. opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
  20. opik/api_objects/prompt/{chat_content_renderer_registry.py → chat/content_renderer_registry.py} +37 -35
  21. opik/api_objects/prompt/client.py +101 -30
  22. opik/api_objects/prompt/text/__init__.py +1 -0
  23. opik/api_objects/prompt/text/prompt.py +174 -0
  24. opik/api_objects/prompt/{prompt_template.py → text/prompt_template.py} +10 -6
  25. opik/api_objects/prompt/types.py +1 -1
  26. opik/cli/export.py +6 -2
  27. opik/cli/usage_report/charts.py +39 -10
  28. opik/cli/usage_report/cli.py +164 -45
  29. opik/cli/usage_report/pdf.py +14 -1
  30. opik/config.py +0 -5
  31. opik/decorator/base_track_decorator.py +37 -40
  32. opik/decorator/context_manager/span_context_manager.py +9 -0
  33. opik/decorator/context_manager/trace_context_manager.py +5 -0
  34. opik/dict_utils.py +3 -3
  35. opik/evaluation/__init__.py +13 -2
  36. opik/evaluation/engine/engine.py +195 -223
  37. opik/evaluation/engine/helpers.py +8 -7
  38. opik/evaluation/engine/metrics_evaluator.py +237 -0
  39. opik/evaluation/evaluation_result.py +35 -1
  40. opik/evaluation/evaluator.py +318 -30
  41. opik/evaluation/models/litellm/util.py +78 -6
  42. opik/evaluation/models/model_capabilities.py +33 -0
  43. opik/evaluation/report.py +14 -2
  44. opik/evaluation/rest_operations.py +36 -33
  45. opik/evaluation/test_case.py +2 -2
  46. opik/evaluation/types.py +9 -1
  47. opik/exceptions.py +17 -0
  48. opik/hooks/__init__.py +17 -1
  49. opik/hooks/anonymizer_hook.py +36 -0
  50. opik/id_helpers.py +18 -0
  51. opik/integrations/adk/helpers.py +16 -7
  52. opik/integrations/adk/legacy_opik_tracer.py +7 -4
  53. opik/integrations/adk/opik_tracer.py +3 -1
  54. opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +7 -3
  55. opik/integrations/adk/recursive_callback_injector.py +1 -6
  56. opik/integrations/dspy/callback.py +1 -4
  57. opik/integrations/haystack/opik_connector.py +2 -2
  58. opik/integrations/haystack/opik_tracer.py +2 -4
  59. opik/integrations/langchain/opik_tracer.py +273 -82
  60. opik/integrations/llama_index/callback.py +110 -108
  61. opik/integrations/openai/agents/opik_tracing_processor.py +1 -2
  62. opik/integrations/openai/opik_tracker.py +1 -1
  63. opik/message_processing/batching/batchers.py +11 -7
  64. opik/message_processing/encoder_helpers.py +79 -0
  65. opik/message_processing/messages.py +25 -1
  66. opik/message_processing/online_message_processor.py +23 -8
  67. opik/opik_context.py +7 -7
  68. opik/rest_api/__init__.py +188 -12
  69. opik/rest_api/client.py +3 -0
  70. opik/rest_api/dashboards/__init__.py +4 -0
  71. opik/rest_api/dashboards/client.py +462 -0
  72. opik/rest_api/dashboards/raw_client.py +648 -0
  73. opik/rest_api/datasets/client.py +893 -89
  74. opik/rest_api/datasets/raw_client.py +1328 -87
  75. opik/rest_api/experiments/client.py +30 -2
  76. opik/rest_api/experiments/raw_client.py +26 -0
  77. opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -1
  78. opik/rest_api/optimizations/client.py +302 -0
  79. opik/rest_api/optimizations/raw_client.py +463 -0
  80. opik/rest_api/optimizations/types/optimization_update_status.py +3 -1
  81. opik/rest_api/prompts/__init__.py +2 -2
  82. opik/rest_api/prompts/client.py +34 -4
  83. opik/rest_api/prompts/raw_client.py +32 -2
  84. opik/rest_api/prompts/types/__init__.py +3 -1
  85. opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
  86. opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
  87. opik/rest_api/spans/__init__.py +0 -2
  88. opik/rest_api/spans/client.py +148 -64
  89. opik/rest_api/spans/raw_client.py +210 -83
  90. opik/rest_api/spans/types/__init__.py +0 -2
  91. opik/rest_api/traces/client.py +241 -73
  92. opik/rest_api/traces/raw_client.py +344 -90
  93. opik/rest_api/types/__init__.py +200 -15
  94. opik/rest_api/types/aggregation_data.py +1 -0
  95. opik/rest_api/types/alert_trigger_config_public_type.py +6 -1
  96. opik/rest_api/types/alert_trigger_config_type.py +6 -1
  97. opik/rest_api/types/alert_trigger_config_write_type.py +6 -1
  98. opik/rest_api/types/automation_rule_evaluator.py +23 -1
  99. opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +2 -0
  100. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +2 -0
  101. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +2 -0
  102. opik/rest_api/types/{automation_rule_evaluator_object_public.py → automation_rule_evaluator_object_object_public.py} +32 -10
  103. opik/rest_api/types/automation_rule_evaluator_page_public.py +2 -2
  104. opik/rest_api/types/automation_rule_evaluator_public.py +23 -1
  105. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
  106. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
  107. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
  108. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +2 -0
  109. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +2 -0
  110. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +2 -0
  111. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +2 -0
  112. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +2 -0
  113. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +2 -0
  114. opik/rest_api/types/automation_rule_evaluator_update.py +23 -1
  115. opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +2 -0
  116. opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
  117. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +2 -0
  118. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +2 -0
  119. opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +2 -0
  120. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +2 -0
  121. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +2 -0
  122. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +2 -0
  123. opik/rest_api/types/automation_rule_evaluator_write.py +23 -1
  124. opik/rest_api/types/boolean_feedback_definition.py +25 -0
  125. opik/rest_api/types/boolean_feedback_definition_create.py +20 -0
  126. opik/rest_api/types/boolean_feedback_definition_public.py +25 -0
  127. opik/rest_api/types/boolean_feedback_definition_update.py +20 -0
  128. opik/rest_api/types/boolean_feedback_detail.py +29 -0
  129. opik/rest_api/types/boolean_feedback_detail_create.py +29 -0
  130. opik/rest_api/types/boolean_feedback_detail_public.py +29 -0
  131. opik/rest_api/types/boolean_feedback_detail_update.py +29 -0
  132. opik/rest_api/types/dashboard_page_public.py +24 -0
  133. opik/rest_api/types/dashboard_public.py +30 -0
  134. opik/rest_api/types/dataset.py +2 -0
  135. opik/rest_api/types/dataset_item.py +2 -0
  136. opik/rest_api/types/dataset_item_compare.py +2 -0
  137. opik/rest_api/types/dataset_item_filter.py +23 -0
  138. opik/rest_api/types/dataset_item_filter_operator.py +21 -0
  139. opik/rest_api/types/dataset_item_page_compare.py +1 -0
  140. opik/rest_api/types/dataset_item_page_public.py +1 -0
  141. opik/rest_api/types/dataset_item_public.py +2 -0
  142. opik/rest_api/types/dataset_item_update.py +39 -0
  143. opik/rest_api/types/dataset_item_write.py +1 -0
  144. opik/rest_api/types/dataset_public.py +2 -0
  145. opik/rest_api/types/dataset_public_status.py +5 -0
  146. opik/rest_api/types/dataset_status.py +5 -0
  147. opik/rest_api/types/dataset_version_diff.py +22 -0
  148. opik/rest_api/types/dataset_version_diff_stats.py +24 -0
  149. opik/rest_api/types/dataset_version_page_public.py +23 -0
  150. opik/rest_api/types/dataset_version_public.py +49 -0
  151. opik/rest_api/types/experiment.py +2 -0
  152. opik/rest_api/types/experiment_public.py +2 -0
  153. opik/rest_api/types/experiment_score.py +20 -0
  154. opik/rest_api/types/experiment_score_public.py +20 -0
  155. opik/rest_api/types/experiment_score_write.py +20 -0
  156. opik/rest_api/types/feedback.py +20 -1
  157. opik/rest_api/types/feedback_create.py +16 -1
  158. opik/rest_api/types/feedback_object_public.py +22 -1
  159. opik/rest_api/types/feedback_public.py +20 -1
  160. opik/rest_api/types/feedback_score_public.py +4 -0
  161. opik/rest_api/types/feedback_update.py +16 -1
  162. opik/rest_api/types/image_url.py +20 -0
  163. opik/rest_api/types/image_url_public.py +20 -0
  164. opik/rest_api/types/image_url_write.py +20 -0
  165. opik/rest_api/types/llm_as_judge_message.py +5 -1
  166. opik/rest_api/types/llm_as_judge_message_content.py +24 -0
  167. opik/rest_api/types/llm_as_judge_message_content_public.py +24 -0
  168. opik/rest_api/types/llm_as_judge_message_content_write.py +24 -0
  169. opik/rest_api/types/llm_as_judge_message_public.py +5 -1
  170. opik/rest_api/types/llm_as_judge_message_write.py +5 -1
  171. opik/rest_api/types/llm_as_judge_model_parameters.py +2 -0
  172. opik/rest_api/types/llm_as_judge_model_parameters_public.py +2 -0
  173. opik/rest_api/types/llm_as_judge_model_parameters_write.py +2 -0
  174. opik/rest_api/types/optimization.py +2 -0
  175. opik/rest_api/types/optimization_public.py +2 -0
  176. opik/rest_api/types/optimization_public_status.py +3 -1
  177. opik/rest_api/types/optimization_status.py +3 -1
  178. opik/rest_api/types/optimization_studio_config.py +27 -0
  179. opik/rest_api/types/optimization_studio_config_public.py +27 -0
  180. opik/rest_api/types/optimization_studio_config_write.py +27 -0
  181. opik/rest_api/types/optimization_studio_log.py +22 -0
  182. opik/rest_api/types/optimization_write.py +2 -0
  183. opik/rest_api/types/optimization_write_status.py +3 -1
  184. opik/rest_api/types/prompt.py +6 -0
  185. opik/rest_api/types/prompt_detail.py +6 -0
  186. opik/rest_api/types/prompt_detail_template_structure.py +5 -0
  187. opik/rest_api/types/prompt_public.py +6 -0
  188. opik/rest_api/types/prompt_public_template_structure.py +5 -0
  189. opik/rest_api/types/prompt_template_structure.py +5 -0
  190. opik/rest_api/types/prompt_version.py +2 -0
  191. opik/rest_api/types/prompt_version_detail.py +2 -0
  192. opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
  193. opik/rest_api/types/prompt_version_public.py +2 -0
  194. opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
  195. opik/rest_api/types/prompt_version_template_structure.py +5 -0
  196. opik/rest_api/types/score_name.py +1 -0
  197. opik/rest_api/types/service_toggles_config.py +6 -0
  198. opik/rest_api/types/span_enrichment_options.py +31 -0
  199. opik/rest_api/types/span_filter.py +23 -0
  200. opik/rest_api/types/span_filter_operator.py +21 -0
  201. opik/rest_api/types/span_filter_write.py +23 -0
  202. opik/rest_api/types/span_filter_write_operator.py +21 -0
  203. opik/rest_api/types/span_llm_as_judge_code.py +27 -0
  204. opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
  205. opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
  206. opik/rest_api/types/span_update.py +46 -0
  207. opik/rest_api/types/studio_evaluation.py +20 -0
  208. opik/rest_api/types/studio_evaluation_public.py +20 -0
  209. opik/rest_api/types/studio_evaluation_write.py +20 -0
  210. opik/rest_api/types/studio_llm_model.py +21 -0
  211. opik/rest_api/types/studio_llm_model_public.py +21 -0
  212. opik/rest_api/types/studio_llm_model_write.py +21 -0
  213. opik/rest_api/types/studio_message.py +20 -0
  214. opik/rest_api/types/studio_message_public.py +20 -0
  215. opik/rest_api/types/studio_message_write.py +20 -0
  216. opik/rest_api/types/studio_metric.py +21 -0
  217. opik/rest_api/types/studio_metric_public.py +21 -0
  218. opik/rest_api/types/studio_metric_write.py +21 -0
  219. opik/rest_api/types/studio_optimizer.py +21 -0
  220. opik/rest_api/types/studio_optimizer_public.py +21 -0
  221. opik/rest_api/types/studio_optimizer_write.py +21 -0
  222. opik/rest_api/types/studio_prompt.py +20 -0
  223. opik/rest_api/types/studio_prompt_public.py +20 -0
  224. opik/rest_api/types/studio_prompt_write.py +20 -0
  225. opik/rest_api/types/trace.py +6 -0
  226. opik/rest_api/types/trace_public.py +6 -0
  227. opik/rest_api/types/trace_thread_filter_write.py +23 -0
  228. opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
  229. opik/rest_api/types/trace_thread_update.py +19 -0
  230. opik/rest_api/types/trace_update.py +39 -0
  231. opik/rest_api/types/value_entry.py +2 -0
  232. opik/rest_api/types/value_entry_compare.py +2 -0
  233. opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +2 -0
  234. opik/rest_api/types/value_entry_public.py +2 -0
  235. opik/rest_api/types/video_url.py +19 -0
  236. opik/rest_api/types/video_url_public.py +19 -0
  237. opik/rest_api/types/video_url_write.py +19 -0
  238. opik/synchronization.py +5 -6
  239. opik/{decorator/tracing_runtime_config.py → tracing_runtime_config.py} +6 -7
  240. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/METADATA +5 -4
  241. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/RECORD +246 -151
  242. opik/api_objects/prompt/chat_prompt_template.py +0 -164
  243. opik/api_objects/prompt/prompt.py +0 -131
  244. /opik/rest_api/{spans/types → types}/span_update_type.py +0 -0
  245. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/WHEEL +0 -0
  246. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/entry_points.txt +0 -0
  247. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/licenses/LICENSE +0 -0
  248. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/top_level.txt +0 -0
@@ -28,6 +28,8 @@ from ..types.project_stats_public import ProjectStatsPublic
28
28
  from ..types.span_filter_public import SpanFilterPublic
29
29
  from ..types.span_page_public import SpanPagePublic
30
30
  from ..types.span_public import SpanPublic
31
+ from ..types.span_update import SpanUpdate
32
+ from ..types.span_update_type import SpanUpdateType
31
33
  from ..types.span_write import SpanWrite
32
34
  from ..types.span_write_type import SpanWriteType
33
35
  from ..types.value_entry import ValueEntry
@@ -35,7 +37,6 @@ from .types.find_feedback_score_names_1_request_type import FindFeedbackScoreNam
35
37
  from .types.get_span_stats_request_type import GetSpanStatsRequestType
36
38
  from .types.get_spans_by_project_request_type import GetSpansByProjectRequestType
37
39
  from .types.span_search_stream_request_public_type import SpanSearchStreamRequestPublicType
38
- from .types.span_update_type import SpanUpdateType
39
40
 
40
41
  # this is used as the default value for optional parameters
41
42
  OMIT = typing.cast(typing.Any, ...)
@@ -189,6 +190,108 @@ class RawSpansClient:
189
190
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
190
191
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
191
192
 
193
+ def create_spans(
194
+ self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
195
+ ) -> HttpResponse[None]:
196
+ """
197
+ Create spans
198
+
199
+ Parameters
200
+ ----------
201
+ spans : typing.Sequence[SpanWrite]
202
+
203
+ request_options : typing.Optional[RequestOptions]
204
+ Request-specific configuration.
205
+
206
+ Returns
207
+ -------
208
+ HttpResponse[None]
209
+ """
210
+ _response = self._client_wrapper.httpx_client.request(
211
+ "v1/private/spans/batch",
212
+ method="POST",
213
+ json={
214
+ "spans": convert_and_respect_annotation_metadata(
215
+ object_=spans, annotation=typing.Sequence[SpanWrite], direction="write"
216
+ ),
217
+ },
218
+ headers={
219
+ "content-type": "application/json",
220
+ },
221
+ request_options=request_options,
222
+ omit=OMIT,
223
+ )
224
+ try:
225
+ if 200 <= _response.status_code < 300:
226
+ return HttpResponse(response=_response, data=None)
227
+ _response_json = _response.json()
228
+ except JSONDecodeError:
229
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
230
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
231
+
232
+ def batch_update_spans(
233
+ self,
234
+ *,
235
+ ids: typing.Sequence[str],
236
+ update: SpanUpdate,
237
+ merge_tags: typing.Optional[bool] = OMIT,
238
+ request_options: typing.Optional[RequestOptions] = None,
239
+ ) -> HttpResponse[None]:
240
+ """
241
+ Update multiple spans
242
+
243
+ Parameters
244
+ ----------
245
+ ids : typing.Sequence[str]
246
+ List of span IDs to update (max 1000)
247
+
248
+ update : SpanUpdate
249
+
250
+ merge_tags : typing.Optional[bool]
251
+ If true, merge tags with existing tags instead of replacing them. Default: false
252
+
253
+ request_options : typing.Optional[RequestOptions]
254
+ Request-specific configuration.
255
+
256
+ Returns
257
+ -------
258
+ HttpResponse[None]
259
+ """
260
+ _response = self._client_wrapper.httpx_client.request(
261
+ "v1/private/spans/batch",
262
+ method="PATCH",
263
+ json={
264
+ "ids": ids,
265
+ "update": convert_and_respect_annotation_metadata(
266
+ object_=update, annotation=SpanUpdate, direction="write"
267
+ ),
268
+ "merge_tags": merge_tags,
269
+ },
270
+ headers={
271
+ "content-type": "application/json",
272
+ },
273
+ request_options=request_options,
274
+ omit=OMIT,
275
+ )
276
+ try:
277
+ if 200 <= _response.status_code < 300:
278
+ return HttpResponse(response=_response, data=None)
279
+ if _response.status_code == 400:
280
+ raise BadRequestError(
281
+ headers=dict(_response.headers),
282
+ body=typing.cast(
283
+ typing.Optional[typing.Any],
284
+ parse_obj_as(
285
+ type_=typing.Optional[typing.Any], # type: ignore
286
+ object_=_response.json(),
287
+ ),
288
+ ),
289
+ )
290
+ _response_json = _response.json()
291
+ except JSONDecodeError:
292
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
293
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
294
+
192
295
  def get_spans_by_project(
193
296
  self,
194
297
  *,
@@ -413,45 +516,6 @@ class RawSpansClient:
413
516
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
414
517
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
415
518
 
416
- def create_spans(
417
- self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
418
- ) -> HttpResponse[None]:
419
- """
420
- Create spans
421
-
422
- Parameters
423
- ----------
424
- spans : typing.Sequence[SpanWrite]
425
-
426
- request_options : typing.Optional[RequestOptions]
427
- Request-specific configuration.
428
-
429
- Returns
430
- -------
431
- HttpResponse[None]
432
- """
433
- _response = self._client_wrapper.httpx_client.request(
434
- "v1/private/spans/batch",
435
- method="POST",
436
- json={
437
- "spans": convert_and_respect_annotation_metadata(
438
- object_=spans, annotation=typing.Sequence[SpanWrite], direction="write"
439
- ),
440
- },
441
- headers={
442
- "content-type": "application/json",
443
- },
444
- request_options=request_options,
445
- omit=OMIT,
446
- )
447
- try:
448
- if 200 <= _response.status_code < 300:
449
- return HttpResponse(response=_response, data=None)
450
- _response_json = _response.json()
451
- except JSONDecodeError:
452
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
453
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
454
-
455
519
  def get_span_by_id(
456
520
  self,
457
521
  id: str,
@@ -1008,10 +1072,10 @@ class RawSpansClient:
1008
1072
  Truncate image included in either input, output or metadata
1009
1073
 
1010
1074
  from_time : typing.Optional[dt.datetime]
1011
- Filter spans created from this time (ISO-8601 format). Must be provided together with 'to_time'.
1075
+ Filter spans created from this time (ISO-8601 format).
1012
1076
 
1013
1077
  to_time : typing.Optional[dt.datetime]
1014
- Filter spans created up to this time (ISO-8601 format). Must be provided together with 'from_time' and must be after 'from_time'.
1078
+ Filter spans created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
1015
1079
 
1016
1080
  request_options : typing.Optional[RequestOptions]
1017
1081
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -1296,6 +1360,108 @@ class AsyncRawSpansClient:
1296
1360
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1297
1361
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1298
1362
 
1363
+ async def create_spans(
1364
+ self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
1365
+ ) -> AsyncHttpResponse[None]:
1366
+ """
1367
+ Create spans
1368
+
1369
+ Parameters
1370
+ ----------
1371
+ spans : typing.Sequence[SpanWrite]
1372
+
1373
+ request_options : typing.Optional[RequestOptions]
1374
+ Request-specific configuration.
1375
+
1376
+ Returns
1377
+ -------
1378
+ AsyncHttpResponse[None]
1379
+ """
1380
+ _response = await self._client_wrapper.httpx_client.request(
1381
+ "v1/private/spans/batch",
1382
+ method="POST",
1383
+ json={
1384
+ "spans": convert_and_respect_annotation_metadata(
1385
+ object_=spans, annotation=typing.Sequence[SpanWrite], direction="write"
1386
+ ),
1387
+ },
1388
+ headers={
1389
+ "content-type": "application/json",
1390
+ },
1391
+ request_options=request_options,
1392
+ omit=OMIT,
1393
+ )
1394
+ try:
1395
+ if 200 <= _response.status_code < 300:
1396
+ return AsyncHttpResponse(response=_response, data=None)
1397
+ _response_json = _response.json()
1398
+ except JSONDecodeError:
1399
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1400
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1401
+
1402
+ async def batch_update_spans(
1403
+ self,
1404
+ *,
1405
+ ids: typing.Sequence[str],
1406
+ update: SpanUpdate,
1407
+ merge_tags: typing.Optional[bool] = OMIT,
1408
+ request_options: typing.Optional[RequestOptions] = None,
1409
+ ) -> AsyncHttpResponse[None]:
1410
+ """
1411
+ Update multiple spans
1412
+
1413
+ Parameters
1414
+ ----------
1415
+ ids : typing.Sequence[str]
1416
+ List of span IDs to update (max 1000)
1417
+
1418
+ update : SpanUpdate
1419
+
1420
+ merge_tags : typing.Optional[bool]
1421
+ If true, merge tags with existing tags instead of replacing them. Default: false
1422
+
1423
+ request_options : typing.Optional[RequestOptions]
1424
+ Request-specific configuration.
1425
+
1426
+ Returns
1427
+ -------
1428
+ AsyncHttpResponse[None]
1429
+ """
1430
+ _response = await self._client_wrapper.httpx_client.request(
1431
+ "v1/private/spans/batch",
1432
+ method="PATCH",
1433
+ json={
1434
+ "ids": ids,
1435
+ "update": convert_and_respect_annotation_metadata(
1436
+ object_=update, annotation=SpanUpdate, direction="write"
1437
+ ),
1438
+ "merge_tags": merge_tags,
1439
+ },
1440
+ headers={
1441
+ "content-type": "application/json",
1442
+ },
1443
+ request_options=request_options,
1444
+ omit=OMIT,
1445
+ )
1446
+ try:
1447
+ if 200 <= _response.status_code < 300:
1448
+ return AsyncHttpResponse(response=_response, data=None)
1449
+ if _response.status_code == 400:
1450
+ raise BadRequestError(
1451
+ headers=dict(_response.headers),
1452
+ body=typing.cast(
1453
+ typing.Optional[typing.Any],
1454
+ parse_obj_as(
1455
+ type_=typing.Optional[typing.Any], # type: ignore
1456
+ object_=_response.json(),
1457
+ ),
1458
+ ),
1459
+ )
1460
+ _response_json = _response.json()
1461
+ except JSONDecodeError:
1462
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1463
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1464
+
1299
1465
  async def get_spans_by_project(
1300
1466
  self,
1301
1467
  *,
@@ -1520,45 +1686,6 @@ class AsyncRawSpansClient:
1520
1686
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1521
1687
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1522
1688
 
1523
- async def create_spans(
1524
- self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
1525
- ) -> AsyncHttpResponse[None]:
1526
- """
1527
- Create spans
1528
-
1529
- Parameters
1530
- ----------
1531
- spans : typing.Sequence[SpanWrite]
1532
-
1533
- request_options : typing.Optional[RequestOptions]
1534
- Request-specific configuration.
1535
-
1536
- Returns
1537
- -------
1538
- AsyncHttpResponse[None]
1539
- """
1540
- _response = await self._client_wrapper.httpx_client.request(
1541
- "v1/private/spans/batch",
1542
- method="POST",
1543
- json={
1544
- "spans": convert_and_respect_annotation_metadata(
1545
- object_=spans, annotation=typing.Sequence[SpanWrite], direction="write"
1546
- ),
1547
- },
1548
- headers={
1549
- "content-type": "application/json",
1550
- },
1551
- request_options=request_options,
1552
- omit=OMIT,
1553
- )
1554
- try:
1555
- if 200 <= _response.status_code < 300:
1556
- return AsyncHttpResponse(response=_response, data=None)
1557
- _response_json = _response.json()
1558
- except JSONDecodeError:
1559
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1560
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1561
-
1562
1689
  async def get_span_by_id(
1563
1690
  self,
1564
1691
  id: str,
@@ -2115,10 +2242,10 @@ class AsyncRawSpansClient:
2115
2242
  Truncate image included in either input, output or metadata
2116
2243
 
2117
2244
  from_time : typing.Optional[dt.datetime]
2118
- Filter spans created from this time (ISO-8601 format). Must be provided together with 'to_time'.
2245
+ Filter spans created from this time (ISO-8601 format).
2119
2246
 
2120
2247
  to_time : typing.Optional[dt.datetime]
2121
- Filter spans created up to this time (ISO-8601 format). Must be provided together with 'from_time' and must be after 'from_time'.
2248
+ Filter spans created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
2122
2249
 
2123
2250
  request_options : typing.Optional[RequestOptions]
2124
2251
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -6,12 +6,10 @@ from .find_feedback_score_names_1_request_type import FindFeedbackScoreNames1Req
6
6
  from .get_span_stats_request_type import GetSpanStatsRequestType
7
7
  from .get_spans_by_project_request_type import GetSpansByProjectRequestType
8
8
  from .span_search_stream_request_public_type import SpanSearchStreamRequestPublicType
9
- from .span_update_type import SpanUpdateType
10
9
 
11
10
  __all__ = [
12
11
  "FindFeedbackScoreNames1RequestType",
13
12
  "GetSpanStatsRequestType",
14
13
  "GetSpansByProjectRequestType",
15
14
  "SpanSearchStreamRequestPublicType",
16
- "SpanUpdateType",
17
15
  ]