opik 1.8.39__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 (592) hide show
  1. opik/__init__.py +19 -3
  2. opik/anonymizer/__init__.py +5 -0
  3. opik/anonymizer/anonymizer.py +12 -0
  4. opik/anonymizer/factory.py +80 -0
  5. opik/anonymizer/recursive_anonymizer.py +64 -0
  6. opik/anonymizer/rules.py +56 -0
  7. opik/anonymizer/rules_anonymizer.py +35 -0
  8. opik/api_objects/attachment/attachment_context.py +36 -0
  9. opik/api_objects/attachment/attachments_extractor.py +153 -0
  10. opik/api_objects/attachment/client.py +1 -0
  11. opik/api_objects/attachment/converters.py +2 -0
  12. opik/api_objects/attachment/decoder.py +18 -0
  13. opik/api_objects/attachment/decoder_base64.py +83 -0
  14. opik/api_objects/attachment/decoder_helpers.py +137 -0
  15. opik/api_objects/data_helpers.py +79 -0
  16. opik/api_objects/dataset/dataset.py +64 -4
  17. opik/api_objects/dataset/rest_operations.py +11 -2
  18. opik/api_objects/experiment/experiment.py +57 -57
  19. opik/api_objects/experiment/experiment_item.py +2 -1
  20. opik/api_objects/experiment/experiments_client.py +64 -0
  21. opik/api_objects/experiment/helpers.py +35 -11
  22. opik/api_objects/experiment/rest_operations.py +65 -5
  23. opik/api_objects/helpers.py +8 -5
  24. opik/api_objects/local_recording.py +81 -0
  25. opik/api_objects/opik_client.py +600 -108
  26. opik/api_objects/opik_query_language.py +39 -5
  27. opik/api_objects/prompt/__init__.py +12 -2
  28. opik/api_objects/prompt/base_prompt.py +69 -0
  29. opik/api_objects/prompt/base_prompt_template.py +29 -0
  30. opik/api_objects/prompt/chat/__init__.py +1 -0
  31. opik/api_objects/prompt/chat/chat_prompt.py +210 -0
  32. opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
  33. opik/api_objects/prompt/chat/content_renderer_registry.py +203 -0
  34. opik/api_objects/prompt/client.py +189 -47
  35. opik/api_objects/prompt/text/__init__.py +1 -0
  36. opik/api_objects/prompt/text/prompt.py +174 -0
  37. opik/api_objects/prompt/{prompt_template.py → text/prompt_template.py} +10 -6
  38. opik/api_objects/prompt/types.py +23 -0
  39. opik/api_objects/search_helpers.py +89 -0
  40. opik/api_objects/span/span_data.py +35 -25
  41. opik/api_objects/threads/threads_client.py +39 -5
  42. opik/api_objects/trace/trace_client.py +52 -2
  43. opik/api_objects/trace/trace_data.py +15 -24
  44. opik/api_objects/validation_helpers.py +3 -3
  45. opik/cli/__init__.py +5 -0
  46. opik/cli/__main__.py +6 -0
  47. opik/cli/configure.py +66 -0
  48. opik/cli/exports/__init__.py +131 -0
  49. opik/cli/exports/dataset.py +278 -0
  50. opik/cli/exports/experiment.py +784 -0
  51. opik/cli/exports/project.py +685 -0
  52. opik/cli/exports/prompt.py +578 -0
  53. opik/cli/exports/utils.py +406 -0
  54. opik/cli/harbor.py +39 -0
  55. opik/cli/healthcheck.py +21 -0
  56. opik/cli/imports/__init__.py +439 -0
  57. opik/cli/imports/dataset.py +143 -0
  58. opik/cli/imports/experiment.py +1192 -0
  59. opik/cli/imports/project.py +262 -0
  60. opik/cli/imports/prompt.py +177 -0
  61. opik/cli/imports/utils.py +280 -0
  62. opik/cli/main.py +49 -0
  63. opik/cli/proxy.py +93 -0
  64. opik/cli/usage_report/__init__.py +16 -0
  65. opik/cli/usage_report/charts.py +783 -0
  66. opik/cli/usage_report/cli.py +274 -0
  67. opik/cli/usage_report/constants.py +9 -0
  68. opik/cli/usage_report/extraction.py +749 -0
  69. opik/cli/usage_report/pdf.py +244 -0
  70. opik/cli/usage_report/statistics.py +78 -0
  71. opik/cli/usage_report/utils.py +235 -0
  72. opik/config.py +13 -7
  73. opik/configurator/configure.py +17 -0
  74. opik/datetime_helpers.py +12 -0
  75. opik/decorator/arguments_helpers.py +9 -1
  76. opik/decorator/base_track_decorator.py +205 -133
  77. opik/decorator/context_manager/span_context_manager.py +123 -0
  78. opik/decorator/context_manager/trace_context_manager.py +84 -0
  79. opik/decorator/opik_args/__init__.py +13 -0
  80. opik/decorator/opik_args/api_classes.py +71 -0
  81. opik/decorator/opik_args/helpers.py +120 -0
  82. opik/decorator/span_creation_handler.py +25 -6
  83. opik/dict_utils.py +3 -3
  84. opik/evaluation/__init__.py +13 -2
  85. opik/evaluation/engine/engine.py +272 -75
  86. opik/evaluation/engine/evaluation_tasks_executor.py +6 -3
  87. opik/evaluation/engine/helpers.py +31 -6
  88. opik/evaluation/engine/metrics_evaluator.py +237 -0
  89. opik/evaluation/evaluation_result.py +168 -2
  90. opik/evaluation/evaluator.py +533 -62
  91. opik/evaluation/metrics/__init__.py +103 -4
  92. opik/evaluation/metrics/aggregated_metric.py +35 -6
  93. opik/evaluation/metrics/base_metric.py +1 -1
  94. opik/evaluation/metrics/conversation/__init__.py +48 -0
  95. opik/evaluation/metrics/conversation/conversation_thread_metric.py +56 -2
  96. opik/evaluation/metrics/conversation/g_eval_wrappers.py +19 -0
  97. opik/evaluation/metrics/conversation/helpers.py +14 -15
  98. opik/evaluation/metrics/conversation/heuristics/__init__.py +14 -0
  99. opik/evaluation/metrics/conversation/heuristics/degeneration/__init__.py +3 -0
  100. opik/evaluation/metrics/conversation/heuristics/degeneration/metric.py +189 -0
  101. opik/evaluation/metrics/conversation/heuristics/degeneration/phrases.py +12 -0
  102. opik/evaluation/metrics/conversation/heuristics/knowledge_retention/__init__.py +3 -0
  103. opik/evaluation/metrics/conversation/heuristics/knowledge_retention/metric.py +172 -0
  104. opik/evaluation/metrics/conversation/llm_judges/__init__.py +32 -0
  105. opik/evaluation/metrics/conversation/{conversational_coherence → llm_judges/conversational_coherence}/metric.py +22 -17
  106. opik/evaluation/metrics/conversation/{conversational_coherence → llm_judges/conversational_coherence}/templates.py +1 -1
  107. opik/evaluation/metrics/conversation/llm_judges/g_eval_wrappers.py +442 -0
  108. opik/evaluation/metrics/conversation/{session_completeness → llm_judges/session_completeness}/metric.py +13 -7
  109. opik/evaluation/metrics/conversation/{session_completeness → llm_judges/session_completeness}/templates.py +1 -1
  110. opik/evaluation/metrics/conversation/llm_judges/user_frustration/__init__.py +0 -0
  111. opik/evaluation/metrics/conversation/{user_frustration → llm_judges/user_frustration}/metric.py +21 -14
  112. opik/evaluation/metrics/conversation/{user_frustration → llm_judges/user_frustration}/templates.py +1 -1
  113. opik/evaluation/metrics/conversation/types.py +4 -5
  114. opik/evaluation/metrics/conversation_types.py +9 -0
  115. opik/evaluation/metrics/heuristics/bertscore.py +107 -0
  116. opik/evaluation/metrics/heuristics/bleu.py +35 -15
  117. opik/evaluation/metrics/heuristics/chrf.py +127 -0
  118. opik/evaluation/metrics/heuristics/contains.py +47 -11
  119. opik/evaluation/metrics/heuristics/distribution_metrics.py +331 -0
  120. opik/evaluation/metrics/heuristics/gleu.py +113 -0
  121. opik/evaluation/metrics/heuristics/language_adherence.py +123 -0
  122. opik/evaluation/metrics/heuristics/meteor.py +119 -0
  123. opik/evaluation/metrics/heuristics/prompt_injection.py +150 -0
  124. opik/evaluation/metrics/heuristics/readability.py +129 -0
  125. opik/evaluation/metrics/heuristics/rouge.py +26 -9
  126. opik/evaluation/metrics/heuristics/spearman.py +88 -0
  127. opik/evaluation/metrics/heuristics/tone.py +155 -0
  128. opik/evaluation/metrics/heuristics/vader_sentiment.py +77 -0
  129. opik/evaluation/metrics/llm_judges/answer_relevance/metric.py +20 -5
  130. opik/evaluation/metrics/llm_judges/context_precision/metric.py +20 -6
  131. opik/evaluation/metrics/llm_judges/context_recall/metric.py +20 -6
  132. opik/evaluation/metrics/llm_judges/g_eval/__init__.py +5 -0
  133. opik/evaluation/metrics/llm_judges/g_eval/metric.py +219 -68
  134. opik/evaluation/metrics/llm_judges/g_eval/parser.py +102 -52
  135. opik/evaluation/metrics/llm_judges/g_eval/presets.py +209 -0
  136. opik/evaluation/metrics/llm_judges/g_eval_presets/__init__.py +36 -0
  137. opik/evaluation/metrics/llm_judges/g_eval_presets/agent_assessment.py +77 -0
  138. opik/evaluation/metrics/llm_judges/g_eval_presets/bias_classifier.py +181 -0
  139. opik/evaluation/metrics/llm_judges/g_eval_presets/compliance_risk.py +41 -0
  140. opik/evaluation/metrics/llm_judges/g_eval_presets/prompt_uncertainty.py +41 -0
  141. opik/evaluation/metrics/llm_judges/g_eval_presets/qa_suite.py +146 -0
  142. opik/evaluation/metrics/llm_judges/hallucination/metric.py +16 -3
  143. opik/evaluation/metrics/llm_judges/llm_juries/__init__.py +3 -0
  144. opik/evaluation/metrics/llm_judges/llm_juries/metric.py +76 -0
  145. opik/evaluation/metrics/llm_judges/moderation/metric.py +16 -4
  146. opik/evaluation/metrics/llm_judges/structure_output_compliance/__init__.py +0 -0
  147. opik/evaluation/metrics/llm_judges/structure_output_compliance/metric.py +144 -0
  148. opik/evaluation/metrics/llm_judges/structure_output_compliance/parser.py +79 -0
  149. opik/evaluation/metrics/llm_judges/structure_output_compliance/schema.py +15 -0
  150. opik/evaluation/metrics/llm_judges/structure_output_compliance/template.py +50 -0
  151. opik/evaluation/metrics/llm_judges/syc_eval/__init__.py +0 -0
  152. opik/evaluation/metrics/llm_judges/syc_eval/metric.py +252 -0
  153. opik/evaluation/metrics/llm_judges/syc_eval/parser.py +82 -0
  154. opik/evaluation/metrics/llm_judges/syc_eval/template.py +155 -0
  155. opik/evaluation/metrics/llm_judges/trajectory_accuracy/metric.py +20 -5
  156. opik/evaluation/metrics/llm_judges/usefulness/metric.py +16 -4
  157. opik/evaluation/metrics/ragas_metric.py +43 -23
  158. opik/evaluation/models/__init__.py +8 -0
  159. opik/evaluation/models/base_model.py +107 -1
  160. opik/evaluation/models/langchain/langchain_chat_model.py +15 -7
  161. opik/evaluation/models/langchain/message_converters.py +97 -15
  162. opik/evaluation/models/litellm/litellm_chat_model.py +156 -29
  163. opik/evaluation/models/litellm/util.py +125 -0
  164. opik/evaluation/models/litellm/warning_filters.py +16 -4
  165. opik/evaluation/models/model_capabilities.py +187 -0
  166. opik/evaluation/models/models_factory.py +25 -3
  167. opik/evaluation/preprocessing.py +92 -0
  168. opik/evaluation/report.py +70 -12
  169. opik/evaluation/rest_operations.py +49 -45
  170. opik/evaluation/samplers/__init__.py +4 -0
  171. opik/evaluation/samplers/base_dataset_sampler.py +40 -0
  172. opik/evaluation/samplers/random_dataset_sampler.py +48 -0
  173. opik/evaluation/score_statistics.py +66 -0
  174. opik/evaluation/scorers/__init__.py +4 -0
  175. opik/evaluation/scorers/scorer_function.py +55 -0
  176. opik/evaluation/scorers/scorer_wrapper_metric.py +130 -0
  177. opik/evaluation/test_case.py +3 -2
  178. opik/evaluation/test_result.py +1 -0
  179. opik/evaluation/threads/evaluator.py +31 -3
  180. opik/evaluation/threads/helpers.py +3 -2
  181. opik/evaluation/types.py +9 -1
  182. opik/exceptions.py +33 -0
  183. opik/file_upload/file_uploader.py +13 -0
  184. opik/file_upload/upload_options.py +2 -0
  185. opik/hooks/__init__.py +23 -0
  186. opik/hooks/anonymizer_hook.py +36 -0
  187. opik/hooks/httpx_client_hook.py +112 -0
  188. opik/httpx_client.py +12 -9
  189. opik/id_helpers.py +18 -0
  190. opik/integrations/adk/graph/subgraph_edges_builders.py +1 -2
  191. opik/integrations/adk/helpers.py +16 -7
  192. opik/integrations/adk/legacy_opik_tracer.py +7 -4
  193. opik/integrations/adk/opik_tracer.py +14 -1
  194. opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +7 -3
  195. opik/integrations/adk/recursive_callback_injector.py +4 -7
  196. opik/integrations/bedrock/converse/__init__.py +0 -0
  197. opik/integrations/bedrock/converse/chunks_aggregator.py +188 -0
  198. opik/integrations/bedrock/{converse_decorator.py → converse/converse_decorator.py} +4 -3
  199. opik/integrations/bedrock/invoke_agent_decorator.py +5 -4
  200. opik/integrations/bedrock/invoke_model/__init__.py +0 -0
  201. opik/integrations/bedrock/invoke_model/chunks_aggregator/__init__.py +78 -0
  202. opik/integrations/bedrock/invoke_model/chunks_aggregator/api.py +45 -0
  203. opik/integrations/bedrock/invoke_model/chunks_aggregator/base.py +23 -0
  204. opik/integrations/bedrock/invoke_model/chunks_aggregator/claude.py +121 -0
  205. opik/integrations/bedrock/invoke_model/chunks_aggregator/format_detector.py +107 -0
  206. opik/integrations/bedrock/invoke_model/chunks_aggregator/llama.py +108 -0
  207. opik/integrations/bedrock/invoke_model/chunks_aggregator/mistral.py +118 -0
  208. opik/integrations/bedrock/invoke_model/chunks_aggregator/nova.py +99 -0
  209. opik/integrations/bedrock/invoke_model/invoke_model_decorator.py +178 -0
  210. opik/integrations/bedrock/invoke_model/response_types.py +34 -0
  211. opik/integrations/bedrock/invoke_model/stream_wrappers.py +122 -0
  212. opik/integrations/bedrock/invoke_model/usage_converters.py +87 -0
  213. opik/integrations/bedrock/invoke_model/usage_extraction.py +108 -0
  214. opik/integrations/bedrock/opik_tracker.py +42 -4
  215. opik/integrations/bedrock/types.py +19 -0
  216. opik/integrations/crewai/crewai_decorator.py +8 -51
  217. opik/integrations/crewai/opik_tracker.py +31 -10
  218. opik/integrations/crewai/patchers/__init__.py +5 -0
  219. opik/integrations/crewai/patchers/flow.py +118 -0
  220. opik/integrations/crewai/patchers/litellm_completion.py +30 -0
  221. opik/integrations/crewai/patchers/llm_client.py +207 -0
  222. opik/integrations/dspy/callback.py +80 -17
  223. opik/integrations/dspy/parsers.py +168 -0
  224. opik/integrations/harbor/__init__.py +17 -0
  225. opik/integrations/harbor/experiment_service.py +269 -0
  226. opik/integrations/harbor/opik_tracker.py +528 -0
  227. opik/integrations/haystack/opik_connector.py +2 -2
  228. opik/integrations/haystack/opik_tracer.py +3 -7
  229. opik/integrations/langchain/__init__.py +3 -1
  230. opik/integrations/langchain/helpers.py +96 -0
  231. opik/integrations/langchain/langgraph_async_context_bridge.py +131 -0
  232. opik/integrations/langchain/langgraph_tracer_injector.py +88 -0
  233. opik/integrations/langchain/opik_encoder_extension.py +1 -1
  234. opik/integrations/langchain/opik_tracer.py +474 -229
  235. opik/integrations/litellm/__init__.py +5 -0
  236. opik/integrations/litellm/completion_chunks_aggregator.py +115 -0
  237. opik/integrations/litellm/litellm_completion_decorator.py +242 -0
  238. opik/integrations/litellm/opik_tracker.py +43 -0
  239. opik/integrations/litellm/stream_patchers.py +151 -0
  240. opik/integrations/llama_index/callback.py +146 -107
  241. opik/integrations/openai/agents/opik_tracing_processor.py +1 -2
  242. opik/integrations/openai/openai_chat_completions_decorator.py +2 -16
  243. opik/integrations/openai/opik_tracker.py +1 -1
  244. opik/integrations/sagemaker/auth.py +5 -1
  245. opik/llm_usage/google_usage.py +3 -1
  246. opik/llm_usage/opik_usage.py +7 -8
  247. opik/llm_usage/opik_usage_factory.py +4 -2
  248. opik/logging_messages.py +6 -0
  249. opik/message_processing/batching/base_batcher.py +14 -21
  250. opik/message_processing/batching/batch_manager.py +22 -10
  251. opik/message_processing/batching/batch_manager_constuctors.py +10 -0
  252. opik/message_processing/batching/batchers.py +59 -27
  253. opik/message_processing/batching/flushing_thread.py +0 -3
  254. opik/message_processing/emulation/__init__.py +0 -0
  255. opik/message_processing/emulation/emulator_message_processor.py +578 -0
  256. opik/message_processing/emulation/local_emulator_message_processor.py +140 -0
  257. opik/message_processing/emulation/models.py +162 -0
  258. opik/message_processing/encoder_helpers.py +79 -0
  259. opik/message_processing/messages.py +56 -1
  260. opik/message_processing/preprocessing/__init__.py +0 -0
  261. opik/message_processing/preprocessing/attachments_preprocessor.py +70 -0
  262. opik/message_processing/preprocessing/batching_preprocessor.py +53 -0
  263. opik/message_processing/preprocessing/constants.py +1 -0
  264. opik/message_processing/preprocessing/file_upload_preprocessor.py +38 -0
  265. opik/message_processing/preprocessing/preprocessor.py +36 -0
  266. opik/message_processing/processors/__init__.py +0 -0
  267. opik/message_processing/processors/attachments_extraction_processor.py +146 -0
  268. opik/message_processing/processors/message_processors.py +92 -0
  269. opik/message_processing/processors/message_processors_chain.py +96 -0
  270. opik/message_processing/{message_processors.py → processors/online_message_processor.py} +85 -29
  271. opik/message_processing/queue_consumer.py +9 -3
  272. opik/message_processing/streamer.py +71 -33
  273. opik/message_processing/streamer_constructors.py +43 -10
  274. opik/opik_context.py +16 -4
  275. opik/plugins/pytest/hooks.py +5 -3
  276. opik/rest_api/__init__.py +346 -15
  277. opik/rest_api/alerts/__init__.py +7 -0
  278. opik/rest_api/alerts/client.py +667 -0
  279. opik/rest_api/alerts/raw_client.py +1015 -0
  280. opik/rest_api/alerts/types/__init__.py +7 -0
  281. opik/rest_api/alerts/types/get_webhook_examples_request_alert_type.py +5 -0
  282. opik/rest_api/annotation_queues/__init__.py +4 -0
  283. opik/rest_api/annotation_queues/client.py +668 -0
  284. opik/rest_api/annotation_queues/raw_client.py +1019 -0
  285. opik/rest_api/automation_rule_evaluators/client.py +34 -2
  286. opik/rest_api/automation_rule_evaluators/raw_client.py +24 -0
  287. opik/rest_api/client.py +15 -0
  288. opik/rest_api/dashboards/__init__.py +4 -0
  289. opik/rest_api/dashboards/client.py +462 -0
  290. opik/rest_api/dashboards/raw_client.py +648 -0
  291. opik/rest_api/datasets/client.py +1310 -44
  292. opik/rest_api/datasets/raw_client.py +2269 -358
  293. opik/rest_api/experiments/__init__.py +2 -2
  294. opik/rest_api/experiments/client.py +191 -5
  295. opik/rest_api/experiments/raw_client.py +301 -7
  296. opik/rest_api/experiments/types/__init__.py +4 -1
  297. opik/rest_api/experiments/types/experiment_update_status.py +5 -0
  298. opik/rest_api/experiments/types/experiment_update_type.py +5 -0
  299. opik/rest_api/experiments/types/experiment_write_status.py +5 -0
  300. opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -1
  301. opik/rest_api/llm_provider_key/client.py +20 -0
  302. opik/rest_api/llm_provider_key/raw_client.py +20 -0
  303. opik/rest_api/llm_provider_key/types/provider_api_key_write_provider.py +1 -1
  304. opik/rest_api/manual_evaluation/__init__.py +4 -0
  305. opik/rest_api/manual_evaluation/client.py +347 -0
  306. opik/rest_api/manual_evaluation/raw_client.py +543 -0
  307. opik/rest_api/optimizations/client.py +145 -9
  308. opik/rest_api/optimizations/raw_client.py +237 -13
  309. opik/rest_api/optimizations/types/optimization_update_status.py +3 -1
  310. opik/rest_api/prompts/__init__.py +2 -2
  311. opik/rest_api/prompts/client.py +227 -6
  312. opik/rest_api/prompts/raw_client.py +331 -2
  313. opik/rest_api/prompts/types/__init__.py +3 -1
  314. opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
  315. opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
  316. opik/rest_api/spans/__init__.py +0 -2
  317. opik/rest_api/spans/client.py +238 -76
  318. opik/rest_api/spans/raw_client.py +307 -95
  319. opik/rest_api/spans/types/__init__.py +0 -2
  320. opik/rest_api/traces/client.py +572 -161
  321. opik/rest_api/traces/raw_client.py +736 -229
  322. opik/rest_api/types/__init__.py +352 -17
  323. opik/rest_api/types/aggregation_data.py +1 -0
  324. opik/rest_api/types/alert.py +33 -0
  325. opik/rest_api/types/alert_alert_type.py +5 -0
  326. opik/rest_api/types/alert_page_public.py +24 -0
  327. opik/rest_api/types/alert_public.py +33 -0
  328. opik/rest_api/types/alert_public_alert_type.py +5 -0
  329. opik/rest_api/types/alert_trigger.py +27 -0
  330. opik/rest_api/types/alert_trigger_config.py +28 -0
  331. opik/rest_api/types/alert_trigger_config_public.py +28 -0
  332. opik/rest_api/types/alert_trigger_config_public_type.py +10 -0
  333. opik/rest_api/types/alert_trigger_config_type.py +10 -0
  334. opik/rest_api/types/alert_trigger_config_write.py +22 -0
  335. opik/rest_api/types/alert_trigger_config_write_type.py +10 -0
  336. opik/rest_api/types/alert_trigger_event_type.py +19 -0
  337. opik/rest_api/types/alert_trigger_public.py +27 -0
  338. opik/rest_api/types/alert_trigger_public_event_type.py +19 -0
  339. opik/rest_api/types/alert_trigger_write.py +23 -0
  340. opik/rest_api/types/alert_trigger_write_event_type.py +19 -0
  341. opik/rest_api/types/alert_write.py +28 -0
  342. opik/rest_api/types/alert_write_alert_type.py +5 -0
  343. opik/rest_api/types/annotation_queue.py +42 -0
  344. opik/rest_api/types/annotation_queue_batch.py +27 -0
  345. opik/rest_api/types/annotation_queue_item_ids.py +19 -0
  346. opik/rest_api/types/annotation_queue_page_public.py +28 -0
  347. opik/rest_api/types/annotation_queue_public.py +38 -0
  348. opik/rest_api/types/annotation_queue_public_scope.py +5 -0
  349. opik/rest_api/types/annotation_queue_reviewer.py +20 -0
  350. opik/rest_api/types/annotation_queue_reviewer_public.py +20 -0
  351. opik/rest_api/types/annotation_queue_scope.py +5 -0
  352. opik/rest_api/types/annotation_queue_write.py +31 -0
  353. opik/rest_api/types/annotation_queue_write_scope.py +5 -0
  354. opik/rest_api/types/audio_url.py +19 -0
  355. opik/rest_api/types/audio_url_public.py +19 -0
  356. opik/rest_api/types/audio_url_write.py +19 -0
  357. opik/rest_api/types/automation_rule_evaluator.py +62 -2
  358. opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +2 -0
  359. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +2 -0
  360. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +2 -0
  361. opik/rest_api/types/automation_rule_evaluator_object_object_public.py +155 -0
  362. opik/rest_api/types/automation_rule_evaluator_page_public.py +3 -2
  363. opik/rest_api/types/automation_rule_evaluator_public.py +57 -2
  364. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
  365. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
  366. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
  367. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python.py +22 -0
  368. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_public.py +22 -0
  369. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_write.py +22 -0
  370. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +2 -0
  371. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +2 -0
  372. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +2 -0
  373. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +2 -0
  374. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +2 -0
  375. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +2 -0
  376. opik/rest_api/types/automation_rule_evaluator_update.py +51 -1
  377. opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +2 -0
  378. opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
  379. opik/rest_api/types/automation_rule_evaluator_update_span_user_defined_metric_python.py +22 -0
  380. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +2 -0
  381. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +2 -0
  382. opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +2 -0
  383. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +2 -0
  384. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +2 -0
  385. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +2 -0
  386. opik/rest_api/types/automation_rule_evaluator_write.py +51 -1
  387. opik/rest_api/types/boolean_feedback_definition.py +25 -0
  388. opik/rest_api/types/boolean_feedback_definition_create.py +20 -0
  389. opik/rest_api/types/boolean_feedback_definition_public.py +25 -0
  390. opik/rest_api/types/boolean_feedback_definition_update.py +20 -0
  391. opik/rest_api/types/boolean_feedback_detail.py +29 -0
  392. opik/rest_api/types/boolean_feedback_detail_create.py +29 -0
  393. opik/rest_api/types/boolean_feedback_detail_public.py +29 -0
  394. opik/rest_api/types/boolean_feedback_detail_update.py +29 -0
  395. opik/rest_api/types/dashboard_page_public.py +24 -0
  396. opik/rest_api/types/dashboard_public.py +30 -0
  397. opik/rest_api/types/dataset.py +4 -0
  398. opik/rest_api/types/dataset_expansion.py +42 -0
  399. opik/rest_api/types/dataset_expansion_response.py +39 -0
  400. opik/rest_api/types/dataset_item.py +2 -0
  401. opik/rest_api/types/dataset_item_changes_public.py +5 -0
  402. opik/rest_api/types/dataset_item_compare.py +2 -0
  403. opik/rest_api/types/dataset_item_filter.py +27 -0
  404. opik/rest_api/types/dataset_item_filter_operator.py +21 -0
  405. opik/rest_api/types/dataset_item_page_compare.py +5 -0
  406. opik/rest_api/types/dataset_item_page_public.py +5 -0
  407. opik/rest_api/types/dataset_item_public.py +2 -0
  408. opik/rest_api/types/dataset_item_update.py +39 -0
  409. opik/rest_api/types/dataset_item_write.py +1 -0
  410. opik/rest_api/types/dataset_public.py +4 -0
  411. opik/rest_api/types/dataset_public_status.py +5 -0
  412. opik/rest_api/types/dataset_status.py +5 -0
  413. opik/rest_api/types/dataset_version_diff.py +22 -0
  414. opik/rest_api/types/dataset_version_diff_stats.py +24 -0
  415. opik/rest_api/types/dataset_version_page_public.py +23 -0
  416. opik/rest_api/types/dataset_version_public.py +59 -0
  417. opik/rest_api/types/dataset_version_summary.py +46 -0
  418. opik/rest_api/types/dataset_version_summary_public.py +46 -0
  419. opik/rest_api/types/experiment.py +7 -2
  420. opik/rest_api/types/experiment_group_response.py +2 -0
  421. opik/rest_api/types/experiment_public.py +7 -2
  422. opik/rest_api/types/experiment_public_status.py +5 -0
  423. opik/rest_api/types/experiment_score.py +20 -0
  424. opik/rest_api/types/experiment_score_public.py +20 -0
  425. opik/rest_api/types/experiment_score_write.py +20 -0
  426. opik/rest_api/types/experiment_status.py +5 -0
  427. opik/rest_api/types/feedback.py +25 -1
  428. opik/rest_api/types/feedback_create.py +20 -1
  429. opik/rest_api/types/feedback_object_public.py +27 -1
  430. opik/rest_api/types/feedback_public.py +25 -1
  431. opik/rest_api/types/feedback_score_batch_item.py +2 -1
  432. opik/rest_api/types/feedback_score_batch_item_thread.py +2 -1
  433. opik/rest_api/types/feedback_score_public.py +4 -0
  434. opik/rest_api/types/feedback_update.py +20 -1
  435. opik/rest_api/types/group_content_with_aggregations.py +1 -0
  436. opik/rest_api/types/group_detail.py +19 -0
  437. opik/rest_api/types/group_details.py +20 -0
  438. opik/rest_api/types/guardrail.py +1 -0
  439. opik/rest_api/types/guardrail_write.py +1 -0
  440. opik/rest_api/types/ids_holder.py +19 -0
  441. opik/rest_api/types/image_url.py +20 -0
  442. opik/rest_api/types/image_url_public.py +20 -0
  443. opik/rest_api/types/image_url_write.py +20 -0
  444. opik/rest_api/types/llm_as_judge_message.py +5 -1
  445. opik/rest_api/types/llm_as_judge_message_content.py +26 -0
  446. opik/rest_api/types/llm_as_judge_message_content_public.py +26 -0
  447. opik/rest_api/types/llm_as_judge_message_content_write.py +26 -0
  448. opik/rest_api/types/llm_as_judge_message_public.py +5 -1
  449. opik/rest_api/types/llm_as_judge_message_write.py +5 -1
  450. opik/rest_api/types/llm_as_judge_model_parameters.py +3 -0
  451. opik/rest_api/types/llm_as_judge_model_parameters_public.py +3 -0
  452. opik/rest_api/types/llm_as_judge_model_parameters_write.py +3 -0
  453. opik/rest_api/types/manual_evaluation_request.py +38 -0
  454. opik/rest_api/types/manual_evaluation_request_entity_type.py +5 -0
  455. opik/rest_api/types/manual_evaluation_response.py +27 -0
  456. opik/rest_api/types/optimization.py +4 -2
  457. opik/rest_api/types/optimization_public.py +4 -2
  458. opik/rest_api/types/optimization_public_status.py +3 -1
  459. opik/rest_api/types/optimization_status.py +3 -1
  460. opik/rest_api/types/optimization_studio_config.py +27 -0
  461. opik/rest_api/types/optimization_studio_config_public.py +27 -0
  462. opik/rest_api/types/optimization_studio_config_write.py +27 -0
  463. opik/rest_api/types/optimization_studio_log.py +22 -0
  464. opik/rest_api/types/optimization_write.py +4 -2
  465. opik/rest_api/types/optimization_write_status.py +3 -1
  466. opik/rest_api/types/project.py +1 -0
  467. opik/rest_api/types/project_detailed.py +1 -0
  468. opik/rest_api/types/project_reference.py +31 -0
  469. opik/rest_api/types/project_reference_public.py +31 -0
  470. opik/rest_api/types/project_stats_summary_item.py +1 -0
  471. opik/rest_api/types/prompt.py +6 -0
  472. opik/rest_api/types/prompt_detail.py +6 -0
  473. opik/rest_api/types/prompt_detail_template_structure.py +5 -0
  474. opik/rest_api/types/prompt_public.py +6 -0
  475. opik/rest_api/types/prompt_public_template_structure.py +5 -0
  476. opik/rest_api/types/prompt_template_structure.py +5 -0
  477. opik/rest_api/types/prompt_version.py +3 -0
  478. opik/rest_api/types/prompt_version_detail.py +3 -0
  479. opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
  480. opik/rest_api/types/prompt_version_link.py +1 -0
  481. opik/rest_api/types/prompt_version_link_public.py +1 -0
  482. opik/rest_api/types/prompt_version_page_public.py +5 -0
  483. opik/rest_api/types/prompt_version_public.py +3 -0
  484. opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
  485. opik/rest_api/types/prompt_version_template_structure.py +5 -0
  486. opik/rest_api/types/prompt_version_update.py +33 -0
  487. opik/rest_api/types/provider_api_key.py +9 -0
  488. opik/rest_api/types/provider_api_key_provider.py +1 -1
  489. opik/rest_api/types/provider_api_key_public.py +9 -0
  490. opik/rest_api/types/provider_api_key_public_provider.py +1 -1
  491. opik/rest_api/types/score_name.py +1 -0
  492. opik/rest_api/types/service_toggles_config.py +18 -0
  493. opik/rest_api/types/span.py +1 -2
  494. opik/rest_api/types/span_enrichment_options.py +31 -0
  495. opik/rest_api/types/span_experiment_item_bulk_write_view.py +1 -2
  496. opik/rest_api/types/span_filter.py +23 -0
  497. opik/rest_api/types/span_filter_operator.py +21 -0
  498. opik/rest_api/types/span_filter_write.py +23 -0
  499. opik/rest_api/types/span_filter_write_operator.py +21 -0
  500. opik/rest_api/types/span_llm_as_judge_code.py +27 -0
  501. opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
  502. opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
  503. opik/rest_api/types/span_public.py +1 -2
  504. opik/rest_api/types/span_update.py +46 -0
  505. opik/rest_api/types/span_user_defined_metric_python_code.py +20 -0
  506. opik/rest_api/types/span_user_defined_metric_python_code_public.py +20 -0
  507. opik/rest_api/types/span_user_defined_metric_python_code_write.py +20 -0
  508. opik/rest_api/types/span_write.py +1 -2
  509. opik/rest_api/types/studio_evaluation.py +20 -0
  510. opik/rest_api/types/studio_evaluation_public.py +20 -0
  511. opik/rest_api/types/studio_evaluation_write.py +20 -0
  512. opik/rest_api/types/studio_llm_model.py +21 -0
  513. opik/rest_api/types/studio_llm_model_public.py +21 -0
  514. opik/rest_api/types/studio_llm_model_write.py +21 -0
  515. opik/rest_api/types/studio_message.py +20 -0
  516. opik/rest_api/types/studio_message_public.py +20 -0
  517. opik/rest_api/types/studio_message_write.py +20 -0
  518. opik/rest_api/types/studio_metric.py +21 -0
  519. opik/rest_api/types/studio_metric_public.py +21 -0
  520. opik/rest_api/types/studio_metric_write.py +21 -0
  521. opik/rest_api/types/studio_optimizer.py +21 -0
  522. opik/rest_api/types/studio_optimizer_public.py +21 -0
  523. opik/rest_api/types/studio_optimizer_write.py +21 -0
  524. opik/rest_api/types/studio_prompt.py +20 -0
  525. opik/rest_api/types/studio_prompt_public.py +20 -0
  526. opik/rest_api/types/studio_prompt_write.py +20 -0
  527. opik/rest_api/types/trace.py +11 -2
  528. opik/rest_api/types/trace_enrichment_options.py +32 -0
  529. opik/rest_api/types/trace_experiment_item_bulk_write_view.py +1 -2
  530. opik/rest_api/types/trace_filter.py +23 -0
  531. opik/rest_api/types/trace_filter_operator.py +21 -0
  532. opik/rest_api/types/trace_filter_write.py +23 -0
  533. opik/rest_api/types/trace_filter_write_operator.py +21 -0
  534. opik/rest_api/types/trace_public.py +11 -2
  535. opik/rest_api/types/trace_thread_filter_write.py +23 -0
  536. opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
  537. opik/rest_api/types/trace_thread_identifier.py +1 -0
  538. opik/rest_api/types/trace_update.py +39 -0
  539. opik/rest_api/types/trace_write.py +1 -2
  540. opik/rest_api/types/value_entry.py +2 -0
  541. opik/rest_api/types/value_entry_compare.py +2 -0
  542. opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +2 -0
  543. opik/rest_api/types/value_entry_public.py +2 -0
  544. opik/rest_api/types/video_url.py +19 -0
  545. opik/rest_api/types/video_url_public.py +19 -0
  546. opik/rest_api/types/video_url_write.py +19 -0
  547. opik/rest_api/types/webhook.py +28 -0
  548. opik/rest_api/types/webhook_examples.py +19 -0
  549. opik/rest_api/types/webhook_public.py +28 -0
  550. opik/rest_api/types/webhook_test_result.py +23 -0
  551. opik/rest_api/types/webhook_test_result_status.py +5 -0
  552. opik/rest_api/types/webhook_write.py +23 -0
  553. opik/rest_api/types/welcome_wizard_tracking.py +22 -0
  554. opik/rest_api/types/workspace_configuration.py +5 -0
  555. opik/rest_api/welcome_wizard/__init__.py +4 -0
  556. opik/rest_api/welcome_wizard/client.py +195 -0
  557. opik/rest_api/welcome_wizard/raw_client.py +208 -0
  558. opik/rest_api/workspaces/client.py +14 -2
  559. opik/rest_api/workspaces/raw_client.py +10 -0
  560. opik/s3_httpx_client.py +14 -1
  561. opik/simulation/__init__.py +6 -0
  562. opik/simulation/simulated_user.py +99 -0
  563. opik/simulation/simulator.py +108 -0
  564. opik/synchronization.py +5 -6
  565. opik/{decorator/tracing_runtime_config.py → tracing_runtime_config.py} +6 -7
  566. opik/types.py +36 -0
  567. opik/validation/chat_prompt_messages.py +241 -0
  568. opik/validation/feedback_score.py +3 -3
  569. opik/validation/validator.py +28 -0
  570. opik-1.9.71.dist-info/METADATA +370 -0
  571. opik-1.9.71.dist-info/RECORD +1110 -0
  572. opik/api_objects/prompt/prompt.py +0 -112
  573. opik/cli.py +0 -193
  574. opik/hooks.py +0 -13
  575. opik/integrations/bedrock/chunks_aggregator.py +0 -55
  576. opik/integrations/bedrock/helpers.py +0 -8
  577. opik/rest_api/types/automation_rule_evaluator_object_public.py +0 -100
  578. opik/rest_api/types/json_node_experiment_item_bulk_write_view.py +0 -5
  579. opik-1.8.39.dist-info/METADATA +0 -339
  580. opik-1.8.39.dist-info/RECORD +0 -790
  581. /opik/{evaluation/metrics/conversation/conversational_coherence → decorator/context_manager}/__init__.py +0 -0
  582. /opik/evaluation/metrics/conversation/{session_completeness → llm_judges/conversational_coherence}/__init__.py +0 -0
  583. /opik/evaluation/metrics/conversation/{conversational_coherence → llm_judges/conversational_coherence}/schema.py +0 -0
  584. /opik/evaluation/metrics/conversation/{user_frustration → llm_judges/session_completeness}/__init__.py +0 -0
  585. /opik/evaluation/metrics/conversation/{session_completeness → llm_judges/session_completeness}/schema.py +0 -0
  586. /opik/evaluation/metrics/conversation/{user_frustration → llm_judges/user_frustration}/schema.py +0 -0
  587. /opik/integrations/bedrock/{stream_wrappers.py → converse/stream_wrappers.py} +0 -0
  588. /opik/rest_api/{spans/types → types}/span_update_type.py +0 -0
  589. {opik-1.8.39.dist-info → opik-1.9.71.dist-info}/WHEEL +0 -0
  590. {opik-1.8.39.dist-info → opik-1.9.71.dist-info}/entry_points.txt +0 -0
  591. {opik-1.8.39.dist-info → opik-1.9.71.dist-info}/licenses/LICENSE +0 -0
  592. {opik-1.8.39.dist-info → opik-1.9.71.dist-info}/top_level.txt +0 -0
@@ -7,6 +7,7 @@ from json.decoder import JSONDecodeError
7
7
 
8
8
  from ..core.api_error import ApiError
9
9
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
10
+ from ..core.datetime_utils import serialize_datetime
10
11
  from ..core.http_response import AsyncHttpResponse, HttpResponse
11
12
  from ..core.jsonable_encoder import jsonable_encoder
12
13
  from ..core.pydantic_utilities import parse_obj_as
@@ -23,8 +24,6 @@ from ..types.feedback_score_batch_item_thread import FeedbackScoreBatchItemThrea
23
24
  from ..types.feedback_score_source import FeedbackScoreSource
24
25
  from ..types.json_list_string import JsonListString
25
26
  from ..types.json_list_string_write import JsonListStringWrite
26
- from ..types.json_node import JsonNode
27
- from ..types.json_node_write import JsonNodeWrite
28
27
  from ..types.project_stats_public import ProjectStatsPublic
29
28
  from ..types.trace_filter_public import TraceFilterPublic
30
29
  from ..types.trace_page_public import TracePagePublic
@@ -32,6 +31,8 @@ from ..types.trace_public import TracePublic
32
31
  from ..types.trace_thread import TraceThread
33
32
  from ..types.trace_thread_filter import TraceThreadFilter
34
33
  from ..types.trace_thread_page import TraceThreadPage
34
+ from ..types.trace_thread_update import TraceThreadUpdate
35
+ from ..types.trace_update import TraceUpdate
35
36
  from ..types.trace_write import TraceWrite
36
37
  from ..types.value_entry import ValueEntry
37
38
 
@@ -250,25 +251,193 @@ class RawTracesClient:
250
251
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
251
252
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
252
253
 
254
+ def create_traces(
255
+ self, *, traces: typing.Sequence[TraceWrite], request_options: typing.Optional[RequestOptions] = None
256
+ ) -> HttpResponse[None]:
257
+ """
258
+ Create traces
259
+
260
+ Parameters
261
+ ----------
262
+ traces : typing.Sequence[TraceWrite]
263
+
264
+ request_options : typing.Optional[RequestOptions]
265
+ Request-specific configuration.
266
+
267
+ Returns
268
+ -------
269
+ HttpResponse[None]
270
+ """
271
+ _response = self._client_wrapper.httpx_client.request(
272
+ "v1/private/traces/batch",
273
+ method="POST",
274
+ json={
275
+ "traces": convert_and_respect_annotation_metadata(
276
+ object_=traces, annotation=typing.Sequence[TraceWrite], direction="write"
277
+ ),
278
+ },
279
+ headers={
280
+ "content-type": "application/json",
281
+ },
282
+ request_options=request_options,
283
+ omit=OMIT,
284
+ )
285
+ try:
286
+ if 200 <= _response.status_code < 300:
287
+ return HttpResponse(response=_response, data=None)
288
+ _response_json = _response.json()
289
+ except JSONDecodeError:
290
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
291
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
292
+
293
+ def batch_update_traces(
294
+ self,
295
+ *,
296
+ ids: typing.Sequence[str],
297
+ update: TraceUpdate,
298
+ merge_tags: typing.Optional[bool] = OMIT,
299
+ request_options: typing.Optional[RequestOptions] = None,
300
+ ) -> HttpResponse[None]:
301
+ """
302
+ Update multiple traces
303
+
304
+ Parameters
305
+ ----------
306
+ ids : typing.Sequence[str]
307
+ List of trace IDs to update (max 1000)
308
+
309
+ update : TraceUpdate
310
+
311
+ merge_tags : typing.Optional[bool]
312
+ If true, merge tags with existing tags instead of replacing them. Default: false
313
+
314
+ request_options : typing.Optional[RequestOptions]
315
+ Request-specific configuration.
316
+
317
+ Returns
318
+ -------
319
+ HttpResponse[None]
320
+ """
321
+ _response = self._client_wrapper.httpx_client.request(
322
+ "v1/private/traces/batch",
323
+ method="PATCH",
324
+ json={
325
+ "ids": ids,
326
+ "update": convert_and_respect_annotation_metadata(
327
+ object_=update, annotation=TraceUpdate, direction="write"
328
+ ),
329
+ "merge_tags": merge_tags,
330
+ },
331
+ headers={
332
+ "content-type": "application/json",
333
+ },
334
+ request_options=request_options,
335
+ omit=OMIT,
336
+ )
337
+ try:
338
+ if 200 <= _response.status_code < 300:
339
+ return HttpResponse(response=_response, data=None)
340
+ if _response.status_code == 400:
341
+ raise BadRequestError(
342
+ headers=dict(_response.headers),
343
+ body=typing.cast(
344
+ typing.Optional[typing.Any],
345
+ parse_obj_as(
346
+ type_=typing.Optional[typing.Any], # type: ignore
347
+ object_=_response.json(),
348
+ ),
349
+ ),
350
+ )
351
+ _response_json = _response.json()
352
+ except JSONDecodeError:
353
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
354
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
355
+
356
+ def batch_update_threads(
357
+ self,
358
+ *,
359
+ ids: typing.Sequence[str],
360
+ update: TraceThreadUpdate,
361
+ merge_tags: typing.Optional[bool] = OMIT,
362
+ request_options: typing.Optional[RequestOptions] = None,
363
+ ) -> HttpResponse[None]:
364
+ """
365
+ Update multiple threads
366
+
367
+ Parameters
368
+ ----------
369
+ ids : typing.Sequence[str]
370
+ List of thread model IDs to update (max 1000)
371
+
372
+ update : TraceThreadUpdate
373
+
374
+ merge_tags : typing.Optional[bool]
375
+ If true, merge tags with existing tags instead of replacing them. Default: false
376
+
377
+ request_options : typing.Optional[RequestOptions]
378
+ Request-specific configuration.
379
+
380
+ Returns
381
+ -------
382
+ HttpResponse[None]
383
+ """
384
+ _response = self._client_wrapper.httpx_client.request(
385
+ "v1/private/traces/threads/batch",
386
+ method="PATCH",
387
+ json={
388
+ "ids": ids,
389
+ "update": convert_and_respect_annotation_metadata(
390
+ object_=update, annotation=TraceThreadUpdate, direction="write"
391
+ ),
392
+ "merge_tags": merge_tags,
393
+ },
394
+ headers={
395
+ "content-type": "application/json",
396
+ },
397
+ request_options=request_options,
398
+ omit=OMIT,
399
+ )
400
+ try:
401
+ if 200 <= _response.status_code < 300:
402
+ return HttpResponse(response=_response, data=None)
403
+ if _response.status_code == 400:
404
+ raise BadRequestError(
405
+ headers=dict(_response.headers),
406
+ body=typing.cast(
407
+ typing.Optional[typing.Any],
408
+ parse_obj_as(
409
+ type_=typing.Optional[typing.Any], # type: ignore
410
+ object_=_response.json(),
411
+ ),
412
+ ),
413
+ )
414
+ _response_json = _response.json()
415
+ except JSONDecodeError:
416
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
417
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
418
+
253
419
  def close_trace_thread(
254
420
  self,
255
421
  *,
256
- thread_id: str,
257
422
  project_name: typing.Optional[str] = OMIT,
258
423
  project_id: typing.Optional[str] = OMIT,
424
+ thread_id: typing.Optional[str] = OMIT,
425
+ thread_ids: typing.Optional[typing.Sequence[str]] = OMIT,
259
426
  request_options: typing.Optional[RequestOptions] = None,
260
427
  ) -> HttpResponse[None]:
261
428
  """
262
- Close trace thread
429
+ Close one or multiple trace threads. Supports both single thread_id and multiple thread_ids for batch operations.
263
430
 
264
431
  Parameters
265
432
  ----------
266
- thread_id : str
267
-
268
433
  project_name : typing.Optional[str]
269
434
 
270
435
  project_id : typing.Optional[str]
271
436
 
437
+ thread_id : typing.Optional[str]
438
+
439
+ thread_ids : typing.Optional[typing.Sequence[str]]
440
+
272
441
  request_options : typing.Optional[RequestOptions]
273
442
  Request-specific configuration.
274
443
 
@@ -283,6 +452,7 @@ class RawTracesClient:
283
452
  "project_name": project_name,
284
453
  "project_id": project_id,
285
454
  "thread_id": thread_id,
455
+ "thread_ids": thread_ids,
286
456
  },
287
457
  headers={
288
458
  "content-type": "application/json",
@@ -318,8 +488,11 @@ class RawTracesClient:
318
488
  project_id: typing.Optional[str] = None,
319
489
  filters: typing.Optional[str] = None,
320
490
  truncate: typing.Optional[bool] = None,
491
+ strip_attachments: typing.Optional[bool] = None,
321
492
  sorting: typing.Optional[str] = None,
322
493
  exclude: typing.Optional[str] = None,
494
+ from_time: typing.Optional[dt.datetime] = None,
495
+ to_time: typing.Optional[dt.datetime] = None,
323
496
  request_options: typing.Optional[RequestOptions] = None,
324
497
  ) -> HttpResponse[TracePagePublic]:
325
498
  """
@@ -339,10 +512,16 @@ class RawTracesClient:
339
512
 
340
513
  truncate : typing.Optional[bool]
341
514
 
515
+ strip_attachments : typing.Optional[bool]
516
+
342
517
  sorting : typing.Optional[str]
343
518
 
344
519
  exclude : typing.Optional[str]
345
520
 
521
+ from_time : typing.Optional[dt.datetime]
522
+
523
+ to_time : typing.Optional[dt.datetime]
524
+
346
525
  request_options : typing.Optional[RequestOptions]
347
526
  Request-specific configuration.
348
527
 
@@ -361,8 +540,11 @@ class RawTracesClient:
361
540
  "project_id": project_id,
362
541
  "filters": filters,
363
542
  "truncate": truncate,
543
+ "strip_attachments": strip_attachments,
364
544
  "sorting": sorting,
365
545
  "exclude": exclude,
546
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
547
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
366
548
  },
367
549
  request_options=request_options,
368
550
  )
@@ -391,7 +573,7 @@ class RawTracesClient:
391
573
  end_time: typing.Optional[dt.datetime] = OMIT,
392
574
  input: typing.Optional[JsonListStringWrite] = OMIT,
393
575
  output: typing.Optional[JsonListStringWrite] = OMIT,
394
- metadata: typing.Optional[JsonNodeWrite] = OMIT,
576
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
395
577
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
396
578
  error_info: typing.Optional[ErrorInfoWrite] = OMIT,
397
579
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
@@ -418,7 +600,7 @@ class RawTracesClient:
418
600
 
419
601
  output : typing.Optional[JsonListStringWrite]
420
602
 
421
- metadata : typing.Optional[JsonNodeWrite]
603
+ metadata : typing.Optional[JsonListStringWrite]
422
604
 
423
605
  tags : typing.Optional[typing.Sequence[str]]
424
606
 
@@ -450,7 +632,9 @@ class RawTracesClient:
450
632
  "output": convert_and_respect_annotation_metadata(
451
633
  object_=output, annotation=JsonListStringWrite, direction="write"
452
634
  ),
453
- "metadata": metadata,
635
+ "metadata": convert_and_respect_annotation_metadata(
636
+ object_=metadata, annotation=JsonListStringWrite, direction="write"
637
+ ),
454
638
  "tags": tags,
455
639
  "error_info": convert_and_respect_annotation_metadata(
456
640
  object_=error_info, annotation=ErrorInfoWrite, direction="write"
@@ -472,47 +656,12 @@ class RawTracesClient:
472
656
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
473
657
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
474
658
 
475
- def create_traces(
476
- self, *, traces: typing.Sequence[TraceWrite], request_options: typing.Optional[RequestOptions] = None
477
- ) -> HttpResponse[None]:
478
- """
479
- Create traces
480
-
481
- Parameters
482
- ----------
483
- traces : typing.Sequence[TraceWrite]
484
-
485
- request_options : typing.Optional[RequestOptions]
486
- Request-specific configuration.
487
-
488
- Returns
489
- -------
490
- HttpResponse[None]
491
- """
492
- _response = self._client_wrapper.httpx_client.request(
493
- "v1/private/traces/batch",
494
- method="POST",
495
- json={
496
- "traces": convert_and_respect_annotation_metadata(
497
- object_=traces, annotation=typing.Sequence[TraceWrite], direction="write"
498
- ),
499
- },
500
- headers={
501
- "content-type": "application/json",
502
- },
503
- request_options=request_options,
504
- omit=OMIT,
505
- )
506
- try:
507
- if 200 <= _response.status_code < 300:
508
- return HttpResponse(response=_response, data=None)
509
- _response_json = _response.json()
510
- except JSONDecodeError:
511
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
512
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
513
-
514
659
  def get_trace_by_id(
515
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
660
+ self,
661
+ id: str,
662
+ *,
663
+ strip_attachments: typing.Optional[bool] = None,
664
+ request_options: typing.Optional[RequestOptions] = None,
516
665
  ) -> HttpResponse[TracePublic]:
517
666
  """
518
667
  Get trace by id
@@ -521,6 +670,8 @@ class RawTracesClient:
521
670
  ----------
522
671
  id : str
523
672
 
673
+ strip_attachments : typing.Optional[bool]
674
+
524
675
  request_options : typing.Optional[RequestOptions]
525
676
  Request-specific configuration.
526
677
 
@@ -532,6 +683,9 @@ class RawTracesClient:
532
683
  _response = self._client_wrapper.httpx_client.request(
533
684
  f"v1/private/traces/{jsonable_encoder(id)}",
534
685
  method="GET",
686
+ params={
687
+ "strip_attachments": strip_attachments,
688
+ },
535
689
  request_options=request_options,
536
690
  )
537
691
  try:
@@ -589,7 +743,7 @@ class RawTracesClient:
589
743
  end_time: typing.Optional[dt.datetime] = OMIT,
590
744
  input: typing.Optional[JsonListString] = OMIT,
591
745
  output: typing.Optional[JsonListString] = OMIT,
592
- metadata: typing.Optional[JsonNode] = OMIT,
746
+ metadata: typing.Optional[JsonListString] = OMIT,
593
747
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
594
748
  error_info: typing.Optional[ErrorInfo] = OMIT,
595
749
  thread_id: typing.Optional[str] = OMIT,
@@ -616,7 +770,7 @@ class RawTracesClient:
616
770
 
617
771
  output : typing.Optional[JsonListString]
618
772
 
619
- metadata : typing.Optional[JsonNode]
773
+ metadata : typing.Optional[JsonListString]
620
774
 
621
775
  tags : typing.Optional[typing.Sequence[str]]
622
776
 
@@ -645,7 +799,9 @@ class RawTracesClient:
645
799
  "output": convert_and_respect_annotation_metadata(
646
800
  object_=output, annotation=JsonListString, direction="write"
647
801
  ),
648
- "metadata": metadata,
802
+ "metadata": convert_and_respect_annotation_metadata(
803
+ object_=metadata, annotation=JsonListString, direction="write"
804
+ ),
649
805
  "tags": tags,
650
806
  "error_info": convert_and_respect_annotation_metadata(
651
807
  object_=error_info, annotation=ErrorInfo, direction="write"
@@ -968,14 +1124,14 @@ class RawTracesClient:
968
1124
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
969
1125
 
970
1126
  def find_trace_threads_feedback_score_names(
971
- self, *, project_id: str, request_options: typing.Optional[RequestOptions] = None
1127
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
972
1128
  ) -> HttpResponse[typing.List[str]]:
973
1129
  """
974
1130
  Find Trace Threads Feedback Score names
975
1131
 
976
1132
  Parameters
977
1133
  ----------
978
- project_id : str
1134
+ project_id : typing.Optional[str]
979
1135
 
980
1136
  request_options : typing.Optional[RequestOptions]
981
1137
  Request-specific configuration.
@@ -1014,6 +1170,8 @@ class RawTracesClient:
1014
1170
  project_id: typing.Optional[str] = None,
1015
1171
  project_name: typing.Optional[str] = None,
1016
1172
  filters: typing.Optional[str] = None,
1173
+ from_time: typing.Optional[dt.datetime] = None,
1174
+ to_time: typing.Optional[dt.datetime] = None,
1017
1175
  request_options: typing.Optional[RequestOptions] = None,
1018
1176
  ) -> HttpResponse[ProjectStatsPublic]:
1019
1177
  """
@@ -1027,6 +1185,10 @@ class RawTracesClient:
1027
1185
 
1028
1186
  filters : typing.Optional[str]
1029
1187
 
1188
+ from_time : typing.Optional[dt.datetime]
1189
+
1190
+ to_time : typing.Optional[dt.datetime]
1191
+
1030
1192
  request_options : typing.Optional[RequestOptions]
1031
1193
  Request-specific configuration.
1032
1194
 
@@ -1042,6 +1204,8 @@ class RawTracesClient:
1042
1204
  "project_id": project_id,
1043
1205
  "project_name": project_name,
1044
1206
  "filters": filters,
1207
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
1208
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
1045
1209
  },
1046
1210
  request_options=request_options,
1047
1211
  )
@@ -1111,6 +1275,66 @@ class RawTracesClient:
1111
1275
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1112
1276
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1113
1277
 
1278
+ def get_trace_thread_stats(
1279
+ self,
1280
+ *,
1281
+ project_id: typing.Optional[str] = None,
1282
+ project_name: typing.Optional[str] = None,
1283
+ filters: typing.Optional[str] = None,
1284
+ from_time: typing.Optional[dt.datetime] = None,
1285
+ to_time: typing.Optional[dt.datetime] = None,
1286
+ request_options: typing.Optional[RequestOptions] = None,
1287
+ ) -> HttpResponse[ProjectStatsPublic]:
1288
+ """
1289
+ Get trace thread stats
1290
+
1291
+ Parameters
1292
+ ----------
1293
+ project_id : typing.Optional[str]
1294
+
1295
+ project_name : typing.Optional[str]
1296
+
1297
+ filters : typing.Optional[str]
1298
+
1299
+ from_time : typing.Optional[dt.datetime]
1300
+
1301
+ to_time : typing.Optional[dt.datetime]
1302
+
1303
+ request_options : typing.Optional[RequestOptions]
1304
+ Request-specific configuration.
1305
+
1306
+ Returns
1307
+ -------
1308
+ HttpResponse[ProjectStatsPublic]
1309
+ Trace thread stats resource
1310
+ """
1311
+ _response = self._client_wrapper.httpx_client.request(
1312
+ "v1/private/traces/threads/stats",
1313
+ method="GET",
1314
+ params={
1315
+ "project_id": project_id,
1316
+ "project_name": project_name,
1317
+ "filters": filters,
1318
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
1319
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
1320
+ },
1321
+ request_options=request_options,
1322
+ )
1323
+ try:
1324
+ if 200 <= _response.status_code < 300:
1325
+ _data = typing.cast(
1326
+ ProjectStatsPublic,
1327
+ parse_obj_as(
1328
+ type_=ProjectStatsPublic, # type: ignore
1329
+ object_=_response.json(),
1330
+ ),
1331
+ )
1332
+ return HttpResponse(response=_response, data=_data)
1333
+ _response_json = _response.json()
1334
+ except JSONDecodeError:
1335
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1336
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1337
+
1114
1338
  def get_trace_comment(
1115
1339
  self, comment_id: str, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
1116
1340
  ) -> HttpResponse[Comment]:
@@ -1168,6 +1392,7 @@ class RawTracesClient:
1168
1392
  thread_id: str,
1169
1393
  project_name: typing.Optional[str] = OMIT,
1170
1394
  project_id: typing.Optional[str] = OMIT,
1395
+ truncate: typing.Optional[bool] = OMIT,
1171
1396
  request_options: typing.Optional[RequestOptions] = None,
1172
1397
  ) -> HttpResponse[TraceThread]:
1173
1398
  """
@@ -1181,6 +1406,8 @@ class RawTracesClient:
1181
1406
 
1182
1407
  project_id : typing.Optional[str]
1183
1408
 
1409
+ truncate : typing.Optional[bool]
1410
+
1184
1411
  request_options : typing.Optional[RequestOptions]
1185
1412
  Request-specific configuration.
1186
1413
 
@@ -1196,6 +1423,7 @@ class RawTracesClient:
1196
1423
  "project_name": project_name,
1197
1424
  "project_id": project_id,
1198
1425
  "thread_id": thread_id,
1426
+ "truncate": truncate,
1199
1427
  },
1200
1428
  headers={
1201
1429
  "content-type": "application/json",
@@ -1237,8 +1465,11 @@ class RawTracesClient:
1237
1465
  project_name: typing.Optional[str] = None,
1238
1466
  project_id: typing.Optional[str] = None,
1239
1467
  truncate: typing.Optional[bool] = None,
1468
+ strip_attachments: typing.Optional[bool] = None,
1240
1469
  filters: typing.Optional[str] = None,
1241
1470
  sorting: typing.Optional[str] = None,
1471
+ from_time: typing.Optional[dt.datetime] = None,
1472
+ to_time: typing.Optional[dt.datetime] = None,
1242
1473
  request_options: typing.Optional[RequestOptions] = None,
1243
1474
  ) -> HttpResponse[TraceThreadPage]:
1244
1475
  """
@@ -1256,10 +1487,16 @@ class RawTracesClient:
1256
1487
 
1257
1488
  truncate : typing.Optional[bool]
1258
1489
 
1490
+ strip_attachments : typing.Optional[bool]
1491
+
1259
1492
  filters : typing.Optional[str]
1260
1493
 
1261
1494
  sorting : typing.Optional[str]
1262
1495
 
1496
+ from_time : typing.Optional[dt.datetime]
1497
+
1498
+ to_time : typing.Optional[dt.datetime]
1499
+
1263
1500
  request_options : typing.Optional[RequestOptions]
1264
1501
  Request-specific configuration.
1265
1502
 
@@ -1277,8 +1514,11 @@ class RawTracesClient:
1277
1514
  "project_name": project_name,
1278
1515
  "project_id": project_id,
1279
1516
  "truncate": truncate,
1517
+ "strip_attachments": strip_attachments,
1280
1518
  "filters": filters,
1281
1519
  "sorting": sorting,
1520
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
1521
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
1282
1522
  },
1283
1523
  request_options=request_options,
1284
1524
  )
@@ -1303,6 +1543,7 @@ class RawTracesClient:
1303
1543
  thread_id: str,
1304
1544
  project_name: typing.Optional[str] = OMIT,
1305
1545
  project_id: typing.Optional[str] = OMIT,
1546
+ truncate: typing.Optional[bool] = OMIT,
1306
1547
  request_options: typing.Optional[RequestOptions] = None,
1307
1548
  ) -> HttpResponse[None]:
1308
1549
  """
@@ -1316,6 +1557,8 @@ class RawTracesClient:
1316
1557
 
1317
1558
  project_id : typing.Optional[str]
1318
1559
 
1560
+ truncate : typing.Optional[bool]
1561
+
1319
1562
  request_options : typing.Optional[RequestOptions]
1320
1563
  Request-specific configuration.
1321
1564
 
@@ -1330,6 +1573,7 @@ class RawTracesClient:
1330
1573
  "project_name": project_name,
1331
1574
  "project_id": project_id,
1332
1575
  "thread_id": thread_id,
1576
+ "truncate": truncate,
1333
1577
  },
1334
1578
  headers={
1335
1579
  "content-type": "application/json",
@@ -1439,6 +1683,9 @@ class RawTracesClient:
1439
1683
  last_retrieved_thread_model_id: typing.Optional[str] = OMIT,
1440
1684
  limit: typing.Optional[int] = OMIT,
1441
1685
  truncate: typing.Optional[bool] = OMIT,
1686
+ strip_attachments: typing.Optional[bool] = OMIT,
1687
+ from_time: typing.Optional[dt.datetime] = OMIT,
1688
+ to_time: typing.Optional[dt.datetime] = OMIT,
1442
1689
  request_options: typing.Optional[RequestOptions] = None,
1443
1690
  ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
1444
1691
  """
@@ -1458,7 +1705,16 @@ class RawTracesClient:
1458
1705
  Max number of trace thread to be streamed
1459
1706
 
1460
1707
  truncate : typing.Optional[bool]
1461
- Truncate image included in either input, output or metadata
1708
+ Truncate input, output and metadata to slim payloads
1709
+
1710
+ strip_attachments : typing.Optional[bool]
1711
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
1712
+
1713
+ from_time : typing.Optional[dt.datetime]
1714
+ Filter trace threads created from this time (ISO-8601 format).
1715
+
1716
+ to_time : typing.Optional[dt.datetime]
1717
+ Filter trace threads created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
1462
1718
 
1463
1719
  request_options : typing.Optional[RequestOptions]
1464
1720
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -1480,6 +1736,9 @@ class RawTracesClient:
1480
1736
  "last_retrieved_thread_model_id": last_retrieved_thread_model_id,
1481
1737
  "limit": limit,
1482
1738
  "truncate": truncate,
1739
+ "strip_attachments": strip_attachments,
1740
+ "from_time": from_time,
1741
+ "to_time": to_time,
1483
1742
  },
1484
1743
  headers={
1485
1744
  "content-type": "application/json",
@@ -1526,6 +1785,9 @@ class RawTracesClient:
1526
1785
  last_retrieved_id: typing.Optional[str] = OMIT,
1527
1786
  limit: typing.Optional[int] = OMIT,
1528
1787
  truncate: typing.Optional[bool] = OMIT,
1788
+ strip_attachments: typing.Optional[bool] = OMIT,
1789
+ from_time: typing.Optional[dt.datetime] = OMIT,
1790
+ to_time: typing.Optional[dt.datetime] = OMIT,
1529
1791
  request_options: typing.Optional[RequestOptions] = None,
1530
1792
  ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
1531
1793
  """
@@ -1545,7 +1807,16 @@ class RawTracesClient:
1545
1807
  Max number of traces to be streamed
1546
1808
 
1547
1809
  truncate : typing.Optional[bool]
1548
- Truncate image included in either input, output or metadata
1810
+ Truncate input, output and metadata to slim payloads
1811
+
1812
+ strip_attachments : typing.Optional[bool]
1813
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
1814
+
1815
+ from_time : typing.Optional[dt.datetime]
1816
+ Filter traces created from this time (ISO-8601 format).
1817
+
1818
+ to_time : typing.Optional[dt.datetime]
1819
+ Filter traces created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
1549
1820
 
1550
1821
  request_options : typing.Optional[RequestOptions]
1551
1822
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -1567,6 +1838,9 @@ class RawTracesClient:
1567
1838
  "last_retrieved_id": last_retrieved_id,
1568
1839
  "limit": limit,
1569
1840
  "truncate": truncate,
1841
+ "strip_attachments": strip_attachments,
1842
+ "from_time": from_time,
1843
+ "to_time": to_time,
1570
1844
  },
1571
1845
  headers={
1572
1846
  "content-type": "application/json",
@@ -1618,12 +1892,7 @@ class RawTracesClient:
1618
1892
  self,
1619
1893
  thread_model_id: str,
1620
1894
  *,
1621
- text: str,
1622
- id: typing.Optional[str] = OMIT,
1623
- created_at: typing.Optional[dt.datetime] = OMIT,
1624
- last_updated_at: typing.Optional[dt.datetime] = OMIT,
1625
- created_by: typing.Optional[str] = OMIT,
1626
- last_updated_by: typing.Optional[str] = OMIT,
1895
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1627
1896
  request_options: typing.Optional[RequestOptions] = None,
1628
1897
  ) -> HttpResponse[None]:
1629
1898
  """
@@ -1633,17 +1902,7 @@ class RawTracesClient:
1633
1902
  ----------
1634
1903
  thread_model_id : str
1635
1904
 
1636
- text : str
1637
-
1638
- id : typing.Optional[str]
1639
-
1640
- created_at : typing.Optional[dt.datetime]
1641
-
1642
- last_updated_at : typing.Optional[dt.datetime]
1643
-
1644
- created_by : typing.Optional[str]
1645
-
1646
- last_updated_by : typing.Optional[str]
1905
+ tags : typing.Optional[typing.Sequence[str]]
1647
1906
 
1648
1907
  request_options : typing.Optional[RequestOptions]
1649
1908
  Request-specific configuration.
@@ -1656,12 +1915,7 @@ class RawTracesClient:
1656
1915
  f"v1/private/traces/threads/{jsonable_encoder(thread_model_id)}",
1657
1916
  method="PATCH",
1658
1917
  json={
1659
- "id": id,
1660
- "text": text,
1661
- "created_at": created_at,
1662
- "last_updated_at": last_updated_at,
1663
- "created_by": created_by,
1664
- "last_updated_by": last_updated_by,
1918
+ "tags": tags,
1665
1919
  },
1666
1920
  headers={
1667
1921
  "content-type": "application/json",
@@ -1904,36 +2158,209 @@ class AsyncRawTracesClient:
1904
2158
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1905
2159
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1906
2160
 
1907
- async def add_trace_comment(
2161
+ async def add_trace_comment(
2162
+ self,
2163
+ id_: str,
2164
+ *,
2165
+ text: str,
2166
+ id: typing.Optional[str] = OMIT,
2167
+ created_at: typing.Optional[dt.datetime] = OMIT,
2168
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
2169
+ created_by: typing.Optional[str] = OMIT,
2170
+ last_updated_by: typing.Optional[str] = OMIT,
2171
+ request_options: typing.Optional[RequestOptions] = None,
2172
+ ) -> AsyncHttpResponse[None]:
2173
+ """
2174
+ Add trace comment
2175
+
2176
+ Parameters
2177
+ ----------
2178
+ id_ : str
2179
+
2180
+ text : str
2181
+
2182
+ id : typing.Optional[str]
2183
+
2184
+ created_at : typing.Optional[dt.datetime]
2185
+
2186
+ last_updated_at : typing.Optional[dt.datetime]
2187
+
2188
+ created_by : typing.Optional[str]
2189
+
2190
+ last_updated_by : typing.Optional[str]
2191
+
2192
+ request_options : typing.Optional[RequestOptions]
2193
+ Request-specific configuration.
2194
+
2195
+ Returns
2196
+ -------
2197
+ AsyncHttpResponse[None]
2198
+ """
2199
+ _response = await self._client_wrapper.httpx_client.request(
2200
+ f"v1/private/traces/{jsonable_encoder(id_)}/comments",
2201
+ method="POST",
2202
+ json={
2203
+ "id": id,
2204
+ "text": text,
2205
+ "created_at": created_at,
2206
+ "last_updated_at": last_updated_at,
2207
+ "created_by": created_by,
2208
+ "last_updated_by": last_updated_by,
2209
+ },
2210
+ headers={
2211
+ "content-type": "application/json",
2212
+ },
2213
+ request_options=request_options,
2214
+ omit=OMIT,
2215
+ )
2216
+ try:
2217
+ if 200 <= _response.status_code < 300:
2218
+ return AsyncHttpResponse(response=_response, data=None)
2219
+ _response_json = _response.json()
2220
+ except JSONDecodeError:
2221
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2222
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2223
+
2224
+ async def add_trace_feedback_score(
2225
+ self,
2226
+ id: str,
2227
+ *,
2228
+ name: str,
2229
+ value: float,
2230
+ source: FeedbackScoreSource,
2231
+ category_name: typing.Optional[str] = OMIT,
2232
+ reason: typing.Optional[str] = OMIT,
2233
+ created_at: typing.Optional[dt.datetime] = OMIT,
2234
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
2235
+ created_by: typing.Optional[str] = OMIT,
2236
+ last_updated_by: typing.Optional[str] = OMIT,
2237
+ value_by_author: typing.Optional[typing.Dict[str, ValueEntry]] = OMIT,
2238
+ request_options: typing.Optional[RequestOptions] = None,
2239
+ ) -> AsyncHttpResponse[None]:
2240
+ """
2241
+ Add trace feedback score
2242
+
2243
+ Parameters
2244
+ ----------
2245
+ id : str
2246
+
2247
+ name : str
2248
+
2249
+ value : float
2250
+
2251
+ source : FeedbackScoreSource
2252
+
2253
+ category_name : typing.Optional[str]
2254
+
2255
+ reason : typing.Optional[str]
2256
+
2257
+ created_at : typing.Optional[dt.datetime]
2258
+
2259
+ last_updated_at : typing.Optional[dt.datetime]
2260
+
2261
+ created_by : typing.Optional[str]
2262
+
2263
+ last_updated_by : typing.Optional[str]
2264
+
2265
+ value_by_author : typing.Optional[typing.Dict[str, ValueEntry]]
2266
+
2267
+ request_options : typing.Optional[RequestOptions]
2268
+ Request-specific configuration.
2269
+
2270
+ Returns
2271
+ -------
2272
+ AsyncHttpResponse[None]
2273
+ """
2274
+ _response = await self._client_wrapper.httpx_client.request(
2275
+ f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores",
2276
+ method="PUT",
2277
+ json={
2278
+ "name": name,
2279
+ "category_name": category_name,
2280
+ "value": value,
2281
+ "reason": reason,
2282
+ "source": source,
2283
+ "created_at": created_at,
2284
+ "last_updated_at": last_updated_at,
2285
+ "created_by": created_by,
2286
+ "last_updated_by": last_updated_by,
2287
+ "value_by_author": convert_and_respect_annotation_metadata(
2288
+ object_=value_by_author, annotation=typing.Dict[str, ValueEntry], direction="write"
2289
+ ),
2290
+ },
2291
+ headers={
2292
+ "content-type": "application/json",
2293
+ },
2294
+ request_options=request_options,
2295
+ omit=OMIT,
2296
+ )
2297
+ try:
2298
+ if 200 <= _response.status_code < 300:
2299
+ return AsyncHttpResponse(response=_response, data=None)
2300
+ _response_json = _response.json()
2301
+ except JSONDecodeError:
2302
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2303
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2304
+
2305
+ async def create_traces(
2306
+ self, *, traces: typing.Sequence[TraceWrite], request_options: typing.Optional[RequestOptions] = None
2307
+ ) -> AsyncHttpResponse[None]:
2308
+ """
2309
+ Create traces
2310
+
2311
+ Parameters
2312
+ ----------
2313
+ traces : typing.Sequence[TraceWrite]
2314
+
2315
+ request_options : typing.Optional[RequestOptions]
2316
+ Request-specific configuration.
2317
+
2318
+ Returns
2319
+ -------
2320
+ AsyncHttpResponse[None]
2321
+ """
2322
+ _response = await self._client_wrapper.httpx_client.request(
2323
+ "v1/private/traces/batch",
2324
+ method="POST",
2325
+ json={
2326
+ "traces": convert_and_respect_annotation_metadata(
2327
+ object_=traces, annotation=typing.Sequence[TraceWrite], direction="write"
2328
+ ),
2329
+ },
2330
+ headers={
2331
+ "content-type": "application/json",
2332
+ },
2333
+ request_options=request_options,
2334
+ omit=OMIT,
2335
+ )
2336
+ try:
2337
+ if 200 <= _response.status_code < 300:
2338
+ return AsyncHttpResponse(response=_response, data=None)
2339
+ _response_json = _response.json()
2340
+ except JSONDecodeError:
2341
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2342
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2343
+
2344
+ async def batch_update_traces(
1908
2345
  self,
1909
- id_: str,
1910
2346
  *,
1911
- text: str,
1912
- id: typing.Optional[str] = OMIT,
1913
- created_at: typing.Optional[dt.datetime] = OMIT,
1914
- last_updated_at: typing.Optional[dt.datetime] = OMIT,
1915
- created_by: typing.Optional[str] = OMIT,
1916
- last_updated_by: typing.Optional[str] = OMIT,
2347
+ ids: typing.Sequence[str],
2348
+ update: TraceUpdate,
2349
+ merge_tags: typing.Optional[bool] = OMIT,
1917
2350
  request_options: typing.Optional[RequestOptions] = None,
1918
2351
  ) -> AsyncHttpResponse[None]:
1919
2352
  """
1920
- Add trace comment
2353
+ Update multiple traces
1921
2354
 
1922
2355
  Parameters
1923
2356
  ----------
1924
- id_ : str
1925
-
1926
- text : str
1927
-
1928
- id : typing.Optional[str]
1929
-
1930
- created_at : typing.Optional[dt.datetime]
1931
-
1932
- last_updated_at : typing.Optional[dt.datetime]
2357
+ ids : typing.Sequence[str]
2358
+ List of trace IDs to update (max 1000)
1933
2359
 
1934
- created_by : typing.Optional[str]
2360
+ update : TraceUpdate
1935
2361
 
1936
- last_updated_by : typing.Optional[str]
2362
+ merge_tags : typing.Optional[bool]
2363
+ If true, merge tags with existing tags instead of replacing them. Default: false
1937
2364
 
1938
2365
  request_options : typing.Optional[RequestOptions]
1939
2366
  Request-specific configuration.
@@ -1943,15 +2370,14 @@ class AsyncRawTracesClient:
1943
2370
  AsyncHttpResponse[None]
1944
2371
  """
1945
2372
  _response = await self._client_wrapper.httpx_client.request(
1946
- f"v1/private/traces/{jsonable_encoder(id_)}/comments",
1947
- method="POST",
2373
+ "v1/private/traces/batch",
2374
+ method="PATCH",
1948
2375
  json={
1949
- "id": id,
1950
- "text": text,
1951
- "created_at": created_at,
1952
- "last_updated_at": last_updated_at,
1953
- "created_by": created_by,
1954
- "last_updated_by": last_updated_by,
2376
+ "ids": ids,
2377
+ "update": convert_and_respect_annotation_metadata(
2378
+ object_=update, annotation=TraceUpdate, direction="write"
2379
+ ),
2380
+ "merge_tags": merge_tags,
1955
2381
  },
1956
2382
  headers={
1957
2383
  "content-type": "application/json",
@@ -1962,53 +2388,42 @@ class AsyncRawTracesClient:
1962
2388
  try:
1963
2389
  if 200 <= _response.status_code < 300:
1964
2390
  return AsyncHttpResponse(response=_response, data=None)
2391
+ if _response.status_code == 400:
2392
+ raise BadRequestError(
2393
+ headers=dict(_response.headers),
2394
+ body=typing.cast(
2395
+ typing.Optional[typing.Any],
2396
+ parse_obj_as(
2397
+ type_=typing.Optional[typing.Any], # type: ignore
2398
+ object_=_response.json(),
2399
+ ),
2400
+ ),
2401
+ )
1965
2402
  _response_json = _response.json()
1966
2403
  except JSONDecodeError:
1967
2404
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1968
2405
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1969
2406
 
1970
- async def add_trace_feedback_score(
2407
+ async def batch_update_threads(
1971
2408
  self,
1972
- id: str,
1973
2409
  *,
1974
- name: str,
1975
- value: float,
1976
- source: FeedbackScoreSource,
1977
- category_name: typing.Optional[str] = OMIT,
1978
- reason: typing.Optional[str] = OMIT,
1979
- created_at: typing.Optional[dt.datetime] = OMIT,
1980
- last_updated_at: typing.Optional[dt.datetime] = OMIT,
1981
- created_by: typing.Optional[str] = OMIT,
1982
- last_updated_by: typing.Optional[str] = OMIT,
1983
- value_by_author: typing.Optional[typing.Dict[str, ValueEntry]] = OMIT,
2410
+ ids: typing.Sequence[str],
2411
+ update: TraceThreadUpdate,
2412
+ merge_tags: typing.Optional[bool] = OMIT,
1984
2413
  request_options: typing.Optional[RequestOptions] = None,
1985
2414
  ) -> AsyncHttpResponse[None]:
1986
2415
  """
1987
- Add trace feedback score
2416
+ Update multiple threads
1988
2417
 
1989
2418
  Parameters
1990
2419
  ----------
1991
- id : str
1992
-
1993
- name : str
1994
-
1995
- value : float
1996
-
1997
- source : FeedbackScoreSource
1998
-
1999
- category_name : typing.Optional[str]
2000
-
2001
- reason : typing.Optional[str]
2002
-
2003
- created_at : typing.Optional[dt.datetime]
2004
-
2005
- last_updated_at : typing.Optional[dt.datetime]
2006
-
2007
- created_by : typing.Optional[str]
2420
+ ids : typing.Sequence[str]
2421
+ List of thread model IDs to update (max 1000)
2008
2422
 
2009
- last_updated_by : typing.Optional[str]
2423
+ update : TraceThreadUpdate
2010
2424
 
2011
- value_by_author : typing.Optional[typing.Dict[str, ValueEntry]]
2425
+ merge_tags : typing.Optional[bool]
2426
+ If true, merge tags with existing tags instead of replacing them. Default: false
2012
2427
 
2013
2428
  request_options : typing.Optional[RequestOptions]
2014
2429
  Request-specific configuration.
@@ -2018,21 +2433,14 @@ class AsyncRawTracesClient:
2018
2433
  AsyncHttpResponse[None]
2019
2434
  """
2020
2435
  _response = await self._client_wrapper.httpx_client.request(
2021
- f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores",
2022
- method="PUT",
2436
+ "v1/private/traces/threads/batch",
2437
+ method="PATCH",
2023
2438
  json={
2024
- "name": name,
2025
- "category_name": category_name,
2026
- "value": value,
2027
- "reason": reason,
2028
- "source": source,
2029
- "created_at": created_at,
2030
- "last_updated_at": last_updated_at,
2031
- "created_by": created_by,
2032
- "last_updated_by": last_updated_by,
2033
- "value_by_author": convert_and_respect_annotation_metadata(
2034
- object_=value_by_author, annotation=typing.Dict[str, ValueEntry], direction="write"
2439
+ "ids": ids,
2440
+ "update": convert_and_respect_annotation_metadata(
2441
+ object_=update, annotation=TraceThreadUpdate, direction="write"
2035
2442
  ),
2443
+ "merge_tags": merge_tags,
2036
2444
  },
2037
2445
  headers={
2038
2446
  "content-type": "application/json",
@@ -2043,6 +2451,17 @@ class AsyncRawTracesClient:
2043
2451
  try:
2044
2452
  if 200 <= _response.status_code < 300:
2045
2453
  return AsyncHttpResponse(response=_response, data=None)
2454
+ if _response.status_code == 400:
2455
+ raise BadRequestError(
2456
+ headers=dict(_response.headers),
2457
+ body=typing.cast(
2458
+ typing.Optional[typing.Any],
2459
+ parse_obj_as(
2460
+ type_=typing.Optional[typing.Any], # type: ignore
2461
+ object_=_response.json(),
2462
+ ),
2463
+ ),
2464
+ )
2046
2465
  _response_json = _response.json()
2047
2466
  except JSONDecodeError:
2048
2467
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
@@ -2051,22 +2470,25 @@ class AsyncRawTracesClient:
2051
2470
  async def close_trace_thread(
2052
2471
  self,
2053
2472
  *,
2054
- thread_id: str,
2055
2473
  project_name: typing.Optional[str] = OMIT,
2056
2474
  project_id: typing.Optional[str] = OMIT,
2475
+ thread_id: typing.Optional[str] = OMIT,
2476
+ thread_ids: typing.Optional[typing.Sequence[str]] = OMIT,
2057
2477
  request_options: typing.Optional[RequestOptions] = None,
2058
2478
  ) -> AsyncHttpResponse[None]:
2059
2479
  """
2060
- Close trace thread
2480
+ Close one or multiple trace threads. Supports both single thread_id and multiple thread_ids for batch operations.
2061
2481
 
2062
2482
  Parameters
2063
2483
  ----------
2064
- thread_id : str
2065
-
2066
2484
  project_name : typing.Optional[str]
2067
2485
 
2068
2486
  project_id : typing.Optional[str]
2069
2487
 
2488
+ thread_id : typing.Optional[str]
2489
+
2490
+ thread_ids : typing.Optional[typing.Sequence[str]]
2491
+
2070
2492
  request_options : typing.Optional[RequestOptions]
2071
2493
  Request-specific configuration.
2072
2494
 
@@ -2081,6 +2503,7 @@ class AsyncRawTracesClient:
2081
2503
  "project_name": project_name,
2082
2504
  "project_id": project_id,
2083
2505
  "thread_id": thread_id,
2506
+ "thread_ids": thread_ids,
2084
2507
  },
2085
2508
  headers={
2086
2509
  "content-type": "application/json",
@@ -2116,8 +2539,11 @@ class AsyncRawTracesClient:
2116
2539
  project_id: typing.Optional[str] = None,
2117
2540
  filters: typing.Optional[str] = None,
2118
2541
  truncate: typing.Optional[bool] = None,
2542
+ strip_attachments: typing.Optional[bool] = None,
2119
2543
  sorting: typing.Optional[str] = None,
2120
2544
  exclude: typing.Optional[str] = None,
2545
+ from_time: typing.Optional[dt.datetime] = None,
2546
+ to_time: typing.Optional[dt.datetime] = None,
2121
2547
  request_options: typing.Optional[RequestOptions] = None,
2122
2548
  ) -> AsyncHttpResponse[TracePagePublic]:
2123
2549
  """
@@ -2137,10 +2563,16 @@ class AsyncRawTracesClient:
2137
2563
 
2138
2564
  truncate : typing.Optional[bool]
2139
2565
 
2566
+ strip_attachments : typing.Optional[bool]
2567
+
2140
2568
  sorting : typing.Optional[str]
2141
2569
 
2142
2570
  exclude : typing.Optional[str]
2143
2571
 
2572
+ from_time : typing.Optional[dt.datetime]
2573
+
2574
+ to_time : typing.Optional[dt.datetime]
2575
+
2144
2576
  request_options : typing.Optional[RequestOptions]
2145
2577
  Request-specific configuration.
2146
2578
 
@@ -2159,8 +2591,11 @@ class AsyncRawTracesClient:
2159
2591
  "project_id": project_id,
2160
2592
  "filters": filters,
2161
2593
  "truncate": truncate,
2594
+ "strip_attachments": strip_attachments,
2162
2595
  "sorting": sorting,
2163
2596
  "exclude": exclude,
2597
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
2598
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
2164
2599
  },
2165
2600
  request_options=request_options,
2166
2601
  )
@@ -2189,7 +2624,7 @@ class AsyncRawTracesClient:
2189
2624
  end_time: typing.Optional[dt.datetime] = OMIT,
2190
2625
  input: typing.Optional[JsonListStringWrite] = OMIT,
2191
2626
  output: typing.Optional[JsonListStringWrite] = OMIT,
2192
- metadata: typing.Optional[JsonNodeWrite] = OMIT,
2627
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
2193
2628
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
2194
2629
  error_info: typing.Optional[ErrorInfoWrite] = OMIT,
2195
2630
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
@@ -2216,7 +2651,7 @@ class AsyncRawTracesClient:
2216
2651
 
2217
2652
  output : typing.Optional[JsonListStringWrite]
2218
2653
 
2219
- metadata : typing.Optional[JsonNodeWrite]
2654
+ metadata : typing.Optional[JsonListStringWrite]
2220
2655
 
2221
2656
  tags : typing.Optional[typing.Sequence[str]]
2222
2657
 
@@ -2248,7 +2683,9 @@ class AsyncRawTracesClient:
2248
2683
  "output": convert_and_respect_annotation_metadata(
2249
2684
  object_=output, annotation=JsonListStringWrite, direction="write"
2250
2685
  ),
2251
- "metadata": metadata,
2686
+ "metadata": convert_and_respect_annotation_metadata(
2687
+ object_=metadata, annotation=JsonListStringWrite, direction="write"
2688
+ ),
2252
2689
  "tags": tags,
2253
2690
  "error_info": convert_and_respect_annotation_metadata(
2254
2691
  object_=error_info, annotation=ErrorInfoWrite, direction="write"
@@ -2270,47 +2707,12 @@ class AsyncRawTracesClient:
2270
2707
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2271
2708
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2272
2709
 
2273
- async def create_traces(
2274
- self, *, traces: typing.Sequence[TraceWrite], request_options: typing.Optional[RequestOptions] = None
2275
- ) -> AsyncHttpResponse[None]:
2276
- """
2277
- Create traces
2278
-
2279
- Parameters
2280
- ----------
2281
- traces : typing.Sequence[TraceWrite]
2282
-
2283
- request_options : typing.Optional[RequestOptions]
2284
- Request-specific configuration.
2285
-
2286
- Returns
2287
- -------
2288
- AsyncHttpResponse[None]
2289
- """
2290
- _response = await self._client_wrapper.httpx_client.request(
2291
- "v1/private/traces/batch",
2292
- method="POST",
2293
- json={
2294
- "traces": convert_and_respect_annotation_metadata(
2295
- object_=traces, annotation=typing.Sequence[TraceWrite], direction="write"
2296
- ),
2297
- },
2298
- headers={
2299
- "content-type": "application/json",
2300
- },
2301
- request_options=request_options,
2302
- omit=OMIT,
2303
- )
2304
- try:
2305
- if 200 <= _response.status_code < 300:
2306
- return AsyncHttpResponse(response=_response, data=None)
2307
- _response_json = _response.json()
2308
- except JSONDecodeError:
2309
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2310
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2311
-
2312
2710
  async def get_trace_by_id(
2313
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2711
+ self,
2712
+ id: str,
2713
+ *,
2714
+ strip_attachments: typing.Optional[bool] = None,
2715
+ request_options: typing.Optional[RequestOptions] = None,
2314
2716
  ) -> AsyncHttpResponse[TracePublic]:
2315
2717
  """
2316
2718
  Get trace by id
@@ -2319,6 +2721,8 @@ class AsyncRawTracesClient:
2319
2721
  ----------
2320
2722
  id : str
2321
2723
 
2724
+ strip_attachments : typing.Optional[bool]
2725
+
2322
2726
  request_options : typing.Optional[RequestOptions]
2323
2727
  Request-specific configuration.
2324
2728
 
@@ -2330,6 +2734,9 @@ class AsyncRawTracesClient:
2330
2734
  _response = await self._client_wrapper.httpx_client.request(
2331
2735
  f"v1/private/traces/{jsonable_encoder(id)}",
2332
2736
  method="GET",
2737
+ params={
2738
+ "strip_attachments": strip_attachments,
2739
+ },
2333
2740
  request_options=request_options,
2334
2741
  )
2335
2742
  try:
@@ -2387,7 +2794,7 @@ class AsyncRawTracesClient:
2387
2794
  end_time: typing.Optional[dt.datetime] = OMIT,
2388
2795
  input: typing.Optional[JsonListString] = OMIT,
2389
2796
  output: typing.Optional[JsonListString] = OMIT,
2390
- metadata: typing.Optional[JsonNode] = OMIT,
2797
+ metadata: typing.Optional[JsonListString] = OMIT,
2391
2798
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
2392
2799
  error_info: typing.Optional[ErrorInfo] = OMIT,
2393
2800
  thread_id: typing.Optional[str] = OMIT,
@@ -2414,7 +2821,7 @@ class AsyncRawTracesClient:
2414
2821
 
2415
2822
  output : typing.Optional[JsonListString]
2416
2823
 
2417
- metadata : typing.Optional[JsonNode]
2824
+ metadata : typing.Optional[JsonListString]
2418
2825
 
2419
2826
  tags : typing.Optional[typing.Sequence[str]]
2420
2827
 
@@ -2443,7 +2850,9 @@ class AsyncRawTracesClient:
2443
2850
  "output": convert_and_respect_annotation_metadata(
2444
2851
  object_=output, annotation=JsonListString, direction="write"
2445
2852
  ),
2446
- "metadata": metadata,
2853
+ "metadata": convert_and_respect_annotation_metadata(
2854
+ object_=metadata, annotation=JsonListString, direction="write"
2855
+ ),
2447
2856
  "tags": tags,
2448
2857
  "error_info": convert_and_respect_annotation_metadata(
2449
2858
  object_=error_info, annotation=ErrorInfo, direction="write"
@@ -2766,14 +3175,14 @@ class AsyncRawTracesClient:
2766
3175
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2767
3176
 
2768
3177
  async def find_trace_threads_feedback_score_names(
2769
- self, *, project_id: str, request_options: typing.Optional[RequestOptions] = None
3178
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
2770
3179
  ) -> AsyncHttpResponse[typing.List[str]]:
2771
3180
  """
2772
3181
  Find Trace Threads Feedback Score names
2773
3182
 
2774
3183
  Parameters
2775
3184
  ----------
2776
- project_id : str
3185
+ project_id : typing.Optional[str]
2777
3186
 
2778
3187
  request_options : typing.Optional[RequestOptions]
2779
3188
  Request-specific configuration.
@@ -2812,6 +3221,8 @@ class AsyncRawTracesClient:
2812
3221
  project_id: typing.Optional[str] = None,
2813
3222
  project_name: typing.Optional[str] = None,
2814
3223
  filters: typing.Optional[str] = None,
3224
+ from_time: typing.Optional[dt.datetime] = None,
3225
+ to_time: typing.Optional[dt.datetime] = None,
2815
3226
  request_options: typing.Optional[RequestOptions] = None,
2816
3227
  ) -> AsyncHttpResponse[ProjectStatsPublic]:
2817
3228
  """
@@ -2825,6 +3236,10 @@ class AsyncRawTracesClient:
2825
3236
 
2826
3237
  filters : typing.Optional[str]
2827
3238
 
3239
+ from_time : typing.Optional[dt.datetime]
3240
+
3241
+ to_time : typing.Optional[dt.datetime]
3242
+
2828
3243
  request_options : typing.Optional[RequestOptions]
2829
3244
  Request-specific configuration.
2830
3245
 
@@ -2840,6 +3255,8 @@ class AsyncRawTracesClient:
2840
3255
  "project_id": project_id,
2841
3256
  "project_name": project_name,
2842
3257
  "filters": filters,
3258
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
3259
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
2843
3260
  },
2844
3261
  request_options=request_options,
2845
3262
  )
@@ -2909,6 +3326,66 @@ class AsyncRawTracesClient:
2909
3326
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2910
3327
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2911
3328
 
3329
+ async def get_trace_thread_stats(
3330
+ self,
3331
+ *,
3332
+ project_id: typing.Optional[str] = None,
3333
+ project_name: typing.Optional[str] = None,
3334
+ filters: typing.Optional[str] = None,
3335
+ from_time: typing.Optional[dt.datetime] = None,
3336
+ to_time: typing.Optional[dt.datetime] = None,
3337
+ request_options: typing.Optional[RequestOptions] = None,
3338
+ ) -> AsyncHttpResponse[ProjectStatsPublic]:
3339
+ """
3340
+ Get trace thread stats
3341
+
3342
+ Parameters
3343
+ ----------
3344
+ project_id : typing.Optional[str]
3345
+
3346
+ project_name : typing.Optional[str]
3347
+
3348
+ filters : typing.Optional[str]
3349
+
3350
+ from_time : typing.Optional[dt.datetime]
3351
+
3352
+ to_time : typing.Optional[dt.datetime]
3353
+
3354
+ request_options : typing.Optional[RequestOptions]
3355
+ Request-specific configuration.
3356
+
3357
+ Returns
3358
+ -------
3359
+ AsyncHttpResponse[ProjectStatsPublic]
3360
+ Trace thread stats resource
3361
+ """
3362
+ _response = await self._client_wrapper.httpx_client.request(
3363
+ "v1/private/traces/threads/stats",
3364
+ method="GET",
3365
+ params={
3366
+ "project_id": project_id,
3367
+ "project_name": project_name,
3368
+ "filters": filters,
3369
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
3370
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
3371
+ },
3372
+ request_options=request_options,
3373
+ )
3374
+ try:
3375
+ if 200 <= _response.status_code < 300:
3376
+ _data = typing.cast(
3377
+ ProjectStatsPublic,
3378
+ parse_obj_as(
3379
+ type_=ProjectStatsPublic, # type: ignore
3380
+ object_=_response.json(),
3381
+ ),
3382
+ )
3383
+ return AsyncHttpResponse(response=_response, data=_data)
3384
+ _response_json = _response.json()
3385
+ except JSONDecodeError:
3386
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3387
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3388
+
2912
3389
  async def get_trace_comment(
2913
3390
  self, comment_id: str, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
2914
3391
  ) -> AsyncHttpResponse[Comment]:
@@ -2966,6 +3443,7 @@ class AsyncRawTracesClient:
2966
3443
  thread_id: str,
2967
3444
  project_name: typing.Optional[str] = OMIT,
2968
3445
  project_id: typing.Optional[str] = OMIT,
3446
+ truncate: typing.Optional[bool] = OMIT,
2969
3447
  request_options: typing.Optional[RequestOptions] = None,
2970
3448
  ) -> AsyncHttpResponse[TraceThread]:
2971
3449
  """
@@ -2979,6 +3457,8 @@ class AsyncRawTracesClient:
2979
3457
 
2980
3458
  project_id : typing.Optional[str]
2981
3459
 
3460
+ truncate : typing.Optional[bool]
3461
+
2982
3462
  request_options : typing.Optional[RequestOptions]
2983
3463
  Request-specific configuration.
2984
3464
 
@@ -2994,6 +3474,7 @@ class AsyncRawTracesClient:
2994
3474
  "project_name": project_name,
2995
3475
  "project_id": project_id,
2996
3476
  "thread_id": thread_id,
3477
+ "truncate": truncate,
2997
3478
  },
2998
3479
  headers={
2999
3480
  "content-type": "application/json",
@@ -3035,8 +3516,11 @@ class AsyncRawTracesClient:
3035
3516
  project_name: typing.Optional[str] = None,
3036
3517
  project_id: typing.Optional[str] = None,
3037
3518
  truncate: typing.Optional[bool] = None,
3519
+ strip_attachments: typing.Optional[bool] = None,
3038
3520
  filters: typing.Optional[str] = None,
3039
3521
  sorting: typing.Optional[str] = None,
3522
+ from_time: typing.Optional[dt.datetime] = None,
3523
+ to_time: typing.Optional[dt.datetime] = None,
3040
3524
  request_options: typing.Optional[RequestOptions] = None,
3041
3525
  ) -> AsyncHttpResponse[TraceThreadPage]:
3042
3526
  """
@@ -3054,10 +3538,16 @@ class AsyncRawTracesClient:
3054
3538
 
3055
3539
  truncate : typing.Optional[bool]
3056
3540
 
3541
+ strip_attachments : typing.Optional[bool]
3542
+
3057
3543
  filters : typing.Optional[str]
3058
3544
 
3059
3545
  sorting : typing.Optional[str]
3060
3546
 
3547
+ from_time : typing.Optional[dt.datetime]
3548
+
3549
+ to_time : typing.Optional[dt.datetime]
3550
+
3061
3551
  request_options : typing.Optional[RequestOptions]
3062
3552
  Request-specific configuration.
3063
3553
 
@@ -3075,8 +3565,11 @@ class AsyncRawTracesClient:
3075
3565
  "project_name": project_name,
3076
3566
  "project_id": project_id,
3077
3567
  "truncate": truncate,
3568
+ "strip_attachments": strip_attachments,
3078
3569
  "filters": filters,
3079
3570
  "sorting": sorting,
3571
+ "from_time": serialize_datetime(from_time) if from_time is not None else None,
3572
+ "to_time": serialize_datetime(to_time) if to_time is not None else None,
3080
3573
  },
3081
3574
  request_options=request_options,
3082
3575
  )
@@ -3101,6 +3594,7 @@ class AsyncRawTracesClient:
3101
3594
  thread_id: str,
3102
3595
  project_name: typing.Optional[str] = OMIT,
3103
3596
  project_id: typing.Optional[str] = OMIT,
3597
+ truncate: typing.Optional[bool] = OMIT,
3104
3598
  request_options: typing.Optional[RequestOptions] = None,
3105
3599
  ) -> AsyncHttpResponse[None]:
3106
3600
  """
@@ -3114,6 +3608,8 @@ class AsyncRawTracesClient:
3114
3608
 
3115
3609
  project_id : typing.Optional[str]
3116
3610
 
3611
+ truncate : typing.Optional[bool]
3612
+
3117
3613
  request_options : typing.Optional[RequestOptions]
3118
3614
  Request-specific configuration.
3119
3615
 
@@ -3128,6 +3624,7 @@ class AsyncRawTracesClient:
3128
3624
  "project_name": project_name,
3129
3625
  "project_id": project_id,
3130
3626
  "thread_id": thread_id,
3627
+ "truncate": truncate,
3131
3628
  },
3132
3629
  headers={
3133
3630
  "content-type": "application/json",
@@ -3237,6 +3734,9 @@ class AsyncRawTracesClient:
3237
3734
  last_retrieved_thread_model_id: typing.Optional[str] = OMIT,
3238
3735
  limit: typing.Optional[int] = OMIT,
3239
3736
  truncate: typing.Optional[bool] = OMIT,
3737
+ strip_attachments: typing.Optional[bool] = OMIT,
3738
+ from_time: typing.Optional[dt.datetime] = OMIT,
3739
+ to_time: typing.Optional[dt.datetime] = OMIT,
3240
3740
  request_options: typing.Optional[RequestOptions] = None,
3241
3741
  ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
3242
3742
  """
@@ -3256,7 +3756,16 @@ class AsyncRawTracesClient:
3256
3756
  Max number of trace thread to be streamed
3257
3757
 
3258
3758
  truncate : typing.Optional[bool]
3259
- Truncate image included in either input, output or metadata
3759
+ Truncate input, output and metadata to slim payloads
3760
+
3761
+ strip_attachments : typing.Optional[bool]
3762
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
3763
+
3764
+ from_time : typing.Optional[dt.datetime]
3765
+ Filter trace threads created from this time (ISO-8601 format).
3766
+
3767
+ to_time : typing.Optional[dt.datetime]
3768
+ Filter trace threads created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
3260
3769
 
3261
3770
  request_options : typing.Optional[RequestOptions]
3262
3771
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -3278,6 +3787,9 @@ class AsyncRawTracesClient:
3278
3787
  "last_retrieved_thread_model_id": last_retrieved_thread_model_id,
3279
3788
  "limit": limit,
3280
3789
  "truncate": truncate,
3790
+ "strip_attachments": strip_attachments,
3791
+ "from_time": from_time,
3792
+ "to_time": to_time,
3281
3793
  },
3282
3794
  headers={
3283
3795
  "content-type": "application/json",
@@ -3325,6 +3837,9 @@ class AsyncRawTracesClient:
3325
3837
  last_retrieved_id: typing.Optional[str] = OMIT,
3326
3838
  limit: typing.Optional[int] = OMIT,
3327
3839
  truncate: typing.Optional[bool] = OMIT,
3840
+ strip_attachments: typing.Optional[bool] = OMIT,
3841
+ from_time: typing.Optional[dt.datetime] = OMIT,
3842
+ to_time: typing.Optional[dt.datetime] = OMIT,
3328
3843
  request_options: typing.Optional[RequestOptions] = None,
3329
3844
  ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
3330
3845
  """
@@ -3344,7 +3859,16 @@ class AsyncRawTracesClient:
3344
3859
  Max number of traces to be streamed
3345
3860
 
3346
3861
  truncate : typing.Optional[bool]
3347
- Truncate image included in either input, output or metadata
3862
+ Truncate input, output and metadata to slim payloads
3863
+
3864
+ strip_attachments : typing.Optional[bool]
3865
+ If true, returns attachment references like [file.png]; if false, downloads and reinjects stripped attachments
3866
+
3867
+ from_time : typing.Optional[dt.datetime]
3868
+ Filter traces created from this time (ISO-8601 format).
3869
+
3870
+ to_time : typing.Optional[dt.datetime]
3871
+ Filter traces created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
3348
3872
 
3349
3873
  request_options : typing.Optional[RequestOptions]
3350
3874
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -3366,6 +3890,9 @@ class AsyncRawTracesClient:
3366
3890
  "last_retrieved_id": last_retrieved_id,
3367
3891
  "limit": limit,
3368
3892
  "truncate": truncate,
3893
+ "strip_attachments": strip_attachments,
3894
+ "from_time": from_time,
3895
+ "to_time": to_time,
3369
3896
  },
3370
3897
  headers={
3371
3898
  "content-type": "application/json",
@@ -3418,12 +3945,7 @@ class AsyncRawTracesClient:
3418
3945
  self,
3419
3946
  thread_model_id: str,
3420
3947
  *,
3421
- text: str,
3422
- id: typing.Optional[str] = OMIT,
3423
- created_at: typing.Optional[dt.datetime] = OMIT,
3424
- last_updated_at: typing.Optional[dt.datetime] = OMIT,
3425
- created_by: typing.Optional[str] = OMIT,
3426
- last_updated_by: typing.Optional[str] = OMIT,
3948
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
3427
3949
  request_options: typing.Optional[RequestOptions] = None,
3428
3950
  ) -> AsyncHttpResponse[None]:
3429
3951
  """
@@ -3433,17 +3955,7 @@ class AsyncRawTracesClient:
3433
3955
  ----------
3434
3956
  thread_model_id : str
3435
3957
 
3436
- text : str
3437
-
3438
- id : typing.Optional[str]
3439
-
3440
- created_at : typing.Optional[dt.datetime]
3441
-
3442
- last_updated_at : typing.Optional[dt.datetime]
3443
-
3444
- created_by : typing.Optional[str]
3445
-
3446
- last_updated_by : typing.Optional[str]
3958
+ tags : typing.Optional[typing.Sequence[str]]
3447
3959
 
3448
3960
  request_options : typing.Optional[RequestOptions]
3449
3961
  Request-specific configuration.
@@ -3456,12 +3968,7 @@ class AsyncRawTracesClient:
3456
3968
  f"v1/private/traces/threads/{jsonable_encoder(thread_model_id)}",
3457
3969
  method="PATCH",
3458
3970
  json={
3459
- "id": id,
3460
- "text": text,
3461
- "created_at": created_at,
3462
- "last_updated_at": last_updated_at,
3463
- "created_by": created_by,
3464
- "last_updated_by": last_updated_by,
3971
+ "tags": tags,
3465
3972
  },
3466
3973
  headers={
3467
3974
  "content-type": "application/json",