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,29 +1,30 @@
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
12
+ from ..types.feedback_score_batch_item_thread import FeedbackScoreBatchItemThread
10
13
  from ..types.feedback_score_source import FeedbackScoreSource
14
+ from ..types.json_list_string import JsonListString
15
+ from ..types.json_list_string_write import JsonListStringWrite
16
+ from ..types.project_stats_public import ProjectStatsPublic
17
+ from ..types.trace_filter_public import TraceFilterPublic
11
18
  from ..types.trace_page_public import TracePagePublic
12
- from ..core.pydantic_utilities import parse_obj_as
13
- from ..types.json_node_write import JsonNodeWrite
14
- from ..types.error_info_write import ErrorInfoWrite
15
- from ..core.serialization import convert_and_respect_annotation_metadata
16
- from ..types.trace_write import TraceWrite
17
19
  from ..types.trace_public import TracePublic
18
- from ..types.json_node import JsonNode
19
- from ..types.error_info import ErrorInfo
20
- from ..types.project_stats_public import ProjectStatsPublic
21
- from ..types.comment import Comment
22
- from ..errors.not_found_error import NotFoundError
23
20
  from ..types.trace_thread import TraceThread
21
+ from ..types.trace_thread_filter import TraceThreadFilter
24
22
  from ..types.trace_thread_page import TraceThreadPage
25
- from ..types.feedback_score_batch_item import FeedbackScoreBatchItem
26
- from ..core.client_wrapper import AsyncClientWrapper
23
+ from ..types.trace_thread_update import TraceThreadUpdate
24
+ from ..types.trace_update import TraceUpdate
25
+ from ..types.trace_write import TraceWrite
26
+ from ..types.value_entry import ValueEntry
27
+ from .raw_client import AsyncRawTracesClient, RawTracesClient
27
28
 
28
29
  # this is used as the default value for optional parameters
29
30
  OMIT = typing.cast(typing.Any, ...)
@@ -31,9 +32,20 @@ OMIT = typing.cast(typing.Any, ...)
31
32
 
32
33
  class TracesClient:
33
34
  def __init__(self, *, client_wrapper: SyncClientWrapper):
34
- self._client_wrapper = client_wrapper
35
+ self._raw_client = RawTracesClient(client_wrapper=client_wrapper)
35
36
 
36
- def add_trace_comment(
37
+ @property
38
+ def with_raw_response(self) -> RawTracesClient:
39
+ """
40
+ Retrieves a raw implementation of this client that returns raw responses.
41
+
42
+ Returns
43
+ -------
44
+ RawTracesClient
45
+ """
46
+ return self._raw_client
47
+
48
+ def add_thread_comment(
37
49
  self,
38
50
  id_: str,
39
51
  *,
@@ -46,7 +58,7 @@ class TracesClient:
46
58
  request_options: typing.Optional[RequestOptions] = None,
47
59
  ) -> None:
48
60
  """
49
- Add trace comment
61
+ Add thread comment
50
62
 
51
63
  Parameters
52
64
  ----------
@@ -74,37 +86,76 @@ class TracesClient:
74
86
  Examples
75
87
  --------
76
88
  from Opik import OpikApi
77
-
78
- client = OpikApi(
79
- api_key="YOUR_API_KEY",
80
- workspace_name="YOUR_WORKSPACE_NAME",
81
- )
82
- client.traces.add_trace_comment(
83
- id_="id",
84
- text="text",
89
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
90
+ client.traces.add_thread_comment(id_='id', text='text', )
91
+ """
92
+ _response = self._raw_client.add_thread_comment(
93
+ id_,
94
+ text=text,
95
+ id=id,
96
+ created_at=created_at,
97
+ last_updated_at=last_updated_at,
98
+ created_by=created_by,
99
+ last_updated_by=last_updated_by,
100
+ request_options=request_options,
85
101
  )
102
+ return _response.data
103
+
104
+ def add_trace_comment(
105
+ self,
106
+ id_: str,
107
+ *,
108
+ text: str,
109
+ id: typing.Optional[str] = OMIT,
110
+ created_at: typing.Optional[dt.datetime] = OMIT,
111
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
112
+ created_by: typing.Optional[str] = OMIT,
113
+ last_updated_by: typing.Optional[str] = OMIT,
114
+ request_options: typing.Optional[RequestOptions] = None,
115
+ ) -> None:
86
116
  """
87
- _response = self._client_wrapper.httpx_client.request(
88
- f"v1/private/traces/{jsonable_encoder(id_)}/comments",
89
- method="POST",
90
- json={
91
- "id": id,
92
- "text": text,
93
- "created_at": created_at,
94
- "last_updated_at": last_updated_at,
95
- "created_by": created_by,
96
- "last_updated_by": last_updated_by,
97
- },
117
+ Add trace comment
118
+
119
+ Parameters
120
+ ----------
121
+ id_ : str
122
+
123
+ text : str
124
+
125
+ id : typing.Optional[str]
126
+
127
+ created_at : typing.Optional[dt.datetime]
128
+
129
+ last_updated_at : typing.Optional[dt.datetime]
130
+
131
+ created_by : typing.Optional[str]
132
+
133
+ last_updated_by : typing.Optional[str]
134
+
135
+ request_options : typing.Optional[RequestOptions]
136
+ Request-specific configuration.
137
+
138
+ Returns
139
+ -------
140
+ None
141
+
142
+ Examples
143
+ --------
144
+ from Opik import OpikApi
145
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
146
+ client.traces.add_trace_comment(id_='id', text='text', )
147
+ """
148
+ _response = self._raw_client.add_trace_comment(
149
+ id_,
150
+ text=text,
151
+ id=id,
152
+ created_at=created_at,
153
+ last_updated_at=last_updated_at,
154
+ created_by=created_by,
155
+ last_updated_by=last_updated_by,
98
156
  request_options=request_options,
99
- omit=OMIT,
100
157
  )
101
- try:
102
- if 200 <= _response.status_code < 300:
103
- return
104
- _response_json = _response.json()
105
- except JSONDecodeError:
106
- raise ApiError(status_code=_response.status_code, body=_response.text)
107
- raise ApiError(status_code=_response.status_code, body=_response_json)
158
+ return _response.data
108
159
 
109
160
  def add_trace_feedback_score(
110
161
  self,
@@ -119,6 +170,7 @@ class TracesClient:
119
170
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
120
171
  created_by: typing.Optional[str] = OMIT,
121
172
  last_updated_by: typing.Optional[str] = OMIT,
173
+ value_by_author: typing.Optional[typing.Dict[str, ValueEntry]] = OMIT,
122
174
  request_options: typing.Optional[RequestOptions] = None,
123
175
  ) -> None:
124
176
  """
@@ -146,6 +198,47 @@ class TracesClient:
146
198
 
147
199
  last_updated_by : typing.Optional[str]
148
200
 
201
+ value_by_author : typing.Optional[typing.Dict[str, ValueEntry]]
202
+
203
+ request_options : typing.Optional[RequestOptions]
204
+ Request-specific configuration.
205
+
206
+ Returns
207
+ -------
208
+ None
209
+
210
+ Examples
211
+ --------
212
+ from Opik import OpikApi
213
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
214
+ client.traces.add_trace_feedback_score(id='id', name='name', value=1.1, source="ui", )
215
+ """
216
+ _response = self._raw_client.add_trace_feedback_score(
217
+ id,
218
+ name=name,
219
+ value=value,
220
+ source=source,
221
+ category_name=category_name,
222
+ reason=reason,
223
+ created_at=created_at,
224
+ last_updated_at=last_updated_at,
225
+ created_by=created_by,
226
+ last_updated_by=last_updated_by,
227
+ value_by_author=value_by_author,
228
+ request_options=request_options,
229
+ )
230
+ return _response.data
231
+
232
+ def create_traces(
233
+ self, *, traces: typing.Sequence[TraceWrite], request_options: typing.Optional[RequestOptions] = None
234
+ ) -> None:
235
+ """
236
+ Create traces
237
+
238
+ Parameters
239
+ ----------
240
+ traces : typing.Sequence[TraceWrite]
241
+
149
242
  request_options : typing.Optional[RequestOptions]
150
243
  Request-specific configuration.
151
244
 
@@ -156,42 +249,137 @@ class TracesClient:
156
249
  Examples
157
250
  --------
158
251
  from Opik import OpikApi
252
+ from Opik import TraceWrite
253
+ import datetime
254
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
255
+ client.traces.create_traces(traces=[TraceWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
256
+ """
257
+ _response = self._raw_client.create_traces(traces=traces, request_options=request_options)
258
+ return _response.data
259
+
260
+ def batch_update_traces(
261
+ self,
262
+ *,
263
+ ids: typing.Sequence[str],
264
+ update: TraceUpdate,
265
+ merge_tags: typing.Optional[bool] = OMIT,
266
+ request_options: typing.Optional[RequestOptions] = None,
267
+ ) -> None:
268
+ """
269
+ Update multiple traces
270
+
271
+ Parameters
272
+ ----------
273
+ ids : typing.Sequence[str]
274
+ List of trace IDs to update (max 1000)
275
+
276
+ update : TraceUpdate
277
+
278
+ merge_tags : typing.Optional[bool]
279
+ If true, merge tags with existing tags instead of replacing them. Default: false
280
+
281
+ request_options : typing.Optional[RequestOptions]
282
+ Request-specific configuration.
283
+
284
+ Returns
285
+ -------
286
+ None
159
287
 
160
- client = OpikApi(
161
- api_key="YOUR_API_KEY",
162
- workspace_name="YOUR_WORKSPACE_NAME",
288
+ Examples
289
+ --------
290
+ from Opik import OpikApi
291
+ from Opik import TraceUpdate
292
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
293
+ client.traces.batch_update_traces(ids=['ids'], update=TraceUpdate(), )
294
+ """
295
+ _response = self._raw_client.batch_update_traces(
296
+ ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
163
297
  )
164
- client.traces.add_trace_feedback_score(
165
- id="id",
166
- name="name",
167
- value=1.1,
168
- source="ui",
298
+ return _response.data
299
+
300
+ def batch_update_threads(
301
+ self,
302
+ *,
303
+ ids: typing.Sequence[str],
304
+ update: TraceThreadUpdate,
305
+ merge_tags: typing.Optional[bool] = OMIT,
306
+ request_options: typing.Optional[RequestOptions] = None,
307
+ ) -> None:
308
+ """
309
+ Update multiple threads
310
+
311
+ Parameters
312
+ ----------
313
+ ids : typing.Sequence[str]
314
+ List of thread model IDs to update (max 1000)
315
+
316
+ update : TraceThreadUpdate
317
+
318
+ merge_tags : typing.Optional[bool]
319
+ If true, merge tags with existing tags instead of replacing them. Default: false
320
+
321
+ request_options : typing.Optional[RequestOptions]
322
+ Request-specific configuration.
323
+
324
+ Returns
325
+ -------
326
+ None
327
+
328
+ Examples
329
+ --------
330
+ from Opik import OpikApi
331
+ from Opik import TraceThreadUpdate
332
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
333
+ client.traces.batch_update_threads(ids=['ids'], update=TraceThreadUpdate(), )
334
+ """
335
+ _response = self._raw_client.batch_update_threads(
336
+ ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
169
337
  )
338
+ return _response.data
339
+
340
+ def close_trace_thread(
341
+ self,
342
+ *,
343
+ project_name: typing.Optional[str] = OMIT,
344
+ project_id: typing.Optional[str] = OMIT,
345
+ thread_id: typing.Optional[str] = OMIT,
346
+ thread_ids: typing.Optional[typing.Sequence[str]] = OMIT,
347
+ request_options: typing.Optional[RequestOptions] = None,
348
+ ) -> None:
170
349
  """
171
- _response = self._client_wrapper.httpx_client.request(
172
- f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores",
173
- method="PUT",
174
- json={
175
- "name": name,
176
- "category_name": category_name,
177
- "value": value,
178
- "reason": reason,
179
- "source": source,
180
- "created_at": created_at,
181
- "last_updated_at": last_updated_at,
182
- "created_by": created_by,
183
- "last_updated_by": last_updated_by,
184
- },
350
+ Close one or multiple trace threads. Supports both single thread_id and multiple thread_ids for batch operations.
351
+
352
+ Parameters
353
+ ----------
354
+ project_name : typing.Optional[str]
355
+
356
+ project_id : typing.Optional[str]
357
+
358
+ thread_id : typing.Optional[str]
359
+
360
+ thread_ids : typing.Optional[typing.Sequence[str]]
361
+
362
+ request_options : typing.Optional[RequestOptions]
363
+ Request-specific configuration.
364
+
365
+ Returns
366
+ -------
367
+ None
368
+
369
+ Examples
370
+ --------
371
+ from Opik import OpikApi
372
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
373
+ client.traces.close_trace_thread()
374
+ """
375
+ _response = self._raw_client.close_trace_thread(
376
+ project_name=project_name,
377
+ project_id=project_id,
378
+ thread_id=thread_id,
379
+ thread_ids=thread_ids,
185
380
  request_options=request_options,
186
- omit=OMIT,
187
381
  )
188
- try:
189
- if 200 <= _response.status_code < 300:
190
- return
191
- _response_json = _response.json()
192
- except JSONDecodeError:
193
- raise ApiError(status_code=_response.status_code, body=_response.text)
194
- raise ApiError(status_code=_response.status_code, body=_response_json)
382
+ return _response.data
195
383
 
196
384
  def get_traces_by_project(
197
385
  self,
@@ -202,7 +390,11 @@ class TracesClient:
202
390
  project_id: typing.Optional[str] = None,
203
391
  filters: typing.Optional[str] = None,
204
392
  truncate: typing.Optional[bool] = None,
393
+ strip_attachments: typing.Optional[bool] = None,
205
394
  sorting: typing.Optional[str] = None,
395
+ exclude: typing.Optional[str] = None,
396
+ from_time: typing.Optional[dt.datetime] = None,
397
+ to_time: typing.Optional[dt.datetime] = None,
206
398
  request_options: typing.Optional[RequestOptions] = None,
207
399
  ) -> TracePagePublic:
208
400
  """
@@ -222,8 +414,16 @@ class TracesClient:
222
414
 
223
415
  truncate : typing.Optional[bool]
224
416
 
417
+ strip_attachments : typing.Optional[bool]
418
+
225
419
  sorting : typing.Optional[str]
226
420
 
421
+ exclude : typing.Optional[str]
422
+
423
+ from_time : typing.Optional[dt.datetime]
424
+
425
+ to_time : typing.Optional[dt.datetime]
426
+
227
427
  request_options : typing.Optional[RequestOptions]
228
428
  Request-specific configuration.
229
429
 
@@ -235,54 +435,39 @@ class TracesClient:
235
435
  Examples
236
436
  --------
237
437
  from Opik import OpikApi
238
-
239
- client = OpikApi(
240
- api_key="YOUR_API_KEY",
241
- workspace_name="YOUR_WORKSPACE_NAME",
242
- )
438
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
243
439
  client.traces.get_traces_by_project()
244
440
  """
245
- _response = self._client_wrapper.httpx_client.request(
246
- "v1/private/traces",
247
- method="GET",
248
- params={
249
- "page": page,
250
- "size": size,
251
- "project_name": project_name,
252
- "project_id": project_id,
253
- "filters": filters,
254
- "truncate": truncate,
255
- "sorting": sorting,
256
- },
441
+ _response = self._raw_client.get_traces_by_project(
442
+ page=page,
443
+ size=size,
444
+ project_name=project_name,
445
+ project_id=project_id,
446
+ filters=filters,
447
+ truncate=truncate,
448
+ strip_attachments=strip_attachments,
449
+ sorting=sorting,
450
+ exclude=exclude,
451
+ from_time=from_time,
452
+ to_time=to_time,
257
453
  request_options=request_options,
258
454
  )
259
- try:
260
- if 200 <= _response.status_code < 300:
261
- return typing.cast(
262
- TracePagePublic,
263
- parse_obj_as(
264
- type_=TracePagePublic, # type: ignore
265
- object_=_response.json(),
266
- ),
267
- )
268
- _response_json = _response.json()
269
- except JSONDecodeError:
270
- raise ApiError(status_code=_response.status_code, body=_response.text)
271
- raise ApiError(status_code=_response.status_code, body=_response_json)
455
+ return _response.data
272
456
 
273
457
  def create_trace(
274
458
  self,
275
459
  *,
276
- name: str,
277
460
  start_time: dt.datetime,
278
461
  id: typing.Optional[str] = OMIT,
279
462
  project_name: typing.Optional[str] = OMIT,
463
+ name: typing.Optional[str] = OMIT,
280
464
  end_time: typing.Optional[dt.datetime] = OMIT,
281
- input: typing.Optional[JsonNodeWrite] = OMIT,
282
- output: typing.Optional[JsonNodeWrite] = OMIT,
283
- metadata: typing.Optional[JsonNodeWrite] = OMIT,
465
+ input: typing.Optional[JsonListStringWrite] = OMIT,
466
+ output: typing.Optional[JsonListStringWrite] = OMIT,
467
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
284
468
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
285
469
  error_info: typing.Optional[ErrorInfoWrite] = OMIT,
470
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
286
471
  thread_id: typing.Optional[str] = OMIT,
287
472
  request_options: typing.Optional[RequestOptions] = None,
288
473
  ) -> None:
@@ -291,8 +476,6 @@ class TracesClient:
291
476
 
292
477
  Parameters
293
478
  ----------
294
- name : str
295
-
296
479
  start_time : dt.datetime
297
480
 
298
481
  id : typing.Optional[str]
@@ -300,18 +483,22 @@ class TracesClient:
300
483
  project_name : typing.Optional[str]
301
484
  If null, the default project is used
302
485
 
486
+ name : typing.Optional[str]
487
+
303
488
  end_time : typing.Optional[dt.datetime]
304
489
 
305
- input : typing.Optional[JsonNodeWrite]
490
+ input : typing.Optional[JsonListStringWrite]
306
491
 
307
- output : typing.Optional[JsonNodeWrite]
492
+ output : typing.Optional[JsonListStringWrite]
308
493
 
309
- metadata : typing.Optional[JsonNodeWrite]
494
+ metadata : typing.Optional[JsonListStringWrite]
310
495
 
311
496
  tags : typing.Optional[typing.Sequence[str]]
312
497
 
313
498
  error_info : typing.Optional[ErrorInfoWrite]
314
499
 
500
+ last_updated_at : typing.Optional[dt.datetime]
501
+
315
502
  thread_id : typing.Optional[str]
316
503
 
317
504
  request_options : typing.Optional[RequestOptions]
@@ -323,117 +510,34 @@ class TracesClient:
323
510
 
324
511
  Examples
325
512
  --------
326
- import datetime
327
-
328
513
  from Opik import OpikApi
329
-
330
- client = OpikApi(
331
- api_key="YOUR_API_KEY",
332
- workspace_name="YOUR_WORKSPACE_NAME",
333
- )
334
- client.traces.create_trace(
335
- name="name",
336
- start_time=datetime.datetime.fromisoformat(
337
- "2024-01-15 09:30:00+00:00",
338
- ),
339
- )
340
- """
341
- _response = self._client_wrapper.httpx_client.request(
342
- "v1/private/traces",
343
- method="POST",
344
- json={
345
- "id": id,
346
- "project_name": project_name,
347
- "name": name,
348
- "start_time": start_time,
349
- "end_time": end_time,
350
- "input": input,
351
- "output": output,
352
- "metadata": metadata,
353
- "tags": tags,
354
- "error_info": convert_and_respect_annotation_metadata(
355
- object_=error_info, annotation=ErrorInfoWrite, direction="write"
356
- ),
357
- "thread_id": thread_id,
358
- },
514
+ import datetime
515
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
516
+ client.traces.create_trace(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )
517
+ """
518
+ _response = self._raw_client.create_trace(
519
+ start_time=start_time,
520
+ id=id,
521
+ project_name=project_name,
522
+ name=name,
523
+ end_time=end_time,
524
+ input=input,
525
+ output=output,
526
+ metadata=metadata,
527
+ tags=tags,
528
+ error_info=error_info,
529
+ last_updated_at=last_updated_at,
530
+ thread_id=thread_id,
359
531
  request_options=request_options,
360
- omit=OMIT,
361
532
  )
362
- try:
363
- if 200 <= _response.status_code < 300:
364
- return
365
- _response_json = _response.json()
366
- except JSONDecodeError:
367
- raise ApiError(status_code=_response.status_code, body=_response.text)
368
- raise ApiError(status_code=_response.status_code, body=_response_json)
533
+ return _response.data
369
534
 
370
- def create_traces(
535
+ def get_trace_by_id(
371
536
  self,
537
+ id: str,
372
538
  *,
373
- traces: typing.Sequence[TraceWrite],
539
+ strip_attachments: typing.Optional[bool] = None,
374
540
  request_options: typing.Optional[RequestOptions] = None,
375
- ) -> None:
376
- """
377
- Create traces
378
-
379
- Parameters
380
- ----------
381
- traces : typing.Sequence[TraceWrite]
382
-
383
- request_options : typing.Optional[RequestOptions]
384
- Request-specific configuration.
385
-
386
- Returns
387
- -------
388
- None
389
-
390
- Examples
391
- --------
392
- import datetime
393
-
394
- from Opik import OpikApi, TraceWrite
395
-
396
- client = OpikApi(
397
- api_key="YOUR_API_KEY",
398
- workspace_name="YOUR_WORKSPACE_NAME",
399
- )
400
- client.traces.create_traces(
401
- traces=[
402
- TraceWrite(
403
- name="name",
404
- start_time=datetime.datetime.fromisoformat(
405
- "2024-01-15 09:30:00+00:00",
406
- ),
407
- )
408
- ],
409
- )
410
- """
411
- _response = self._client_wrapper.httpx_client.request(
412
- "v1/private/traces/batch",
413
- method="POST",
414
- json={
415
- "traces": convert_and_respect_annotation_metadata(
416
- object_=traces,
417
- annotation=typing.Sequence[TraceWrite],
418
- direction="write",
419
- ),
420
- },
421
- headers={
422
- "content-type": "application/json",
423
- },
424
- request_options=request_options,
425
- omit=OMIT,
426
- )
427
- try:
428
- if 200 <= _response.status_code < 300:
429
- return
430
- _response_json = _response.json()
431
- except JSONDecodeError:
432
- raise ApiError(status_code=_response.status_code, body=_response.text)
433
- raise ApiError(status_code=_response.status_code, body=_response_json)
434
-
435
- def get_trace_by_id(
436
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
437
541
  ) -> TracePublic:
438
542
  """
439
543
  Get trace by id
@@ -442,6 +546,8 @@ class TracesClient:
442
546
  ----------
443
547
  id : str
444
548
 
549
+ strip_attachments : typing.Optional[bool]
550
+
445
551
  request_options : typing.Optional[RequestOptions]
446
552
  Request-specific configuration.
447
553
 
@@ -453,37 +559,15 @@ class TracesClient:
453
559
  Examples
454
560
  --------
455
561
  from Opik import OpikApi
456
-
457
- client = OpikApi(
458
- api_key="YOUR_API_KEY",
459
- workspace_name="YOUR_WORKSPACE_NAME",
460
- )
461
- client.traces.get_trace_by_id(
462
- id="id",
463
- )
562
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
563
+ client.traces.get_trace_by_id(id='id', )
464
564
  """
465
- _response = self._client_wrapper.httpx_client.request(
466
- f"v1/private/traces/{jsonable_encoder(id)}",
467
- method="GET",
468
- request_options=request_options,
565
+ _response = self._raw_client.get_trace_by_id(
566
+ id, strip_attachments=strip_attachments, request_options=request_options
469
567
  )
470
- try:
471
- if 200 <= _response.status_code < 300:
472
- return typing.cast(
473
- TracePublic,
474
- parse_obj_as(
475
- type_=TracePublic, # type: ignore
476
- object_=_response.json(),
477
- ),
478
- )
479
- _response_json = _response.json()
480
- except JSONDecodeError:
481
- raise ApiError(status_code=_response.status_code, body=_response.text)
482
- raise ApiError(status_code=_response.status_code, body=_response_json)
483
-
484
- def delete_trace_by_id(
485
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
486
- ) -> None:
568
+ return _response.data
569
+
570
+ def delete_trace_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
487
571
  """
488
572
  Delete trace by id
489
573
 
@@ -501,27 +585,11 @@ class TracesClient:
501
585
  Examples
502
586
  --------
503
587
  from Opik import OpikApi
504
-
505
- client = OpikApi(
506
- api_key="YOUR_API_KEY",
507
- workspace_name="YOUR_WORKSPACE_NAME",
508
- )
509
- client.traces.delete_trace_by_id(
510
- id="id",
511
- )
588
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
589
+ client.traces.delete_trace_by_id(id='id', )
512
590
  """
513
- _response = self._client_wrapper.httpx_client.request(
514
- f"v1/private/traces/{jsonable_encoder(id)}",
515
- method="DELETE",
516
- request_options=request_options,
517
- )
518
- try:
519
- if 200 <= _response.status_code < 300:
520
- return
521
- _response_json = _response.json()
522
- except JSONDecodeError:
523
- raise ApiError(status_code=_response.status_code, body=_response.text)
524
- raise ApiError(status_code=_response.status_code, body=_response_json)
591
+ _response = self._raw_client.delete_trace_by_id(id, request_options=request_options)
592
+ return _response.data
525
593
 
526
594
  def update_trace(
527
595
  self,
@@ -529,10 +597,11 @@ class TracesClient:
529
597
  *,
530
598
  project_name: typing.Optional[str] = OMIT,
531
599
  project_id: typing.Optional[str] = OMIT,
600
+ name: typing.Optional[str] = OMIT,
532
601
  end_time: typing.Optional[dt.datetime] = OMIT,
533
- input: typing.Optional[JsonNode] = OMIT,
534
- output: typing.Optional[JsonNode] = OMIT,
535
- metadata: typing.Optional[JsonNode] = OMIT,
602
+ input: typing.Optional[JsonListString] = OMIT,
603
+ output: typing.Optional[JsonListString] = OMIT,
604
+ metadata: typing.Optional[JsonListString] = OMIT,
536
605
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
537
606
  error_info: typing.Optional[ErrorInfo] = OMIT,
538
607
  thread_id: typing.Optional[str] = OMIT,
@@ -551,13 +620,15 @@ class TracesClient:
551
620
  project_id : typing.Optional[str]
552
621
  If null and project_name not specified, Default Project is assumed
553
622
 
623
+ name : typing.Optional[str]
624
+
554
625
  end_time : typing.Optional[dt.datetime]
555
626
 
556
- input : typing.Optional[JsonNode]
627
+ input : typing.Optional[JsonListString]
557
628
 
558
- output : typing.Optional[JsonNode]
629
+ output : typing.Optional[JsonListString]
559
630
 
560
- metadata : typing.Optional[JsonNode]
631
+ metadata : typing.Optional[JsonListString]
561
632
 
562
633
  tags : typing.Optional[typing.Sequence[str]]
563
634
 
@@ -575,53 +646,30 @@ class TracesClient:
575
646
  Examples
576
647
  --------
577
648
  from Opik import OpikApi
578
-
579
- client = OpikApi(
580
- api_key="YOUR_API_KEY",
581
- workspace_name="YOUR_WORKSPACE_NAME",
582
- )
583
- client.traces.update_trace(
584
- id="id",
585
- )
586
- """
587
- _response = self._client_wrapper.httpx_client.request(
588
- f"v1/private/traces/{jsonable_encoder(id)}",
589
- method="PATCH",
590
- json={
591
- "project_name": project_name,
592
- "project_id": project_id,
593
- "end_time": end_time,
594
- "input": input,
595
- "output": output,
596
- "metadata": metadata,
597
- "tags": tags,
598
- "error_info": convert_and_respect_annotation_metadata(
599
- object_=error_info, annotation=ErrorInfo, direction="write"
600
- ),
601
- "thread_id": thread_id,
602
- },
603
- headers={
604
- "content-type": "application/json",
605
- },
649
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
650
+ client.traces.update_trace(id='id', )
651
+ """
652
+ _response = self._raw_client.update_trace(
653
+ id,
654
+ project_name=project_name,
655
+ project_id=project_id,
656
+ name=name,
657
+ end_time=end_time,
658
+ input=input,
659
+ output=output,
660
+ metadata=metadata,
661
+ tags=tags,
662
+ error_info=error_info,
663
+ thread_id=thread_id,
606
664
  request_options=request_options,
607
- omit=OMIT,
608
665
  )
609
- try:
610
- if 200 <= _response.status_code < 300:
611
- return
612
- _response_json = _response.json()
613
- except JSONDecodeError:
614
- raise ApiError(status_code=_response.status_code, body=_response.text)
615
- raise ApiError(status_code=_response.status_code, body=_response_json)
666
+ return _response.data
616
667
 
617
- def delete_trace_comments(
618
- self,
619
- *,
620
- ids: typing.Sequence[str],
621
- request_options: typing.Optional[RequestOptions] = None,
668
+ def delete_thread_comments(
669
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
622
670
  ) -> None:
623
671
  """
624
- Delete trace comments
672
+ Delete thread comments
625
673
 
626
674
  Parameters
627
675
  ----------
@@ -637,49 +685,35 @@ class TracesClient:
637
685
  Examples
638
686
  --------
639
687
  from Opik import OpikApi
640
-
641
- client = OpikApi(
642
- api_key="YOUR_API_KEY",
643
- workspace_name="YOUR_WORKSPACE_NAME",
644
- )
645
- client.traces.delete_trace_comments(
646
- ids=["ids"],
647
- )
688
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
689
+ client.traces.delete_thread_comments(ids=['ids'], )
648
690
  """
649
- _response = self._client_wrapper.httpx_client.request(
650
- "v1/private/traces/comments/delete",
651
- method="POST",
652
- json={
653
- "ids": ids,
654
- },
655
- request_options=request_options,
656
- omit=OMIT,
657
- )
658
- try:
659
- if 200 <= _response.status_code < 300:
660
- return
661
- _response_json = _response.json()
662
- except JSONDecodeError:
663
- raise ApiError(status_code=_response.status_code, body=_response.text)
664
- raise ApiError(status_code=_response.status_code, body=_response_json)
691
+ _response = self._raw_client.delete_thread_comments(ids=ids, request_options=request_options)
692
+ return _response.data
665
693
 
666
- def delete_trace_feedback_score(
694
+ def delete_thread_feedback_scores(
667
695
  self,
668
- id: str,
669
696
  *,
670
- name: str,
697
+ project_name: str,
698
+ thread_id: str,
699
+ names: typing.Sequence[str],
700
+ author: typing.Optional[str] = OMIT,
671
701
  request_options: typing.Optional[RequestOptions] = None,
672
702
  ) -> None:
673
703
  """
674
- Delete trace feedback score
704
+ Delete thread feedback scores
675
705
 
676
706
  Parameters
677
707
  ----------
678
- id : str
708
+ project_name : str
679
709
 
680
- name : str
710
+ thread_id : str
681
711
 
682
- request_options : typing.Optional[RequestOptions]
712
+ names : typing.Sequence[str]
713
+
714
+ author : typing.Optional[str]
715
+
716
+ request_options : typing.Optional[RequestOptions]
683
717
  Request-specific configuration.
684
718
 
685
719
  Returns
@@ -689,32 +723,76 @@ class TracesClient:
689
723
  Examples
690
724
  --------
691
725
  from Opik import OpikApi
692
-
693
- client = OpikApi(
694
- api_key="YOUR_API_KEY",
695
- workspace_name="YOUR_WORKSPACE_NAME",
696
- )
697
- client.traces.delete_trace_feedback_score(
698
- id="id",
699
- name="name",
726
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
727
+ client.traces.delete_thread_feedback_scores(project_name='project_name', thread_id='thread_id', names=['names'], )
728
+ """
729
+ _response = self._raw_client.delete_thread_feedback_scores(
730
+ project_name=project_name, thread_id=thread_id, names=names, author=author, request_options=request_options
700
731
  )
732
+ return _response.data
733
+
734
+ def delete_trace_comments(
735
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
736
+ ) -> None:
701
737
  """
702
- _response = self._client_wrapper.httpx_client.request(
703
- f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores/delete",
704
- method="POST",
705
- json={
706
- "name": name,
707
- },
708
- request_options=request_options,
709
- omit=OMIT,
738
+ Delete trace comments
739
+
740
+ Parameters
741
+ ----------
742
+ ids : typing.Sequence[str]
743
+
744
+ request_options : typing.Optional[RequestOptions]
745
+ Request-specific configuration.
746
+
747
+ Returns
748
+ -------
749
+ None
750
+
751
+ Examples
752
+ --------
753
+ from Opik import OpikApi
754
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
755
+ client.traces.delete_trace_comments(ids=['ids'], )
756
+ """
757
+ _response = self._raw_client.delete_trace_comments(ids=ids, request_options=request_options)
758
+ return _response.data
759
+
760
+ def delete_trace_feedback_score(
761
+ self,
762
+ id: str,
763
+ *,
764
+ name: str,
765
+ author: typing.Optional[str] = OMIT,
766
+ request_options: typing.Optional[RequestOptions] = None,
767
+ ) -> None:
768
+ """
769
+ Delete trace feedback score
770
+
771
+ Parameters
772
+ ----------
773
+ id : str
774
+
775
+ name : str
776
+
777
+ author : typing.Optional[str]
778
+
779
+ request_options : typing.Optional[RequestOptions]
780
+ Request-specific configuration.
781
+
782
+ Returns
783
+ -------
784
+ None
785
+
786
+ Examples
787
+ --------
788
+ from Opik import OpikApi
789
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
790
+ client.traces.delete_trace_feedback_score(id='id', name='name', )
791
+ """
792
+ _response = self._raw_client.delete_trace_feedback_score(
793
+ id, name=name, author=author, request_options=request_options
710
794
  )
711
- try:
712
- if 200 <= _response.status_code < 300:
713
- return
714
- _response_json = _response.json()
715
- except JSONDecodeError:
716
- raise ApiError(status_code=_response.status_code, body=_response.text)
717
- raise ApiError(status_code=_response.status_code, body=_response_json)
795
+ return _response.data
718
796
 
719
797
  def delete_trace_threads(
720
798
  self,
@@ -747,42 +825,16 @@ class TracesClient:
747
825
  Examples
748
826
  --------
749
827
  from Opik import OpikApi
750
-
751
- client = OpikApi(
752
- api_key="YOUR_API_KEY",
753
- workspace_name="YOUR_WORKSPACE_NAME",
754
- )
755
- client.traces.delete_trace_threads(
756
- thread_ids=["thread_ids"],
757
- )
828
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
829
+ client.traces.delete_trace_threads(thread_ids=['thread_ids'], )
758
830
  """
759
- _response = self._client_wrapper.httpx_client.request(
760
- "v1/private/traces/threads/delete",
761
- method="POST",
762
- json={
763
- "project_name": project_name,
764
- "project_id": project_id,
765
- "thread_ids": thread_ids,
766
- },
767
- headers={
768
- "content-type": "application/json",
769
- },
770
- request_options=request_options,
771
- omit=OMIT,
831
+ _response = self._raw_client.delete_trace_threads(
832
+ thread_ids=thread_ids, project_name=project_name, project_id=project_id, request_options=request_options
772
833
  )
773
- try:
774
- if 200 <= _response.status_code < 300:
775
- return
776
- _response_json = _response.json()
777
- except JSONDecodeError:
778
- raise ApiError(status_code=_response.status_code, body=_response.text)
779
- raise ApiError(status_code=_response.status_code, body=_response_json)
834
+ return _response.data
780
835
 
781
836
  def delete_traces(
782
- self,
783
- *,
784
- ids: typing.Sequence[str],
785
- request_options: typing.Optional[RequestOptions] = None,
837
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
786
838
  ) -> None:
787
839
  """
788
840
  Delete traces
@@ -801,37 +853,14 @@ class TracesClient:
801
853
  Examples
802
854
  --------
803
855
  from Opik import OpikApi
804
-
805
- client = OpikApi(
806
- api_key="YOUR_API_KEY",
807
- workspace_name="YOUR_WORKSPACE_NAME",
808
- )
809
- client.traces.delete_traces(
810
- ids=["ids"],
811
- )
856
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
857
+ client.traces.delete_traces(ids=['ids'], )
812
858
  """
813
- _response = self._client_wrapper.httpx_client.request(
814
- "v1/private/traces/delete",
815
- method="POST",
816
- json={
817
- "ids": ids,
818
- },
819
- request_options=request_options,
820
- omit=OMIT,
821
- )
822
- try:
823
- if 200 <= _response.status_code < 300:
824
- return
825
- _response_json = _response.json()
826
- except JSONDecodeError:
827
- raise ApiError(status_code=_response.status_code, body=_response.text)
828
- raise ApiError(status_code=_response.status_code, body=_response_json)
859
+ _response = self._raw_client.delete_traces(ids=ids, request_options=request_options)
860
+ return _response.data
829
861
 
830
862
  def find_feedback_score_names_2(
831
- self,
832
- *,
833
- project_id: typing.Optional[str] = None,
834
- request_options: typing.Optional[RequestOptions] = None,
863
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
835
864
  ) -> typing.List[str]:
836
865
  """
837
866
  Find Feedback Score names
@@ -851,34 +880,40 @@ class TracesClient:
851
880
  Examples
852
881
  --------
853
882
  from Opik import OpikApi
854
-
855
- client = OpikApi(
856
- api_key="YOUR_API_KEY",
857
- workspace_name="YOUR_WORKSPACE_NAME",
858
- )
883
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
859
884
  client.traces.find_feedback_score_names_2()
860
885
  """
861
- _response = self._client_wrapper.httpx_client.request(
862
- "v1/private/traces/feedback-scores/names",
863
- method="GET",
864
- params={
865
- "project_id": project_id,
866
- },
867
- request_options=request_options,
886
+ _response = self._raw_client.find_feedback_score_names_2(project_id=project_id, request_options=request_options)
887
+ return _response.data
888
+
889
+ def find_trace_threads_feedback_score_names(
890
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
891
+ ) -> typing.List[str]:
892
+ """
893
+ Find Trace Threads Feedback Score names
894
+
895
+ Parameters
896
+ ----------
897
+ project_id : typing.Optional[str]
898
+
899
+ request_options : typing.Optional[RequestOptions]
900
+ Request-specific configuration.
901
+
902
+ Returns
903
+ -------
904
+ typing.List[str]
905
+ Find Trace Threads Feedback Score names
906
+
907
+ Examples
908
+ --------
909
+ from Opik import OpikApi
910
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
911
+ client.traces.find_trace_threads_feedback_score_names()
912
+ """
913
+ _response = self._raw_client.find_trace_threads_feedback_score_names(
914
+ project_id=project_id, request_options=request_options
868
915
  )
869
- try:
870
- if 200 <= _response.status_code < 300:
871
- return typing.cast(
872
- typing.List[str],
873
- parse_obj_as(
874
- type_=typing.List[str], # type: ignore
875
- object_=_response.json(),
876
- ),
877
- )
878
- _response_json = _response.json()
879
- except JSONDecodeError:
880
- raise ApiError(status_code=_response.status_code, body=_response.text)
881
- raise ApiError(status_code=_response.status_code, body=_response_json)
916
+ return _response.data
882
917
 
883
918
  def get_trace_stats(
884
919
  self,
@@ -886,6 +921,8 @@ class TracesClient:
886
921
  project_id: typing.Optional[str] = None,
887
922
  project_name: typing.Optional[str] = None,
888
923
  filters: typing.Optional[str] = None,
924
+ from_time: typing.Optional[dt.datetime] = None,
925
+ to_time: typing.Optional[dt.datetime] = None,
889
926
  request_options: typing.Optional[RequestOptions] = None,
890
927
  ) -> ProjectStatsPublic:
891
928
  """
@@ -899,6 +936,10 @@ class TracesClient:
899
936
 
900
937
  filters : typing.Optional[str]
901
938
 
939
+ from_time : typing.Optional[dt.datetime]
940
+
941
+ to_time : typing.Optional[dt.datetime]
942
+
902
943
  request_options : typing.Optional[RequestOptions]
903
944
  Request-specific configuration.
904
945
 
@@ -910,43 +951,99 @@ class TracesClient:
910
951
  Examples
911
952
  --------
912
953
  from Opik import OpikApi
913
-
914
- client = OpikApi(
915
- api_key="YOUR_API_KEY",
916
- workspace_name="YOUR_WORKSPACE_NAME",
917
- )
954
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
918
955
  client.traces.get_trace_stats()
919
956
  """
920
- _response = self._client_wrapper.httpx_client.request(
921
- "v1/private/traces/stats",
922
- method="GET",
923
- params={
924
- "project_id": project_id,
925
- "project_name": project_name,
926
- "filters": filters,
927
- },
957
+ _response = self._raw_client.get_trace_stats(
958
+ project_id=project_id,
959
+ project_name=project_name,
960
+ filters=filters,
961
+ from_time=from_time,
962
+ to_time=to_time,
928
963
  request_options=request_options,
929
964
  )
930
- try:
931
- if 200 <= _response.status_code < 300:
932
- return typing.cast(
933
- ProjectStatsPublic,
934
- parse_obj_as(
935
- type_=ProjectStatsPublic, # type: ignore
936
- object_=_response.json(),
937
- ),
938
- )
939
- _response_json = _response.json()
940
- except JSONDecodeError:
941
- raise ApiError(status_code=_response.status_code, body=_response.text)
942
- raise ApiError(status_code=_response.status_code, body=_response_json)
965
+ return _response.data
943
966
 
944
- def get_trace_comment(
967
+ def get_thread_comment(
968
+ self, comment_id: str, thread_id: str, *, request_options: typing.Optional[RequestOptions] = None
969
+ ) -> Comment:
970
+ """
971
+ Get thread comment
972
+
973
+ Parameters
974
+ ----------
975
+ comment_id : str
976
+
977
+ thread_id : str
978
+
979
+ request_options : typing.Optional[RequestOptions]
980
+ Request-specific configuration.
981
+
982
+ Returns
983
+ -------
984
+ Comment
985
+ Comment resource
986
+
987
+ Examples
988
+ --------
989
+ from Opik import OpikApi
990
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
991
+ client.traces.get_thread_comment(comment_id='commentId', thread_id='threadId', )
992
+ """
993
+ _response = self._raw_client.get_thread_comment(comment_id, thread_id, request_options=request_options)
994
+ return _response.data
995
+
996
+ def get_trace_thread_stats(
945
997
  self,
946
- comment_id: str,
947
- trace_id: str,
948
998
  *,
999
+ project_id: typing.Optional[str] = None,
1000
+ project_name: typing.Optional[str] = None,
1001
+ filters: typing.Optional[str] = None,
1002
+ from_time: typing.Optional[dt.datetime] = None,
1003
+ to_time: typing.Optional[dt.datetime] = None,
949
1004
  request_options: typing.Optional[RequestOptions] = None,
1005
+ ) -> ProjectStatsPublic:
1006
+ """
1007
+ Get trace thread stats
1008
+
1009
+ Parameters
1010
+ ----------
1011
+ project_id : typing.Optional[str]
1012
+
1013
+ project_name : typing.Optional[str]
1014
+
1015
+ filters : typing.Optional[str]
1016
+
1017
+ from_time : typing.Optional[dt.datetime]
1018
+
1019
+ to_time : typing.Optional[dt.datetime]
1020
+
1021
+ request_options : typing.Optional[RequestOptions]
1022
+ Request-specific configuration.
1023
+
1024
+ Returns
1025
+ -------
1026
+ ProjectStatsPublic
1027
+ Trace thread stats resource
1028
+
1029
+ Examples
1030
+ --------
1031
+ from Opik import OpikApi
1032
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1033
+ client.traces.get_trace_thread_stats()
1034
+ """
1035
+ _response = self._raw_client.get_trace_thread_stats(
1036
+ project_id=project_id,
1037
+ project_name=project_name,
1038
+ filters=filters,
1039
+ from_time=from_time,
1040
+ to_time=to_time,
1041
+ request_options=request_options,
1042
+ )
1043
+ return _response.data
1044
+
1045
+ def get_trace_comment(
1046
+ self, comment_id: str, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
950
1047
  ) -> Comment:
951
1048
  """
952
1049
  Get trace comment
@@ -968,50 +1065,19 @@ class TracesClient:
968
1065
  Examples
969
1066
  --------
970
1067
  from Opik import OpikApi
971
-
972
- client = OpikApi(
973
- api_key="YOUR_API_KEY",
974
- workspace_name="YOUR_WORKSPACE_NAME",
975
- )
976
- client.traces.get_trace_comment(
977
- comment_id="commentId",
978
- trace_id="traceId",
979
- )
1068
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1069
+ client.traces.get_trace_comment(comment_id='commentId', trace_id='traceId', )
980
1070
  """
981
- _response = self._client_wrapper.httpx_client.request(
982
- f"v1/private/traces/{jsonable_encoder(trace_id)}/comments/{jsonable_encoder(comment_id)}",
983
- method="GET",
984
- request_options=request_options,
985
- )
986
- try:
987
- if 200 <= _response.status_code < 300:
988
- return typing.cast(
989
- Comment,
990
- parse_obj_as(
991
- type_=Comment, # type: ignore
992
- object_=_response.json(),
993
- ),
994
- )
995
- if _response.status_code == 404:
996
- raise NotFoundError(
997
- typing.cast(
998
- typing.Optional[typing.Any],
999
- parse_obj_as(
1000
- type_=typing.Optional[typing.Any], # type: ignore
1001
- object_=_response.json(),
1002
- ),
1003
- )
1004
- )
1005
- _response_json = _response.json()
1006
- except JSONDecodeError:
1007
- raise ApiError(status_code=_response.status_code, body=_response.text)
1008
- raise ApiError(status_code=_response.status_code, body=_response_json)
1071
+ _response = self._raw_client.get_trace_comment(comment_id, trace_id, request_options=request_options)
1072
+ return _response.data
1009
1073
 
1010
1074
  def get_trace_thread(
1011
1075
  self,
1012
1076
  *,
1013
- project_id: str,
1014
1077
  thread_id: str,
1078
+ project_name: typing.Optional[str] = OMIT,
1079
+ project_id: typing.Optional[str] = OMIT,
1080
+ truncate: typing.Optional[bool] = OMIT,
1015
1081
  request_options: typing.Optional[RequestOptions] = None,
1016
1082
  ) -> TraceThread:
1017
1083
  """
@@ -1019,10 +1085,14 @@ class TracesClient:
1019
1085
 
1020
1086
  Parameters
1021
1087
  ----------
1022
- project_id : str
1023
-
1024
1088
  thread_id : str
1025
1089
 
1090
+ project_name : typing.Optional[str]
1091
+
1092
+ project_id : typing.Optional[str]
1093
+
1094
+ truncate : typing.Optional[bool]
1095
+
1026
1096
  request_options : typing.Optional[RequestOptions]
1027
1097
  Request-specific configuration.
1028
1098
 
@@ -1034,52 +1104,17 @@ class TracesClient:
1034
1104
  Examples
1035
1105
  --------
1036
1106
  from Opik import OpikApi
1037
-
1038
- client = OpikApi(
1039
- api_key="YOUR_API_KEY",
1040
- workspace_name="YOUR_WORKSPACE_NAME",
1041
- )
1042
- client.traces.get_trace_thread(
1043
- project_id="project_id",
1044
- thread_id="thread_id",
1045
- )
1046
- """
1047
- _response = self._client_wrapper.httpx_client.request(
1048
- "v1/private/traces/threads/retrieve",
1049
- method="POST",
1050
- json={
1051
- "project_id": project_id,
1052
- "thread_id": thread_id,
1053
- },
1054
- headers={
1055
- "content-type": "application/json",
1056
- },
1107
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1108
+ client.traces.get_trace_thread(thread_id='thread_id', )
1109
+ """
1110
+ _response = self._raw_client.get_trace_thread(
1111
+ thread_id=thread_id,
1112
+ project_name=project_name,
1113
+ project_id=project_id,
1114
+ truncate=truncate,
1057
1115
  request_options=request_options,
1058
- omit=OMIT,
1059
1116
  )
1060
- try:
1061
- if 200 <= _response.status_code < 300:
1062
- return typing.cast(
1063
- TraceThread,
1064
- parse_obj_as(
1065
- type_=TraceThread, # type: ignore
1066
- object_=_response.json(),
1067
- ),
1068
- )
1069
- if _response.status_code == 404:
1070
- raise NotFoundError(
1071
- typing.cast(
1072
- typing.Optional[typing.Any],
1073
- parse_obj_as(
1074
- type_=typing.Optional[typing.Any], # type: ignore
1075
- object_=_response.json(),
1076
- ),
1077
- )
1078
- )
1079
- _response_json = _response.json()
1080
- except JSONDecodeError:
1081
- raise ApiError(status_code=_response.status_code, body=_response.text)
1082
- raise ApiError(status_code=_response.status_code, body=_response_json)
1117
+ return _response.data
1083
1118
 
1084
1119
  def get_trace_threads(
1085
1120
  self,
@@ -1089,7 +1124,11 @@ class TracesClient:
1089
1124
  project_name: typing.Optional[str] = None,
1090
1125
  project_id: typing.Optional[str] = None,
1091
1126
  truncate: typing.Optional[bool] = None,
1127
+ strip_attachments: typing.Optional[bool] = None,
1092
1128
  filters: typing.Optional[str] = None,
1129
+ sorting: typing.Optional[str] = None,
1130
+ from_time: typing.Optional[dt.datetime] = None,
1131
+ to_time: typing.Optional[dt.datetime] = None,
1093
1132
  request_options: typing.Optional[RequestOptions] = None,
1094
1133
  ) -> TraceThreadPage:
1095
1134
  """
@@ -1107,8 +1146,16 @@ class TracesClient:
1107
1146
 
1108
1147
  truncate : typing.Optional[bool]
1109
1148
 
1149
+ strip_attachments : typing.Optional[bool]
1150
+
1110
1151
  filters : typing.Optional[str]
1111
1152
 
1153
+ sorting : typing.Optional[str]
1154
+
1155
+ from_time : typing.Optional[dt.datetime]
1156
+
1157
+ to_time : typing.Optional[dt.datetime]
1158
+
1112
1159
  request_options : typing.Optional[RequestOptions]
1113
1160
  Request-specific configuration.
1114
1161
 
@@ -1120,52 +1167,45 @@ class TracesClient:
1120
1167
  Examples
1121
1168
  --------
1122
1169
  from Opik import OpikApi
1123
-
1124
- client = OpikApi(
1125
- api_key="YOUR_API_KEY",
1126
- workspace_name="YOUR_WORKSPACE_NAME",
1127
- )
1170
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1128
1171
  client.traces.get_trace_threads()
1129
1172
  """
1130
- _response = self._client_wrapper.httpx_client.request(
1131
- "v1/private/traces/threads",
1132
- method="GET",
1133
- params={
1134
- "page": page,
1135
- "size": size,
1136
- "project_name": project_name,
1137
- "project_id": project_id,
1138
- "truncate": truncate,
1139
- "filters": filters,
1140
- },
1173
+ _response = self._raw_client.get_trace_threads(
1174
+ page=page,
1175
+ size=size,
1176
+ project_name=project_name,
1177
+ project_id=project_id,
1178
+ truncate=truncate,
1179
+ strip_attachments=strip_attachments,
1180
+ filters=filters,
1181
+ sorting=sorting,
1182
+ from_time=from_time,
1183
+ to_time=to_time,
1141
1184
  request_options=request_options,
1142
1185
  )
1143
- try:
1144
- if 200 <= _response.status_code < 300:
1145
- return typing.cast(
1146
- TraceThreadPage,
1147
- parse_obj_as(
1148
- type_=TraceThreadPage, # type: ignore
1149
- object_=_response.json(),
1150
- ),
1151
- )
1152
- _response_json = _response.json()
1153
- except JSONDecodeError:
1154
- raise ApiError(status_code=_response.status_code, body=_response.text)
1155
- raise ApiError(status_code=_response.status_code, body=_response_json)
1186
+ return _response.data
1156
1187
 
1157
- def score_batch_of_traces(
1188
+ def open_trace_thread(
1158
1189
  self,
1159
1190
  *,
1160
- scores: typing.Sequence[FeedbackScoreBatchItem],
1191
+ thread_id: str,
1192
+ project_name: typing.Optional[str] = OMIT,
1193
+ project_id: typing.Optional[str] = OMIT,
1194
+ truncate: typing.Optional[bool] = OMIT,
1161
1195
  request_options: typing.Optional[RequestOptions] = None,
1162
1196
  ) -> None:
1163
1197
  """
1164
- Batch feedback scoring for traces
1198
+ Open trace thread
1165
1199
 
1166
1200
  Parameters
1167
1201
  ----------
1168
- scores : typing.Sequence[FeedbackScoreBatchItem]
1202
+ thread_id : str
1203
+
1204
+ project_name : typing.Optional[str]
1205
+
1206
+ project_id : typing.Optional[str]
1207
+
1208
+ truncate : typing.Optional[bool]
1169
1209
 
1170
1210
  request_options : typing.Optional[RequestOptions]
1171
1211
  Request-specific configuration.
@@ -1176,74 +1216,31 @@ class TracesClient:
1176
1216
 
1177
1217
  Examples
1178
1218
  --------
1179
- from Opik import FeedbackScoreBatchItem, OpikApi
1180
-
1181
- client = OpikApi(
1182
- api_key="YOUR_API_KEY",
1183
- workspace_name="YOUR_WORKSPACE_NAME",
1184
- )
1185
- client.traces.score_batch_of_traces(
1186
- scores=[
1187
- FeedbackScoreBatchItem(
1188
- id="id",
1189
- name="name",
1190
- value=1.1,
1191
- source="ui",
1192
- )
1193
- ],
1194
- )
1195
- """
1196
- _response = self._client_wrapper.httpx_client.request(
1197
- "v1/private/traces/feedback-scores",
1198
- method="PUT",
1199
- json={
1200
- "scores": convert_and_respect_annotation_metadata(
1201
- object_=scores,
1202
- annotation=typing.Sequence[FeedbackScoreBatchItem],
1203
- direction="write",
1204
- ),
1205
- },
1219
+ from Opik import OpikApi
1220
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1221
+ client.traces.open_trace_thread(thread_id='thread_id', )
1222
+ """
1223
+ _response = self._raw_client.open_trace_thread(
1224
+ thread_id=thread_id,
1225
+ project_name=project_name,
1226
+ project_id=project_id,
1227
+ truncate=truncate,
1206
1228
  request_options=request_options,
1207
- omit=OMIT,
1208
1229
  )
1209
- try:
1210
- if 200 <= _response.status_code < 300:
1211
- return
1212
- _response_json = _response.json()
1213
- except JSONDecodeError:
1214
- raise ApiError(status_code=_response.status_code, body=_response.text)
1215
- raise ApiError(status_code=_response.status_code, body=_response_json)
1230
+ return _response.data
1216
1231
 
1217
- def update_trace_comment(
1232
+ def score_batch_of_threads(
1218
1233
  self,
1219
- comment_id: str,
1220
1234
  *,
1221
- text: str,
1222
- id: typing.Optional[str] = OMIT,
1223
- created_at: typing.Optional[dt.datetime] = OMIT,
1224
- last_updated_at: typing.Optional[dt.datetime] = OMIT,
1225
- created_by: typing.Optional[str] = OMIT,
1226
- last_updated_by: typing.Optional[str] = OMIT,
1235
+ scores: typing.Sequence[FeedbackScoreBatchItemThread],
1227
1236
  request_options: typing.Optional[RequestOptions] = None,
1228
1237
  ) -> None:
1229
1238
  """
1230
- Update trace comment by id
1239
+ Batch feedback scoring for threads
1231
1240
 
1232
1241
  Parameters
1233
1242
  ----------
1234
- comment_id : str
1235
-
1236
- text : str
1237
-
1238
- id : typing.Optional[str]
1239
-
1240
- created_at : typing.Optional[dt.datetime]
1241
-
1242
- last_updated_at : typing.Optional[dt.datetime]
1243
-
1244
- created_by : typing.Optional[str]
1245
-
1246
- last_updated_by : typing.Optional[str]
1243
+ scores : typing.Sequence[FeedbackScoreBatchItemThread]
1247
1244
 
1248
1245
  request_options : typing.Optional[RequestOptions]
1249
1246
  Request-specific configuration.
@@ -1255,83 +1252,25 @@ class TracesClient:
1255
1252
  Examples
1256
1253
  --------
1257
1254
  from Opik import OpikApi
1258
-
1259
- client = OpikApi(
1260
- api_key="YOUR_API_KEY",
1261
- workspace_name="YOUR_WORKSPACE_NAME",
1262
- )
1263
- client.traces.update_trace_comment(
1264
- comment_id="commentId",
1265
- text="text",
1266
- )
1255
+ from Opik import FeedbackScoreBatchItemThread
1256
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1257
+ client.traces.score_batch_of_threads(scores=[FeedbackScoreBatchItemThread(name='name', value=1.1, source="ui", thread_id='thread_id', )], )
1267
1258
  """
1268
- _response = self._client_wrapper.httpx_client.request(
1269
- f"v1/private/traces/comments/{jsonable_encoder(comment_id)}",
1270
- method="PATCH",
1271
- json={
1272
- "id": id,
1273
- "text": text,
1274
- "created_at": created_at,
1275
- "last_updated_at": last_updated_at,
1276
- "created_by": created_by,
1277
- "last_updated_by": last_updated_by,
1278
- },
1279
- request_options=request_options,
1280
- omit=OMIT,
1281
- )
1282
- try:
1283
- if 200 <= _response.status_code < 300:
1284
- return
1285
- if _response.status_code == 404:
1286
- raise NotFoundError(
1287
- typing.cast(
1288
- typing.Optional[typing.Any],
1289
- parse_obj_as(
1290
- type_=typing.Optional[typing.Any], # type: ignore
1291
- object_=_response.json(),
1292
- ),
1293
- )
1294
- )
1295
- _response_json = _response.json()
1296
- except JSONDecodeError:
1297
- raise ApiError(status_code=_response.status_code, body=_response.text)
1298
- raise ApiError(status_code=_response.status_code, body=_response_json)
1299
-
1300
-
1301
- class AsyncTracesClient:
1302
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
1303
- self._client_wrapper = client_wrapper
1259
+ _response = self._raw_client.score_batch_of_threads(scores=scores, request_options=request_options)
1260
+ return _response.data
1304
1261
 
1305
- async def add_trace_comment(
1262
+ def score_batch_of_traces(
1306
1263
  self,
1307
- id_: str,
1308
1264
  *,
1309
- text: str,
1310
- id: typing.Optional[str] = OMIT,
1311
- created_at: typing.Optional[dt.datetime] = OMIT,
1312
- last_updated_at: typing.Optional[dt.datetime] = OMIT,
1313
- created_by: typing.Optional[str] = OMIT,
1314
- last_updated_by: typing.Optional[str] = OMIT,
1265
+ scores: typing.Sequence[FeedbackScoreBatchItem],
1315
1266
  request_options: typing.Optional[RequestOptions] = None,
1316
1267
  ) -> None:
1317
1268
  """
1318
- Add trace comment
1269
+ Batch feedback scoring for traces
1319
1270
 
1320
1271
  Parameters
1321
1272
  ----------
1322
- id_ : str
1323
-
1324
- text : str
1325
-
1326
- id : typing.Optional[str]
1327
-
1328
- created_at : typing.Optional[dt.datetime]
1329
-
1330
- last_updated_at : typing.Optional[dt.datetime]
1331
-
1332
- created_by : typing.Optional[str]
1333
-
1334
- last_updated_by : typing.Optional[str]
1273
+ scores : typing.Sequence[FeedbackScoreBatchItem]
1335
1274
 
1336
1275
  request_options : typing.Optional[RequestOptions]
1337
1276
  Request-specific configuration.
@@ -1342,56 +1281,180 @@ class AsyncTracesClient:
1342
1281
 
1343
1282
  Examples
1344
1283
  --------
1345
- import asyncio
1284
+ from Opik import OpikApi
1285
+ from Opik import FeedbackScoreBatchItem
1286
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1287
+ client.traces.score_batch_of_traces(scores=[FeedbackScoreBatchItem(name='name', value=1.1, source="ui", id='id', )], )
1288
+ """
1289
+ _response = self._raw_client.score_batch_of_traces(scores=scores, request_options=request_options)
1290
+ return _response.data
1346
1291
 
1347
- from Opik import AsyncOpikApi
1292
+ def search_trace_threads(
1293
+ self,
1294
+ *,
1295
+ project_name: typing.Optional[str] = OMIT,
1296
+ project_id: typing.Optional[str] = OMIT,
1297
+ filters: typing.Optional[typing.Sequence[TraceThreadFilter]] = OMIT,
1298
+ last_retrieved_thread_model_id: typing.Optional[str] = OMIT,
1299
+ limit: typing.Optional[int] = OMIT,
1300
+ truncate: typing.Optional[bool] = OMIT,
1301
+ strip_attachments: typing.Optional[bool] = OMIT,
1302
+ from_time: typing.Optional[dt.datetime] = OMIT,
1303
+ to_time: typing.Optional[dt.datetime] = OMIT,
1304
+ request_options: typing.Optional[RequestOptions] = None,
1305
+ ) -> typing.Iterator[bytes]:
1306
+ """
1307
+ Search trace threads
1348
1308
 
1349
- client = AsyncOpikApi(
1350
- api_key="YOUR_API_KEY",
1351
- workspace_name="YOUR_WORKSPACE_NAME",
1352
- )
1309
+ Parameters
1310
+ ----------
1311
+ project_name : typing.Optional[str]
1353
1312
 
1313
+ project_id : typing.Optional[str]
1354
1314
 
1355
- async def main() -> None:
1356
- await client.traces.add_trace_comment(
1357
- id_="id",
1358
- text="text",
1359
- )
1315
+ filters : typing.Optional[typing.Sequence[TraceThreadFilter]]
1360
1316
 
1317
+ last_retrieved_thread_model_id : typing.Optional[str]
1361
1318
 
1362
- asyncio.run(main())
1319
+ limit : typing.Optional[int]
1320
+ Max number of trace thread to be streamed
1321
+
1322
+ truncate : typing.Optional[bool]
1323
+ Truncate input, output and metadata to slim payloads
1324
+
1325
+ strip_attachments : typing.Optional[bool]
1326
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
1327
+
1328
+ from_time : typing.Optional[dt.datetime]
1329
+ Filter trace threads created from this time (ISO-8601 format).
1330
+
1331
+ to_time : typing.Optional[dt.datetime]
1332
+ Filter trace threads created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
1333
+
1334
+ request_options : typing.Optional[RequestOptions]
1335
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
1336
+
1337
+ Returns
1338
+ -------
1339
+ typing.Iterator[bytes]
1340
+ Trace threads stream or error during process
1341
+ """
1342
+ with self._raw_client.search_trace_threads(
1343
+ project_name=project_name,
1344
+ project_id=project_id,
1345
+ filters=filters,
1346
+ last_retrieved_thread_model_id=last_retrieved_thread_model_id,
1347
+ limit=limit,
1348
+ truncate=truncate,
1349
+ strip_attachments=strip_attachments,
1350
+ from_time=from_time,
1351
+ to_time=to_time,
1352
+ request_options=request_options,
1353
+ ) as r:
1354
+ yield from r.data
1355
+
1356
+ def search_traces(
1357
+ self,
1358
+ *,
1359
+ project_name: typing.Optional[str] = OMIT,
1360
+ project_id: typing.Optional[str] = OMIT,
1361
+ filters: typing.Optional[typing.Sequence[TraceFilterPublic]] = OMIT,
1362
+ last_retrieved_id: typing.Optional[str] = OMIT,
1363
+ limit: typing.Optional[int] = OMIT,
1364
+ truncate: typing.Optional[bool] = OMIT,
1365
+ strip_attachments: typing.Optional[bool] = OMIT,
1366
+ from_time: typing.Optional[dt.datetime] = OMIT,
1367
+ to_time: typing.Optional[dt.datetime] = OMIT,
1368
+ request_options: typing.Optional[RequestOptions] = None,
1369
+ ) -> typing.Iterator[bytes]:
1363
1370
  """
1364
- _response = await self._client_wrapper.httpx_client.request(
1365
- f"v1/private/traces/{jsonable_encoder(id_)}/comments",
1366
- method="POST",
1367
- json={
1368
- "id": id,
1369
- "text": text,
1370
- "created_at": created_at,
1371
- "last_updated_at": last_updated_at,
1372
- "created_by": created_by,
1373
- "last_updated_by": last_updated_by,
1374
- },
1371
+ Search traces
1372
+
1373
+ Parameters
1374
+ ----------
1375
+ project_name : typing.Optional[str]
1376
+
1377
+ project_id : typing.Optional[str]
1378
+
1379
+ filters : typing.Optional[typing.Sequence[TraceFilterPublic]]
1380
+
1381
+ last_retrieved_id : typing.Optional[str]
1382
+
1383
+ limit : typing.Optional[int]
1384
+ Max number of traces to be streamed
1385
+
1386
+ truncate : typing.Optional[bool]
1387
+ Truncate input, output and metadata to slim payloads
1388
+
1389
+ strip_attachments : typing.Optional[bool]
1390
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
1391
+
1392
+ from_time : typing.Optional[dt.datetime]
1393
+ Filter traces created from this time (ISO-8601 format).
1394
+
1395
+ to_time : typing.Optional[dt.datetime]
1396
+ Filter traces created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
1397
+
1398
+ request_options : typing.Optional[RequestOptions]
1399
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
1400
+
1401
+ Returns
1402
+ -------
1403
+ typing.Iterator[bytes]
1404
+ Traces stream or error during process
1405
+ """
1406
+ with self._raw_client.search_traces(
1407
+ project_name=project_name,
1408
+ project_id=project_id,
1409
+ filters=filters,
1410
+ last_retrieved_id=last_retrieved_id,
1411
+ limit=limit,
1412
+ truncate=truncate,
1413
+ strip_attachments=strip_attachments,
1414
+ from_time=from_time,
1415
+ to_time=to_time,
1375
1416
  request_options=request_options,
1376
- omit=OMIT,
1377
- )
1378
- try:
1379
- if 200 <= _response.status_code < 300:
1380
- return
1381
- _response_json = _response.json()
1382
- except JSONDecodeError:
1383
- raise ApiError(status_code=_response.status_code, body=_response.text)
1384
- raise ApiError(status_code=_response.status_code, body=_response_json)
1417
+ ) as r:
1418
+ yield from r.data
1385
1419
 
1386
- async def add_trace_feedback_score(
1420
+ def update_thread(
1387
1421
  self,
1388
- id: str,
1422
+ thread_model_id: str,
1389
1423
  *,
1390
- name: str,
1391
- value: float,
1392
- source: FeedbackScoreSource,
1393
- category_name: typing.Optional[str] = OMIT,
1394
- reason: typing.Optional[str] = OMIT,
1424
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1425
+ request_options: typing.Optional[RequestOptions] = None,
1426
+ ) -> None:
1427
+ """
1428
+ Update thread
1429
+
1430
+ Parameters
1431
+ ----------
1432
+ thread_model_id : str
1433
+
1434
+ tags : typing.Optional[typing.Sequence[str]]
1435
+
1436
+ request_options : typing.Optional[RequestOptions]
1437
+ Request-specific configuration.
1438
+
1439
+ Returns
1440
+ -------
1441
+ None
1442
+
1443
+ Examples
1444
+ --------
1445
+ from Opik import OpikApi
1446
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1447
+ client.traces.update_thread(thread_model_id='threadModelId', )
1448
+ """
1449
+ _response = self._raw_client.update_thread(thread_model_id, tags=tags, request_options=request_options)
1450
+ return _response.data
1451
+
1452
+ def update_thread_comment(
1453
+ self,
1454
+ comment_id: str,
1455
+ *,
1456
+ text: str,
1457
+ id: typing.Optional[str] = OMIT,
1395
1458
  created_at: typing.Optional[dt.datetime] = OMIT,
1396
1459
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
1397
1460
  created_by: typing.Optional[str] = OMIT,
@@ -1399,21 +1462,71 @@ class AsyncTracesClient:
1399
1462
  request_options: typing.Optional[RequestOptions] = None,
1400
1463
  ) -> None:
1401
1464
  """
1402
- Add trace feedback score
1465
+ Update thread comment by id
1403
1466
 
1404
1467
  Parameters
1405
1468
  ----------
1406
- id : str
1469
+ comment_id : str
1407
1470
 
1408
- name : str
1471
+ text : str
1409
1472
 
1410
- value : float
1473
+ id : typing.Optional[str]
1411
1474
 
1412
- source : FeedbackScoreSource
1475
+ created_at : typing.Optional[dt.datetime]
1413
1476
 
1414
- category_name : typing.Optional[str]
1477
+ last_updated_at : typing.Optional[dt.datetime]
1415
1478
 
1416
- reason : typing.Optional[str]
1479
+ created_by : typing.Optional[str]
1480
+
1481
+ last_updated_by : typing.Optional[str]
1482
+
1483
+ request_options : typing.Optional[RequestOptions]
1484
+ Request-specific configuration.
1485
+
1486
+ Returns
1487
+ -------
1488
+ None
1489
+
1490
+ Examples
1491
+ --------
1492
+ from Opik import OpikApi
1493
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1494
+ client.traces.update_thread_comment(comment_id='commentId', text='text', )
1495
+ """
1496
+ _response = self._raw_client.update_thread_comment(
1497
+ comment_id,
1498
+ text=text,
1499
+ id=id,
1500
+ created_at=created_at,
1501
+ last_updated_at=last_updated_at,
1502
+ created_by=created_by,
1503
+ last_updated_by=last_updated_by,
1504
+ request_options=request_options,
1505
+ )
1506
+ return _response.data
1507
+
1508
+ def update_trace_comment(
1509
+ self,
1510
+ comment_id: str,
1511
+ *,
1512
+ text: str,
1513
+ id: typing.Optional[str] = OMIT,
1514
+ created_at: typing.Optional[dt.datetime] = OMIT,
1515
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
1516
+ created_by: typing.Optional[str] = OMIT,
1517
+ last_updated_by: typing.Optional[str] = OMIT,
1518
+ request_options: typing.Optional[RequestOptions] = None,
1519
+ ) -> None:
1520
+ """
1521
+ Update trace comment by id
1522
+
1523
+ Parameters
1524
+ ----------
1525
+ comment_id : str
1526
+
1527
+ text : str
1528
+
1529
+ id : typing.Optional[str]
1417
1530
 
1418
1531
  created_at : typing.Optional[dt.datetime]
1419
1532
 
@@ -1432,180 +1545,855 @@ class AsyncTracesClient:
1432
1545
 
1433
1546
  Examples
1434
1547
  --------
1435
- import asyncio
1548
+ from Opik import OpikApi
1549
+ client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1550
+ client.traces.update_trace_comment(comment_id='commentId', text='text', )
1551
+ """
1552
+ _response = self._raw_client.update_trace_comment(
1553
+ comment_id,
1554
+ text=text,
1555
+ id=id,
1556
+ created_at=created_at,
1557
+ last_updated_at=last_updated_at,
1558
+ created_by=created_by,
1559
+ last_updated_by=last_updated_by,
1560
+ request_options=request_options,
1561
+ )
1562
+ return _response.data
1436
1563
 
1437
- from Opik import AsyncOpikApi
1438
1564
 
1439
- client = AsyncOpikApi(
1440
- api_key="YOUR_API_KEY",
1441
- workspace_name="YOUR_WORKSPACE_NAME",
1442
- )
1565
+ class AsyncTracesClient:
1566
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
1567
+ self._raw_client = AsyncRawTracesClient(client_wrapper=client_wrapper)
1443
1568
 
1569
+ @property
1570
+ def with_raw_response(self) -> AsyncRawTracesClient:
1571
+ """
1572
+ Retrieves a raw implementation of this client that returns raw responses.
1444
1573
 
1445
- async def main() -> None:
1446
- await client.traces.add_trace_feedback_score(
1447
- id="id",
1448
- name="name",
1449
- value=1.1,
1450
- source="ui",
1451
- )
1574
+ Returns
1575
+ -------
1576
+ AsyncRawTracesClient
1577
+ """
1578
+ return self._raw_client
1579
+
1580
+ async def add_thread_comment(
1581
+ self,
1582
+ id_: str,
1583
+ *,
1584
+ text: str,
1585
+ id: typing.Optional[str] = OMIT,
1586
+ created_at: typing.Optional[dt.datetime] = OMIT,
1587
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
1588
+ created_by: typing.Optional[str] = OMIT,
1589
+ last_updated_by: typing.Optional[str] = OMIT,
1590
+ request_options: typing.Optional[RequestOptions] = None,
1591
+ ) -> None:
1592
+ """
1593
+ Add thread comment
1594
+
1595
+ Parameters
1596
+ ----------
1597
+ id_ : str
1598
+
1599
+ text : str
1600
+
1601
+ id : typing.Optional[str]
1602
+
1603
+ created_at : typing.Optional[dt.datetime]
1604
+
1605
+ last_updated_at : typing.Optional[dt.datetime]
1452
1606
 
1607
+ created_by : typing.Optional[str]
1608
+
1609
+ last_updated_by : typing.Optional[str]
1610
+
1611
+ request_options : typing.Optional[RequestOptions]
1612
+ Request-specific configuration.
1613
+
1614
+ Returns
1615
+ -------
1616
+ None
1453
1617
 
1618
+ Examples
1619
+ --------
1620
+ from Opik import AsyncOpikApi
1621
+ import asyncio
1622
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1623
+ async def main() -> None:
1624
+ await client.traces.add_thread_comment(id_='id', text='text', )
1454
1625
  asyncio.run(main())
1455
1626
  """
1456
- _response = await self._client_wrapper.httpx_client.request(
1457
- f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores",
1458
- method="PUT",
1459
- json={
1460
- "name": name,
1461
- "category_name": category_name,
1462
- "value": value,
1463
- "reason": reason,
1464
- "source": source,
1465
- "created_at": created_at,
1466
- "last_updated_at": last_updated_at,
1467
- "created_by": created_by,
1468
- "last_updated_by": last_updated_by,
1469
- },
1627
+ _response = await self._raw_client.add_thread_comment(
1628
+ id_,
1629
+ text=text,
1630
+ id=id,
1631
+ created_at=created_at,
1632
+ last_updated_at=last_updated_at,
1633
+ created_by=created_by,
1634
+ last_updated_by=last_updated_by,
1470
1635
  request_options=request_options,
1471
- omit=OMIT,
1472
1636
  )
1473
- try:
1474
- if 200 <= _response.status_code < 300:
1475
- return
1476
- _response_json = _response.json()
1477
- except JSONDecodeError:
1478
- raise ApiError(status_code=_response.status_code, body=_response.text)
1479
- raise ApiError(status_code=_response.status_code, body=_response_json)
1637
+ return _response.data
1480
1638
 
1481
- async def get_traces_by_project(
1639
+ async def add_trace_comment(
1482
1640
  self,
1641
+ id_: str,
1483
1642
  *,
1484
- page: typing.Optional[int] = None,
1485
- size: typing.Optional[int] = None,
1486
- project_name: typing.Optional[str] = None,
1487
- project_id: typing.Optional[str] = None,
1488
- filters: typing.Optional[str] = None,
1489
- truncate: typing.Optional[bool] = None,
1490
- sorting: typing.Optional[str] = None,
1643
+ text: str,
1644
+ id: typing.Optional[str] = OMIT,
1645
+ created_at: typing.Optional[dt.datetime] = OMIT,
1646
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
1647
+ created_by: typing.Optional[str] = OMIT,
1648
+ last_updated_by: typing.Optional[str] = OMIT,
1491
1649
  request_options: typing.Optional[RequestOptions] = None,
1492
- ) -> TracePagePublic:
1650
+ ) -> None:
1493
1651
  """
1494
- Get traces by project_name or project_id
1652
+ Add trace comment
1495
1653
 
1496
1654
  Parameters
1497
1655
  ----------
1498
- page : typing.Optional[int]
1656
+ id_ : str
1499
1657
 
1500
- size : typing.Optional[int]
1658
+ text : str
1501
1659
 
1502
- project_name : typing.Optional[str]
1660
+ id : typing.Optional[str]
1503
1661
 
1504
- project_id : typing.Optional[str]
1662
+ created_at : typing.Optional[dt.datetime]
1505
1663
 
1506
- filters : typing.Optional[str]
1664
+ last_updated_at : typing.Optional[dt.datetime]
1507
1665
 
1508
- truncate : typing.Optional[bool]
1666
+ created_by : typing.Optional[str]
1509
1667
 
1510
- sorting : typing.Optional[str]
1668
+ last_updated_by : typing.Optional[str]
1511
1669
 
1512
1670
  request_options : typing.Optional[RequestOptions]
1513
1671
  Request-specific configuration.
1514
1672
 
1515
1673
  Returns
1516
1674
  -------
1517
- TracePagePublic
1518
- Trace resource
1675
+ None
1676
+
1677
+ Examples
1678
+ --------
1679
+ from Opik import AsyncOpikApi
1680
+ import asyncio
1681
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1682
+ async def main() -> None:
1683
+ await client.traces.add_trace_comment(id_='id', text='text', )
1684
+ asyncio.run(main())
1685
+ """
1686
+ _response = await self._raw_client.add_trace_comment(
1687
+ id_,
1688
+ text=text,
1689
+ id=id,
1690
+ created_at=created_at,
1691
+ last_updated_at=last_updated_at,
1692
+ created_by=created_by,
1693
+ last_updated_by=last_updated_by,
1694
+ request_options=request_options,
1695
+ )
1696
+ return _response.data
1697
+
1698
+ async def add_trace_feedback_score(
1699
+ self,
1700
+ id: str,
1701
+ *,
1702
+ name: str,
1703
+ value: float,
1704
+ source: FeedbackScoreSource,
1705
+ category_name: typing.Optional[str] = OMIT,
1706
+ reason: typing.Optional[str] = OMIT,
1707
+ created_at: typing.Optional[dt.datetime] = OMIT,
1708
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
1709
+ created_by: typing.Optional[str] = OMIT,
1710
+ last_updated_by: typing.Optional[str] = OMIT,
1711
+ value_by_author: typing.Optional[typing.Dict[str, ValueEntry]] = OMIT,
1712
+ request_options: typing.Optional[RequestOptions] = None,
1713
+ ) -> None:
1714
+ """
1715
+ Add trace feedback score
1716
+
1717
+ Parameters
1718
+ ----------
1719
+ id : str
1720
+
1721
+ name : str
1722
+
1723
+ value : float
1724
+
1725
+ source : FeedbackScoreSource
1726
+
1727
+ category_name : typing.Optional[str]
1728
+
1729
+ reason : typing.Optional[str]
1730
+
1731
+ created_at : typing.Optional[dt.datetime]
1732
+
1733
+ last_updated_at : typing.Optional[dt.datetime]
1734
+
1735
+ created_by : typing.Optional[str]
1736
+
1737
+ last_updated_by : typing.Optional[str]
1738
+
1739
+ value_by_author : typing.Optional[typing.Dict[str, ValueEntry]]
1740
+
1741
+ request_options : typing.Optional[RequestOptions]
1742
+ Request-specific configuration.
1743
+
1744
+ Returns
1745
+ -------
1746
+ None
1747
+
1748
+ Examples
1749
+ --------
1750
+ from Opik import AsyncOpikApi
1751
+ import asyncio
1752
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1753
+ async def main() -> None:
1754
+ await client.traces.add_trace_feedback_score(id='id', name='name', value=1.1, source="ui", )
1755
+ asyncio.run(main())
1756
+ """
1757
+ _response = await self._raw_client.add_trace_feedback_score(
1758
+ id,
1759
+ name=name,
1760
+ value=value,
1761
+ source=source,
1762
+ category_name=category_name,
1763
+ reason=reason,
1764
+ created_at=created_at,
1765
+ last_updated_at=last_updated_at,
1766
+ created_by=created_by,
1767
+ last_updated_by=last_updated_by,
1768
+ value_by_author=value_by_author,
1769
+ request_options=request_options,
1770
+ )
1771
+ return _response.data
1772
+
1773
+ async def create_traces(
1774
+ self, *, traces: typing.Sequence[TraceWrite], request_options: typing.Optional[RequestOptions] = None
1775
+ ) -> None:
1776
+ """
1777
+ Create traces
1778
+
1779
+ Parameters
1780
+ ----------
1781
+ traces : typing.Sequence[TraceWrite]
1782
+
1783
+ request_options : typing.Optional[RequestOptions]
1784
+ Request-specific configuration.
1785
+
1786
+ Returns
1787
+ -------
1788
+ None
1789
+
1790
+ Examples
1791
+ --------
1792
+ from Opik import AsyncOpikApi
1793
+ from Opik import TraceWrite
1794
+ import datetime
1795
+ import asyncio
1796
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1797
+ async def main() -> None:
1798
+ await client.traces.create_traces(traces=[TraceWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
1799
+ asyncio.run(main())
1800
+ """
1801
+ _response = await self._raw_client.create_traces(traces=traces, request_options=request_options)
1802
+ return _response.data
1803
+
1804
+ async def batch_update_traces(
1805
+ self,
1806
+ *,
1807
+ ids: typing.Sequence[str],
1808
+ update: TraceUpdate,
1809
+ merge_tags: typing.Optional[bool] = OMIT,
1810
+ request_options: typing.Optional[RequestOptions] = None,
1811
+ ) -> None:
1812
+ """
1813
+ Update multiple traces
1814
+
1815
+ Parameters
1816
+ ----------
1817
+ ids : typing.Sequence[str]
1818
+ List of trace IDs to update (max 1000)
1819
+
1820
+ update : TraceUpdate
1821
+
1822
+ merge_tags : typing.Optional[bool]
1823
+ If true, merge tags with existing tags instead of replacing them. Default: false
1824
+
1825
+ request_options : typing.Optional[RequestOptions]
1826
+ Request-specific configuration.
1827
+
1828
+ Returns
1829
+ -------
1830
+ None
1831
+
1832
+ Examples
1833
+ --------
1834
+ from Opik import AsyncOpikApi
1835
+ from Opik import TraceUpdate
1836
+ import asyncio
1837
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1838
+ async def main() -> None:
1839
+ await client.traces.batch_update_traces(ids=['ids'], update=TraceUpdate(), )
1840
+ asyncio.run(main())
1841
+ """
1842
+ _response = await self._raw_client.batch_update_traces(
1843
+ ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
1844
+ )
1845
+ return _response.data
1846
+
1847
+ async def batch_update_threads(
1848
+ self,
1849
+ *,
1850
+ ids: typing.Sequence[str],
1851
+ update: TraceThreadUpdate,
1852
+ merge_tags: typing.Optional[bool] = OMIT,
1853
+ request_options: typing.Optional[RequestOptions] = None,
1854
+ ) -> None:
1855
+ """
1856
+ Update multiple threads
1857
+
1858
+ Parameters
1859
+ ----------
1860
+ ids : typing.Sequence[str]
1861
+ List of thread model IDs to update (max 1000)
1862
+
1863
+ update : TraceThreadUpdate
1864
+
1865
+ merge_tags : typing.Optional[bool]
1866
+ If true, merge tags with existing tags instead of replacing them. Default: false
1867
+
1868
+ request_options : typing.Optional[RequestOptions]
1869
+ Request-specific configuration.
1870
+
1871
+ Returns
1872
+ -------
1873
+ None
1874
+
1875
+ Examples
1876
+ --------
1877
+ from Opik import AsyncOpikApi
1878
+ from Opik import TraceThreadUpdate
1879
+ import asyncio
1880
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1881
+ async def main() -> None:
1882
+ await client.traces.batch_update_threads(ids=['ids'], update=TraceThreadUpdate(), )
1883
+ asyncio.run(main())
1884
+ """
1885
+ _response = await self._raw_client.batch_update_threads(
1886
+ ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
1887
+ )
1888
+ return _response.data
1889
+
1890
+ async def close_trace_thread(
1891
+ self,
1892
+ *,
1893
+ project_name: typing.Optional[str] = OMIT,
1894
+ project_id: typing.Optional[str] = OMIT,
1895
+ thread_id: typing.Optional[str] = OMIT,
1896
+ thread_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1897
+ request_options: typing.Optional[RequestOptions] = None,
1898
+ ) -> None:
1899
+ """
1900
+ Close one or multiple trace threads. Supports both single thread_id and multiple thread_ids for batch operations.
1901
+
1902
+ Parameters
1903
+ ----------
1904
+ project_name : typing.Optional[str]
1905
+
1906
+ project_id : typing.Optional[str]
1907
+
1908
+ thread_id : typing.Optional[str]
1909
+
1910
+ thread_ids : typing.Optional[typing.Sequence[str]]
1911
+
1912
+ request_options : typing.Optional[RequestOptions]
1913
+ Request-specific configuration.
1914
+
1915
+ Returns
1916
+ -------
1917
+ None
1918
+
1919
+ Examples
1920
+ --------
1921
+ from Opik import AsyncOpikApi
1922
+ import asyncio
1923
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1924
+ async def main() -> None:
1925
+ await client.traces.close_trace_thread()
1926
+ asyncio.run(main())
1927
+ """
1928
+ _response = await self._raw_client.close_trace_thread(
1929
+ project_name=project_name,
1930
+ project_id=project_id,
1931
+ thread_id=thread_id,
1932
+ thread_ids=thread_ids,
1933
+ request_options=request_options,
1934
+ )
1935
+ return _response.data
1936
+
1937
+ async def get_traces_by_project(
1938
+ self,
1939
+ *,
1940
+ page: typing.Optional[int] = None,
1941
+ size: typing.Optional[int] = None,
1942
+ project_name: typing.Optional[str] = None,
1943
+ project_id: typing.Optional[str] = None,
1944
+ filters: typing.Optional[str] = None,
1945
+ truncate: typing.Optional[bool] = None,
1946
+ strip_attachments: typing.Optional[bool] = None,
1947
+ sorting: typing.Optional[str] = None,
1948
+ exclude: typing.Optional[str] = None,
1949
+ from_time: typing.Optional[dt.datetime] = None,
1950
+ to_time: typing.Optional[dt.datetime] = None,
1951
+ request_options: typing.Optional[RequestOptions] = None,
1952
+ ) -> TracePagePublic:
1953
+ """
1954
+ Get traces by project_name or project_id
1955
+
1956
+ Parameters
1957
+ ----------
1958
+ page : typing.Optional[int]
1959
+
1960
+ size : typing.Optional[int]
1961
+
1962
+ project_name : typing.Optional[str]
1963
+
1964
+ project_id : typing.Optional[str]
1965
+
1966
+ filters : typing.Optional[str]
1967
+
1968
+ truncate : typing.Optional[bool]
1969
+
1970
+ strip_attachments : typing.Optional[bool]
1971
+
1972
+ sorting : typing.Optional[str]
1973
+
1974
+ exclude : typing.Optional[str]
1975
+
1976
+ from_time : typing.Optional[dt.datetime]
1977
+
1978
+ to_time : typing.Optional[dt.datetime]
1979
+
1980
+ request_options : typing.Optional[RequestOptions]
1981
+ Request-specific configuration.
1982
+
1983
+ Returns
1984
+ -------
1985
+ TracePagePublic
1986
+ Trace resource
1987
+
1988
+ Examples
1989
+ --------
1990
+ from Opik import AsyncOpikApi
1991
+ import asyncio
1992
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1993
+ async def main() -> None:
1994
+ await client.traces.get_traces_by_project()
1995
+ asyncio.run(main())
1996
+ """
1997
+ _response = await self._raw_client.get_traces_by_project(
1998
+ page=page,
1999
+ size=size,
2000
+ project_name=project_name,
2001
+ project_id=project_id,
2002
+ filters=filters,
2003
+ truncate=truncate,
2004
+ strip_attachments=strip_attachments,
2005
+ sorting=sorting,
2006
+ exclude=exclude,
2007
+ from_time=from_time,
2008
+ to_time=to_time,
2009
+ request_options=request_options,
2010
+ )
2011
+ return _response.data
2012
+
2013
+ async def create_trace(
2014
+ self,
2015
+ *,
2016
+ start_time: dt.datetime,
2017
+ id: typing.Optional[str] = OMIT,
2018
+ project_name: typing.Optional[str] = OMIT,
2019
+ name: typing.Optional[str] = OMIT,
2020
+ end_time: typing.Optional[dt.datetime] = OMIT,
2021
+ input: typing.Optional[JsonListStringWrite] = OMIT,
2022
+ output: typing.Optional[JsonListStringWrite] = OMIT,
2023
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
2024
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2025
+ error_info: typing.Optional[ErrorInfoWrite] = OMIT,
2026
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
2027
+ thread_id: typing.Optional[str] = OMIT,
2028
+ request_options: typing.Optional[RequestOptions] = None,
2029
+ ) -> None:
2030
+ """
2031
+ Get trace
2032
+
2033
+ Parameters
2034
+ ----------
2035
+ start_time : dt.datetime
2036
+
2037
+ id : typing.Optional[str]
2038
+
2039
+ project_name : typing.Optional[str]
2040
+ If null, the default project is used
2041
+
2042
+ name : typing.Optional[str]
2043
+
2044
+ end_time : typing.Optional[dt.datetime]
2045
+
2046
+ input : typing.Optional[JsonListStringWrite]
2047
+
2048
+ output : typing.Optional[JsonListStringWrite]
2049
+
2050
+ metadata : typing.Optional[JsonListStringWrite]
2051
+
2052
+ tags : typing.Optional[typing.Sequence[str]]
2053
+
2054
+ error_info : typing.Optional[ErrorInfoWrite]
2055
+
2056
+ last_updated_at : typing.Optional[dt.datetime]
2057
+
2058
+ thread_id : typing.Optional[str]
2059
+
2060
+ request_options : typing.Optional[RequestOptions]
2061
+ Request-specific configuration.
2062
+
2063
+ Returns
2064
+ -------
2065
+ None
2066
+
2067
+ Examples
2068
+ --------
2069
+ from Opik import AsyncOpikApi
2070
+ import datetime
2071
+ import asyncio
2072
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2073
+ async def main() -> None:
2074
+ await client.traces.create_trace(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )
2075
+ asyncio.run(main())
2076
+ """
2077
+ _response = await self._raw_client.create_trace(
2078
+ start_time=start_time,
2079
+ id=id,
2080
+ project_name=project_name,
2081
+ name=name,
2082
+ end_time=end_time,
2083
+ input=input,
2084
+ output=output,
2085
+ metadata=metadata,
2086
+ tags=tags,
2087
+ error_info=error_info,
2088
+ last_updated_at=last_updated_at,
2089
+ thread_id=thread_id,
2090
+ request_options=request_options,
2091
+ )
2092
+ return _response.data
2093
+
2094
+ async def get_trace_by_id(
2095
+ self,
2096
+ id: str,
2097
+ *,
2098
+ strip_attachments: typing.Optional[bool] = None,
2099
+ request_options: typing.Optional[RequestOptions] = None,
2100
+ ) -> TracePublic:
2101
+ """
2102
+ Get trace by id
2103
+
2104
+ Parameters
2105
+ ----------
2106
+ id : str
2107
+
2108
+ strip_attachments : typing.Optional[bool]
2109
+
2110
+ request_options : typing.Optional[RequestOptions]
2111
+ Request-specific configuration.
2112
+
2113
+ Returns
2114
+ -------
2115
+ TracePublic
2116
+ Trace resource
2117
+
2118
+ Examples
2119
+ --------
2120
+ from Opik import AsyncOpikApi
2121
+ import asyncio
2122
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2123
+ async def main() -> None:
2124
+ await client.traces.get_trace_by_id(id='id', )
2125
+ asyncio.run(main())
2126
+ """
2127
+ _response = await self._raw_client.get_trace_by_id(
2128
+ id, strip_attachments=strip_attachments, request_options=request_options
2129
+ )
2130
+ return _response.data
2131
+
2132
+ async def delete_trace_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
2133
+ """
2134
+ Delete trace by id
2135
+
2136
+ Parameters
2137
+ ----------
2138
+ id : str
2139
+
2140
+ request_options : typing.Optional[RequestOptions]
2141
+ Request-specific configuration.
2142
+
2143
+ Returns
2144
+ -------
2145
+ None
2146
+
2147
+ Examples
2148
+ --------
2149
+ from Opik import AsyncOpikApi
2150
+ import asyncio
2151
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2152
+ async def main() -> None:
2153
+ await client.traces.delete_trace_by_id(id='id', )
2154
+ asyncio.run(main())
2155
+ """
2156
+ _response = await self._raw_client.delete_trace_by_id(id, request_options=request_options)
2157
+ return _response.data
2158
+
2159
+ async def update_trace(
2160
+ self,
2161
+ id: str,
2162
+ *,
2163
+ project_name: typing.Optional[str] = OMIT,
2164
+ project_id: typing.Optional[str] = OMIT,
2165
+ name: typing.Optional[str] = OMIT,
2166
+ end_time: typing.Optional[dt.datetime] = OMIT,
2167
+ input: typing.Optional[JsonListString] = OMIT,
2168
+ output: typing.Optional[JsonListString] = OMIT,
2169
+ metadata: typing.Optional[JsonListString] = OMIT,
2170
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2171
+ error_info: typing.Optional[ErrorInfo] = OMIT,
2172
+ thread_id: typing.Optional[str] = OMIT,
2173
+ request_options: typing.Optional[RequestOptions] = None,
2174
+ ) -> None:
2175
+ """
2176
+ Update trace by id
2177
+
2178
+ Parameters
2179
+ ----------
2180
+ id : str
2181
+
2182
+ project_name : typing.Optional[str]
2183
+ If null and project_id not specified, Default Project is assumed
2184
+
2185
+ project_id : typing.Optional[str]
2186
+ If null and project_name not specified, Default Project is assumed
2187
+
2188
+ name : typing.Optional[str]
2189
+
2190
+ end_time : typing.Optional[dt.datetime]
2191
+
2192
+ input : typing.Optional[JsonListString]
2193
+
2194
+ output : typing.Optional[JsonListString]
2195
+
2196
+ metadata : typing.Optional[JsonListString]
2197
+
2198
+ tags : typing.Optional[typing.Sequence[str]]
2199
+
2200
+ error_info : typing.Optional[ErrorInfo]
2201
+
2202
+ thread_id : typing.Optional[str]
2203
+
2204
+ request_options : typing.Optional[RequestOptions]
2205
+ Request-specific configuration.
2206
+
2207
+ Returns
2208
+ -------
2209
+ None
2210
+
2211
+ Examples
2212
+ --------
2213
+ from Opik import AsyncOpikApi
2214
+ import asyncio
2215
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2216
+ async def main() -> None:
2217
+ await client.traces.update_trace(id='id', )
2218
+ asyncio.run(main())
2219
+ """
2220
+ _response = await self._raw_client.update_trace(
2221
+ id,
2222
+ project_name=project_name,
2223
+ project_id=project_id,
2224
+ name=name,
2225
+ end_time=end_time,
2226
+ input=input,
2227
+ output=output,
2228
+ metadata=metadata,
2229
+ tags=tags,
2230
+ error_info=error_info,
2231
+ thread_id=thread_id,
2232
+ request_options=request_options,
2233
+ )
2234
+ return _response.data
2235
+
2236
+ async def delete_thread_comments(
2237
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
2238
+ ) -> None:
2239
+ """
2240
+ Delete thread comments
2241
+
2242
+ Parameters
2243
+ ----------
2244
+ ids : typing.Sequence[str]
2245
+
2246
+ request_options : typing.Optional[RequestOptions]
2247
+ Request-specific configuration.
2248
+
2249
+ Returns
2250
+ -------
2251
+ None
2252
+
2253
+ Examples
2254
+ --------
2255
+ from Opik import AsyncOpikApi
2256
+ import asyncio
2257
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2258
+ async def main() -> None:
2259
+ await client.traces.delete_thread_comments(ids=['ids'], )
2260
+ asyncio.run(main())
2261
+ """
2262
+ _response = await self._raw_client.delete_thread_comments(ids=ids, request_options=request_options)
2263
+ return _response.data
2264
+
2265
+ async def delete_thread_feedback_scores(
2266
+ self,
2267
+ *,
2268
+ project_name: str,
2269
+ thread_id: str,
2270
+ names: typing.Sequence[str],
2271
+ author: typing.Optional[str] = OMIT,
2272
+ request_options: typing.Optional[RequestOptions] = None,
2273
+ ) -> None:
2274
+ """
2275
+ Delete thread feedback scores
2276
+
2277
+ Parameters
2278
+ ----------
2279
+ project_name : str
2280
+
2281
+ thread_id : str
2282
+
2283
+ names : typing.Sequence[str]
2284
+
2285
+ author : typing.Optional[str]
2286
+
2287
+ request_options : typing.Optional[RequestOptions]
2288
+ Request-specific configuration.
2289
+
2290
+ Returns
2291
+ -------
2292
+ None
2293
+
2294
+ Examples
2295
+ --------
2296
+ from Opik import AsyncOpikApi
2297
+ import asyncio
2298
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2299
+ async def main() -> None:
2300
+ await client.traces.delete_thread_feedback_scores(project_name='project_name', thread_id='thread_id', names=['names'], )
2301
+ asyncio.run(main())
2302
+ """
2303
+ _response = await self._raw_client.delete_thread_feedback_scores(
2304
+ project_name=project_name, thread_id=thread_id, names=names, author=author, request_options=request_options
2305
+ )
2306
+ return _response.data
2307
+
2308
+ async def delete_trace_comments(
2309
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
2310
+ ) -> None:
2311
+ """
2312
+ Delete trace comments
2313
+
2314
+ Parameters
2315
+ ----------
2316
+ ids : typing.Sequence[str]
2317
+
2318
+ request_options : typing.Optional[RequestOptions]
2319
+ Request-specific configuration.
2320
+
2321
+ Returns
2322
+ -------
2323
+ None
2324
+
2325
+ Examples
2326
+ --------
2327
+ from Opik import AsyncOpikApi
2328
+ import asyncio
2329
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2330
+ async def main() -> None:
2331
+ await client.traces.delete_trace_comments(ids=['ids'], )
2332
+ asyncio.run(main())
2333
+ """
2334
+ _response = await self._raw_client.delete_trace_comments(ids=ids, request_options=request_options)
2335
+ return _response.data
2336
+
2337
+ async def delete_trace_feedback_score(
2338
+ self,
2339
+ id: str,
2340
+ *,
2341
+ name: str,
2342
+ author: typing.Optional[str] = OMIT,
2343
+ request_options: typing.Optional[RequestOptions] = None,
2344
+ ) -> None:
2345
+ """
2346
+ Delete trace feedback score
2347
+
2348
+ Parameters
2349
+ ----------
2350
+ id : str
2351
+
2352
+ name : str
2353
+
2354
+ author : typing.Optional[str]
2355
+
2356
+ request_options : typing.Optional[RequestOptions]
2357
+ Request-specific configuration.
2358
+
2359
+ Returns
2360
+ -------
2361
+ None
1519
2362
 
1520
2363
  Examples
1521
2364
  --------
1522
- import asyncio
1523
-
1524
2365
  from Opik import AsyncOpikApi
1525
-
1526
- client = AsyncOpikApi(
1527
- api_key="YOUR_API_KEY",
1528
- workspace_name="YOUR_WORKSPACE_NAME",
1529
- )
1530
-
1531
-
2366
+ import asyncio
2367
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1532
2368
  async def main() -> None:
1533
- await client.traces.get_traces_by_project()
1534
-
1535
-
2369
+ await client.traces.delete_trace_feedback_score(id='id', name='name', )
1536
2370
  asyncio.run(main())
1537
2371
  """
1538
- _response = await self._client_wrapper.httpx_client.request(
1539
- "v1/private/traces",
1540
- method="GET",
1541
- params={
1542
- "page": page,
1543
- "size": size,
1544
- "project_name": project_name,
1545
- "project_id": project_id,
1546
- "filters": filters,
1547
- "truncate": truncate,
1548
- "sorting": sorting,
1549
- },
1550
- request_options=request_options,
2372
+ _response = await self._raw_client.delete_trace_feedback_score(
2373
+ id, name=name, author=author, request_options=request_options
1551
2374
  )
1552
- try:
1553
- if 200 <= _response.status_code < 300:
1554
- return typing.cast(
1555
- TracePagePublic,
1556
- parse_obj_as(
1557
- type_=TracePagePublic, # type: ignore
1558
- object_=_response.json(),
1559
- ),
1560
- )
1561
- _response_json = _response.json()
1562
- except JSONDecodeError:
1563
- raise ApiError(status_code=_response.status_code, body=_response.text)
1564
- raise ApiError(status_code=_response.status_code, body=_response_json)
2375
+ return _response.data
1565
2376
 
1566
- async def create_trace(
2377
+ async def delete_trace_threads(
1567
2378
  self,
1568
2379
  *,
1569
- name: str,
1570
- start_time: dt.datetime,
1571
- id: typing.Optional[str] = OMIT,
2380
+ thread_ids: typing.Sequence[str],
1572
2381
  project_name: typing.Optional[str] = OMIT,
1573
- end_time: typing.Optional[dt.datetime] = OMIT,
1574
- input: typing.Optional[JsonNodeWrite] = OMIT,
1575
- output: typing.Optional[JsonNodeWrite] = OMIT,
1576
- metadata: typing.Optional[JsonNodeWrite] = OMIT,
1577
- tags: typing.Optional[typing.Sequence[str]] = OMIT,
1578
- error_info: typing.Optional[ErrorInfoWrite] = OMIT,
1579
- thread_id: typing.Optional[str] = OMIT,
2382
+ project_id: typing.Optional[str] = OMIT,
1580
2383
  request_options: typing.Optional[RequestOptions] = None,
1581
2384
  ) -> None:
1582
2385
  """
1583
- Get trace
2386
+ Delete trace threads
1584
2387
 
1585
2388
  Parameters
1586
2389
  ----------
1587
- name : str
1588
-
1589
- start_time : dt.datetime
1590
-
1591
- id : typing.Optional[str]
2390
+ thread_ids : typing.Sequence[str]
1592
2391
 
1593
2392
  project_name : typing.Optional[str]
1594
- If null, the default project is used
1595
-
1596
- end_time : typing.Optional[dt.datetime]
1597
-
1598
- input : typing.Optional[JsonNodeWrite]
1599
-
1600
- output : typing.Optional[JsonNodeWrite]
1601
-
1602
- metadata : typing.Optional[JsonNodeWrite]
1603
-
1604
- tags : typing.Optional[typing.Sequence[str]]
1605
-
1606
- error_info : typing.Optional[ErrorInfoWrite]
2393
+ If null, project_id must be provided
1607
2394
 
1608
- thread_id : typing.Optional[str]
2395
+ project_id : typing.Optional[str]
2396
+ If null, project_name must be provided
1609
2397
 
1610
2398
  request_options : typing.Optional[RequestOptions]
1611
2399
  Request-specific configuration.
@@ -1616,69 +2404,27 @@ class AsyncTracesClient:
1616
2404
 
1617
2405
  Examples
1618
2406
  --------
1619
- import asyncio
1620
- import datetime
1621
-
1622
2407
  from Opik import AsyncOpikApi
1623
-
1624
- client = AsyncOpikApi(
1625
- api_key="YOUR_API_KEY",
1626
- workspace_name="YOUR_WORKSPACE_NAME",
1627
- )
1628
-
1629
-
2408
+ import asyncio
2409
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1630
2410
  async def main() -> None:
1631
- await client.traces.create_trace(
1632
- name="name",
1633
- start_time=datetime.datetime.fromisoformat(
1634
- "2024-01-15 09:30:00+00:00",
1635
- ),
1636
- )
1637
-
1638
-
2411
+ await client.traces.delete_trace_threads(thread_ids=['thread_ids'], )
1639
2412
  asyncio.run(main())
1640
2413
  """
1641
- _response = await self._client_wrapper.httpx_client.request(
1642
- "v1/private/traces",
1643
- method="POST",
1644
- json={
1645
- "id": id,
1646
- "project_name": project_name,
1647
- "name": name,
1648
- "start_time": start_time,
1649
- "end_time": end_time,
1650
- "input": input,
1651
- "output": output,
1652
- "metadata": metadata,
1653
- "tags": tags,
1654
- "error_info": convert_and_respect_annotation_metadata(
1655
- object_=error_info, annotation=ErrorInfoWrite, direction="write"
1656
- ),
1657
- "thread_id": thread_id,
1658
- },
1659
- request_options=request_options,
1660
- omit=OMIT,
2414
+ _response = await self._raw_client.delete_trace_threads(
2415
+ thread_ids=thread_ids, project_name=project_name, project_id=project_id, request_options=request_options
1661
2416
  )
1662
- try:
1663
- if 200 <= _response.status_code < 300:
1664
- return
1665
- _response_json = _response.json()
1666
- except JSONDecodeError:
1667
- raise ApiError(status_code=_response.status_code, body=_response.text)
1668
- raise ApiError(status_code=_response.status_code, body=_response_json)
2417
+ return _response.data
1669
2418
 
1670
- async def create_traces(
1671
- self,
1672
- *,
1673
- traces: typing.Sequence[TraceWrite],
1674
- request_options: typing.Optional[RequestOptions] = None,
2419
+ async def delete_traces(
2420
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
1675
2421
  ) -> None:
1676
2422
  """
1677
- Create traces
2423
+ Delete traces
1678
2424
 
1679
2425
  Parameters
1680
2426
  ----------
1681
- traces : typing.Sequence[TraceWrite]
2427
+ ids : typing.Sequence[str]
1682
2428
 
1683
2429
  request_options : typing.Optional[RequestOptions]
1684
2430
  Request-specific configuration.
@@ -1689,462 +2435,389 @@ class AsyncTracesClient:
1689
2435
 
1690
2436
  Examples
1691
2437
  --------
2438
+ from Opik import AsyncOpikApi
1692
2439
  import asyncio
1693
- import datetime
1694
-
1695
- from Opik import AsyncOpikApi, TraceWrite
1696
-
1697
- client = AsyncOpikApi(
1698
- api_key="YOUR_API_KEY",
1699
- workspace_name="YOUR_WORKSPACE_NAME",
1700
- )
1701
-
1702
-
2440
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1703
2441
  async def main() -> None:
1704
- await client.traces.create_traces(
1705
- traces=[
1706
- TraceWrite(
1707
- name="name",
1708
- start_time=datetime.datetime.fromisoformat(
1709
- "2024-01-15 09:30:00+00:00",
1710
- ),
1711
- )
1712
- ],
1713
- )
1714
-
1715
-
2442
+ await client.traces.delete_traces(ids=['ids'], )
1716
2443
  asyncio.run(main())
1717
2444
  """
1718
- _response = await self._client_wrapper.httpx_client.request(
1719
- "v1/private/traces/batch",
1720
- method="POST",
1721
- json={
1722
- "traces": convert_and_respect_annotation_metadata(
1723
- object_=traces,
1724
- annotation=typing.Sequence[TraceWrite],
1725
- direction="write",
1726
- ),
1727
- },
1728
- headers={
1729
- "content-type": "application/json",
1730
- },
1731
- request_options=request_options,
1732
- omit=OMIT,
1733
- )
1734
- try:
1735
- if 200 <= _response.status_code < 300:
1736
- return
1737
- _response_json = _response.json()
1738
- except JSONDecodeError:
1739
- raise ApiError(status_code=_response.status_code, body=_response.text)
1740
- raise ApiError(status_code=_response.status_code, body=_response_json)
2445
+ _response = await self._raw_client.delete_traces(ids=ids, request_options=request_options)
2446
+ return _response.data
1741
2447
 
1742
- async def get_trace_by_id(
1743
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1744
- ) -> TracePublic:
2448
+ async def find_feedback_score_names_2(
2449
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
2450
+ ) -> typing.List[str]:
1745
2451
  """
1746
- Get trace by id
2452
+ Find Feedback Score names
1747
2453
 
1748
2454
  Parameters
1749
2455
  ----------
1750
- id : str
2456
+ project_id : typing.Optional[str]
1751
2457
 
1752
2458
  request_options : typing.Optional[RequestOptions]
1753
2459
  Request-specific configuration.
1754
2460
 
1755
2461
  Returns
1756
2462
  -------
1757
- TracePublic
1758
- Trace resource
2463
+ typing.List[str]
2464
+ Feedback Scores resource
1759
2465
 
1760
2466
  Examples
1761
2467
  --------
1762
- import asyncio
1763
-
1764
2468
  from Opik import AsyncOpikApi
1765
-
1766
- client = AsyncOpikApi(
1767
- api_key="YOUR_API_KEY",
1768
- workspace_name="YOUR_WORKSPACE_NAME",
1769
- )
1770
-
1771
-
2469
+ import asyncio
2470
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1772
2471
  async def main() -> None:
1773
- await client.traces.get_trace_by_id(
1774
- id="id",
1775
- )
1776
-
1777
-
2472
+ await client.traces.find_feedback_score_names_2()
1778
2473
  asyncio.run(main())
1779
2474
  """
1780
- _response = await self._client_wrapper.httpx_client.request(
1781
- f"v1/private/traces/{jsonable_encoder(id)}",
1782
- method="GET",
1783
- request_options=request_options,
2475
+ _response = await self._raw_client.find_feedback_score_names_2(
2476
+ project_id=project_id, request_options=request_options
1784
2477
  )
1785
- try:
1786
- if 200 <= _response.status_code < 300:
1787
- return typing.cast(
1788
- TracePublic,
1789
- parse_obj_as(
1790
- type_=TracePublic, # type: ignore
1791
- object_=_response.json(),
1792
- ),
1793
- )
1794
- _response_json = _response.json()
1795
- except JSONDecodeError:
1796
- raise ApiError(status_code=_response.status_code, body=_response.text)
1797
- raise ApiError(status_code=_response.status_code, body=_response_json)
1798
-
1799
- async def delete_trace_by_id(
1800
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1801
- ) -> None:
2478
+ return _response.data
2479
+
2480
+ async def find_trace_threads_feedback_score_names(
2481
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
2482
+ ) -> typing.List[str]:
1802
2483
  """
1803
- Delete trace by id
2484
+ Find Trace Threads Feedback Score names
1804
2485
 
1805
2486
  Parameters
1806
2487
  ----------
1807
- id : str
2488
+ project_id : typing.Optional[str]
1808
2489
 
1809
2490
  request_options : typing.Optional[RequestOptions]
1810
2491
  Request-specific configuration.
1811
2492
 
1812
2493
  Returns
1813
2494
  -------
1814
- None
2495
+ typing.List[str]
2496
+ Find Trace Threads Feedback Score names
1815
2497
 
1816
2498
  Examples
1817
2499
  --------
1818
- import asyncio
1819
-
1820
2500
  from Opik import AsyncOpikApi
1821
-
1822
- client = AsyncOpikApi(
1823
- api_key="YOUR_API_KEY",
1824
- workspace_name="YOUR_WORKSPACE_NAME",
1825
- )
1826
-
1827
-
2501
+ import asyncio
2502
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
1828
2503
  async def main() -> None:
1829
- await client.traces.delete_trace_by_id(
1830
- id="id",
1831
- )
1832
-
1833
-
2504
+ await client.traces.find_trace_threads_feedback_score_names()
1834
2505
  asyncio.run(main())
1835
2506
  """
1836
- _response = await self._client_wrapper.httpx_client.request(
1837
- f"v1/private/traces/{jsonable_encoder(id)}",
1838
- method="DELETE",
1839
- request_options=request_options,
2507
+ _response = await self._raw_client.find_trace_threads_feedback_score_names(
2508
+ project_id=project_id, request_options=request_options
1840
2509
  )
1841
- try:
1842
- if 200 <= _response.status_code < 300:
1843
- return
1844
- _response_json = _response.json()
1845
- except JSONDecodeError:
1846
- raise ApiError(status_code=_response.status_code, body=_response.text)
1847
- raise ApiError(status_code=_response.status_code, body=_response_json)
2510
+ return _response.data
1848
2511
 
1849
- async def update_trace(
2512
+ async def get_trace_stats(
1850
2513
  self,
1851
- id: str,
1852
2514
  *,
1853
- project_name: typing.Optional[str] = OMIT,
1854
- project_id: typing.Optional[str] = OMIT,
1855
- end_time: typing.Optional[dt.datetime] = OMIT,
1856
- input: typing.Optional[JsonNode] = OMIT,
1857
- output: typing.Optional[JsonNode] = OMIT,
1858
- metadata: typing.Optional[JsonNode] = OMIT,
1859
- tags: typing.Optional[typing.Sequence[str]] = OMIT,
1860
- error_info: typing.Optional[ErrorInfo] = OMIT,
1861
- thread_id: typing.Optional[str] = OMIT,
2515
+ project_id: typing.Optional[str] = None,
2516
+ project_name: typing.Optional[str] = None,
2517
+ filters: typing.Optional[str] = None,
2518
+ from_time: typing.Optional[dt.datetime] = None,
2519
+ to_time: typing.Optional[dt.datetime] = None,
1862
2520
  request_options: typing.Optional[RequestOptions] = None,
1863
- ) -> None:
2521
+ ) -> ProjectStatsPublic:
1864
2522
  """
1865
- Update trace by id
2523
+ Get trace stats
1866
2524
 
1867
2525
  Parameters
1868
2526
  ----------
1869
- id : str
1870
-
1871
- project_name : typing.Optional[str]
1872
- If null and project_id not specified, Default Project is assumed
1873
-
1874
2527
  project_id : typing.Optional[str]
1875
- If null and project_name not specified, Default Project is assumed
1876
-
1877
- end_time : typing.Optional[dt.datetime]
1878
2528
 
1879
- input : typing.Optional[JsonNode]
1880
-
1881
- output : typing.Optional[JsonNode]
1882
-
1883
- metadata : typing.Optional[JsonNode]
2529
+ project_name : typing.Optional[str]
1884
2530
 
1885
- tags : typing.Optional[typing.Sequence[str]]
2531
+ filters : typing.Optional[str]
1886
2532
 
1887
- error_info : typing.Optional[ErrorInfo]
2533
+ from_time : typing.Optional[dt.datetime]
1888
2534
 
1889
- thread_id : typing.Optional[str]
2535
+ to_time : typing.Optional[dt.datetime]
1890
2536
 
1891
2537
  request_options : typing.Optional[RequestOptions]
1892
2538
  Request-specific configuration.
1893
2539
 
1894
2540
  Returns
1895
2541
  -------
1896
- None
2542
+ ProjectStatsPublic
2543
+ Trace stats resource
1897
2544
 
1898
2545
  Examples
1899
2546
  --------
2547
+ from Opik import AsyncOpikApi
1900
2548
  import asyncio
2549
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2550
+ async def main() -> None:
2551
+ await client.traces.get_trace_stats()
2552
+ asyncio.run(main())
2553
+ """
2554
+ _response = await self._raw_client.get_trace_stats(
2555
+ project_id=project_id,
2556
+ project_name=project_name,
2557
+ filters=filters,
2558
+ from_time=from_time,
2559
+ to_time=to_time,
2560
+ request_options=request_options,
2561
+ )
2562
+ return _response.data
1901
2563
 
1902
- from Opik import AsyncOpikApi
2564
+ async def get_thread_comment(
2565
+ self, comment_id: str, thread_id: str, *, request_options: typing.Optional[RequestOptions] = None
2566
+ ) -> Comment:
2567
+ """
2568
+ Get thread comment
1903
2569
 
1904
- client = AsyncOpikApi(
1905
- api_key="YOUR_API_KEY",
1906
- workspace_name="YOUR_WORKSPACE_NAME",
1907
- )
2570
+ Parameters
2571
+ ----------
2572
+ comment_id : str
1908
2573
 
2574
+ thread_id : str
1909
2575
 
1910
- async def main() -> None:
1911
- await client.traces.update_trace(
1912
- id="id",
1913
- )
2576
+ request_options : typing.Optional[RequestOptions]
2577
+ Request-specific configuration.
1914
2578
 
2579
+ Returns
2580
+ -------
2581
+ Comment
2582
+ Comment resource
1915
2583
 
2584
+ Examples
2585
+ --------
2586
+ from Opik import AsyncOpikApi
2587
+ import asyncio
2588
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2589
+ async def main() -> None:
2590
+ await client.traces.get_thread_comment(comment_id='commentId', thread_id='threadId', )
1916
2591
  asyncio.run(main())
1917
2592
  """
1918
- _response = await self._client_wrapper.httpx_client.request(
1919
- f"v1/private/traces/{jsonable_encoder(id)}",
1920
- method="PATCH",
1921
- json={
1922
- "project_name": project_name,
1923
- "project_id": project_id,
1924
- "end_time": end_time,
1925
- "input": input,
1926
- "output": output,
1927
- "metadata": metadata,
1928
- "tags": tags,
1929
- "error_info": convert_and_respect_annotation_metadata(
1930
- object_=error_info, annotation=ErrorInfo, direction="write"
1931
- ),
1932
- "thread_id": thread_id,
1933
- },
1934
- headers={
1935
- "content-type": "application/json",
1936
- },
1937
- request_options=request_options,
1938
- omit=OMIT,
1939
- )
1940
- try:
1941
- if 200 <= _response.status_code < 300:
1942
- return
1943
- _response_json = _response.json()
1944
- except JSONDecodeError:
1945
- raise ApiError(status_code=_response.status_code, body=_response.text)
1946
- raise ApiError(status_code=_response.status_code, body=_response_json)
2593
+ _response = await self._raw_client.get_thread_comment(comment_id, thread_id, request_options=request_options)
2594
+ return _response.data
1947
2595
 
1948
- async def delete_trace_comments(
2596
+ async def get_trace_thread_stats(
1949
2597
  self,
1950
2598
  *,
1951
- ids: typing.Sequence[str],
2599
+ project_id: typing.Optional[str] = None,
2600
+ project_name: typing.Optional[str] = None,
2601
+ filters: typing.Optional[str] = None,
2602
+ from_time: typing.Optional[dt.datetime] = None,
2603
+ to_time: typing.Optional[dt.datetime] = None,
1952
2604
  request_options: typing.Optional[RequestOptions] = None,
1953
- ) -> None:
2605
+ ) -> ProjectStatsPublic:
1954
2606
  """
1955
- Delete trace comments
2607
+ Get trace thread stats
1956
2608
 
1957
2609
  Parameters
1958
2610
  ----------
1959
- ids : typing.Sequence[str]
2611
+ project_id : typing.Optional[str]
2612
+
2613
+ project_name : typing.Optional[str]
2614
+
2615
+ filters : typing.Optional[str]
2616
+
2617
+ from_time : typing.Optional[dt.datetime]
2618
+
2619
+ to_time : typing.Optional[dt.datetime]
1960
2620
 
1961
2621
  request_options : typing.Optional[RequestOptions]
1962
2622
  Request-specific configuration.
1963
2623
 
1964
2624
  Returns
1965
2625
  -------
1966
- None
2626
+ ProjectStatsPublic
2627
+ Trace thread stats resource
1967
2628
 
1968
2629
  Examples
1969
2630
  --------
2631
+ from Opik import AsyncOpikApi
1970
2632
  import asyncio
2633
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2634
+ async def main() -> None:
2635
+ await client.traces.get_trace_thread_stats()
2636
+ asyncio.run(main())
2637
+ """
2638
+ _response = await self._raw_client.get_trace_thread_stats(
2639
+ project_id=project_id,
2640
+ project_name=project_name,
2641
+ filters=filters,
2642
+ from_time=from_time,
2643
+ to_time=to_time,
2644
+ request_options=request_options,
2645
+ )
2646
+ return _response.data
1971
2647
 
1972
- from Opik import AsyncOpikApi
2648
+ async def get_trace_comment(
2649
+ self, comment_id: str, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
2650
+ ) -> Comment:
2651
+ """
2652
+ Get trace comment
1973
2653
 
1974
- client = AsyncOpikApi(
1975
- api_key="YOUR_API_KEY",
1976
- workspace_name="YOUR_WORKSPACE_NAME",
1977
- )
2654
+ Parameters
2655
+ ----------
2656
+ comment_id : str
1978
2657
 
2658
+ trace_id : str
1979
2659
 
1980
- async def main() -> None:
1981
- await client.traces.delete_trace_comments(
1982
- ids=["ids"],
1983
- )
2660
+ request_options : typing.Optional[RequestOptions]
2661
+ Request-specific configuration.
1984
2662
 
2663
+ Returns
2664
+ -------
2665
+ Comment
2666
+ Comment resource
1985
2667
 
2668
+ Examples
2669
+ --------
2670
+ from Opik import AsyncOpikApi
2671
+ import asyncio
2672
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2673
+ async def main() -> None:
2674
+ await client.traces.get_trace_comment(comment_id='commentId', trace_id='traceId', )
1986
2675
  asyncio.run(main())
1987
2676
  """
1988
- _response = await self._client_wrapper.httpx_client.request(
1989
- "v1/private/traces/comments/delete",
1990
- method="POST",
1991
- json={
1992
- "ids": ids,
1993
- },
1994
- request_options=request_options,
1995
- omit=OMIT,
1996
- )
1997
- try:
1998
- if 200 <= _response.status_code < 300:
1999
- return
2000
- _response_json = _response.json()
2001
- except JSONDecodeError:
2002
- raise ApiError(status_code=_response.status_code, body=_response.text)
2003
- raise ApiError(status_code=_response.status_code, body=_response_json)
2677
+ _response = await self._raw_client.get_trace_comment(comment_id, trace_id, request_options=request_options)
2678
+ return _response.data
2004
2679
 
2005
- async def delete_trace_feedback_score(
2680
+ async def get_trace_thread(
2006
2681
  self,
2007
- id: str,
2008
2682
  *,
2009
- name: str,
2683
+ thread_id: str,
2684
+ project_name: typing.Optional[str] = OMIT,
2685
+ project_id: typing.Optional[str] = OMIT,
2686
+ truncate: typing.Optional[bool] = OMIT,
2010
2687
  request_options: typing.Optional[RequestOptions] = None,
2011
- ) -> None:
2688
+ ) -> TraceThread:
2012
2689
  """
2013
- Delete trace feedback score
2690
+ Get trace thread
2014
2691
 
2015
2692
  Parameters
2016
2693
  ----------
2017
- id : str
2694
+ thread_id : str
2018
2695
 
2019
- name : str
2696
+ project_name : typing.Optional[str]
2697
+
2698
+ project_id : typing.Optional[str]
2699
+
2700
+ truncate : typing.Optional[bool]
2020
2701
 
2021
2702
  request_options : typing.Optional[RequestOptions]
2022
2703
  Request-specific configuration.
2023
2704
 
2024
2705
  Returns
2025
2706
  -------
2026
- None
2707
+ TraceThread
2708
+ Trace thread resource
2027
2709
 
2028
2710
  Examples
2029
2711
  --------
2030
- import asyncio
2031
-
2032
2712
  from Opik import AsyncOpikApi
2033
-
2034
- client = AsyncOpikApi(
2035
- api_key="YOUR_API_KEY",
2036
- workspace_name="YOUR_WORKSPACE_NAME",
2037
- )
2038
-
2039
-
2713
+ import asyncio
2714
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2040
2715
  async def main() -> None:
2041
- await client.traces.delete_trace_feedback_score(
2042
- id="id",
2043
- name="name",
2044
- )
2045
-
2046
-
2716
+ await client.traces.get_trace_thread(thread_id='thread_id', )
2047
2717
  asyncio.run(main())
2048
2718
  """
2049
- _response = await self._client_wrapper.httpx_client.request(
2050
- f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores/delete",
2051
- method="POST",
2052
- json={
2053
- "name": name,
2054
- },
2719
+ _response = await self._raw_client.get_trace_thread(
2720
+ thread_id=thread_id,
2721
+ project_name=project_name,
2722
+ project_id=project_id,
2723
+ truncate=truncate,
2055
2724
  request_options=request_options,
2056
- omit=OMIT,
2057
2725
  )
2058
- try:
2059
- if 200 <= _response.status_code < 300:
2060
- return
2061
- _response_json = _response.json()
2062
- except JSONDecodeError:
2063
- raise ApiError(status_code=_response.status_code, body=_response.text)
2064
- raise ApiError(status_code=_response.status_code, body=_response_json)
2726
+ return _response.data
2065
2727
 
2066
- async def delete_trace_threads(
2728
+ async def get_trace_threads(
2067
2729
  self,
2068
2730
  *,
2069
- thread_ids: typing.Sequence[str],
2070
- project_name: typing.Optional[str] = OMIT,
2071
- project_id: typing.Optional[str] = OMIT,
2731
+ page: typing.Optional[int] = None,
2732
+ size: typing.Optional[int] = None,
2733
+ project_name: typing.Optional[str] = None,
2734
+ project_id: typing.Optional[str] = None,
2735
+ truncate: typing.Optional[bool] = None,
2736
+ strip_attachments: typing.Optional[bool] = None,
2737
+ filters: typing.Optional[str] = None,
2738
+ sorting: typing.Optional[str] = None,
2739
+ from_time: typing.Optional[dt.datetime] = None,
2740
+ to_time: typing.Optional[dt.datetime] = None,
2072
2741
  request_options: typing.Optional[RequestOptions] = None,
2073
- ) -> None:
2742
+ ) -> TraceThreadPage:
2074
2743
  """
2075
- Delete trace threads
2744
+ Get trace threads
2076
2745
 
2077
2746
  Parameters
2078
2747
  ----------
2079
- thread_ids : typing.Sequence[str]
2748
+ page : typing.Optional[int]
2749
+
2750
+ size : typing.Optional[int]
2080
2751
 
2081
2752
  project_name : typing.Optional[str]
2082
- If null, project_id must be provided
2083
2753
 
2084
2754
  project_id : typing.Optional[str]
2085
- If null, project_name must be provided
2755
+
2756
+ truncate : typing.Optional[bool]
2757
+
2758
+ strip_attachments : typing.Optional[bool]
2759
+
2760
+ filters : typing.Optional[str]
2761
+
2762
+ sorting : typing.Optional[str]
2763
+
2764
+ from_time : typing.Optional[dt.datetime]
2765
+
2766
+ to_time : typing.Optional[dt.datetime]
2086
2767
 
2087
2768
  request_options : typing.Optional[RequestOptions]
2088
2769
  Request-specific configuration.
2089
2770
 
2090
2771
  Returns
2091
2772
  -------
2092
- None
2773
+ TraceThreadPage
2774
+ Trace threads resource
2093
2775
 
2094
2776
  Examples
2095
2777
  --------
2096
- import asyncio
2097
-
2098
2778
  from Opik import AsyncOpikApi
2099
-
2100
- client = AsyncOpikApi(
2101
- api_key="YOUR_API_KEY",
2102
- workspace_name="YOUR_WORKSPACE_NAME",
2103
- )
2104
-
2105
-
2779
+ import asyncio
2780
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2106
2781
  async def main() -> None:
2107
- await client.traces.delete_trace_threads(
2108
- thread_ids=["thread_ids"],
2109
- )
2110
-
2111
-
2782
+ await client.traces.get_trace_threads()
2112
2783
  asyncio.run(main())
2113
2784
  """
2114
- _response = await self._client_wrapper.httpx_client.request(
2115
- "v1/private/traces/threads/delete",
2116
- method="POST",
2117
- json={
2118
- "project_name": project_name,
2119
- "project_id": project_id,
2120
- "thread_ids": thread_ids,
2121
- },
2122
- headers={
2123
- "content-type": "application/json",
2124
- },
2785
+ _response = await self._raw_client.get_trace_threads(
2786
+ page=page,
2787
+ size=size,
2788
+ project_name=project_name,
2789
+ project_id=project_id,
2790
+ truncate=truncate,
2791
+ strip_attachments=strip_attachments,
2792
+ filters=filters,
2793
+ sorting=sorting,
2794
+ from_time=from_time,
2795
+ to_time=to_time,
2125
2796
  request_options=request_options,
2126
- omit=OMIT,
2127
2797
  )
2128
- try:
2129
- if 200 <= _response.status_code < 300:
2130
- return
2131
- _response_json = _response.json()
2132
- except JSONDecodeError:
2133
- raise ApiError(status_code=_response.status_code, body=_response.text)
2134
- raise ApiError(status_code=_response.status_code, body=_response_json)
2798
+ return _response.data
2135
2799
 
2136
- async def delete_traces(
2800
+ async def open_trace_thread(
2137
2801
  self,
2138
2802
  *,
2139
- ids: typing.Sequence[str],
2803
+ thread_id: str,
2804
+ project_name: typing.Optional[str] = OMIT,
2805
+ project_id: typing.Optional[str] = OMIT,
2806
+ truncate: typing.Optional[bool] = OMIT,
2140
2807
  request_options: typing.Optional[RequestOptions] = None,
2141
2808
  ) -> None:
2142
2809
  """
2143
- Delete traces
2810
+ Open trace thread
2144
2811
 
2145
2812
  Parameters
2146
2813
  ----------
2147
- ids : typing.Sequence[str]
2814
+ thread_id : str
2815
+
2816
+ project_name : typing.Optional[str]
2817
+
2818
+ project_id : typing.Optional[str]
2819
+
2820
+ truncate : typing.Optional[bool]
2148
2821
 
2149
2822
  request_options : typing.Optional[RequestOptions]
2150
2823
  Request-specific configuration.
@@ -2155,420 +2828,283 @@ class AsyncTracesClient:
2155
2828
 
2156
2829
  Examples
2157
2830
  --------
2158
- import asyncio
2159
-
2160
2831
  from Opik import AsyncOpikApi
2161
-
2162
- client = AsyncOpikApi(
2163
- api_key="YOUR_API_KEY",
2164
- workspace_name="YOUR_WORKSPACE_NAME",
2165
- )
2166
-
2167
-
2832
+ import asyncio
2833
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2168
2834
  async def main() -> None:
2169
- await client.traces.delete_traces(
2170
- ids=["ids"],
2171
- )
2172
-
2173
-
2835
+ await client.traces.open_trace_thread(thread_id='thread_id', )
2174
2836
  asyncio.run(main())
2175
2837
  """
2176
- _response = await self._client_wrapper.httpx_client.request(
2177
- "v1/private/traces/delete",
2178
- method="POST",
2179
- json={
2180
- "ids": ids,
2181
- },
2838
+ _response = await self._raw_client.open_trace_thread(
2839
+ thread_id=thread_id,
2840
+ project_name=project_name,
2841
+ project_id=project_id,
2842
+ truncate=truncate,
2182
2843
  request_options=request_options,
2183
- omit=OMIT,
2184
2844
  )
2185
- try:
2186
- if 200 <= _response.status_code < 300:
2187
- return
2188
- _response_json = _response.json()
2189
- except JSONDecodeError:
2190
- raise ApiError(status_code=_response.status_code, body=_response.text)
2191
- raise ApiError(status_code=_response.status_code, body=_response_json)
2845
+ return _response.data
2192
2846
 
2193
- async def find_feedback_score_names_2(
2847
+ async def score_batch_of_threads(
2194
2848
  self,
2195
2849
  *,
2196
- project_id: typing.Optional[str] = None,
2850
+ scores: typing.Sequence[FeedbackScoreBatchItemThread],
2197
2851
  request_options: typing.Optional[RequestOptions] = None,
2198
- ) -> typing.List[str]:
2852
+ ) -> None:
2199
2853
  """
2200
- Find Feedback Score names
2854
+ Batch feedback scoring for threads
2201
2855
 
2202
2856
  Parameters
2203
2857
  ----------
2204
- project_id : typing.Optional[str]
2858
+ scores : typing.Sequence[FeedbackScoreBatchItemThread]
2205
2859
 
2206
2860
  request_options : typing.Optional[RequestOptions]
2207
2861
  Request-specific configuration.
2208
2862
 
2209
2863
  Returns
2210
2864
  -------
2211
- typing.List[str]
2212
- Feedback Scores resource
2865
+ None
2213
2866
 
2214
2867
  Examples
2215
2868
  --------
2216
- import asyncio
2217
-
2218
2869
  from Opik import AsyncOpikApi
2219
-
2220
- client = AsyncOpikApi(
2221
- api_key="YOUR_API_KEY",
2222
- workspace_name="YOUR_WORKSPACE_NAME",
2223
- )
2224
-
2225
-
2870
+ from Opik import FeedbackScoreBatchItemThread
2871
+ import asyncio
2872
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2226
2873
  async def main() -> None:
2227
- await client.traces.find_feedback_score_names_2()
2228
-
2229
-
2874
+ await client.traces.score_batch_of_threads(scores=[FeedbackScoreBatchItemThread(name='name', value=1.1, source="ui", thread_id='thread_id', )], )
2230
2875
  asyncio.run(main())
2231
2876
  """
2232
- _response = await self._client_wrapper.httpx_client.request(
2233
- "v1/private/traces/feedback-scores/names",
2234
- method="GET",
2235
- params={
2236
- "project_id": project_id,
2237
- },
2238
- request_options=request_options,
2239
- )
2240
- try:
2241
- if 200 <= _response.status_code < 300:
2242
- return typing.cast(
2243
- typing.List[str],
2244
- parse_obj_as(
2245
- type_=typing.List[str], # type: ignore
2246
- object_=_response.json(),
2247
- ),
2248
- )
2249
- _response_json = _response.json()
2250
- except JSONDecodeError:
2251
- raise ApiError(status_code=_response.status_code, body=_response.text)
2252
- raise ApiError(status_code=_response.status_code, body=_response_json)
2877
+ _response = await self._raw_client.score_batch_of_threads(scores=scores, request_options=request_options)
2878
+ return _response.data
2253
2879
 
2254
- async def get_trace_stats(
2880
+ async def score_batch_of_traces(
2255
2881
  self,
2256
2882
  *,
2257
- project_id: typing.Optional[str] = None,
2258
- project_name: typing.Optional[str] = None,
2259
- filters: typing.Optional[str] = None,
2883
+ scores: typing.Sequence[FeedbackScoreBatchItem],
2260
2884
  request_options: typing.Optional[RequestOptions] = None,
2261
- ) -> ProjectStatsPublic:
2885
+ ) -> None:
2262
2886
  """
2263
- Get trace stats
2887
+ Batch feedback scoring for traces
2264
2888
 
2265
2889
  Parameters
2266
2890
  ----------
2267
- project_id : typing.Optional[str]
2268
-
2269
- project_name : typing.Optional[str]
2270
-
2271
- filters : typing.Optional[str]
2891
+ scores : typing.Sequence[FeedbackScoreBatchItem]
2272
2892
 
2273
2893
  request_options : typing.Optional[RequestOptions]
2274
2894
  Request-specific configuration.
2275
2895
 
2276
2896
  Returns
2277
2897
  -------
2278
- ProjectStatsPublic
2279
- Trace stats resource
2898
+ None
2280
2899
 
2281
2900
  Examples
2282
2901
  --------
2283
- import asyncio
2284
-
2285
2902
  from Opik import AsyncOpikApi
2286
-
2287
- client = AsyncOpikApi(
2288
- api_key="YOUR_API_KEY",
2289
- workspace_name="YOUR_WORKSPACE_NAME",
2290
- )
2291
-
2292
-
2903
+ from Opik import FeedbackScoreBatchItem
2904
+ import asyncio
2905
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2293
2906
  async def main() -> None:
2294
- await client.traces.get_trace_stats()
2295
-
2296
-
2907
+ await client.traces.score_batch_of_traces(scores=[FeedbackScoreBatchItem(name='name', value=1.1, source="ui", id='id', )], )
2297
2908
  asyncio.run(main())
2298
2909
  """
2299
- _response = await self._client_wrapper.httpx_client.request(
2300
- "v1/private/traces/stats",
2301
- method="GET",
2302
- params={
2303
- "project_id": project_id,
2304
- "project_name": project_name,
2305
- "filters": filters,
2306
- },
2307
- request_options=request_options,
2308
- )
2309
- try:
2310
- if 200 <= _response.status_code < 300:
2311
- return typing.cast(
2312
- ProjectStatsPublic,
2313
- parse_obj_as(
2314
- type_=ProjectStatsPublic, # type: ignore
2315
- object_=_response.json(),
2316
- ),
2317
- )
2318
- _response_json = _response.json()
2319
- except JSONDecodeError:
2320
- raise ApiError(status_code=_response.status_code, body=_response.text)
2321
- raise ApiError(status_code=_response.status_code, body=_response_json)
2910
+ _response = await self._raw_client.score_batch_of_traces(scores=scores, request_options=request_options)
2911
+ return _response.data
2322
2912
 
2323
- async def get_trace_comment(
2913
+ async def search_trace_threads(
2324
2914
  self,
2325
- comment_id: str,
2326
- trace_id: str,
2327
2915
  *,
2916
+ project_name: typing.Optional[str] = OMIT,
2917
+ project_id: typing.Optional[str] = OMIT,
2918
+ filters: typing.Optional[typing.Sequence[TraceThreadFilter]] = OMIT,
2919
+ last_retrieved_thread_model_id: typing.Optional[str] = OMIT,
2920
+ limit: typing.Optional[int] = OMIT,
2921
+ truncate: typing.Optional[bool] = OMIT,
2922
+ strip_attachments: typing.Optional[bool] = OMIT,
2923
+ from_time: typing.Optional[dt.datetime] = OMIT,
2924
+ to_time: typing.Optional[dt.datetime] = OMIT,
2328
2925
  request_options: typing.Optional[RequestOptions] = None,
2329
- ) -> Comment:
2926
+ ) -> typing.AsyncIterator[bytes]:
2330
2927
  """
2331
- Get trace comment
2928
+ Search trace threads
2332
2929
 
2333
2930
  Parameters
2334
2931
  ----------
2335
- comment_id : str
2932
+ project_name : typing.Optional[str]
2336
2933
 
2337
- trace_id : str
2934
+ project_id : typing.Optional[str]
2338
2935
 
2339
- request_options : typing.Optional[RequestOptions]
2340
- Request-specific configuration.
2936
+ filters : typing.Optional[typing.Sequence[TraceThreadFilter]]
2341
2937
 
2342
- Returns
2343
- -------
2344
- Comment
2345
- Comment resource
2938
+ last_retrieved_thread_model_id : typing.Optional[str]
2346
2939
 
2347
- Examples
2348
- --------
2349
- import asyncio
2940
+ limit : typing.Optional[int]
2941
+ Max number of trace thread to be streamed
2350
2942
 
2351
- from Opik import AsyncOpikApi
2943
+ truncate : typing.Optional[bool]
2944
+ Truncate input, output and metadata to slim payloads
2352
2945
 
2353
- client = AsyncOpikApi(
2354
- api_key="YOUR_API_KEY",
2355
- workspace_name="YOUR_WORKSPACE_NAME",
2356
- )
2946
+ strip_attachments : typing.Optional[bool]
2947
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
2357
2948
 
2949
+ from_time : typing.Optional[dt.datetime]
2950
+ Filter trace threads created from this time (ISO-8601 format).
2358
2951
 
2359
- async def main() -> None:
2360
- await client.traces.get_trace_comment(
2361
- comment_id="commentId",
2362
- trace_id="traceId",
2363
- )
2952
+ to_time : typing.Optional[dt.datetime]
2953
+ Filter trace threads created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
2364
2954
 
2955
+ request_options : typing.Optional[RequestOptions]
2956
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
2365
2957
 
2366
- asyncio.run(main())
2367
- """
2368
- _response = await self._client_wrapper.httpx_client.request(
2369
- f"v1/private/traces/{jsonable_encoder(trace_id)}/comments/{jsonable_encoder(comment_id)}",
2370
- method="GET",
2958
+ Returns
2959
+ -------
2960
+ typing.AsyncIterator[bytes]
2961
+ Trace threads stream or error during process
2962
+ """
2963
+ async with self._raw_client.search_trace_threads(
2964
+ project_name=project_name,
2965
+ project_id=project_id,
2966
+ filters=filters,
2967
+ last_retrieved_thread_model_id=last_retrieved_thread_model_id,
2968
+ limit=limit,
2969
+ truncate=truncate,
2970
+ strip_attachments=strip_attachments,
2971
+ from_time=from_time,
2972
+ to_time=to_time,
2371
2973
  request_options=request_options,
2372
- )
2373
- try:
2374
- if 200 <= _response.status_code < 300:
2375
- return typing.cast(
2376
- Comment,
2377
- parse_obj_as(
2378
- type_=Comment, # type: ignore
2379
- object_=_response.json(),
2380
- ),
2381
- )
2382
- if _response.status_code == 404:
2383
- raise NotFoundError(
2384
- typing.cast(
2385
- typing.Optional[typing.Any],
2386
- parse_obj_as(
2387
- type_=typing.Optional[typing.Any], # type: ignore
2388
- object_=_response.json(),
2389
- ),
2390
- )
2391
- )
2392
- _response_json = _response.json()
2393
- except JSONDecodeError:
2394
- raise ApiError(status_code=_response.status_code, body=_response.text)
2395
- raise ApiError(status_code=_response.status_code, body=_response_json)
2974
+ ) as r:
2975
+ async for data in r.data:
2976
+ yield data
2396
2977
 
2397
- async def get_trace_thread(
2978
+ async def search_traces(
2398
2979
  self,
2399
2980
  *,
2400
- project_id: str,
2401
- thread_id: str,
2981
+ project_name: typing.Optional[str] = OMIT,
2982
+ project_id: typing.Optional[str] = OMIT,
2983
+ filters: typing.Optional[typing.Sequence[TraceFilterPublic]] = OMIT,
2984
+ last_retrieved_id: typing.Optional[str] = OMIT,
2985
+ limit: typing.Optional[int] = OMIT,
2986
+ truncate: typing.Optional[bool] = OMIT,
2987
+ strip_attachments: typing.Optional[bool] = OMIT,
2988
+ from_time: typing.Optional[dt.datetime] = OMIT,
2989
+ to_time: typing.Optional[dt.datetime] = OMIT,
2402
2990
  request_options: typing.Optional[RequestOptions] = None,
2403
- ) -> TraceThread:
2991
+ ) -> typing.AsyncIterator[bytes]:
2404
2992
  """
2405
- Get trace thread
2993
+ Search traces
2406
2994
 
2407
2995
  Parameters
2408
2996
  ----------
2409
- project_id : str
2997
+ project_name : typing.Optional[str]
2410
2998
 
2411
- thread_id : str
2999
+ project_id : typing.Optional[str]
2412
3000
 
2413
- request_options : typing.Optional[RequestOptions]
2414
- Request-specific configuration.
3001
+ filters : typing.Optional[typing.Sequence[TraceFilterPublic]]
2415
3002
 
2416
- Returns
2417
- -------
2418
- TraceThread
2419
- Trace thread resource
3003
+ last_retrieved_id : typing.Optional[str]
2420
3004
 
2421
- Examples
2422
- --------
2423
- import asyncio
3005
+ limit : typing.Optional[int]
3006
+ Max number of traces to be streamed
2424
3007
 
2425
- from Opik import AsyncOpikApi
3008
+ truncate : typing.Optional[bool]
3009
+ Truncate input, output and metadata to slim payloads
2426
3010
 
2427
- client = AsyncOpikApi(
2428
- api_key="YOUR_API_KEY",
2429
- workspace_name="YOUR_WORKSPACE_NAME",
2430
- )
3011
+ strip_attachments : typing.Optional[bool]
3012
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
2431
3013
 
3014
+ from_time : typing.Optional[dt.datetime]
3015
+ Filter traces created from this time (ISO-8601 format).
2432
3016
 
2433
- async def main() -> None:
2434
- await client.traces.get_trace_thread(
2435
- project_id="project_id",
2436
- thread_id="thread_id",
2437
- )
3017
+ to_time : typing.Optional[dt.datetime]
3018
+ Filter traces created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
2438
3019
 
3020
+ request_options : typing.Optional[RequestOptions]
3021
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
2439
3022
 
2440
- asyncio.run(main())
2441
- """
2442
- _response = await self._client_wrapper.httpx_client.request(
2443
- "v1/private/traces/threads/retrieve",
2444
- method="POST",
2445
- json={
2446
- "project_id": project_id,
2447
- "thread_id": thread_id,
2448
- },
2449
- headers={
2450
- "content-type": "application/json",
2451
- },
3023
+ Returns
3024
+ -------
3025
+ typing.AsyncIterator[bytes]
3026
+ Traces stream or error during process
3027
+ """
3028
+ async with self._raw_client.search_traces(
3029
+ project_name=project_name,
3030
+ project_id=project_id,
3031
+ filters=filters,
3032
+ last_retrieved_id=last_retrieved_id,
3033
+ limit=limit,
3034
+ truncate=truncate,
3035
+ strip_attachments=strip_attachments,
3036
+ from_time=from_time,
3037
+ to_time=to_time,
2452
3038
  request_options=request_options,
2453
- omit=OMIT,
2454
- )
2455
- try:
2456
- if 200 <= _response.status_code < 300:
2457
- return typing.cast(
2458
- TraceThread,
2459
- parse_obj_as(
2460
- type_=TraceThread, # type: ignore
2461
- object_=_response.json(),
2462
- ),
2463
- )
2464
- if _response.status_code == 404:
2465
- raise NotFoundError(
2466
- typing.cast(
2467
- typing.Optional[typing.Any],
2468
- parse_obj_as(
2469
- type_=typing.Optional[typing.Any], # type: ignore
2470
- object_=_response.json(),
2471
- ),
2472
- )
2473
- )
2474
- _response_json = _response.json()
2475
- except JSONDecodeError:
2476
- raise ApiError(status_code=_response.status_code, body=_response.text)
2477
- raise ApiError(status_code=_response.status_code, body=_response_json)
3039
+ ) as r:
3040
+ async for data in r.data:
3041
+ yield data
2478
3042
 
2479
- async def get_trace_threads(
3043
+ async def update_thread(
2480
3044
  self,
3045
+ thread_model_id: str,
2481
3046
  *,
2482
- page: typing.Optional[int] = None,
2483
- size: typing.Optional[int] = None,
2484
- project_name: typing.Optional[str] = None,
2485
- project_id: typing.Optional[str] = None,
2486
- truncate: typing.Optional[bool] = None,
2487
- filters: typing.Optional[str] = None,
3047
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2488
3048
  request_options: typing.Optional[RequestOptions] = None,
2489
- ) -> TraceThreadPage:
3049
+ ) -> None:
2490
3050
  """
2491
- Get trace threads
3051
+ Update thread
2492
3052
 
2493
3053
  Parameters
2494
3054
  ----------
2495
- page : typing.Optional[int]
2496
-
2497
- size : typing.Optional[int]
3055
+ thread_model_id : str
2498
3056
 
2499
- project_name : typing.Optional[str]
2500
-
2501
- project_id : typing.Optional[str]
2502
-
2503
- truncate : typing.Optional[bool]
2504
-
2505
- filters : typing.Optional[str]
3057
+ tags : typing.Optional[typing.Sequence[str]]
2506
3058
 
2507
3059
  request_options : typing.Optional[RequestOptions]
2508
3060
  Request-specific configuration.
2509
3061
 
2510
3062
  Returns
2511
3063
  -------
2512
- TraceThreadPage
2513
- Trace threads resource
3064
+ None
2514
3065
 
2515
3066
  Examples
2516
3067
  --------
2517
- import asyncio
2518
-
2519
3068
  from Opik import AsyncOpikApi
2520
-
2521
- client = AsyncOpikApi(
2522
- api_key="YOUR_API_KEY",
2523
- workspace_name="YOUR_WORKSPACE_NAME",
2524
- )
2525
-
2526
-
3069
+ import asyncio
3070
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2527
3071
  async def main() -> None:
2528
- await client.traces.get_trace_threads()
2529
-
2530
-
3072
+ await client.traces.update_thread(thread_model_id='threadModelId', )
2531
3073
  asyncio.run(main())
2532
3074
  """
2533
- _response = await self._client_wrapper.httpx_client.request(
2534
- "v1/private/traces/threads",
2535
- method="GET",
2536
- params={
2537
- "page": page,
2538
- "size": size,
2539
- "project_name": project_name,
2540
- "project_id": project_id,
2541
- "truncate": truncate,
2542
- "filters": filters,
2543
- },
2544
- request_options=request_options,
2545
- )
2546
- try:
2547
- if 200 <= _response.status_code < 300:
2548
- return typing.cast(
2549
- TraceThreadPage,
2550
- parse_obj_as(
2551
- type_=TraceThreadPage, # type: ignore
2552
- object_=_response.json(),
2553
- ),
2554
- )
2555
- _response_json = _response.json()
2556
- except JSONDecodeError:
2557
- raise ApiError(status_code=_response.status_code, body=_response.text)
2558
- raise ApiError(status_code=_response.status_code, body=_response_json)
3075
+ _response = await self._raw_client.update_thread(thread_model_id, tags=tags, request_options=request_options)
3076
+ return _response.data
2559
3077
 
2560
- async def score_batch_of_traces(
3078
+ async def update_thread_comment(
2561
3079
  self,
3080
+ comment_id: str,
2562
3081
  *,
2563
- scores: typing.Sequence[FeedbackScoreBatchItem],
3082
+ text: str,
3083
+ id: typing.Optional[str] = OMIT,
3084
+ created_at: typing.Optional[dt.datetime] = OMIT,
3085
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
3086
+ created_by: typing.Optional[str] = OMIT,
3087
+ last_updated_by: typing.Optional[str] = OMIT,
2564
3088
  request_options: typing.Optional[RequestOptions] = None,
2565
3089
  ) -> None:
2566
3090
  """
2567
- Batch feedback scoring for traces
3091
+ Update thread comment by id
2568
3092
 
2569
3093
  Parameters
2570
3094
  ----------
2571
- scores : typing.Sequence[FeedbackScoreBatchItem]
3095
+ comment_id : str
3096
+
3097
+ text : str
3098
+
3099
+ id : typing.Optional[str]
3100
+
3101
+ created_at : typing.Optional[dt.datetime]
3102
+
3103
+ last_updated_at : typing.Optional[dt.datetime]
3104
+
3105
+ created_by : typing.Optional[str]
3106
+
3107
+ last_updated_by : typing.Optional[str]
2572
3108
 
2573
3109
  request_options : typing.Optional[RequestOptions]
2574
3110
  Request-specific configuration.
@@ -2579,51 +3115,24 @@ class AsyncTracesClient:
2579
3115
 
2580
3116
  Examples
2581
3117
  --------
3118
+ from Opik import AsyncOpikApi
2582
3119
  import asyncio
2583
-
2584
- from Opik import AsyncOpikApi, FeedbackScoreBatchItem
2585
-
2586
- client = AsyncOpikApi(
2587
- api_key="YOUR_API_KEY",
2588
- workspace_name="YOUR_WORKSPACE_NAME",
2589
- )
2590
-
2591
-
3120
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2592
3121
  async def main() -> None:
2593
- await client.traces.score_batch_of_traces(
2594
- scores=[
2595
- FeedbackScoreBatchItem(
2596
- id="id",
2597
- name="name",
2598
- value=1.1,
2599
- source="ui",
2600
- )
2601
- ],
2602
- )
2603
-
2604
-
3122
+ await client.traces.update_thread_comment(comment_id='commentId', text='text', )
2605
3123
  asyncio.run(main())
2606
3124
  """
2607
- _response = await self._client_wrapper.httpx_client.request(
2608
- "v1/private/traces/feedback-scores",
2609
- method="PUT",
2610
- json={
2611
- "scores": convert_and_respect_annotation_metadata(
2612
- object_=scores,
2613
- annotation=typing.Sequence[FeedbackScoreBatchItem],
2614
- direction="write",
2615
- ),
2616
- },
3125
+ _response = await self._raw_client.update_thread_comment(
3126
+ comment_id,
3127
+ text=text,
3128
+ id=id,
3129
+ created_at=created_at,
3130
+ last_updated_at=last_updated_at,
3131
+ created_by=created_by,
3132
+ last_updated_by=last_updated_by,
2617
3133
  request_options=request_options,
2618
- omit=OMIT,
2619
3134
  )
2620
- try:
2621
- if 200 <= _response.status_code < 300:
2622
- return
2623
- _response_json = _response.json()
2624
- except JSONDecodeError:
2625
- raise ApiError(status_code=_response.status_code, body=_response.text)
2626
- raise ApiError(status_code=_response.status_code, body=_response_json)
3135
+ return _response.data
2627
3136
 
2628
3137
  async def update_trace_comment(
2629
3138
  self,
@@ -2665,53 +3174,21 @@ class AsyncTracesClient:
2665
3174
 
2666
3175
  Examples
2667
3176
  --------
2668
- import asyncio
2669
-
2670
3177
  from Opik import AsyncOpikApi
2671
-
2672
- client = AsyncOpikApi(
2673
- api_key="YOUR_API_KEY",
2674
- workspace_name="YOUR_WORKSPACE_NAME",
2675
- )
2676
-
2677
-
3178
+ import asyncio
3179
+ client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
2678
3180
  async def main() -> None:
2679
- await client.traces.update_trace_comment(
2680
- comment_id="commentId",
2681
- text="text",
2682
- )
2683
-
2684
-
3181
+ await client.traces.update_trace_comment(comment_id='commentId', text='text', )
2685
3182
  asyncio.run(main())
2686
3183
  """
2687
- _response = await self._client_wrapper.httpx_client.request(
2688
- f"v1/private/traces/comments/{jsonable_encoder(comment_id)}",
2689
- method="PATCH",
2690
- json={
2691
- "id": id,
2692
- "text": text,
2693
- "created_at": created_at,
2694
- "last_updated_at": last_updated_at,
2695
- "created_by": created_by,
2696
- "last_updated_by": last_updated_by,
2697
- },
3184
+ _response = await self._raw_client.update_trace_comment(
3185
+ comment_id,
3186
+ text=text,
3187
+ id=id,
3188
+ created_at=created_at,
3189
+ last_updated_at=last_updated_at,
3190
+ created_by=created_by,
3191
+ last_updated_by=last_updated_by,
2698
3192
  request_options=request_options,
2699
- omit=OMIT,
2700
3193
  )
2701
- try:
2702
- if 200 <= _response.status_code < 300:
2703
- return
2704
- if _response.status_code == 404:
2705
- raise NotFoundError(
2706
- typing.cast(
2707
- typing.Optional[typing.Any],
2708
- parse_obj_as(
2709
- type_=typing.Optional[typing.Any], # type: ignore
2710
- object_=_response.json(),
2711
- ),
2712
- )
2713
- )
2714
- _response_json = _response.json()
2715
- except JSONDecodeError:
2716
- raise ApiError(status_code=_response.status_code, body=_response.text)
2717
- raise ApiError(status_code=_response.status_code, body=_response_json)
3194
+ return _response.data