opik 1.6.4__py3-none-any.whl → 1.9.71__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1021) hide show
  1. opik/__init__.py +33 -2
  2. opik/anonymizer/__init__.py +5 -0
  3. opik/anonymizer/anonymizer.py +12 -0
  4. opik/anonymizer/factory.py +80 -0
  5. opik/anonymizer/recursive_anonymizer.py +64 -0
  6. opik/anonymizer/rules.py +56 -0
  7. opik/anonymizer/rules_anonymizer.py +35 -0
  8. opik/api_objects/attachment/__init__.py +5 -0
  9. opik/api_objects/attachment/attachment.py +20 -0
  10. opik/api_objects/attachment/attachment_context.py +36 -0
  11. opik/api_objects/attachment/attachments_extractor.py +153 -0
  12. opik/api_objects/attachment/client.py +220 -0
  13. opik/api_objects/attachment/converters.py +51 -0
  14. opik/api_objects/attachment/decoder.py +18 -0
  15. opik/api_objects/attachment/decoder_base64.py +83 -0
  16. opik/api_objects/attachment/decoder_helpers.py +137 -0
  17. opik/api_objects/conversation/__init__.py +0 -0
  18. opik/api_objects/conversation/conversation_factory.py +43 -0
  19. opik/api_objects/conversation/conversation_thread.py +49 -0
  20. opik/api_objects/data_helpers.py +79 -0
  21. opik/api_objects/dataset/dataset.py +107 -45
  22. opik/api_objects/dataset/rest_operations.py +12 -3
  23. opik/api_objects/experiment/experiment.py +81 -45
  24. opik/api_objects/experiment/experiment_item.py +2 -1
  25. opik/api_objects/experiment/experiments_client.py +64 -0
  26. opik/api_objects/experiment/helpers.py +35 -11
  27. opik/api_objects/experiment/rest_operations.py +88 -19
  28. opik/api_objects/helpers.py +104 -7
  29. opik/api_objects/local_recording.py +81 -0
  30. opik/api_objects/opik_client.py +872 -174
  31. opik/api_objects/opik_query_language.py +136 -18
  32. opik/api_objects/optimization/__init__.py +3 -0
  33. opik/api_objects/optimization/optimization.py +39 -0
  34. opik/api_objects/prompt/__init__.py +13 -1
  35. opik/api_objects/prompt/base_prompt.py +69 -0
  36. opik/api_objects/prompt/base_prompt_template.py +29 -0
  37. opik/api_objects/prompt/chat/__init__.py +1 -0
  38. opik/api_objects/prompt/chat/chat_prompt.py +210 -0
  39. opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
  40. opik/api_objects/prompt/chat/content_renderer_registry.py +203 -0
  41. opik/api_objects/prompt/client.py +193 -41
  42. opik/api_objects/prompt/text/__init__.py +1 -0
  43. opik/api_objects/prompt/text/prompt.py +174 -0
  44. opik/api_objects/prompt/text/prompt_template.py +55 -0
  45. opik/api_objects/prompt/types.py +29 -0
  46. opik/api_objects/rest_stream_parser.py +98 -0
  47. opik/api_objects/search_helpers.py +89 -0
  48. opik/api_objects/span/span_client.py +165 -45
  49. opik/api_objects/span/span_data.py +136 -25
  50. opik/api_objects/threads/__init__.py +0 -0
  51. opik/api_objects/threads/threads_client.py +185 -0
  52. opik/api_objects/trace/trace_client.py +72 -36
  53. opik/api_objects/trace/trace_data.py +112 -26
  54. opik/api_objects/validation_helpers.py +3 -3
  55. opik/cli/__init__.py +5 -0
  56. opik/cli/__main__.py +6 -0
  57. opik/cli/configure.py +66 -0
  58. opik/cli/exports/__init__.py +131 -0
  59. opik/cli/exports/dataset.py +278 -0
  60. opik/cli/exports/experiment.py +784 -0
  61. opik/cli/exports/project.py +685 -0
  62. opik/cli/exports/prompt.py +578 -0
  63. opik/cli/exports/utils.py +406 -0
  64. opik/cli/harbor.py +39 -0
  65. opik/cli/healthcheck.py +21 -0
  66. opik/cli/imports/__init__.py +439 -0
  67. opik/cli/imports/dataset.py +143 -0
  68. opik/cli/imports/experiment.py +1192 -0
  69. opik/cli/imports/project.py +262 -0
  70. opik/cli/imports/prompt.py +177 -0
  71. opik/cli/imports/utils.py +280 -0
  72. opik/cli/main.py +49 -0
  73. opik/cli/proxy.py +93 -0
  74. opik/cli/usage_report/__init__.py +16 -0
  75. opik/cli/usage_report/charts.py +783 -0
  76. opik/cli/usage_report/cli.py +274 -0
  77. opik/cli/usage_report/constants.py +9 -0
  78. opik/cli/usage_report/extraction.py +749 -0
  79. opik/cli/usage_report/pdf.py +244 -0
  80. opik/cli/usage_report/statistics.py +78 -0
  81. opik/cli/usage_report/utils.py +235 -0
  82. opik/config.py +62 -4
  83. opik/configurator/configure.py +45 -6
  84. opik/configurator/opik_rest_helpers.py +4 -1
  85. opik/context_storage.py +164 -65
  86. opik/datetime_helpers.py +12 -0
  87. opik/decorator/arguments_helpers.py +9 -1
  88. opik/decorator/base_track_decorator.py +298 -146
  89. opik/decorator/context_manager/__init__.py +0 -0
  90. opik/decorator/context_manager/span_context_manager.py +123 -0
  91. opik/decorator/context_manager/trace_context_manager.py +84 -0
  92. opik/decorator/generator_wrappers.py +3 -2
  93. opik/decorator/inspect_helpers.py +11 -0
  94. opik/decorator/opik_args/__init__.py +13 -0
  95. opik/decorator/opik_args/api_classes.py +71 -0
  96. opik/decorator/opik_args/helpers.py +120 -0
  97. opik/decorator/span_creation_handler.py +49 -21
  98. opik/decorator/tracker.py +9 -1
  99. opik/dict_utils.py +3 -3
  100. opik/environment.py +13 -1
  101. opik/error_tracking/api.py +1 -1
  102. opik/error_tracking/before_send.py +6 -5
  103. opik/error_tracking/environment_details.py +29 -7
  104. opik/error_tracking/error_filtering/filter_by_response_status_code.py +42 -0
  105. opik/error_tracking/error_filtering/filter_chain_builder.py +14 -3
  106. opik/evaluation/__init__.py +14 -2
  107. opik/evaluation/engine/engine.py +280 -82
  108. opik/evaluation/engine/evaluation_tasks_executor.py +15 -10
  109. opik/evaluation/engine/helpers.py +34 -9
  110. opik/evaluation/engine/metrics_evaluator.py +237 -0
  111. opik/evaluation/engine/types.py +5 -4
  112. opik/evaluation/evaluation_result.py +169 -2
  113. opik/evaluation/evaluator.py +659 -58
  114. opik/evaluation/metrics/__init__.py +121 -6
  115. opik/evaluation/metrics/aggregated_metric.py +92 -0
  116. opik/evaluation/metrics/arguments_helpers.py +15 -21
  117. opik/evaluation/metrics/arguments_validator.py +38 -0
  118. opik/evaluation/metrics/base_metric.py +20 -10
  119. opik/evaluation/metrics/conversation/__init__.py +48 -0
  120. opik/evaluation/metrics/conversation/conversation_thread_metric.py +79 -0
  121. opik/evaluation/metrics/conversation/conversation_turns_factory.py +39 -0
  122. opik/evaluation/metrics/conversation/g_eval_wrappers.py +19 -0
  123. opik/evaluation/metrics/conversation/helpers.py +84 -0
  124. opik/evaluation/metrics/conversation/heuristics/__init__.py +14 -0
  125. opik/evaluation/metrics/conversation/heuristics/degeneration/__init__.py +3 -0
  126. opik/evaluation/metrics/conversation/heuristics/degeneration/metric.py +189 -0
  127. opik/evaluation/metrics/conversation/heuristics/degeneration/phrases.py +12 -0
  128. opik/evaluation/metrics/conversation/heuristics/knowledge_retention/__init__.py +3 -0
  129. opik/evaluation/metrics/conversation/heuristics/knowledge_retention/metric.py +172 -0
  130. opik/evaluation/metrics/conversation/llm_judges/__init__.py +32 -0
  131. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/__init__.py +0 -0
  132. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/metric.py +274 -0
  133. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/schema.py +16 -0
  134. opik/evaluation/metrics/conversation/llm_judges/conversational_coherence/templates.py +95 -0
  135. opik/evaluation/metrics/conversation/llm_judges/g_eval_wrappers.py +442 -0
  136. opik/evaluation/metrics/conversation/llm_judges/session_completeness/__init__.py +0 -0
  137. opik/evaluation/metrics/conversation/llm_judges/session_completeness/metric.py +295 -0
  138. opik/evaluation/metrics/conversation/llm_judges/session_completeness/schema.py +22 -0
  139. opik/evaluation/metrics/conversation/llm_judges/session_completeness/templates.py +139 -0
  140. opik/evaluation/metrics/conversation/llm_judges/user_frustration/__init__.py +0 -0
  141. opik/evaluation/metrics/conversation/llm_judges/user_frustration/metric.py +277 -0
  142. opik/evaluation/metrics/conversation/llm_judges/user_frustration/schema.py +16 -0
  143. opik/evaluation/metrics/conversation/llm_judges/user_frustration/templates.py +135 -0
  144. opik/evaluation/metrics/conversation/types.py +34 -0
  145. opik/evaluation/metrics/conversation_types.py +9 -0
  146. opik/evaluation/metrics/heuristics/bertscore.py +107 -0
  147. opik/evaluation/metrics/heuristics/bleu.py +43 -16
  148. opik/evaluation/metrics/heuristics/chrf.py +127 -0
  149. opik/evaluation/metrics/heuristics/contains.py +50 -11
  150. opik/evaluation/metrics/heuristics/distribution_metrics.py +331 -0
  151. opik/evaluation/metrics/heuristics/equals.py +4 -1
  152. opik/evaluation/metrics/heuristics/gleu.py +113 -0
  153. opik/evaluation/metrics/heuristics/is_json.py +9 -3
  154. opik/evaluation/metrics/heuristics/language_adherence.py +123 -0
  155. opik/evaluation/metrics/heuristics/levenshtein_ratio.py +6 -5
  156. opik/evaluation/metrics/heuristics/meteor.py +119 -0
  157. opik/evaluation/metrics/heuristics/prompt_injection.py +150 -0
  158. opik/evaluation/metrics/heuristics/readability.py +129 -0
  159. opik/evaluation/metrics/heuristics/regex_match.py +4 -1
  160. opik/evaluation/metrics/heuristics/rouge.py +148 -0
  161. opik/evaluation/metrics/heuristics/sentiment.py +98 -0
  162. opik/evaluation/metrics/heuristics/spearman.py +88 -0
  163. opik/evaluation/metrics/heuristics/tone.py +155 -0
  164. opik/evaluation/metrics/heuristics/vader_sentiment.py +77 -0
  165. opik/evaluation/metrics/llm_judges/answer_relevance/metric.py +27 -30
  166. opik/evaluation/metrics/llm_judges/answer_relevance/parser.py +27 -0
  167. opik/evaluation/metrics/llm_judges/answer_relevance/templates.py +10 -10
  168. opik/evaluation/metrics/llm_judges/context_precision/metric.py +28 -31
  169. opik/evaluation/metrics/llm_judges/context_precision/parser.py +27 -0
  170. opik/evaluation/metrics/llm_judges/context_precision/template.py +7 -7
  171. opik/evaluation/metrics/llm_judges/context_recall/metric.py +27 -31
  172. opik/evaluation/metrics/llm_judges/context_recall/parser.py +27 -0
  173. opik/evaluation/metrics/llm_judges/context_recall/template.py +7 -7
  174. opik/evaluation/metrics/llm_judges/factuality/metric.py +7 -26
  175. opik/evaluation/metrics/llm_judges/factuality/parser.py +35 -0
  176. opik/evaluation/metrics/llm_judges/factuality/template.py +1 -1
  177. opik/evaluation/metrics/llm_judges/g_eval/__init__.py +5 -0
  178. opik/evaluation/metrics/llm_judges/g_eval/metric.py +244 -113
  179. opik/evaluation/metrics/llm_judges/g_eval/parser.py +161 -0
  180. opik/evaluation/metrics/llm_judges/g_eval/presets.py +209 -0
  181. opik/evaluation/metrics/llm_judges/g_eval_presets/__init__.py +36 -0
  182. opik/evaluation/metrics/llm_judges/g_eval_presets/agent_assessment.py +77 -0
  183. opik/evaluation/metrics/llm_judges/g_eval_presets/bias_classifier.py +181 -0
  184. opik/evaluation/metrics/llm_judges/g_eval_presets/compliance_risk.py +41 -0
  185. opik/evaluation/metrics/llm_judges/g_eval_presets/prompt_uncertainty.py +41 -0
  186. opik/evaluation/metrics/llm_judges/g_eval_presets/qa_suite.py +146 -0
  187. opik/evaluation/metrics/llm_judges/hallucination/metric.py +23 -27
  188. opik/evaluation/metrics/llm_judges/hallucination/parser.py +29 -0
  189. opik/evaluation/metrics/llm_judges/hallucination/template.py +2 -4
  190. opik/evaluation/metrics/llm_judges/llm_juries/__init__.py +3 -0
  191. opik/evaluation/metrics/llm_judges/llm_juries/metric.py +76 -0
  192. opik/evaluation/metrics/llm_judges/moderation/metric.py +23 -28
  193. opik/evaluation/metrics/llm_judges/moderation/parser.py +27 -0
  194. opik/evaluation/metrics/llm_judges/moderation/template.py +2 -2
  195. opik/evaluation/metrics/llm_judges/parsing_helpers.py +26 -0
  196. opik/evaluation/metrics/llm_judges/structure_output_compliance/__init__.py +0 -0
  197. opik/evaluation/metrics/llm_judges/structure_output_compliance/metric.py +144 -0
  198. opik/evaluation/metrics/llm_judges/structure_output_compliance/parser.py +79 -0
  199. opik/evaluation/metrics/llm_judges/structure_output_compliance/schema.py +15 -0
  200. opik/evaluation/metrics/llm_judges/structure_output_compliance/template.py +50 -0
  201. opik/evaluation/metrics/llm_judges/syc_eval/__init__.py +0 -0
  202. opik/evaluation/metrics/llm_judges/syc_eval/metric.py +252 -0
  203. opik/evaluation/metrics/llm_judges/syc_eval/parser.py +82 -0
  204. opik/evaluation/metrics/llm_judges/syc_eval/template.py +155 -0
  205. opik/evaluation/metrics/llm_judges/trajectory_accuracy/__init__.py +3 -0
  206. opik/evaluation/metrics/llm_judges/trajectory_accuracy/metric.py +171 -0
  207. opik/evaluation/metrics/llm_judges/trajectory_accuracy/parser.py +38 -0
  208. opik/evaluation/metrics/llm_judges/trajectory_accuracy/templates.py +65 -0
  209. opik/evaluation/metrics/llm_judges/usefulness/metric.py +23 -32
  210. opik/evaluation/metrics/llm_judges/usefulness/parser.py +28 -0
  211. opik/evaluation/metrics/ragas_metric.py +112 -0
  212. opik/evaluation/models/__init__.py +10 -0
  213. opik/evaluation/models/base_model.py +140 -18
  214. opik/evaluation/models/langchain/__init__.py +3 -0
  215. opik/evaluation/models/langchain/langchain_chat_model.py +166 -0
  216. opik/evaluation/models/langchain/message_converters.py +106 -0
  217. opik/evaluation/models/langchain/opik_monitoring.py +23 -0
  218. opik/evaluation/models/litellm/litellm_chat_model.py +186 -40
  219. opik/evaluation/models/litellm/opik_monitor.py +24 -21
  220. opik/evaluation/models/litellm/util.py +125 -0
  221. opik/evaluation/models/litellm/warning_filters.py +16 -4
  222. opik/evaluation/models/model_capabilities.py +187 -0
  223. opik/evaluation/models/models_factory.py +25 -3
  224. opik/evaluation/preprocessing.py +92 -0
  225. opik/evaluation/report.py +70 -12
  226. opik/evaluation/rest_operations.py +49 -45
  227. opik/evaluation/samplers/__init__.py +4 -0
  228. opik/evaluation/samplers/base_dataset_sampler.py +40 -0
  229. opik/evaluation/samplers/random_dataset_sampler.py +48 -0
  230. opik/evaluation/score_statistics.py +66 -0
  231. opik/evaluation/scorers/__init__.py +4 -0
  232. opik/evaluation/scorers/scorer_function.py +55 -0
  233. opik/evaluation/scorers/scorer_wrapper_metric.py +130 -0
  234. opik/evaluation/test_case.py +3 -2
  235. opik/evaluation/test_result.py +1 -0
  236. opik/evaluation/threads/__init__.py +0 -0
  237. opik/evaluation/threads/context_helper.py +32 -0
  238. opik/evaluation/threads/evaluation_engine.py +181 -0
  239. opik/evaluation/threads/evaluation_result.py +18 -0
  240. opik/evaluation/threads/evaluator.py +120 -0
  241. opik/evaluation/threads/helpers.py +51 -0
  242. opik/evaluation/types.py +9 -1
  243. opik/exceptions.py +116 -3
  244. opik/file_upload/__init__.py +0 -0
  245. opik/file_upload/base_upload_manager.py +39 -0
  246. opik/file_upload/file_upload_monitor.py +14 -0
  247. opik/file_upload/file_uploader.py +141 -0
  248. opik/file_upload/mime_type.py +9 -0
  249. opik/file_upload/s3_multipart_upload/__init__.py +0 -0
  250. opik/file_upload/s3_multipart_upload/file_parts_strategy.py +89 -0
  251. opik/file_upload/s3_multipart_upload/s3_file_uploader.py +86 -0
  252. opik/file_upload/s3_multipart_upload/s3_upload_error.py +29 -0
  253. opik/file_upload/thread_pool.py +17 -0
  254. opik/file_upload/upload_client.py +114 -0
  255. opik/file_upload/upload_manager.py +255 -0
  256. opik/file_upload/upload_options.py +37 -0
  257. opik/format_helpers.py +17 -0
  258. opik/guardrails/__init__.py +4 -0
  259. opik/guardrails/guardrail.py +157 -0
  260. opik/guardrails/guards/__init__.py +5 -0
  261. opik/guardrails/guards/guard.py +17 -0
  262. opik/guardrails/guards/pii.py +47 -0
  263. opik/guardrails/guards/topic.py +76 -0
  264. opik/guardrails/rest_api_client.py +34 -0
  265. opik/guardrails/schemas.py +24 -0
  266. opik/guardrails/tracing.py +61 -0
  267. opik/healthcheck/__init__.py +2 -1
  268. opik/healthcheck/checks.py +2 -2
  269. opik/healthcheck/rich_representation.py +1 -1
  270. opik/hooks/__init__.py +23 -0
  271. opik/hooks/anonymizer_hook.py +36 -0
  272. opik/hooks/httpx_client_hook.py +112 -0
  273. opik/httpx_client.py +75 -4
  274. opik/id_helpers.py +18 -0
  275. opik/integrations/adk/__init__.py +14 -0
  276. opik/integrations/adk/callback_context_info_extractors.py +32 -0
  277. opik/integrations/adk/graph/__init__.py +0 -0
  278. opik/integrations/adk/graph/mermaid_graph_builder.py +128 -0
  279. opik/integrations/adk/graph/nodes.py +101 -0
  280. opik/integrations/adk/graph/subgraph_edges_builders.py +41 -0
  281. opik/integrations/adk/helpers.py +48 -0
  282. opik/integrations/adk/legacy_opik_tracer.py +381 -0
  283. opik/integrations/adk/opik_tracer.py +370 -0
  284. opik/integrations/adk/patchers/__init__.py +4 -0
  285. opik/integrations/adk/patchers/adk_otel_tracer/__init__.py +0 -0
  286. opik/integrations/adk/patchers/adk_otel_tracer/llm_span_helpers.py +30 -0
  287. opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +201 -0
  288. opik/integrations/adk/patchers/litellm_wrappers.py +91 -0
  289. opik/integrations/adk/patchers/llm_response_wrapper.py +105 -0
  290. opik/integrations/adk/patchers/patchers.py +64 -0
  291. opik/integrations/adk/recursive_callback_injector.py +126 -0
  292. opik/integrations/aisuite/aisuite_decorator.py +8 -3
  293. opik/integrations/aisuite/opik_tracker.py +1 -0
  294. opik/integrations/anthropic/messages_create_decorator.py +8 -3
  295. opik/integrations/anthropic/opik_tracker.py +0 -1
  296. opik/integrations/bedrock/converse/__init__.py +0 -0
  297. opik/integrations/bedrock/converse/chunks_aggregator.py +188 -0
  298. opik/integrations/bedrock/{converse_decorator.py → converse/converse_decorator.py} +18 -8
  299. opik/integrations/bedrock/invoke_agent_decorator.py +12 -7
  300. opik/integrations/bedrock/invoke_model/__init__.py +0 -0
  301. opik/integrations/bedrock/invoke_model/chunks_aggregator/__init__.py +78 -0
  302. opik/integrations/bedrock/invoke_model/chunks_aggregator/api.py +45 -0
  303. opik/integrations/bedrock/invoke_model/chunks_aggregator/base.py +23 -0
  304. opik/integrations/bedrock/invoke_model/chunks_aggregator/claude.py +121 -0
  305. opik/integrations/bedrock/invoke_model/chunks_aggregator/format_detector.py +107 -0
  306. opik/integrations/bedrock/invoke_model/chunks_aggregator/llama.py +108 -0
  307. opik/integrations/bedrock/invoke_model/chunks_aggregator/mistral.py +118 -0
  308. opik/integrations/bedrock/invoke_model/chunks_aggregator/nova.py +99 -0
  309. opik/integrations/bedrock/invoke_model/invoke_model_decorator.py +178 -0
  310. opik/integrations/bedrock/invoke_model/response_types.py +34 -0
  311. opik/integrations/bedrock/invoke_model/stream_wrappers.py +122 -0
  312. opik/integrations/bedrock/invoke_model/usage_converters.py +87 -0
  313. opik/integrations/bedrock/invoke_model/usage_extraction.py +108 -0
  314. opik/integrations/bedrock/opik_tracker.py +43 -4
  315. opik/integrations/bedrock/types.py +19 -0
  316. opik/integrations/crewai/crewai_decorator.py +34 -56
  317. opik/integrations/crewai/opik_tracker.py +31 -10
  318. opik/integrations/crewai/patchers/__init__.py +5 -0
  319. opik/integrations/crewai/patchers/flow.py +118 -0
  320. opik/integrations/crewai/patchers/litellm_completion.py +30 -0
  321. opik/integrations/crewai/patchers/llm_client.py +207 -0
  322. opik/integrations/dspy/callback.py +246 -84
  323. opik/integrations/dspy/graph.py +88 -0
  324. opik/integrations/dspy/parsers.py +168 -0
  325. opik/integrations/genai/encoder_extension.py +2 -6
  326. opik/integrations/genai/generate_content_decorator.py +20 -13
  327. opik/integrations/guardrails/guardrails_decorator.py +4 -0
  328. opik/integrations/harbor/__init__.py +17 -0
  329. opik/integrations/harbor/experiment_service.py +269 -0
  330. opik/integrations/harbor/opik_tracker.py +528 -0
  331. opik/integrations/haystack/constants.py +35 -0
  332. opik/integrations/haystack/converters.py +1 -2
  333. opik/integrations/haystack/opik_connector.py +28 -6
  334. opik/integrations/haystack/opik_span_bridge.py +284 -0
  335. opik/integrations/haystack/opik_tracer.py +124 -222
  336. opik/integrations/langchain/__init__.py +3 -1
  337. opik/integrations/langchain/helpers.py +96 -0
  338. opik/integrations/langchain/langgraph_async_context_bridge.py +131 -0
  339. opik/integrations/langchain/langgraph_tracer_injector.py +88 -0
  340. opik/integrations/langchain/opik_encoder_extension.py +2 -2
  341. opik/integrations/langchain/opik_tracer.py +641 -206
  342. opik/integrations/langchain/provider_usage_extractors/__init__.py +5 -0
  343. opik/integrations/langchain/provider_usage_extractors/anthropic_usage_extractor.py +101 -0
  344. opik/integrations/langchain/provider_usage_extractors/anthropic_vertexai_usage_extractor.py +67 -0
  345. opik/integrations/langchain/provider_usage_extractors/bedrock_usage_extractor.py +94 -0
  346. opik/integrations/langchain/provider_usage_extractors/google_generative_ai_usage_extractor.py +109 -0
  347. opik/integrations/langchain/provider_usage_extractors/groq_usage_extractor.py +92 -0
  348. opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/__init__.py +15 -0
  349. opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/helpers.py +134 -0
  350. opik/integrations/langchain/provider_usage_extractors/langchain_run_helpers/langchain_usage.py +163 -0
  351. opik/integrations/langchain/provider_usage_extractors/openai_usage_extractor.py +124 -0
  352. opik/integrations/langchain/provider_usage_extractors/provider_usage_extractor_protocol.py +29 -0
  353. opik/integrations/langchain/provider_usage_extractors/usage_extractor.py +48 -0
  354. opik/integrations/langchain/provider_usage_extractors/vertexai_usage_extractor.py +109 -0
  355. opik/integrations/litellm/__init__.py +5 -0
  356. opik/integrations/litellm/completion_chunks_aggregator.py +115 -0
  357. opik/integrations/litellm/litellm_completion_decorator.py +242 -0
  358. opik/integrations/litellm/opik_tracker.py +43 -0
  359. opik/integrations/litellm/stream_patchers.py +151 -0
  360. opik/integrations/llama_index/callback.py +179 -78
  361. opik/integrations/llama_index/event_parsing_utils.py +29 -9
  362. opik/integrations/openai/agents/opik_tracing_processor.py +204 -32
  363. opik/integrations/openai/agents/span_data_parsers.py +15 -6
  364. opik/integrations/openai/chat_completion_chunks_aggregator.py +1 -1
  365. opik/integrations/openai/{openai_decorator.py → openai_chat_completions_decorator.py} +45 -35
  366. opik/integrations/openai/openai_responses_decorator.py +158 -0
  367. opik/integrations/openai/opik_tracker.py +94 -13
  368. opik/integrations/openai/response_events_aggregator.py +36 -0
  369. opik/integrations/openai/stream_patchers.py +125 -15
  370. opik/integrations/sagemaker/auth.py +5 -1
  371. opik/jsonable_encoder.py +29 -1
  372. opik/llm_usage/base_original_provider_usage.py +15 -8
  373. opik/llm_usage/bedrock_usage.py +8 -2
  374. opik/llm_usage/google_usage.py +6 -1
  375. opik/llm_usage/llm_usage_info.py +6 -0
  376. opik/llm_usage/{openai_usage.py → openai_chat_completions_usage.py} +2 -12
  377. opik/llm_usage/{openai_agent_usage.py → openai_responses_usage.py} +7 -15
  378. opik/llm_usage/opik_usage.py +36 -10
  379. opik/llm_usage/opik_usage_factory.py +35 -19
  380. opik/logging_messages.py +19 -7
  381. opik/message_processing/arguments_utils.py +22 -0
  382. opik/message_processing/batching/base_batcher.py +45 -17
  383. opik/message_processing/batching/batch_manager.py +22 -10
  384. opik/message_processing/batching/batch_manager_constuctors.py +36 -11
  385. opik/message_processing/batching/batchers.py +167 -44
  386. opik/message_processing/batching/flushing_thread.py +0 -3
  387. opik/message_processing/batching/sequence_splitter.py +50 -5
  388. opik/message_processing/emulation/__init__.py +0 -0
  389. opik/message_processing/emulation/emulator_message_processor.py +578 -0
  390. opik/message_processing/emulation/local_emulator_message_processor.py +140 -0
  391. opik/message_processing/emulation/models.py +162 -0
  392. opik/message_processing/encoder_helpers.py +79 -0
  393. opik/message_processing/message_queue.py +79 -0
  394. opik/message_processing/messages.py +154 -12
  395. opik/message_processing/preprocessing/__init__.py +0 -0
  396. opik/message_processing/preprocessing/attachments_preprocessor.py +70 -0
  397. opik/message_processing/preprocessing/batching_preprocessor.py +53 -0
  398. opik/message_processing/preprocessing/constants.py +1 -0
  399. opik/message_processing/preprocessing/file_upload_preprocessor.py +38 -0
  400. opik/message_processing/preprocessing/preprocessor.py +36 -0
  401. opik/message_processing/processors/__init__.py +0 -0
  402. opik/message_processing/processors/attachments_extraction_processor.py +146 -0
  403. opik/message_processing/processors/message_processors.py +92 -0
  404. opik/message_processing/processors/message_processors_chain.py +96 -0
  405. opik/message_processing/processors/online_message_processor.py +324 -0
  406. opik/message_processing/queue_consumer.py +61 -13
  407. opik/message_processing/streamer.py +102 -31
  408. opik/message_processing/streamer_constructors.py +67 -12
  409. opik/opik_context.py +103 -11
  410. opik/plugins/pytest/decorator.py +2 -2
  411. opik/plugins/pytest/experiment_runner.py +3 -2
  412. opik/plugins/pytest/hooks.py +6 -4
  413. opik/rate_limit/__init__.py +0 -0
  414. opik/rate_limit/rate_limit.py +25 -0
  415. opik/rest_api/__init__.py +643 -11
  416. opik/rest_api/alerts/__init__.py +7 -0
  417. opik/rest_api/alerts/client.py +667 -0
  418. opik/rest_api/alerts/raw_client.py +1015 -0
  419. opik/rest_api/alerts/types/__init__.py +7 -0
  420. opik/rest_api/alerts/types/get_webhook_examples_request_alert_type.py +5 -0
  421. opik/rest_api/annotation_queues/__init__.py +4 -0
  422. opik/rest_api/annotation_queues/client.py +668 -0
  423. opik/rest_api/annotation_queues/raw_client.py +1019 -0
  424. opik/rest_api/attachments/__init__.py +17 -0
  425. opik/rest_api/attachments/client.py +752 -0
  426. opik/rest_api/attachments/raw_client.py +1125 -0
  427. opik/rest_api/attachments/types/__init__.py +15 -0
  428. opik/rest_api/attachments/types/attachment_list_request_entity_type.py +5 -0
  429. opik/rest_api/attachments/types/download_attachment_request_entity_type.py +5 -0
  430. opik/rest_api/attachments/types/start_multipart_upload_request_entity_type.py +5 -0
  431. opik/rest_api/attachments/types/upload_attachment_request_entity_type.py +5 -0
  432. opik/rest_api/automation_rule_evaluators/__init__.py +2 -0
  433. opik/rest_api/automation_rule_evaluators/client.py +182 -1162
  434. opik/rest_api/automation_rule_evaluators/raw_client.py +598 -0
  435. opik/rest_api/chat_completions/__init__.py +2 -0
  436. opik/rest_api/chat_completions/client.py +115 -149
  437. opik/rest_api/chat_completions/raw_client.py +339 -0
  438. opik/rest_api/check/__init__.py +2 -0
  439. opik/rest_api/check/client.py +88 -106
  440. opik/rest_api/check/raw_client.py +258 -0
  441. opik/rest_api/client.py +112 -212
  442. opik/rest_api/core/__init__.py +5 -0
  443. opik/rest_api/core/api_error.py +12 -6
  444. opik/rest_api/core/client_wrapper.py +4 -14
  445. opik/rest_api/core/datetime_utils.py +1 -3
  446. opik/rest_api/core/file.py +2 -5
  447. opik/rest_api/core/http_client.py +42 -120
  448. opik/rest_api/core/http_response.py +55 -0
  449. opik/rest_api/core/jsonable_encoder.py +1 -4
  450. opik/rest_api/core/pydantic_utilities.py +79 -147
  451. opik/rest_api/core/query_encoder.py +1 -3
  452. opik/rest_api/core/serialization.py +10 -10
  453. opik/rest_api/dashboards/__init__.py +4 -0
  454. opik/rest_api/dashboards/client.py +462 -0
  455. opik/rest_api/dashboards/raw_client.py +648 -0
  456. opik/rest_api/datasets/__init__.py +5 -0
  457. opik/rest_api/datasets/client.py +1638 -1091
  458. opik/rest_api/datasets/raw_client.py +3389 -0
  459. opik/rest_api/datasets/types/__init__.py +8 -0
  460. opik/rest_api/datasets/types/dataset_update_visibility.py +5 -0
  461. opik/rest_api/datasets/types/dataset_write_visibility.py +5 -0
  462. opik/rest_api/errors/__init__.py +2 -0
  463. opik/rest_api/errors/bad_request_error.py +4 -3
  464. opik/rest_api/errors/conflict_error.py +4 -3
  465. opik/rest_api/errors/forbidden_error.py +4 -2
  466. opik/rest_api/errors/not_found_error.py +4 -3
  467. opik/rest_api/errors/not_implemented_error.py +4 -3
  468. opik/rest_api/errors/unauthorized_error.py +4 -3
  469. opik/rest_api/errors/unprocessable_entity_error.py +4 -3
  470. opik/rest_api/experiments/__init__.py +5 -0
  471. opik/rest_api/experiments/client.py +676 -752
  472. opik/rest_api/experiments/raw_client.py +1872 -0
  473. opik/rest_api/experiments/types/__init__.py +10 -0
  474. opik/rest_api/experiments/types/experiment_update_status.py +5 -0
  475. opik/rest_api/experiments/types/experiment_update_type.py +5 -0
  476. opik/rest_api/experiments/types/experiment_write_status.py +5 -0
  477. opik/rest_api/experiments/types/experiment_write_type.py +5 -0
  478. opik/rest_api/feedback_definitions/__init__.py +2 -0
  479. opik/rest_api/feedback_definitions/client.py +96 -370
  480. opik/rest_api/feedback_definitions/raw_client.py +541 -0
  481. opik/rest_api/feedback_definitions/types/__init__.py +2 -0
  482. opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -3
  483. opik/rest_api/guardrails/__init__.py +4 -0
  484. opik/rest_api/guardrails/client.py +104 -0
  485. opik/rest_api/guardrails/raw_client.py +102 -0
  486. opik/rest_api/llm_provider_key/__init__.py +2 -0
  487. opik/rest_api/llm_provider_key/client.py +166 -440
  488. opik/rest_api/llm_provider_key/raw_client.py +643 -0
  489. opik/rest_api/llm_provider_key/types/__init__.py +2 -0
  490. opik/rest_api/llm_provider_key/types/provider_api_key_write_provider.py +1 -1
  491. opik/rest_api/manual_evaluation/__init__.py +4 -0
  492. opik/rest_api/manual_evaluation/client.py +347 -0
  493. opik/rest_api/manual_evaluation/raw_client.py +543 -0
  494. opik/rest_api/open_telemetry_ingestion/__init__.py +2 -0
  495. opik/rest_api/open_telemetry_ingestion/client.py +38 -63
  496. opik/rest_api/open_telemetry_ingestion/raw_client.py +88 -0
  497. opik/rest_api/optimizations/__init__.py +7 -0
  498. opik/rest_api/optimizations/client.py +704 -0
  499. opik/rest_api/optimizations/raw_client.py +920 -0
  500. opik/rest_api/optimizations/types/__init__.py +7 -0
  501. opik/rest_api/optimizations/types/optimization_update_status.py +7 -0
  502. opik/rest_api/projects/__init__.py +10 -1
  503. opik/rest_api/projects/client.py +180 -855
  504. opik/rest_api/projects/raw_client.py +1216 -0
  505. opik/rest_api/projects/types/__init__.py +11 -4
  506. opik/rest_api/projects/types/project_metric_request_public_interval.py +1 -3
  507. opik/rest_api/projects/types/project_metric_request_public_metric_type.py +11 -1
  508. opik/rest_api/projects/types/project_update_visibility.py +5 -0
  509. opik/rest_api/projects/types/project_write_visibility.py +5 -0
  510. opik/rest_api/prompts/__init__.py +4 -2
  511. opik/rest_api/prompts/client.py +381 -970
  512. opik/rest_api/prompts/raw_client.py +1634 -0
  513. opik/rest_api/prompts/types/__init__.py +5 -1
  514. opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
  515. opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
  516. opik/rest_api/raw_client.py +156 -0
  517. opik/rest_api/redirect/__init__.py +4 -0
  518. opik/rest_api/redirect/client.py +375 -0
  519. opik/rest_api/redirect/raw_client.py +566 -0
  520. opik/rest_api/service_toggles/__init__.py +4 -0
  521. opik/rest_api/service_toggles/client.py +91 -0
  522. opik/rest_api/service_toggles/raw_client.py +93 -0
  523. opik/rest_api/spans/__init__.py +2 -0
  524. opik/rest_api/spans/client.py +659 -1354
  525. opik/rest_api/spans/raw_client.py +2383 -0
  526. opik/rest_api/spans/types/__init__.py +2 -0
  527. opik/rest_api/spans/types/find_feedback_score_names_1_request_type.py +1 -3
  528. opik/rest_api/spans/types/get_span_stats_request_type.py +1 -3
  529. opik/rest_api/spans/types/get_spans_by_project_request_type.py +1 -3
  530. opik/rest_api/spans/types/span_search_stream_request_public_type.py +1 -3
  531. opik/rest_api/system_usage/__init__.py +2 -0
  532. opik/rest_api/system_usage/client.py +157 -216
  533. opik/rest_api/system_usage/raw_client.py +455 -0
  534. opik/rest_api/traces/__init__.py +2 -0
  535. opik/rest_api/traces/client.py +2102 -1625
  536. opik/rest_api/traces/raw_client.py +4144 -0
  537. opik/rest_api/types/__init__.py +629 -24
  538. opik/rest_api/types/aggregation_data.py +27 -0
  539. opik/rest_api/types/alert.py +33 -0
  540. opik/rest_api/types/alert_alert_type.py +5 -0
  541. opik/rest_api/types/alert_page_public.py +24 -0
  542. opik/rest_api/types/alert_public.py +33 -0
  543. opik/rest_api/types/alert_public_alert_type.py +5 -0
  544. opik/rest_api/types/alert_trigger.py +27 -0
  545. opik/rest_api/types/alert_trigger_config.py +28 -0
  546. opik/rest_api/types/alert_trigger_config_public.py +28 -0
  547. opik/rest_api/types/alert_trigger_config_public_type.py +10 -0
  548. opik/rest_api/types/alert_trigger_config_type.py +10 -0
  549. opik/rest_api/types/alert_trigger_config_write.py +22 -0
  550. opik/rest_api/types/alert_trigger_config_write_type.py +10 -0
  551. opik/rest_api/types/alert_trigger_event_type.py +19 -0
  552. opik/rest_api/types/alert_trigger_public.py +27 -0
  553. opik/rest_api/types/alert_trigger_public_event_type.py +19 -0
  554. opik/rest_api/types/alert_trigger_write.py +23 -0
  555. opik/rest_api/types/alert_trigger_write_event_type.py +19 -0
  556. opik/rest_api/types/alert_write.py +28 -0
  557. opik/rest_api/types/alert_write_alert_type.py +5 -0
  558. opik/rest_api/types/annotation_queue.py +42 -0
  559. opik/rest_api/types/annotation_queue_batch.py +27 -0
  560. opik/rest_api/types/{json_schema_element.py → annotation_queue_item_ids.py} +5 -7
  561. opik/rest_api/types/annotation_queue_page_public.py +28 -0
  562. opik/rest_api/types/annotation_queue_public.py +38 -0
  563. opik/rest_api/types/annotation_queue_public_scope.py +5 -0
  564. opik/rest_api/types/{workspace_metadata.py → annotation_queue_reviewer.py} +6 -7
  565. opik/rest_api/types/annotation_queue_reviewer_public.py +20 -0
  566. opik/rest_api/types/annotation_queue_scope.py +5 -0
  567. opik/rest_api/types/annotation_queue_write.py +31 -0
  568. opik/rest_api/types/annotation_queue_write_scope.py +5 -0
  569. opik/rest_api/types/assistant_message.py +7 -8
  570. opik/rest_api/types/assistant_message_role.py +1 -3
  571. opik/rest_api/types/attachment.py +22 -0
  572. opik/rest_api/types/attachment_page.py +28 -0
  573. opik/rest_api/types/audio_url.py +19 -0
  574. opik/rest_api/types/audio_url_public.py +19 -0
  575. opik/rest_api/types/audio_url_write.py +19 -0
  576. opik/rest_api/types/automation_rule_evaluator.py +160 -0
  577. opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +6 -6
  578. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +6 -6
  579. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +6 -6
  580. opik/rest_api/types/automation_rule_evaluator_object_object_public.py +155 -0
  581. opik/rest_api/types/automation_rule_evaluator_page_public.py +6 -6
  582. opik/rest_api/types/automation_rule_evaluator_public.py +155 -0
  583. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
  584. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
  585. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
  586. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python.py +22 -0
  587. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_public.py +22 -0
  588. opik/rest_api/types/automation_rule_evaluator_span_user_defined_metric_python_write.py +22 -0
  589. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +22 -0
  590. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +22 -0
  591. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +22 -0
  592. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +22 -0
  593. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +22 -0
  594. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +22 -0
  595. opik/rest_api/types/automation_rule_evaluator_update.py +143 -0
  596. opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +6 -6
  597. opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
  598. opik/rest_api/types/automation_rule_evaluator_update_span_user_defined_metric_python.py +22 -0
  599. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +22 -0
  600. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +22 -0
  601. opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +6 -6
  602. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +6 -6
  603. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +6 -6
  604. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +6 -6
  605. opik/rest_api/types/automation_rule_evaluator_write.py +143 -0
  606. opik/rest_api/types/avg_value_stat_public.py +3 -5
  607. opik/rest_api/types/batch_delete.py +3 -5
  608. opik/rest_api/types/batch_delete_by_project.py +20 -0
  609. opik/rest_api/types/bi_information.py +3 -5
  610. opik/rest_api/types/bi_information_response.py +4 -6
  611. opik/rest_api/types/boolean_feedback_definition.py +25 -0
  612. opik/rest_api/types/boolean_feedback_definition_create.py +20 -0
  613. opik/rest_api/types/boolean_feedback_definition_public.py +25 -0
  614. opik/rest_api/types/boolean_feedback_definition_update.py +20 -0
  615. opik/rest_api/types/boolean_feedback_detail.py +29 -0
  616. opik/rest_api/types/boolean_feedback_detail_create.py +29 -0
  617. opik/rest_api/types/boolean_feedback_detail_public.py +29 -0
  618. opik/rest_api/types/boolean_feedback_detail_update.py +29 -0
  619. opik/rest_api/types/categorical_feedback_definition.py +5 -7
  620. opik/rest_api/types/categorical_feedback_definition_create.py +4 -6
  621. opik/rest_api/types/categorical_feedback_definition_public.py +5 -7
  622. opik/rest_api/types/categorical_feedback_definition_update.py +4 -6
  623. opik/rest_api/types/categorical_feedback_detail.py +3 -5
  624. opik/rest_api/types/categorical_feedback_detail_create.py +3 -5
  625. opik/rest_api/types/categorical_feedback_detail_public.py +3 -5
  626. opik/rest_api/types/categorical_feedback_detail_update.py +3 -5
  627. opik/rest_api/types/chat_completion_choice.py +4 -6
  628. opik/rest_api/types/chat_completion_response.py +5 -6
  629. opik/rest_api/types/check.py +22 -0
  630. opik/rest_api/types/{json_node_compare.py → check_name.py} +1 -1
  631. opik/rest_api/types/check_public.py +22 -0
  632. opik/rest_api/types/check_public_name.py +5 -0
  633. opik/rest_api/types/check_public_result.py +5 -0
  634. opik/rest_api/types/check_result.py +5 -0
  635. opik/rest_api/types/chunked_output_json_node.py +4 -6
  636. opik/rest_api/types/chunked_output_json_node_public.py +4 -6
  637. opik/rest_api/types/chunked_output_json_node_public_type.py +6 -10
  638. opik/rest_api/types/chunked_output_json_node_type.py +6 -10
  639. opik/rest_api/types/column.py +8 -10
  640. opik/rest_api/types/column_compare.py +8 -10
  641. opik/rest_api/types/column_public.py +8 -10
  642. opik/rest_api/types/column_types_item.py +1 -3
  643. opik/rest_api/types/comment.py +4 -6
  644. opik/rest_api/types/comment_compare.py +4 -6
  645. opik/rest_api/types/comment_public.py +4 -6
  646. opik/rest_api/types/complete_multipart_upload_request.py +33 -0
  647. opik/rest_api/types/complete_multipart_upload_request_entity_type.py +5 -0
  648. opik/rest_api/types/completion_tokens_details.py +3 -5
  649. opik/rest_api/types/count_value_stat_public.py +3 -5
  650. opik/rest_api/types/dashboard_page_public.py +24 -0
  651. opik/rest_api/types/dashboard_public.py +30 -0
  652. opik/rest_api/types/data_point_double.py +21 -0
  653. opik/rest_api/types/data_point_number_public.py +3 -5
  654. opik/rest_api/types/dataset.py +14 -6
  655. opik/rest_api/types/dataset_expansion.py +42 -0
  656. opik/rest_api/types/dataset_expansion_response.py +39 -0
  657. opik/rest_api/types/dataset_item.py +9 -8
  658. opik/rest_api/types/dataset_item_batch.py +3 -5
  659. opik/rest_api/types/dataset_item_changes_public.py +5 -0
  660. opik/rest_api/types/dataset_item_compare.py +9 -8
  661. opik/rest_api/types/dataset_item_compare_source.py +1 -3
  662. opik/rest_api/types/dataset_item_filter.py +27 -0
  663. opik/rest_api/types/dataset_item_filter_operator.py +21 -0
  664. opik/rest_api/types/dataset_item_page_compare.py +10 -7
  665. opik/rest_api/types/dataset_item_page_public.py +10 -7
  666. opik/rest_api/types/dataset_item_public.py +9 -8
  667. opik/rest_api/types/dataset_item_public_source.py +1 -3
  668. opik/rest_api/types/dataset_item_source.py +1 -3
  669. opik/rest_api/types/dataset_item_update.py +39 -0
  670. opik/rest_api/types/dataset_item_write.py +5 -6
  671. opik/rest_api/types/dataset_item_write_source.py +1 -3
  672. opik/rest_api/types/dataset_page_public.py +9 -6
  673. opik/rest_api/types/dataset_public.py +14 -6
  674. opik/rest_api/types/dataset_public_status.py +5 -0
  675. opik/rest_api/types/dataset_public_visibility.py +5 -0
  676. opik/rest_api/types/dataset_status.py +5 -0
  677. opik/rest_api/types/dataset_version_diff.py +22 -0
  678. opik/rest_api/types/dataset_version_diff_stats.py +24 -0
  679. opik/rest_api/types/dataset_version_page_public.py +23 -0
  680. opik/rest_api/types/dataset_version_public.py +59 -0
  681. opik/rest_api/types/dataset_version_summary.py +46 -0
  682. opik/rest_api/types/dataset_version_summary_public.py +46 -0
  683. opik/rest_api/types/dataset_visibility.py +5 -0
  684. opik/rest_api/types/delete_attachments_request.py +23 -0
  685. opik/rest_api/types/delete_attachments_request_entity_type.py +5 -0
  686. opik/rest_api/types/delete_feedback_score.py +4 -5
  687. opik/rest_api/types/delete_ids_holder.py +19 -0
  688. opik/rest_api/types/delta.py +7 -9
  689. opik/rest_api/types/error_count_with_deviation.py +21 -0
  690. opik/rest_api/types/error_count_with_deviation_detailed.py +21 -0
  691. opik/rest_api/types/error_info.py +3 -5
  692. opik/rest_api/types/error_info_experiment_item_bulk_write_view.py +21 -0
  693. opik/rest_api/types/error_info_public.py +3 -5
  694. opik/rest_api/types/error_info_write.py +3 -5
  695. opik/rest_api/types/error_message.py +3 -5
  696. opik/rest_api/types/error_message_detail.py +3 -5
  697. opik/rest_api/types/error_message_detailed.py +3 -5
  698. opik/rest_api/types/error_message_public.py +3 -5
  699. opik/rest_api/types/experiment.py +21 -10
  700. opik/rest_api/types/experiment_group_aggregations_response.py +20 -0
  701. opik/rest_api/types/experiment_group_response.py +22 -0
  702. opik/rest_api/types/experiment_item.py +14 -11
  703. opik/rest_api/types/experiment_item_bulk_record.py +27 -0
  704. opik/rest_api/types/experiment_item_bulk_record_experiment_item_bulk_write_view.py +27 -0
  705. opik/rest_api/types/experiment_item_bulk_upload.py +27 -0
  706. opik/rest_api/types/experiment_item_compare.py +14 -11
  707. opik/rest_api/types/experiment_item_compare_trace_visibility_mode.py +5 -0
  708. opik/rest_api/types/experiment_item_public.py +6 -6
  709. opik/rest_api/types/experiment_item_public_trace_visibility_mode.py +5 -0
  710. opik/rest_api/types/experiment_item_trace_visibility_mode.py +5 -0
  711. opik/rest_api/types/experiment_page_public.py +9 -6
  712. opik/rest_api/types/experiment_public.py +21 -10
  713. opik/rest_api/types/experiment_public_status.py +5 -0
  714. opik/rest_api/types/experiment_public_type.py +5 -0
  715. opik/rest_api/types/experiment_score.py +20 -0
  716. opik/rest_api/types/experiment_score_public.py +20 -0
  717. opik/rest_api/types/experiment_score_write.py +20 -0
  718. opik/rest_api/types/experiment_status.py +5 -0
  719. opik/rest_api/types/experiment_type.py +5 -0
  720. opik/rest_api/types/export_trace_service_request.py +5 -0
  721. opik/rest_api/types/feedback.py +40 -27
  722. opik/rest_api/types/feedback_create.py +27 -13
  723. opik/rest_api/types/feedback_definition_page_public.py +4 -6
  724. opik/rest_api/types/feedback_object_public.py +40 -27
  725. opik/rest_api/types/feedback_public.py +40 -27
  726. opik/rest_api/types/feedback_score.py +7 -7
  727. opik/rest_api/types/feedback_score_average.py +3 -5
  728. opik/rest_api/types/feedback_score_average_detailed.py +3 -5
  729. opik/rest_api/types/feedback_score_average_public.py +3 -5
  730. opik/rest_api/types/feedback_score_batch.py +4 -6
  731. opik/rest_api/types/feedback_score_batch_item.py +6 -6
  732. opik/rest_api/types/feedback_score_batch_item_source.py +1 -3
  733. opik/rest_api/types/feedback_score_batch_item_thread.py +32 -0
  734. opik/rest_api/types/feedback_score_batch_item_thread_source.py +5 -0
  735. opik/rest_api/types/feedback_score_compare.py +7 -7
  736. opik/rest_api/types/feedback_score_compare_source.py +1 -3
  737. opik/rest_api/types/feedback_score_experiment_item_bulk_write_view.py +31 -0
  738. opik/rest_api/types/feedback_score_experiment_item_bulk_write_view_source.py +5 -0
  739. opik/rest_api/types/feedback_score_names.py +4 -6
  740. opik/rest_api/types/feedback_score_public.py +11 -7
  741. opik/rest_api/types/feedback_score_public_source.py +1 -3
  742. opik/rest_api/types/feedback_score_source.py +1 -3
  743. opik/rest_api/types/feedback_update.py +27 -13
  744. opik/rest_api/types/function.py +4 -7
  745. opik/rest_api/types/function_call.py +3 -5
  746. opik/rest_api/types/group_content.py +19 -0
  747. opik/rest_api/types/group_content_with_aggregations.py +21 -0
  748. opik/rest_api/types/group_detail.py +19 -0
  749. opik/rest_api/types/group_details.py +20 -0
  750. opik/rest_api/types/guardrail.py +34 -0
  751. opik/rest_api/types/guardrail_batch.py +20 -0
  752. opik/rest_api/types/guardrail_name.py +5 -0
  753. opik/rest_api/types/guardrail_result.py +5 -0
  754. opik/rest_api/types/guardrail_write.py +33 -0
  755. opik/rest_api/types/guardrail_write_name.py +5 -0
  756. opik/rest_api/types/guardrail_write_result.py +5 -0
  757. opik/rest_api/types/guardrails_validation.py +21 -0
  758. opik/rest_api/types/guardrails_validation_public.py +21 -0
  759. opik/rest_api/types/ids_holder.py +19 -0
  760. opik/rest_api/types/image_url.py +20 -0
  761. opik/rest_api/types/image_url_public.py +20 -0
  762. opik/rest_api/types/image_url_write.py +20 -0
  763. opik/rest_api/types/json_list_string.py +7 -0
  764. opik/rest_api/types/json_list_string_compare.py +7 -0
  765. opik/rest_api/types/json_list_string_experiment_item_bulk_write_view.py +7 -0
  766. opik/rest_api/types/json_list_string_public.py +7 -0
  767. opik/rest_api/types/json_list_string_write.py +7 -0
  768. opik/rest_api/types/json_schema.py +5 -8
  769. opik/rest_api/types/llm_as_judge_code.py +8 -12
  770. opik/rest_api/types/llm_as_judge_code_public.py +8 -12
  771. opik/rest_api/types/llm_as_judge_code_write.py +8 -12
  772. opik/rest_api/types/llm_as_judge_message.py +9 -7
  773. opik/rest_api/types/llm_as_judge_message_content.py +26 -0
  774. opik/rest_api/types/llm_as_judge_message_content_public.py +26 -0
  775. opik/rest_api/types/llm_as_judge_message_content_write.py +26 -0
  776. opik/rest_api/types/llm_as_judge_message_public.py +9 -7
  777. opik/rest_api/types/llm_as_judge_message_public_role.py +1 -1
  778. opik/rest_api/types/llm_as_judge_message_role.py +1 -1
  779. opik/rest_api/types/llm_as_judge_message_write.py +9 -7
  780. opik/rest_api/types/llm_as_judge_message_write_role.py +1 -1
  781. opik/rest_api/types/llm_as_judge_model_parameters.py +6 -5
  782. opik/rest_api/types/llm_as_judge_model_parameters_public.py +6 -5
  783. opik/rest_api/types/llm_as_judge_model_parameters_write.py +6 -5
  784. opik/rest_api/types/llm_as_judge_output_schema.py +4 -6
  785. opik/rest_api/types/llm_as_judge_output_schema_public.py +4 -6
  786. opik/rest_api/types/llm_as_judge_output_schema_public_type.py +1 -3
  787. opik/rest_api/types/llm_as_judge_output_schema_type.py +1 -3
  788. opik/rest_api/types/llm_as_judge_output_schema_write.py +4 -6
  789. opik/rest_api/types/llm_as_judge_output_schema_write_type.py +1 -3
  790. opik/rest_api/types/log_item.py +5 -7
  791. opik/rest_api/types/log_item_level.py +1 -3
  792. opik/rest_api/types/log_page.py +4 -6
  793. opik/rest_api/types/manual_evaluation_request.py +38 -0
  794. opik/rest_api/types/manual_evaluation_request_entity_type.py +5 -0
  795. opik/rest_api/types/manual_evaluation_response.py +27 -0
  796. opik/rest_api/types/multipart_upload_part.py +20 -0
  797. opik/rest_api/types/numerical_feedback_definition.py +5 -7
  798. opik/rest_api/types/numerical_feedback_definition_create.py +4 -6
  799. opik/rest_api/types/numerical_feedback_definition_public.py +5 -7
  800. opik/rest_api/types/numerical_feedback_definition_update.py +4 -6
  801. opik/rest_api/types/numerical_feedback_detail.py +3 -5
  802. opik/rest_api/types/numerical_feedback_detail_create.py +3 -5
  803. opik/rest_api/types/numerical_feedback_detail_public.py +3 -5
  804. opik/rest_api/types/numerical_feedback_detail_update.py +3 -5
  805. opik/rest_api/types/optimization.py +37 -0
  806. opik/rest_api/types/optimization_page_public.py +28 -0
  807. opik/rest_api/types/optimization_public.py +37 -0
  808. opik/rest_api/types/optimization_public_status.py +7 -0
  809. opik/rest_api/types/optimization_status.py +7 -0
  810. opik/rest_api/types/optimization_studio_config.py +27 -0
  811. opik/rest_api/types/optimization_studio_config_public.py +27 -0
  812. opik/rest_api/types/optimization_studio_config_write.py +27 -0
  813. opik/rest_api/types/optimization_studio_log.py +22 -0
  814. opik/rest_api/types/optimization_write.py +30 -0
  815. opik/rest_api/types/optimization_write_status.py +7 -0
  816. opik/rest_api/types/page_columns.py +4 -6
  817. opik/rest_api/types/percentage_value_stat_public.py +4 -6
  818. opik/rest_api/types/percentage_values.py +8 -16
  819. opik/rest_api/types/percentage_values_detailed.py +8 -16
  820. opik/rest_api/types/percentage_values_public.py +8 -16
  821. opik/rest_api/types/project.py +12 -7
  822. opik/rest_api/types/project_detailed.py +12 -7
  823. opik/rest_api/types/project_detailed_visibility.py +5 -0
  824. opik/rest_api/types/project_metric_response_public.py +5 -9
  825. opik/rest_api/types/project_metric_response_public_interval.py +1 -3
  826. opik/rest_api/types/project_metric_response_public_metric_type.py +11 -1
  827. opik/rest_api/types/project_page_public.py +8 -10
  828. opik/rest_api/types/project_public.py +6 -6
  829. opik/rest_api/types/project_public_visibility.py +5 -0
  830. opik/rest_api/types/project_reference.py +31 -0
  831. opik/rest_api/types/project_reference_public.py +31 -0
  832. opik/rest_api/types/project_stat_item_object_public.py +8 -17
  833. opik/rest_api/types/project_stats_public.py +4 -6
  834. opik/rest_api/types/project_stats_summary.py +4 -6
  835. opik/rest_api/types/project_stats_summary_item.py +9 -6
  836. opik/rest_api/types/project_visibility.py +5 -0
  837. opik/rest_api/types/prompt.py +12 -7
  838. opik/rest_api/types/prompt_detail.py +12 -7
  839. opik/rest_api/types/prompt_detail_template_structure.py +5 -0
  840. opik/rest_api/types/prompt_page_public.py +9 -6
  841. opik/rest_api/types/prompt_public.py +11 -6
  842. opik/rest_api/types/prompt_public_template_structure.py +5 -0
  843. opik/rest_api/types/prompt_template_structure.py +5 -0
  844. opik/rest_api/types/prompt_tokens_details.py +19 -0
  845. opik/rest_api/types/prompt_version.py +7 -6
  846. opik/rest_api/types/prompt_version_detail.py +7 -6
  847. opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
  848. opik/rest_api/types/prompt_version_link.py +4 -5
  849. opik/rest_api/types/prompt_version_link_public.py +4 -5
  850. opik/rest_api/types/prompt_version_link_write.py +3 -5
  851. opik/rest_api/types/prompt_version_page_public.py +9 -6
  852. opik/rest_api/types/prompt_version_public.py +7 -6
  853. opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
  854. opik/rest_api/types/prompt_version_template_structure.py +5 -0
  855. opik/rest_api/types/prompt_version_update.py +33 -0
  856. opik/rest_api/types/provider_api_key.py +18 -8
  857. opik/rest_api/types/provider_api_key_page_public.py +27 -0
  858. opik/rest_api/types/provider_api_key_provider.py +1 -1
  859. opik/rest_api/types/provider_api_key_public.py +18 -8
  860. opik/rest_api/types/provider_api_key_public_provider.py +1 -1
  861. opik/rest_api/types/response_format.py +5 -7
  862. opik/rest_api/types/response_format_type.py +1 -3
  863. opik/rest_api/types/result.py +21 -0
  864. opik/rest_api/types/results_number_public.py +4 -6
  865. opik/rest_api/types/score_name.py +4 -5
  866. opik/rest_api/types/service_toggles_config.py +44 -0
  867. opik/rest_api/types/span.py +13 -15
  868. opik/rest_api/types/span_batch.py +4 -6
  869. opik/rest_api/types/span_enrichment_options.py +31 -0
  870. opik/rest_api/types/span_experiment_item_bulk_write_view.py +39 -0
  871. opik/rest_api/types/span_experiment_item_bulk_write_view_type.py +5 -0
  872. opik/rest_api/types/span_filter.py +23 -0
  873. opik/rest_api/types/span_filter_operator.py +21 -0
  874. opik/rest_api/types/span_filter_public.py +4 -6
  875. opik/rest_api/types/span_filter_public_operator.py +2 -0
  876. opik/rest_api/types/span_filter_write.py +23 -0
  877. opik/rest_api/types/span_filter_write_operator.py +21 -0
  878. opik/rest_api/types/span_llm_as_judge_code.py +27 -0
  879. opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
  880. opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
  881. opik/rest_api/types/span_page_public.py +9 -6
  882. opik/rest_api/types/span_public.py +19 -16
  883. opik/rest_api/types/span_public_type.py +1 -1
  884. opik/rest_api/types/span_type.py +1 -1
  885. opik/rest_api/types/span_update.py +46 -0
  886. opik/rest_api/types/span_update_type.py +5 -0
  887. opik/rest_api/types/span_user_defined_metric_python_code.py +20 -0
  888. opik/rest_api/types/span_user_defined_metric_python_code_public.py +20 -0
  889. opik/rest_api/types/span_user_defined_metric_python_code_write.py +20 -0
  890. opik/rest_api/types/span_write.py +13 -14
  891. opik/rest_api/types/span_write_type.py +1 -1
  892. opik/rest_api/types/spans_count_response.py +20 -0
  893. opik/rest_api/types/start_multipart_upload_response.py +20 -0
  894. opik/rest_api/types/stream_options.py +3 -5
  895. opik/rest_api/types/studio_evaluation.py +20 -0
  896. opik/rest_api/types/studio_evaluation_public.py +20 -0
  897. opik/rest_api/types/studio_evaluation_write.py +20 -0
  898. opik/rest_api/types/studio_llm_model.py +21 -0
  899. opik/rest_api/types/studio_llm_model_public.py +21 -0
  900. opik/rest_api/types/studio_llm_model_write.py +21 -0
  901. opik/rest_api/types/studio_message.py +20 -0
  902. opik/rest_api/types/studio_message_public.py +20 -0
  903. opik/rest_api/types/studio_message_write.py +20 -0
  904. opik/rest_api/types/studio_metric.py +21 -0
  905. opik/rest_api/types/studio_metric_public.py +21 -0
  906. opik/rest_api/types/studio_metric_write.py +21 -0
  907. opik/rest_api/types/studio_optimizer.py +21 -0
  908. opik/rest_api/types/studio_optimizer_public.py +21 -0
  909. opik/rest_api/types/studio_optimizer_write.py +21 -0
  910. opik/rest_api/types/studio_prompt.py +20 -0
  911. opik/rest_api/types/studio_prompt_public.py +20 -0
  912. opik/rest_api/types/studio_prompt_write.py +20 -0
  913. opik/rest_api/types/tool.py +4 -6
  914. opik/rest_api/types/tool_call.py +4 -6
  915. opik/rest_api/types/trace.py +26 -12
  916. opik/rest_api/types/trace_batch.py +4 -6
  917. opik/rest_api/types/trace_count_response.py +4 -6
  918. opik/rest_api/types/trace_enrichment_options.py +32 -0
  919. opik/rest_api/types/trace_experiment_item_bulk_write_view.py +41 -0
  920. opik/rest_api/types/trace_filter.py +23 -0
  921. opik/rest_api/types/trace_filter_operator.py +21 -0
  922. opik/rest_api/types/trace_filter_public.py +23 -0
  923. opik/rest_api/types/trace_filter_public_operator.py +21 -0
  924. opik/rest_api/types/trace_filter_write.py +23 -0
  925. opik/rest_api/types/trace_filter_write_operator.py +21 -0
  926. opik/rest_api/types/trace_page_public.py +8 -10
  927. opik/rest_api/types/trace_public.py +27 -13
  928. opik/rest_api/types/trace_public_visibility_mode.py +5 -0
  929. opik/rest_api/types/trace_thread.py +18 -9
  930. opik/rest_api/types/trace_thread_filter.py +23 -0
  931. opik/rest_api/types/trace_thread_filter_operator.py +21 -0
  932. opik/rest_api/types/trace_thread_filter_public.py +23 -0
  933. opik/rest_api/types/trace_thread_filter_public_operator.py +21 -0
  934. opik/rest_api/types/trace_thread_filter_write.py +23 -0
  935. opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
  936. opik/rest_api/types/trace_thread_identifier.py +22 -0
  937. opik/rest_api/types/trace_thread_llm_as_judge_code.py +26 -0
  938. opik/rest_api/types/trace_thread_llm_as_judge_code_public.py +26 -0
  939. opik/rest_api/types/trace_thread_llm_as_judge_code_write.py +26 -0
  940. opik/rest_api/types/trace_thread_page.py +9 -6
  941. opik/rest_api/types/trace_thread_status.py +5 -0
  942. opik/rest_api/types/trace_thread_update.py +19 -0
  943. opik/rest_api/types/trace_thread_user_defined_metric_python_code.py +19 -0
  944. opik/rest_api/types/trace_thread_user_defined_metric_python_code_public.py +19 -0
  945. opik/rest_api/types/trace_thread_user_defined_metric_python_code_write.py +19 -0
  946. opik/rest_api/types/trace_update.py +39 -0
  947. opik/rest_api/types/trace_visibility_mode.py +5 -0
  948. opik/rest_api/types/trace_write.py +10 -11
  949. opik/rest_api/types/usage.py +6 -6
  950. opik/rest_api/types/user_defined_metric_python_code.py +3 -5
  951. opik/rest_api/types/user_defined_metric_python_code_public.py +3 -5
  952. opik/rest_api/types/user_defined_metric_python_code_write.py +3 -5
  953. opik/rest_api/types/value_entry.py +27 -0
  954. opik/rest_api/types/value_entry_compare.py +27 -0
  955. opik/rest_api/types/value_entry_compare_source.py +5 -0
  956. opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +27 -0
  957. opik/rest_api/types/value_entry_experiment_item_bulk_write_view_source.py +5 -0
  958. opik/rest_api/types/value_entry_public.py +27 -0
  959. opik/rest_api/types/value_entry_public_source.py +5 -0
  960. opik/rest_api/types/value_entry_source.py +5 -0
  961. opik/rest_api/types/video_url.py +19 -0
  962. opik/rest_api/types/video_url_public.py +19 -0
  963. opik/rest_api/types/video_url_write.py +19 -0
  964. opik/rest_api/types/webhook.py +28 -0
  965. opik/rest_api/types/webhook_examples.py +19 -0
  966. opik/rest_api/types/webhook_public.py +28 -0
  967. opik/rest_api/types/webhook_test_result.py +23 -0
  968. opik/rest_api/types/webhook_test_result_status.py +5 -0
  969. opik/rest_api/types/webhook_write.py +23 -0
  970. opik/rest_api/types/welcome_wizard_tracking.py +22 -0
  971. opik/rest_api/types/workspace_configuration.py +27 -0
  972. opik/rest_api/types/workspace_metric_request.py +24 -0
  973. opik/rest_api/types/workspace_metric_response.py +20 -0
  974. opik/rest_api/types/workspace_metrics_summary_request.py +23 -0
  975. opik/rest_api/types/workspace_metrics_summary_response.py +20 -0
  976. opik/rest_api/types/workspace_name_holder.py +19 -0
  977. opik/rest_api/types/workspace_spans_count.py +20 -0
  978. opik/rest_api/types/workspace_trace_count.py +3 -5
  979. opik/rest_api/welcome_wizard/__init__.py +4 -0
  980. opik/rest_api/welcome_wizard/client.py +195 -0
  981. opik/rest_api/welcome_wizard/raw_client.py +208 -0
  982. opik/rest_api/workspaces/__init__.py +2 -0
  983. opik/rest_api/workspaces/client.py +550 -77
  984. opik/rest_api/workspaces/raw_client.py +923 -0
  985. opik/rest_client_configurator/api.py +1 -0
  986. opik/rest_client_configurator/retry_decorator.py +1 -0
  987. opik/s3_httpx_client.py +67 -0
  988. opik/simulation/__init__.py +6 -0
  989. opik/simulation/simulated_user.py +99 -0
  990. opik/simulation/simulator.py +108 -0
  991. opik/synchronization.py +11 -24
  992. opik/tracing_runtime_config.py +48 -0
  993. opik/types.py +48 -2
  994. opik/url_helpers.py +13 -3
  995. opik/validation/chat_prompt_messages.py +241 -0
  996. opik/validation/feedback_score.py +4 -5
  997. opik/validation/parameter.py +122 -0
  998. opik/validation/parameters_validator.py +175 -0
  999. opik/validation/validator.py +30 -2
  1000. opik/validation/validator_helpers.py +147 -0
  1001. opik-1.9.71.dist-info/METADATA +370 -0
  1002. opik-1.9.71.dist-info/RECORD +1110 -0
  1003. {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/WHEEL +1 -1
  1004. opik-1.9.71.dist-info/licenses/LICENSE +203 -0
  1005. opik/api_objects/prompt/prompt.py +0 -107
  1006. opik/api_objects/prompt/prompt_template.py +0 -35
  1007. opik/cli.py +0 -193
  1008. opik/evaluation/metrics/models.py +0 -8
  1009. opik/hooks.py +0 -13
  1010. opik/integrations/bedrock/chunks_aggregator.py +0 -55
  1011. opik/integrations/bedrock/helpers.py +0 -8
  1012. opik/integrations/langchain/google_run_helpers.py +0 -75
  1013. opik/integrations/langchain/openai_run_helpers.py +0 -122
  1014. opik/message_processing/message_processors.py +0 -203
  1015. opik/rest_api/types/delta_role.py +0 -7
  1016. opik/rest_api/types/json_object_schema.py +0 -34
  1017. opik-1.6.4.dist-info/METADATA +0 -270
  1018. opik-1.6.4.dist-info/RECORD +0 -507
  1019. /opik/integrations/bedrock/{stream_wrappers.py → converse/stream_wrappers.py} +0 -0
  1020. {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/entry_points.txt +0 -0
  1021. {opik-1.6.4.dist-info → opik-1.9.71.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,4144 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import contextlib
4
+ import datetime as dt
5
+ import typing
6
+ from json.decoder import JSONDecodeError
7
+
8
+ from ..core.api_error import ApiError
9
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
10
+ from ..core.datetime_utils import serialize_datetime
11
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
12
+ from ..core.jsonable_encoder import jsonable_encoder
13
+ from ..core.pydantic_utilities import parse_obj_as
14
+ from ..core.request_options import RequestOptions
15
+ from ..core.serialization import convert_and_respect_annotation_metadata
16
+ from ..errors.bad_request_error import BadRequestError
17
+ from ..errors.not_found_error import NotFoundError
18
+ from ..errors.unauthorized_error import UnauthorizedError
19
+ from ..types.comment import Comment
20
+ from ..types.error_info import ErrorInfo
21
+ from ..types.error_info_write import ErrorInfoWrite
22
+ from ..types.feedback_score_batch_item import FeedbackScoreBatchItem
23
+ from ..types.feedback_score_batch_item_thread import FeedbackScoreBatchItemThread
24
+ from ..types.feedback_score_source import FeedbackScoreSource
25
+ from ..types.json_list_string import JsonListString
26
+ from ..types.json_list_string_write import JsonListStringWrite
27
+ from ..types.project_stats_public import ProjectStatsPublic
28
+ from ..types.trace_filter_public import TraceFilterPublic
29
+ from ..types.trace_page_public import TracePagePublic
30
+ from ..types.trace_public import TracePublic
31
+ from ..types.trace_thread import TraceThread
32
+ from ..types.trace_thread_filter import TraceThreadFilter
33
+ from ..types.trace_thread_page import TraceThreadPage
34
+ from ..types.trace_thread_update import TraceThreadUpdate
35
+ from ..types.trace_update import TraceUpdate
36
+ from ..types.trace_write import TraceWrite
37
+ from ..types.value_entry import ValueEntry
38
+
39
+ # this is used as the default value for optional parameters
40
+ OMIT = typing.cast(typing.Any, ...)
41
+
42
+
43
+ class RawTracesClient:
44
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
45
+ self._client_wrapper = client_wrapper
46
+
47
+ def add_thread_comment(
48
+ self,
49
+ id_: str,
50
+ *,
51
+ text: str,
52
+ id: typing.Optional[str] = OMIT,
53
+ created_at: typing.Optional[dt.datetime] = OMIT,
54
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
55
+ created_by: typing.Optional[str] = OMIT,
56
+ last_updated_by: typing.Optional[str] = OMIT,
57
+ request_options: typing.Optional[RequestOptions] = None,
58
+ ) -> HttpResponse[None]:
59
+ """
60
+ Add thread comment
61
+
62
+ Parameters
63
+ ----------
64
+ id_ : str
65
+
66
+ text : str
67
+
68
+ id : typing.Optional[str]
69
+
70
+ created_at : typing.Optional[dt.datetime]
71
+
72
+ last_updated_at : typing.Optional[dt.datetime]
73
+
74
+ created_by : typing.Optional[str]
75
+
76
+ last_updated_by : typing.Optional[str]
77
+
78
+ request_options : typing.Optional[RequestOptions]
79
+ Request-specific configuration.
80
+
81
+ Returns
82
+ -------
83
+ HttpResponse[None]
84
+ """
85
+ _response = self._client_wrapper.httpx_client.request(
86
+ f"v1/private/traces/threads/{jsonable_encoder(id_)}/comments",
87
+ method="POST",
88
+ json={
89
+ "id": id,
90
+ "text": text,
91
+ "created_at": created_at,
92
+ "last_updated_at": last_updated_at,
93
+ "created_by": created_by,
94
+ "last_updated_by": last_updated_by,
95
+ },
96
+ headers={
97
+ "content-type": "application/json",
98
+ },
99
+ request_options=request_options,
100
+ omit=OMIT,
101
+ )
102
+ try:
103
+ if 200 <= _response.status_code < 300:
104
+ return HttpResponse(response=_response, data=None)
105
+ _response_json = _response.json()
106
+ except JSONDecodeError:
107
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
108
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
109
+
110
+ def add_trace_comment(
111
+ self,
112
+ id_: str,
113
+ *,
114
+ text: str,
115
+ id: typing.Optional[str] = OMIT,
116
+ created_at: typing.Optional[dt.datetime] = OMIT,
117
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
118
+ created_by: typing.Optional[str] = OMIT,
119
+ last_updated_by: typing.Optional[str] = OMIT,
120
+ request_options: typing.Optional[RequestOptions] = None,
121
+ ) -> HttpResponse[None]:
122
+ """
123
+ Add trace comment
124
+
125
+ Parameters
126
+ ----------
127
+ id_ : str
128
+
129
+ text : str
130
+
131
+ id : typing.Optional[str]
132
+
133
+ created_at : typing.Optional[dt.datetime]
134
+
135
+ last_updated_at : typing.Optional[dt.datetime]
136
+
137
+ created_by : typing.Optional[str]
138
+
139
+ last_updated_by : typing.Optional[str]
140
+
141
+ request_options : typing.Optional[RequestOptions]
142
+ Request-specific configuration.
143
+
144
+ Returns
145
+ -------
146
+ HttpResponse[None]
147
+ """
148
+ _response = self._client_wrapper.httpx_client.request(
149
+ f"v1/private/traces/{jsonable_encoder(id_)}/comments",
150
+ method="POST",
151
+ json={
152
+ "id": id,
153
+ "text": text,
154
+ "created_at": created_at,
155
+ "last_updated_at": last_updated_at,
156
+ "created_by": created_by,
157
+ "last_updated_by": last_updated_by,
158
+ },
159
+ headers={
160
+ "content-type": "application/json",
161
+ },
162
+ request_options=request_options,
163
+ omit=OMIT,
164
+ )
165
+ try:
166
+ if 200 <= _response.status_code < 300:
167
+ return HttpResponse(response=_response, data=None)
168
+ _response_json = _response.json()
169
+ except JSONDecodeError:
170
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
171
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
172
+
173
+ def add_trace_feedback_score(
174
+ self,
175
+ id: str,
176
+ *,
177
+ name: str,
178
+ value: float,
179
+ source: FeedbackScoreSource,
180
+ category_name: typing.Optional[str] = OMIT,
181
+ reason: typing.Optional[str] = OMIT,
182
+ created_at: typing.Optional[dt.datetime] = OMIT,
183
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
184
+ created_by: typing.Optional[str] = OMIT,
185
+ last_updated_by: typing.Optional[str] = OMIT,
186
+ value_by_author: typing.Optional[typing.Dict[str, ValueEntry]] = OMIT,
187
+ request_options: typing.Optional[RequestOptions] = None,
188
+ ) -> HttpResponse[None]:
189
+ """
190
+ Add trace feedback score
191
+
192
+ Parameters
193
+ ----------
194
+ id : str
195
+
196
+ name : str
197
+
198
+ value : float
199
+
200
+ source : FeedbackScoreSource
201
+
202
+ category_name : typing.Optional[str]
203
+
204
+ reason : typing.Optional[str]
205
+
206
+ created_at : typing.Optional[dt.datetime]
207
+
208
+ last_updated_at : typing.Optional[dt.datetime]
209
+
210
+ created_by : typing.Optional[str]
211
+
212
+ last_updated_by : typing.Optional[str]
213
+
214
+ value_by_author : typing.Optional[typing.Dict[str, ValueEntry]]
215
+
216
+ request_options : typing.Optional[RequestOptions]
217
+ Request-specific configuration.
218
+
219
+ Returns
220
+ -------
221
+ HttpResponse[None]
222
+ """
223
+ _response = self._client_wrapper.httpx_client.request(
224
+ f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores",
225
+ method="PUT",
226
+ json={
227
+ "name": name,
228
+ "category_name": category_name,
229
+ "value": value,
230
+ "reason": reason,
231
+ "source": source,
232
+ "created_at": created_at,
233
+ "last_updated_at": last_updated_at,
234
+ "created_by": created_by,
235
+ "last_updated_by": last_updated_by,
236
+ "value_by_author": convert_and_respect_annotation_metadata(
237
+ object_=value_by_author, annotation=typing.Dict[str, ValueEntry], direction="write"
238
+ ),
239
+ },
240
+ headers={
241
+ "content-type": "application/json",
242
+ },
243
+ request_options=request_options,
244
+ omit=OMIT,
245
+ )
246
+ try:
247
+ if 200 <= _response.status_code < 300:
248
+ return HttpResponse(response=_response, data=None)
249
+ _response_json = _response.json()
250
+ except JSONDecodeError:
251
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
252
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
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
+
419
+ def close_trace_thread(
420
+ self,
421
+ *,
422
+ project_name: typing.Optional[str] = OMIT,
423
+ project_id: typing.Optional[str] = OMIT,
424
+ thread_id: typing.Optional[str] = OMIT,
425
+ thread_ids: typing.Optional[typing.Sequence[str]] = OMIT,
426
+ request_options: typing.Optional[RequestOptions] = None,
427
+ ) -> HttpResponse[None]:
428
+ """
429
+ Close one or multiple trace threads. Supports both single thread_id and multiple thread_ids for batch operations.
430
+
431
+ Parameters
432
+ ----------
433
+ project_name : typing.Optional[str]
434
+
435
+ project_id : typing.Optional[str]
436
+
437
+ thread_id : typing.Optional[str]
438
+
439
+ thread_ids : typing.Optional[typing.Sequence[str]]
440
+
441
+ request_options : typing.Optional[RequestOptions]
442
+ Request-specific configuration.
443
+
444
+ Returns
445
+ -------
446
+ HttpResponse[None]
447
+ """
448
+ _response = self._client_wrapper.httpx_client.request(
449
+ "v1/private/traces/threads/close",
450
+ method="PUT",
451
+ json={
452
+ "project_name": project_name,
453
+ "project_id": project_id,
454
+ "thread_id": thread_id,
455
+ "thread_ids": thread_ids,
456
+ },
457
+ headers={
458
+ "content-type": "application/json",
459
+ },
460
+ request_options=request_options,
461
+ omit=OMIT,
462
+ )
463
+ try:
464
+ if 200 <= _response.status_code < 300:
465
+ return HttpResponse(response=_response, data=None)
466
+ if _response.status_code == 404:
467
+ raise NotFoundError(
468
+ headers=dict(_response.headers),
469
+ body=typing.cast(
470
+ typing.Optional[typing.Any],
471
+ parse_obj_as(
472
+ type_=typing.Optional[typing.Any], # type: ignore
473
+ object_=_response.json(),
474
+ ),
475
+ ),
476
+ )
477
+ _response_json = _response.json()
478
+ except JSONDecodeError:
479
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
480
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
481
+
482
+ def get_traces_by_project(
483
+ self,
484
+ *,
485
+ page: typing.Optional[int] = None,
486
+ size: typing.Optional[int] = None,
487
+ project_name: typing.Optional[str] = None,
488
+ project_id: typing.Optional[str] = None,
489
+ filters: typing.Optional[str] = None,
490
+ truncate: typing.Optional[bool] = None,
491
+ strip_attachments: typing.Optional[bool] = None,
492
+ sorting: typing.Optional[str] = None,
493
+ exclude: typing.Optional[str] = None,
494
+ from_time: typing.Optional[dt.datetime] = None,
495
+ to_time: typing.Optional[dt.datetime] = None,
496
+ request_options: typing.Optional[RequestOptions] = None,
497
+ ) -> HttpResponse[TracePagePublic]:
498
+ """
499
+ Get traces by project_name or project_id
500
+
501
+ Parameters
502
+ ----------
503
+ page : typing.Optional[int]
504
+
505
+ size : typing.Optional[int]
506
+
507
+ project_name : typing.Optional[str]
508
+
509
+ project_id : typing.Optional[str]
510
+
511
+ filters : typing.Optional[str]
512
+
513
+ truncate : typing.Optional[bool]
514
+
515
+ strip_attachments : typing.Optional[bool]
516
+
517
+ sorting : typing.Optional[str]
518
+
519
+ exclude : typing.Optional[str]
520
+
521
+ from_time : typing.Optional[dt.datetime]
522
+
523
+ to_time : typing.Optional[dt.datetime]
524
+
525
+ request_options : typing.Optional[RequestOptions]
526
+ Request-specific configuration.
527
+
528
+ Returns
529
+ -------
530
+ HttpResponse[TracePagePublic]
531
+ Trace resource
532
+ """
533
+ _response = self._client_wrapper.httpx_client.request(
534
+ "v1/private/traces",
535
+ method="GET",
536
+ params={
537
+ "page": page,
538
+ "size": size,
539
+ "project_name": project_name,
540
+ "project_id": project_id,
541
+ "filters": filters,
542
+ "truncate": truncate,
543
+ "strip_attachments": strip_attachments,
544
+ "sorting": sorting,
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,
548
+ },
549
+ request_options=request_options,
550
+ )
551
+ try:
552
+ if 200 <= _response.status_code < 300:
553
+ _data = typing.cast(
554
+ TracePagePublic,
555
+ parse_obj_as(
556
+ type_=TracePagePublic, # type: ignore
557
+ object_=_response.json(),
558
+ ),
559
+ )
560
+ return HttpResponse(response=_response, data=_data)
561
+ _response_json = _response.json()
562
+ except JSONDecodeError:
563
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
564
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
565
+
566
+ def create_trace(
567
+ self,
568
+ *,
569
+ start_time: dt.datetime,
570
+ id: typing.Optional[str] = OMIT,
571
+ project_name: typing.Optional[str] = OMIT,
572
+ name: typing.Optional[str] = OMIT,
573
+ end_time: typing.Optional[dt.datetime] = OMIT,
574
+ input: typing.Optional[JsonListStringWrite] = OMIT,
575
+ output: typing.Optional[JsonListStringWrite] = OMIT,
576
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
577
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
578
+ error_info: typing.Optional[ErrorInfoWrite] = OMIT,
579
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
580
+ thread_id: typing.Optional[str] = OMIT,
581
+ request_options: typing.Optional[RequestOptions] = None,
582
+ ) -> HttpResponse[None]:
583
+ """
584
+ Get trace
585
+
586
+ Parameters
587
+ ----------
588
+ start_time : dt.datetime
589
+
590
+ id : typing.Optional[str]
591
+
592
+ project_name : typing.Optional[str]
593
+ If null, the default project is used
594
+
595
+ name : typing.Optional[str]
596
+
597
+ end_time : typing.Optional[dt.datetime]
598
+
599
+ input : typing.Optional[JsonListStringWrite]
600
+
601
+ output : typing.Optional[JsonListStringWrite]
602
+
603
+ metadata : typing.Optional[JsonListStringWrite]
604
+
605
+ tags : typing.Optional[typing.Sequence[str]]
606
+
607
+ error_info : typing.Optional[ErrorInfoWrite]
608
+
609
+ last_updated_at : typing.Optional[dt.datetime]
610
+
611
+ thread_id : typing.Optional[str]
612
+
613
+ request_options : typing.Optional[RequestOptions]
614
+ Request-specific configuration.
615
+
616
+ Returns
617
+ -------
618
+ HttpResponse[None]
619
+ """
620
+ _response = self._client_wrapper.httpx_client.request(
621
+ "v1/private/traces",
622
+ method="POST",
623
+ json={
624
+ "id": id,
625
+ "project_name": project_name,
626
+ "name": name,
627
+ "start_time": start_time,
628
+ "end_time": end_time,
629
+ "input": convert_and_respect_annotation_metadata(
630
+ object_=input, annotation=JsonListStringWrite, direction="write"
631
+ ),
632
+ "output": convert_and_respect_annotation_metadata(
633
+ object_=output, annotation=JsonListStringWrite, direction="write"
634
+ ),
635
+ "metadata": convert_and_respect_annotation_metadata(
636
+ object_=metadata, annotation=JsonListStringWrite, direction="write"
637
+ ),
638
+ "tags": tags,
639
+ "error_info": convert_and_respect_annotation_metadata(
640
+ object_=error_info, annotation=ErrorInfoWrite, direction="write"
641
+ ),
642
+ "last_updated_at": last_updated_at,
643
+ "thread_id": thread_id,
644
+ },
645
+ headers={
646
+ "content-type": "application/json",
647
+ },
648
+ request_options=request_options,
649
+ omit=OMIT,
650
+ )
651
+ try:
652
+ if 200 <= _response.status_code < 300:
653
+ return HttpResponse(response=_response, data=None)
654
+ _response_json = _response.json()
655
+ except JSONDecodeError:
656
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
657
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
658
+
659
+ def get_trace_by_id(
660
+ self,
661
+ id: str,
662
+ *,
663
+ strip_attachments: typing.Optional[bool] = None,
664
+ request_options: typing.Optional[RequestOptions] = None,
665
+ ) -> HttpResponse[TracePublic]:
666
+ """
667
+ Get trace by id
668
+
669
+ Parameters
670
+ ----------
671
+ id : str
672
+
673
+ strip_attachments : typing.Optional[bool]
674
+
675
+ request_options : typing.Optional[RequestOptions]
676
+ Request-specific configuration.
677
+
678
+ Returns
679
+ -------
680
+ HttpResponse[TracePublic]
681
+ Trace resource
682
+ """
683
+ _response = self._client_wrapper.httpx_client.request(
684
+ f"v1/private/traces/{jsonable_encoder(id)}",
685
+ method="GET",
686
+ params={
687
+ "strip_attachments": strip_attachments,
688
+ },
689
+ request_options=request_options,
690
+ )
691
+ try:
692
+ if 200 <= _response.status_code < 300:
693
+ _data = typing.cast(
694
+ TracePublic,
695
+ parse_obj_as(
696
+ type_=TracePublic, # type: ignore
697
+ object_=_response.json(),
698
+ ),
699
+ )
700
+ return HttpResponse(response=_response, data=_data)
701
+ _response_json = _response.json()
702
+ except JSONDecodeError:
703
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
704
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
705
+
706
+ def delete_trace_by_id(
707
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
708
+ ) -> HttpResponse[None]:
709
+ """
710
+ Delete trace by id
711
+
712
+ Parameters
713
+ ----------
714
+ id : str
715
+
716
+ request_options : typing.Optional[RequestOptions]
717
+ Request-specific configuration.
718
+
719
+ Returns
720
+ -------
721
+ HttpResponse[None]
722
+ """
723
+ _response = self._client_wrapper.httpx_client.request(
724
+ f"v1/private/traces/{jsonable_encoder(id)}",
725
+ method="DELETE",
726
+ request_options=request_options,
727
+ )
728
+ try:
729
+ if 200 <= _response.status_code < 300:
730
+ return HttpResponse(response=_response, data=None)
731
+ _response_json = _response.json()
732
+ except JSONDecodeError:
733
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
734
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
735
+
736
+ def update_trace(
737
+ self,
738
+ id: str,
739
+ *,
740
+ project_name: typing.Optional[str] = OMIT,
741
+ project_id: typing.Optional[str] = OMIT,
742
+ name: typing.Optional[str] = OMIT,
743
+ end_time: typing.Optional[dt.datetime] = OMIT,
744
+ input: typing.Optional[JsonListString] = OMIT,
745
+ output: typing.Optional[JsonListString] = OMIT,
746
+ metadata: typing.Optional[JsonListString] = OMIT,
747
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
748
+ error_info: typing.Optional[ErrorInfo] = OMIT,
749
+ thread_id: typing.Optional[str] = OMIT,
750
+ request_options: typing.Optional[RequestOptions] = None,
751
+ ) -> HttpResponse[None]:
752
+ """
753
+ Update trace by id
754
+
755
+ Parameters
756
+ ----------
757
+ id : str
758
+
759
+ project_name : typing.Optional[str]
760
+ If null and project_id not specified, Default Project is assumed
761
+
762
+ project_id : typing.Optional[str]
763
+ If null and project_name not specified, Default Project is assumed
764
+
765
+ name : typing.Optional[str]
766
+
767
+ end_time : typing.Optional[dt.datetime]
768
+
769
+ input : typing.Optional[JsonListString]
770
+
771
+ output : typing.Optional[JsonListString]
772
+
773
+ metadata : typing.Optional[JsonListString]
774
+
775
+ tags : typing.Optional[typing.Sequence[str]]
776
+
777
+ error_info : typing.Optional[ErrorInfo]
778
+
779
+ thread_id : typing.Optional[str]
780
+
781
+ request_options : typing.Optional[RequestOptions]
782
+ Request-specific configuration.
783
+
784
+ Returns
785
+ -------
786
+ HttpResponse[None]
787
+ """
788
+ _response = self._client_wrapper.httpx_client.request(
789
+ f"v1/private/traces/{jsonable_encoder(id)}",
790
+ method="PATCH",
791
+ json={
792
+ "project_name": project_name,
793
+ "project_id": project_id,
794
+ "name": name,
795
+ "end_time": end_time,
796
+ "input": convert_and_respect_annotation_metadata(
797
+ object_=input, annotation=JsonListString, direction="write"
798
+ ),
799
+ "output": convert_and_respect_annotation_metadata(
800
+ object_=output, annotation=JsonListString, direction="write"
801
+ ),
802
+ "metadata": convert_and_respect_annotation_metadata(
803
+ object_=metadata, annotation=JsonListString, direction="write"
804
+ ),
805
+ "tags": tags,
806
+ "error_info": convert_and_respect_annotation_metadata(
807
+ object_=error_info, annotation=ErrorInfo, direction="write"
808
+ ),
809
+ "thread_id": thread_id,
810
+ },
811
+ headers={
812
+ "content-type": "application/json",
813
+ },
814
+ request_options=request_options,
815
+ omit=OMIT,
816
+ )
817
+ try:
818
+ if 200 <= _response.status_code < 300:
819
+ return HttpResponse(response=_response, data=None)
820
+ _response_json = _response.json()
821
+ except JSONDecodeError:
822
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
823
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
824
+
825
+ def delete_thread_comments(
826
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
827
+ ) -> HttpResponse[None]:
828
+ """
829
+ Delete thread comments
830
+
831
+ Parameters
832
+ ----------
833
+ ids : typing.Sequence[str]
834
+
835
+ request_options : typing.Optional[RequestOptions]
836
+ Request-specific configuration.
837
+
838
+ Returns
839
+ -------
840
+ HttpResponse[None]
841
+ """
842
+ _response = self._client_wrapper.httpx_client.request(
843
+ "v1/private/traces/threads/comments/delete",
844
+ method="POST",
845
+ json={
846
+ "ids": ids,
847
+ },
848
+ headers={
849
+ "content-type": "application/json",
850
+ },
851
+ request_options=request_options,
852
+ omit=OMIT,
853
+ )
854
+ try:
855
+ if 200 <= _response.status_code < 300:
856
+ return HttpResponse(response=_response, data=None)
857
+ _response_json = _response.json()
858
+ except JSONDecodeError:
859
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
860
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
861
+
862
+ def delete_thread_feedback_scores(
863
+ self,
864
+ *,
865
+ project_name: str,
866
+ thread_id: str,
867
+ names: typing.Sequence[str],
868
+ author: typing.Optional[str] = OMIT,
869
+ request_options: typing.Optional[RequestOptions] = None,
870
+ ) -> HttpResponse[None]:
871
+ """
872
+ Delete thread feedback scores
873
+
874
+ Parameters
875
+ ----------
876
+ project_name : str
877
+
878
+ thread_id : str
879
+
880
+ names : typing.Sequence[str]
881
+
882
+ author : typing.Optional[str]
883
+
884
+ request_options : typing.Optional[RequestOptions]
885
+ Request-specific configuration.
886
+
887
+ Returns
888
+ -------
889
+ HttpResponse[None]
890
+ """
891
+ _response = self._client_wrapper.httpx_client.request(
892
+ "v1/private/traces/threads/feedback-scores/delete",
893
+ method="POST",
894
+ json={
895
+ "project_name": project_name,
896
+ "thread_id": thread_id,
897
+ "names": names,
898
+ "author": author,
899
+ },
900
+ headers={
901
+ "content-type": "application/json",
902
+ },
903
+ request_options=request_options,
904
+ omit=OMIT,
905
+ )
906
+ try:
907
+ if 200 <= _response.status_code < 300:
908
+ return HttpResponse(response=_response, data=None)
909
+ _response_json = _response.json()
910
+ except JSONDecodeError:
911
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
912
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
913
+
914
+ def delete_trace_comments(
915
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
916
+ ) -> HttpResponse[None]:
917
+ """
918
+ Delete trace comments
919
+
920
+ Parameters
921
+ ----------
922
+ ids : typing.Sequence[str]
923
+
924
+ request_options : typing.Optional[RequestOptions]
925
+ Request-specific configuration.
926
+
927
+ Returns
928
+ -------
929
+ HttpResponse[None]
930
+ """
931
+ _response = self._client_wrapper.httpx_client.request(
932
+ "v1/private/traces/comments/delete",
933
+ method="POST",
934
+ json={
935
+ "ids": ids,
936
+ },
937
+ headers={
938
+ "content-type": "application/json",
939
+ },
940
+ request_options=request_options,
941
+ omit=OMIT,
942
+ )
943
+ try:
944
+ if 200 <= _response.status_code < 300:
945
+ return HttpResponse(response=_response, data=None)
946
+ _response_json = _response.json()
947
+ except JSONDecodeError:
948
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
949
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
950
+
951
+ def delete_trace_feedback_score(
952
+ self,
953
+ id: str,
954
+ *,
955
+ name: str,
956
+ author: typing.Optional[str] = OMIT,
957
+ request_options: typing.Optional[RequestOptions] = None,
958
+ ) -> HttpResponse[None]:
959
+ """
960
+ Delete trace feedback score
961
+
962
+ Parameters
963
+ ----------
964
+ id : str
965
+
966
+ name : str
967
+
968
+ author : typing.Optional[str]
969
+
970
+ request_options : typing.Optional[RequestOptions]
971
+ Request-specific configuration.
972
+
973
+ Returns
974
+ -------
975
+ HttpResponse[None]
976
+ """
977
+ _response = self._client_wrapper.httpx_client.request(
978
+ f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores/delete",
979
+ method="POST",
980
+ json={
981
+ "name": name,
982
+ "author": author,
983
+ },
984
+ headers={
985
+ "content-type": "application/json",
986
+ },
987
+ request_options=request_options,
988
+ omit=OMIT,
989
+ )
990
+ try:
991
+ if 200 <= _response.status_code < 300:
992
+ return HttpResponse(response=_response, data=None)
993
+ _response_json = _response.json()
994
+ except JSONDecodeError:
995
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
996
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
997
+
998
+ def delete_trace_threads(
999
+ self,
1000
+ *,
1001
+ thread_ids: typing.Sequence[str],
1002
+ project_name: typing.Optional[str] = OMIT,
1003
+ project_id: typing.Optional[str] = OMIT,
1004
+ request_options: typing.Optional[RequestOptions] = None,
1005
+ ) -> HttpResponse[None]:
1006
+ """
1007
+ Delete trace threads
1008
+
1009
+ Parameters
1010
+ ----------
1011
+ thread_ids : typing.Sequence[str]
1012
+
1013
+ project_name : typing.Optional[str]
1014
+ If null, project_id must be provided
1015
+
1016
+ project_id : typing.Optional[str]
1017
+ If null, project_name must be provided
1018
+
1019
+ request_options : typing.Optional[RequestOptions]
1020
+ Request-specific configuration.
1021
+
1022
+ Returns
1023
+ -------
1024
+ HttpResponse[None]
1025
+ """
1026
+ _response = self._client_wrapper.httpx_client.request(
1027
+ "v1/private/traces/threads/delete",
1028
+ method="POST",
1029
+ json={
1030
+ "project_name": project_name,
1031
+ "project_id": project_id,
1032
+ "thread_ids": thread_ids,
1033
+ },
1034
+ headers={
1035
+ "content-type": "application/json",
1036
+ },
1037
+ request_options=request_options,
1038
+ omit=OMIT,
1039
+ )
1040
+ try:
1041
+ if 200 <= _response.status_code < 300:
1042
+ return HttpResponse(response=_response, data=None)
1043
+ _response_json = _response.json()
1044
+ except JSONDecodeError:
1045
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1046
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1047
+
1048
+ def delete_traces(
1049
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
1050
+ ) -> HttpResponse[None]:
1051
+ """
1052
+ Delete traces
1053
+
1054
+ Parameters
1055
+ ----------
1056
+ ids : typing.Sequence[str]
1057
+
1058
+ request_options : typing.Optional[RequestOptions]
1059
+ Request-specific configuration.
1060
+
1061
+ Returns
1062
+ -------
1063
+ HttpResponse[None]
1064
+ """
1065
+ _response = self._client_wrapper.httpx_client.request(
1066
+ "v1/private/traces/delete",
1067
+ method="POST",
1068
+ json={
1069
+ "ids": ids,
1070
+ },
1071
+ headers={
1072
+ "content-type": "application/json",
1073
+ },
1074
+ request_options=request_options,
1075
+ omit=OMIT,
1076
+ )
1077
+ try:
1078
+ if 200 <= _response.status_code < 300:
1079
+ return HttpResponse(response=_response, data=None)
1080
+ _response_json = _response.json()
1081
+ except JSONDecodeError:
1082
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1083
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1084
+
1085
+ def find_feedback_score_names_2(
1086
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
1087
+ ) -> HttpResponse[typing.List[str]]:
1088
+ """
1089
+ Find Feedback Score names
1090
+
1091
+ Parameters
1092
+ ----------
1093
+ project_id : typing.Optional[str]
1094
+
1095
+ request_options : typing.Optional[RequestOptions]
1096
+ Request-specific configuration.
1097
+
1098
+ Returns
1099
+ -------
1100
+ HttpResponse[typing.List[str]]
1101
+ Feedback Scores resource
1102
+ """
1103
+ _response = self._client_wrapper.httpx_client.request(
1104
+ "v1/private/traces/feedback-scores/names",
1105
+ method="GET",
1106
+ params={
1107
+ "project_id": project_id,
1108
+ },
1109
+ request_options=request_options,
1110
+ )
1111
+ try:
1112
+ if 200 <= _response.status_code < 300:
1113
+ _data = typing.cast(
1114
+ typing.List[str],
1115
+ parse_obj_as(
1116
+ type_=typing.List[str], # type: ignore
1117
+ object_=_response.json(),
1118
+ ),
1119
+ )
1120
+ return HttpResponse(response=_response, data=_data)
1121
+ _response_json = _response.json()
1122
+ except JSONDecodeError:
1123
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1124
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1125
+
1126
+ def find_trace_threads_feedback_score_names(
1127
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
1128
+ ) -> HttpResponse[typing.List[str]]:
1129
+ """
1130
+ Find Trace Threads Feedback Score names
1131
+
1132
+ Parameters
1133
+ ----------
1134
+ project_id : typing.Optional[str]
1135
+
1136
+ request_options : typing.Optional[RequestOptions]
1137
+ Request-specific configuration.
1138
+
1139
+ Returns
1140
+ -------
1141
+ HttpResponse[typing.List[str]]
1142
+ Find Trace Threads Feedback Score names
1143
+ """
1144
+ _response = self._client_wrapper.httpx_client.request(
1145
+ "v1/private/traces/threads/feedback-scores/names",
1146
+ method="GET",
1147
+ params={
1148
+ "project_id": project_id,
1149
+ },
1150
+ request_options=request_options,
1151
+ )
1152
+ try:
1153
+ if 200 <= _response.status_code < 300:
1154
+ _data = typing.cast(
1155
+ typing.List[str],
1156
+ parse_obj_as(
1157
+ type_=typing.List[str], # type: ignore
1158
+ object_=_response.json(),
1159
+ ),
1160
+ )
1161
+ return HttpResponse(response=_response, data=_data)
1162
+ _response_json = _response.json()
1163
+ except JSONDecodeError:
1164
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1165
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1166
+
1167
+ def get_trace_stats(
1168
+ self,
1169
+ *,
1170
+ project_id: typing.Optional[str] = None,
1171
+ project_name: typing.Optional[str] = None,
1172
+ filters: typing.Optional[str] = None,
1173
+ from_time: typing.Optional[dt.datetime] = None,
1174
+ to_time: typing.Optional[dt.datetime] = None,
1175
+ request_options: typing.Optional[RequestOptions] = None,
1176
+ ) -> HttpResponse[ProjectStatsPublic]:
1177
+ """
1178
+ Get trace stats
1179
+
1180
+ Parameters
1181
+ ----------
1182
+ project_id : typing.Optional[str]
1183
+
1184
+ project_name : typing.Optional[str]
1185
+
1186
+ filters : typing.Optional[str]
1187
+
1188
+ from_time : typing.Optional[dt.datetime]
1189
+
1190
+ to_time : typing.Optional[dt.datetime]
1191
+
1192
+ request_options : typing.Optional[RequestOptions]
1193
+ Request-specific configuration.
1194
+
1195
+ Returns
1196
+ -------
1197
+ HttpResponse[ProjectStatsPublic]
1198
+ Trace stats resource
1199
+ """
1200
+ _response = self._client_wrapper.httpx_client.request(
1201
+ "v1/private/traces/stats",
1202
+ method="GET",
1203
+ params={
1204
+ "project_id": project_id,
1205
+ "project_name": project_name,
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,
1209
+ },
1210
+ request_options=request_options,
1211
+ )
1212
+ try:
1213
+ if 200 <= _response.status_code < 300:
1214
+ _data = typing.cast(
1215
+ ProjectStatsPublic,
1216
+ parse_obj_as(
1217
+ type_=ProjectStatsPublic, # type: ignore
1218
+ object_=_response.json(),
1219
+ ),
1220
+ )
1221
+ return HttpResponse(response=_response, data=_data)
1222
+ _response_json = _response.json()
1223
+ except JSONDecodeError:
1224
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1225
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1226
+
1227
+ def get_thread_comment(
1228
+ self, comment_id: str, thread_id: str, *, request_options: typing.Optional[RequestOptions] = None
1229
+ ) -> HttpResponse[Comment]:
1230
+ """
1231
+ Get thread comment
1232
+
1233
+ Parameters
1234
+ ----------
1235
+ comment_id : str
1236
+
1237
+ thread_id : str
1238
+
1239
+ request_options : typing.Optional[RequestOptions]
1240
+ Request-specific configuration.
1241
+
1242
+ Returns
1243
+ -------
1244
+ HttpResponse[Comment]
1245
+ Comment resource
1246
+ """
1247
+ _response = self._client_wrapper.httpx_client.request(
1248
+ f"v1/private/traces/threads/{jsonable_encoder(thread_id)}/comments/{jsonable_encoder(comment_id)}",
1249
+ method="GET",
1250
+ request_options=request_options,
1251
+ )
1252
+ try:
1253
+ if 200 <= _response.status_code < 300:
1254
+ _data = typing.cast(
1255
+ Comment,
1256
+ parse_obj_as(
1257
+ type_=Comment, # type: ignore
1258
+ object_=_response.json(),
1259
+ ),
1260
+ )
1261
+ return HttpResponse(response=_response, data=_data)
1262
+ if _response.status_code == 404:
1263
+ raise NotFoundError(
1264
+ headers=dict(_response.headers),
1265
+ body=typing.cast(
1266
+ typing.Optional[typing.Any],
1267
+ parse_obj_as(
1268
+ type_=typing.Optional[typing.Any], # type: ignore
1269
+ object_=_response.json(),
1270
+ ),
1271
+ ),
1272
+ )
1273
+ _response_json = _response.json()
1274
+ except JSONDecodeError:
1275
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1276
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
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
+
1338
+ def get_trace_comment(
1339
+ self, comment_id: str, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
1340
+ ) -> HttpResponse[Comment]:
1341
+ """
1342
+ Get trace comment
1343
+
1344
+ Parameters
1345
+ ----------
1346
+ comment_id : str
1347
+
1348
+ trace_id : str
1349
+
1350
+ request_options : typing.Optional[RequestOptions]
1351
+ Request-specific configuration.
1352
+
1353
+ Returns
1354
+ -------
1355
+ HttpResponse[Comment]
1356
+ Comment resource
1357
+ """
1358
+ _response = self._client_wrapper.httpx_client.request(
1359
+ f"v1/private/traces/{jsonable_encoder(trace_id)}/comments/{jsonable_encoder(comment_id)}",
1360
+ method="GET",
1361
+ request_options=request_options,
1362
+ )
1363
+ try:
1364
+ if 200 <= _response.status_code < 300:
1365
+ _data = typing.cast(
1366
+ Comment,
1367
+ parse_obj_as(
1368
+ type_=Comment, # type: ignore
1369
+ object_=_response.json(),
1370
+ ),
1371
+ )
1372
+ return HttpResponse(response=_response, data=_data)
1373
+ if _response.status_code == 404:
1374
+ raise NotFoundError(
1375
+ headers=dict(_response.headers),
1376
+ body=typing.cast(
1377
+ typing.Optional[typing.Any],
1378
+ parse_obj_as(
1379
+ type_=typing.Optional[typing.Any], # type: ignore
1380
+ object_=_response.json(),
1381
+ ),
1382
+ ),
1383
+ )
1384
+ _response_json = _response.json()
1385
+ except JSONDecodeError:
1386
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1387
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1388
+
1389
+ def get_trace_thread(
1390
+ self,
1391
+ *,
1392
+ thread_id: str,
1393
+ project_name: typing.Optional[str] = OMIT,
1394
+ project_id: typing.Optional[str] = OMIT,
1395
+ truncate: typing.Optional[bool] = OMIT,
1396
+ request_options: typing.Optional[RequestOptions] = None,
1397
+ ) -> HttpResponse[TraceThread]:
1398
+ """
1399
+ Get trace thread
1400
+
1401
+ Parameters
1402
+ ----------
1403
+ thread_id : str
1404
+
1405
+ project_name : typing.Optional[str]
1406
+
1407
+ project_id : typing.Optional[str]
1408
+
1409
+ truncate : typing.Optional[bool]
1410
+
1411
+ request_options : typing.Optional[RequestOptions]
1412
+ Request-specific configuration.
1413
+
1414
+ Returns
1415
+ -------
1416
+ HttpResponse[TraceThread]
1417
+ Trace thread resource
1418
+ """
1419
+ _response = self._client_wrapper.httpx_client.request(
1420
+ "v1/private/traces/threads/retrieve",
1421
+ method="POST",
1422
+ json={
1423
+ "project_name": project_name,
1424
+ "project_id": project_id,
1425
+ "thread_id": thread_id,
1426
+ "truncate": truncate,
1427
+ },
1428
+ headers={
1429
+ "content-type": "application/json",
1430
+ },
1431
+ request_options=request_options,
1432
+ omit=OMIT,
1433
+ )
1434
+ try:
1435
+ if 200 <= _response.status_code < 300:
1436
+ _data = typing.cast(
1437
+ TraceThread,
1438
+ parse_obj_as(
1439
+ type_=TraceThread, # type: ignore
1440
+ object_=_response.json(),
1441
+ ),
1442
+ )
1443
+ return HttpResponse(response=_response, data=_data)
1444
+ if _response.status_code == 404:
1445
+ raise NotFoundError(
1446
+ headers=dict(_response.headers),
1447
+ body=typing.cast(
1448
+ typing.Optional[typing.Any],
1449
+ parse_obj_as(
1450
+ type_=typing.Optional[typing.Any], # type: ignore
1451
+ object_=_response.json(),
1452
+ ),
1453
+ ),
1454
+ )
1455
+ _response_json = _response.json()
1456
+ except JSONDecodeError:
1457
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1458
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1459
+
1460
+ def get_trace_threads(
1461
+ self,
1462
+ *,
1463
+ page: typing.Optional[int] = None,
1464
+ size: typing.Optional[int] = None,
1465
+ project_name: typing.Optional[str] = None,
1466
+ project_id: typing.Optional[str] = None,
1467
+ truncate: typing.Optional[bool] = None,
1468
+ strip_attachments: typing.Optional[bool] = None,
1469
+ filters: typing.Optional[str] = None,
1470
+ sorting: typing.Optional[str] = None,
1471
+ from_time: typing.Optional[dt.datetime] = None,
1472
+ to_time: typing.Optional[dt.datetime] = None,
1473
+ request_options: typing.Optional[RequestOptions] = None,
1474
+ ) -> HttpResponse[TraceThreadPage]:
1475
+ """
1476
+ Get trace threads
1477
+
1478
+ Parameters
1479
+ ----------
1480
+ page : typing.Optional[int]
1481
+
1482
+ size : typing.Optional[int]
1483
+
1484
+ project_name : typing.Optional[str]
1485
+
1486
+ project_id : typing.Optional[str]
1487
+
1488
+ truncate : typing.Optional[bool]
1489
+
1490
+ strip_attachments : typing.Optional[bool]
1491
+
1492
+ filters : typing.Optional[str]
1493
+
1494
+ sorting : typing.Optional[str]
1495
+
1496
+ from_time : typing.Optional[dt.datetime]
1497
+
1498
+ to_time : typing.Optional[dt.datetime]
1499
+
1500
+ request_options : typing.Optional[RequestOptions]
1501
+ Request-specific configuration.
1502
+
1503
+ Returns
1504
+ -------
1505
+ HttpResponse[TraceThreadPage]
1506
+ Trace threads resource
1507
+ """
1508
+ _response = self._client_wrapper.httpx_client.request(
1509
+ "v1/private/traces/threads",
1510
+ method="GET",
1511
+ params={
1512
+ "page": page,
1513
+ "size": size,
1514
+ "project_name": project_name,
1515
+ "project_id": project_id,
1516
+ "truncate": truncate,
1517
+ "strip_attachments": strip_attachments,
1518
+ "filters": filters,
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,
1522
+ },
1523
+ request_options=request_options,
1524
+ )
1525
+ try:
1526
+ if 200 <= _response.status_code < 300:
1527
+ _data = typing.cast(
1528
+ TraceThreadPage,
1529
+ parse_obj_as(
1530
+ type_=TraceThreadPage, # type: ignore
1531
+ object_=_response.json(),
1532
+ ),
1533
+ )
1534
+ return HttpResponse(response=_response, data=_data)
1535
+ _response_json = _response.json()
1536
+ except JSONDecodeError:
1537
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1538
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1539
+
1540
+ def open_trace_thread(
1541
+ self,
1542
+ *,
1543
+ thread_id: str,
1544
+ project_name: typing.Optional[str] = OMIT,
1545
+ project_id: typing.Optional[str] = OMIT,
1546
+ truncate: typing.Optional[bool] = OMIT,
1547
+ request_options: typing.Optional[RequestOptions] = None,
1548
+ ) -> HttpResponse[None]:
1549
+ """
1550
+ Open trace thread
1551
+
1552
+ Parameters
1553
+ ----------
1554
+ thread_id : str
1555
+
1556
+ project_name : typing.Optional[str]
1557
+
1558
+ project_id : typing.Optional[str]
1559
+
1560
+ truncate : typing.Optional[bool]
1561
+
1562
+ request_options : typing.Optional[RequestOptions]
1563
+ Request-specific configuration.
1564
+
1565
+ Returns
1566
+ -------
1567
+ HttpResponse[None]
1568
+ """
1569
+ _response = self._client_wrapper.httpx_client.request(
1570
+ "v1/private/traces/threads/open",
1571
+ method="PUT",
1572
+ json={
1573
+ "project_name": project_name,
1574
+ "project_id": project_id,
1575
+ "thread_id": thread_id,
1576
+ "truncate": truncate,
1577
+ },
1578
+ headers={
1579
+ "content-type": "application/json",
1580
+ },
1581
+ request_options=request_options,
1582
+ omit=OMIT,
1583
+ )
1584
+ try:
1585
+ if 200 <= _response.status_code < 300:
1586
+ return HttpResponse(response=_response, data=None)
1587
+ _response_json = _response.json()
1588
+ except JSONDecodeError:
1589
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1590
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1591
+
1592
+ def score_batch_of_threads(
1593
+ self,
1594
+ *,
1595
+ scores: typing.Sequence[FeedbackScoreBatchItemThread],
1596
+ request_options: typing.Optional[RequestOptions] = None,
1597
+ ) -> HttpResponse[None]:
1598
+ """
1599
+ Batch feedback scoring for threads
1600
+
1601
+ Parameters
1602
+ ----------
1603
+ scores : typing.Sequence[FeedbackScoreBatchItemThread]
1604
+
1605
+ request_options : typing.Optional[RequestOptions]
1606
+ Request-specific configuration.
1607
+
1608
+ Returns
1609
+ -------
1610
+ HttpResponse[None]
1611
+ """
1612
+ _response = self._client_wrapper.httpx_client.request(
1613
+ "v1/private/traces/threads/feedback-scores",
1614
+ method="PUT",
1615
+ json={
1616
+ "scores": convert_and_respect_annotation_metadata(
1617
+ object_=scores, annotation=typing.Sequence[FeedbackScoreBatchItemThread], direction="write"
1618
+ ),
1619
+ },
1620
+ headers={
1621
+ "content-type": "application/json",
1622
+ },
1623
+ request_options=request_options,
1624
+ omit=OMIT,
1625
+ )
1626
+ try:
1627
+ if 200 <= _response.status_code < 300:
1628
+ return HttpResponse(response=_response, data=None)
1629
+ _response_json = _response.json()
1630
+ except JSONDecodeError:
1631
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1632
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1633
+
1634
+ def score_batch_of_traces(
1635
+ self,
1636
+ *,
1637
+ scores: typing.Sequence[FeedbackScoreBatchItem],
1638
+ request_options: typing.Optional[RequestOptions] = None,
1639
+ ) -> HttpResponse[None]:
1640
+ """
1641
+ Batch feedback scoring for traces
1642
+
1643
+ Parameters
1644
+ ----------
1645
+ scores : typing.Sequence[FeedbackScoreBatchItem]
1646
+
1647
+ request_options : typing.Optional[RequestOptions]
1648
+ Request-specific configuration.
1649
+
1650
+ Returns
1651
+ -------
1652
+ HttpResponse[None]
1653
+ """
1654
+ _response = self._client_wrapper.httpx_client.request(
1655
+ "v1/private/traces/feedback-scores",
1656
+ method="PUT",
1657
+ json={
1658
+ "scores": convert_and_respect_annotation_metadata(
1659
+ object_=scores, annotation=typing.Sequence[FeedbackScoreBatchItem], direction="write"
1660
+ ),
1661
+ },
1662
+ headers={
1663
+ "content-type": "application/json",
1664
+ },
1665
+ request_options=request_options,
1666
+ omit=OMIT,
1667
+ )
1668
+ try:
1669
+ if 200 <= _response.status_code < 300:
1670
+ return HttpResponse(response=_response, data=None)
1671
+ _response_json = _response.json()
1672
+ except JSONDecodeError:
1673
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1674
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1675
+
1676
+ @contextlib.contextmanager
1677
+ def search_trace_threads(
1678
+ self,
1679
+ *,
1680
+ project_name: typing.Optional[str] = OMIT,
1681
+ project_id: typing.Optional[str] = OMIT,
1682
+ filters: typing.Optional[typing.Sequence[TraceThreadFilter]] = OMIT,
1683
+ last_retrieved_thread_model_id: typing.Optional[str] = OMIT,
1684
+ limit: typing.Optional[int] = OMIT,
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,
1689
+ request_options: typing.Optional[RequestOptions] = None,
1690
+ ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
1691
+ """
1692
+ Search trace threads
1693
+
1694
+ Parameters
1695
+ ----------
1696
+ project_name : typing.Optional[str]
1697
+
1698
+ project_id : typing.Optional[str]
1699
+
1700
+ filters : typing.Optional[typing.Sequence[TraceThreadFilter]]
1701
+
1702
+ last_retrieved_thread_model_id : typing.Optional[str]
1703
+
1704
+ limit : typing.Optional[int]
1705
+ Max number of trace thread to be streamed
1706
+
1707
+ truncate : typing.Optional[bool]
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'.
1718
+
1719
+ request_options : typing.Optional[RequestOptions]
1720
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
1721
+
1722
+ Returns
1723
+ -------
1724
+ typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
1725
+ Trace threads stream or error during process
1726
+ """
1727
+ with self._client_wrapper.httpx_client.stream(
1728
+ "v1/private/traces/threads/search",
1729
+ method="POST",
1730
+ json={
1731
+ "project_name": project_name,
1732
+ "project_id": project_id,
1733
+ "filters": convert_and_respect_annotation_metadata(
1734
+ object_=filters, annotation=typing.Sequence[TraceThreadFilter], direction="write"
1735
+ ),
1736
+ "last_retrieved_thread_model_id": last_retrieved_thread_model_id,
1737
+ "limit": limit,
1738
+ "truncate": truncate,
1739
+ "strip_attachments": strip_attachments,
1740
+ "from_time": from_time,
1741
+ "to_time": to_time,
1742
+ },
1743
+ headers={
1744
+ "content-type": "application/json",
1745
+ },
1746
+ request_options=request_options,
1747
+ omit=OMIT,
1748
+ ) as _response:
1749
+
1750
+ def stream() -> HttpResponse[typing.Iterator[bytes]]:
1751
+ try:
1752
+ if 200 <= _response.status_code < 300:
1753
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
1754
+ return HttpResponse(
1755
+ response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
1756
+ )
1757
+ _response.read()
1758
+ if _response.status_code == 400:
1759
+ raise BadRequestError(
1760
+ headers=dict(_response.headers),
1761
+ body=typing.cast(
1762
+ typing.Optional[typing.Any],
1763
+ parse_obj_as(
1764
+ type_=typing.Optional[typing.Any], # type: ignore
1765
+ object_=_response.json(),
1766
+ ),
1767
+ ),
1768
+ )
1769
+ _response_json = _response.json()
1770
+ except JSONDecodeError:
1771
+ raise ApiError(
1772
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
1773
+ )
1774
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1775
+
1776
+ yield stream()
1777
+
1778
+ @contextlib.contextmanager
1779
+ def search_traces(
1780
+ self,
1781
+ *,
1782
+ project_name: typing.Optional[str] = OMIT,
1783
+ project_id: typing.Optional[str] = OMIT,
1784
+ filters: typing.Optional[typing.Sequence[TraceFilterPublic]] = OMIT,
1785
+ last_retrieved_id: typing.Optional[str] = OMIT,
1786
+ limit: typing.Optional[int] = OMIT,
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,
1791
+ request_options: typing.Optional[RequestOptions] = None,
1792
+ ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
1793
+ """
1794
+ Search traces
1795
+
1796
+ Parameters
1797
+ ----------
1798
+ project_name : typing.Optional[str]
1799
+
1800
+ project_id : typing.Optional[str]
1801
+
1802
+ filters : typing.Optional[typing.Sequence[TraceFilterPublic]]
1803
+
1804
+ last_retrieved_id : typing.Optional[str]
1805
+
1806
+ limit : typing.Optional[int]
1807
+ Max number of traces to be streamed
1808
+
1809
+ truncate : typing.Optional[bool]
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'.
1820
+
1821
+ request_options : typing.Optional[RequestOptions]
1822
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
1823
+
1824
+ Returns
1825
+ -------
1826
+ typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
1827
+ Traces stream or error during process
1828
+ """
1829
+ with self._client_wrapper.httpx_client.stream(
1830
+ "v1/private/traces/search",
1831
+ method="POST",
1832
+ json={
1833
+ "project_name": project_name,
1834
+ "project_id": project_id,
1835
+ "filters": convert_and_respect_annotation_metadata(
1836
+ object_=filters, annotation=typing.Sequence[TraceFilterPublic], direction="write"
1837
+ ),
1838
+ "last_retrieved_id": last_retrieved_id,
1839
+ "limit": limit,
1840
+ "truncate": truncate,
1841
+ "strip_attachments": strip_attachments,
1842
+ "from_time": from_time,
1843
+ "to_time": to_time,
1844
+ },
1845
+ headers={
1846
+ "content-type": "application/json",
1847
+ },
1848
+ request_options=request_options,
1849
+ omit=OMIT,
1850
+ ) as _response:
1851
+
1852
+ def stream() -> HttpResponse[typing.Iterator[bytes]]:
1853
+ try:
1854
+ if 200 <= _response.status_code < 300:
1855
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
1856
+ return HttpResponse(
1857
+ response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
1858
+ )
1859
+ _response.read()
1860
+ if _response.status_code == 400:
1861
+ raise BadRequestError(
1862
+ headers=dict(_response.headers),
1863
+ body=typing.cast(
1864
+ typing.Optional[typing.Any],
1865
+ parse_obj_as(
1866
+ type_=typing.Optional[typing.Any], # type: ignore
1867
+ object_=_response.json(),
1868
+ ),
1869
+ ),
1870
+ )
1871
+ if _response.status_code == 401:
1872
+ raise UnauthorizedError(
1873
+ headers=dict(_response.headers),
1874
+ body=typing.cast(
1875
+ typing.Optional[typing.Any],
1876
+ parse_obj_as(
1877
+ type_=typing.Optional[typing.Any], # type: ignore
1878
+ object_=_response.json(),
1879
+ ),
1880
+ ),
1881
+ )
1882
+ _response_json = _response.json()
1883
+ except JSONDecodeError:
1884
+ raise ApiError(
1885
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
1886
+ )
1887
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1888
+
1889
+ yield stream()
1890
+
1891
+ def update_thread(
1892
+ self,
1893
+ thread_model_id: str,
1894
+ *,
1895
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1896
+ request_options: typing.Optional[RequestOptions] = None,
1897
+ ) -> HttpResponse[None]:
1898
+ """
1899
+ Update thread
1900
+
1901
+ Parameters
1902
+ ----------
1903
+ thread_model_id : str
1904
+
1905
+ tags : typing.Optional[typing.Sequence[str]]
1906
+
1907
+ request_options : typing.Optional[RequestOptions]
1908
+ Request-specific configuration.
1909
+
1910
+ Returns
1911
+ -------
1912
+ HttpResponse[None]
1913
+ """
1914
+ _response = self._client_wrapper.httpx_client.request(
1915
+ f"v1/private/traces/threads/{jsonable_encoder(thread_model_id)}",
1916
+ method="PATCH",
1917
+ json={
1918
+ "tags": tags,
1919
+ },
1920
+ headers={
1921
+ "content-type": "application/json",
1922
+ },
1923
+ request_options=request_options,
1924
+ omit=OMIT,
1925
+ )
1926
+ try:
1927
+ if 200 <= _response.status_code < 300:
1928
+ return HttpResponse(response=_response, data=None)
1929
+ if _response.status_code == 404:
1930
+ raise NotFoundError(
1931
+ headers=dict(_response.headers),
1932
+ body=typing.cast(
1933
+ typing.Optional[typing.Any],
1934
+ parse_obj_as(
1935
+ type_=typing.Optional[typing.Any], # type: ignore
1936
+ object_=_response.json(),
1937
+ ),
1938
+ ),
1939
+ )
1940
+ _response_json = _response.json()
1941
+ except JSONDecodeError:
1942
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1943
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1944
+
1945
+ def update_thread_comment(
1946
+ self,
1947
+ comment_id: str,
1948
+ *,
1949
+ text: str,
1950
+ id: typing.Optional[str] = OMIT,
1951
+ created_at: typing.Optional[dt.datetime] = OMIT,
1952
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
1953
+ created_by: typing.Optional[str] = OMIT,
1954
+ last_updated_by: typing.Optional[str] = OMIT,
1955
+ request_options: typing.Optional[RequestOptions] = None,
1956
+ ) -> HttpResponse[None]:
1957
+ """
1958
+ Update thread comment by id
1959
+
1960
+ Parameters
1961
+ ----------
1962
+ comment_id : str
1963
+
1964
+ text : str
1965
+
1966
+ id : typing.Optional[str]
1967
+
1968
+ created_at : typing.Optional[dt.datetime]
1969
+
1970
+ last_updated_at : typing.Optional[dt.datetime]
1971
+
1972
+ created_by : typing.Optional[str]
1973
+
1974
+ last_updated_by : typing.Optional[str]
1975
+
1976
+ request_options : typing.Optional[RequestOptions]
1977
+ Request-specific configuration.
1978
+
1979
+ Returns
1980
+ -------
1981
+ HttpResponse[None]
1982
+ """
1983
+ _response = self._client_wrapper.httpx_client.request(
1984
+ f"v1/private/traces/threads/comments/{jsonable_encoder(comment_id)}",
1985
+ method="PATCH",
1986
+ json={
1987
+ "id": id,
1988
+ "text": text,
1989
+ "created_at": created_at,
1990
+ "last_updated_at": last_updated_at,
1991
+ "created_by": created_by,
1992
+ "last_updated_by": last_updated_by,
1993
+ },
1994
+ headers={
1995
+ "content-type": "application/json",
1996
+ },
1997
+ request_options=request_options,
1998
+ omit=OMIT,
1999
+ )
2000
+ try:
2001
+ if 200 <= _response.status_code < 300:
2002
+ return HttpResponse(response=_response, data=None)
2003
+ if _response.status_code == 404:
2004
+ raise NotFoundError(
2005
+ headers=dict(_response.headers),
2006
+ body=typing.cast(
2007
+ typing.Optional[typing.Any],
2008
+ parse_obj_as(
2009
+ type_=typing.Optional[typing.Any], # type: ignore
2010
+ object_=_response.json(),
2011
+ ),
2012
+ ),
2013
+ )
2014
+ _response_json = _response.json()
2015
+ except JSONDecodeError:
2016
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2017
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2018
+
2019
+ def update_trace_comment(
2020
+ self,
2021
+ comment_id: str,
2022
+ *,
2023
+ text: str,
2024
+ id: typing.Optional[str] = OMIT,
2025
+ created_at: typing.Optional[dt.datetime] = OMIT,
2026
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
2027
+ created_by: typing.Optional[str] = OMIT,
2028
+ last_updated_by: typing.Optional[str] = OMIT,
2029
+ request_options: typing.Optional[RequestOptions] = None,
2030
+ ) -> HttpResponse[None]:
2031
+ """
2032
+ Update trace comment by id
2033
+
2034
+ Parameters
2035
+ ----------
2036
+ comment_id : str
2037
+
2038
+ text : str
2039
+
2040
+ id : typing.Optional[str]
2041
+
2042
+ created_at : typing.Optional[dt.datetime]
2043
+
2044
+ last_updated_at : typing.Optional[dt.datetime]
2045
+
2046
+ created_by : typing.Optional[str]
2047
+
2048
+ last_updated_by : typing.Optional[str]
2049
+
2050
+ request_options : typing.Optional[RequestOptions]
2051
+ Request-specific configuration.
2052
+
2053
+ Returns
2054
+ -------
2055
+ HttpResponse[None]
2056
+ """
2057
+ _response = self._client_wrapper.httpx_client.request(
2058
+ f"v1/private/traces/comments/{jsonable_encoder(comment_id)}",
2059
+ method="PATCH",
2060
+ json={
2061
+ "id": id,
2062
+ "text": text,
2063
+ "created_at": created_at,
2064
+ "last_updated_at": last_updated_at,
2065
+ "created_by": created_by,
2066
+ "last_updated_by": last_updated_by,
2067
+ },
2068
+ headers={
2069
+ "content-type": "application/json",
2070
+ },
2071
+ request_options=request_options,
2072
+ omit=OMIT,
2073
+ )
2074
+ try:
2075
+ if 200 <= _response.status_code < 300:
2076
+ return HttpResponse(response=_response, data=None)
2077
+ if _response.status_code == 404:
2078
+ raise NotFoundError(
2079
+ headers=dict(_response.headers),
2080
+ body=typing.cast(
2081
+ typing.Optional[typing.Any],
2082
+ parse_obj_as(
2083
+ type_=typing.Optional[typing.Any], # type: ignore
2084
+ object_=_response.json(),
2085
+ ),
2086
+ ),
2087
+ )
2088
+ _response_json = _response.json()
2089
+ except JSONDecodeError:
2090
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2091
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2092
+
2093
+
2094
+ class AsyncRawTracesClient:
2095
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
2096
+ self._client_wrapper = client_wrapper
2097
+
2098
+ async def add_thread_comment(
2099
+ self,
2100
+ id_: str,
2101
+ *,
2102
+ text: str,
2103
+ id: typing.Optional[str] = OMIT,
2104
+ created_at: typing.Optional[dt.datetime] = OMIT,
2105
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
2106
+ created_by: typing.Optional[str] = OMIT,
2107
+ last_updated_by: typing.Optional[str] = OMIT,
2108
+ request_options: typing.Optional[RequestOptions] = None,
2109
+ ) -> AsyncHttpResponse[None]:
2110
+ """
2111
+ Add thread comment
2112
+
2113
+ Parameters
2114
+ ----------
2115
+ id_ : str
2116
+
2117
+ text : str
2118
+
2119
+ id : typing.Optional[str]
2120
+
2121
+ created_at : typing.Optional[dt.datetime]
2122
+
2123
+ last_updated_at : typing.Optional[dt.datetime]
2124
+
2125
+ created_by : typing.Optional[str]
2126
+
2127
+ last_updated_by : typing.Optional[str]
2128
+
2129
+ request_options : typing.Optional[RequestOptions]
2130
+ Request-specific configuration.
2131
+
2132
+ Returns
2133
+ -------
2134
+ AsyncHttpResponse[None]
2135
+ """
2136
+ _response = await self._client_wrapper.httpx_client.request(
2137
+ f"v1/private/traces/threads/{jsonable_encoder(id_)}/comments",
2138
+ method="POST",
2139
+ json={
2140
+ "id": id,
2141
+ "text": text,
2142
+ "created_at": created_at,
2143
+ "last_updated_at": last_updated_at,
2144
+ "created_by": created_by,
2145
+ "last_updated_by": last_updated_by,
2146
+ },
2147
+ headers={
2148
+ "content-type": "application/json",
2149
+ },
2150
+ request_options=request_options,
2151
+ omit=OMIT,
2152
+ )
2153
+ try:
2154
+ if 200 <= _response.status_code < 300:
2155
+ return AsyncHttpResponse(response=_response, data=None)
2156
+ _response_json = _response.json()
2157
+ except JSONDecodeError:
2158
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2159
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2160
+
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(
2345
+ self,
2346
+ *,
2347
+ ids: typing.Sequence[str],
2348
+ update: TraceUpdate,
2349
+ merge_tags: typing.Optional[bool] = OMIT,
2350
+ request_options: typing.Optional[RequestOptions] = None,
2351
+ ) -> AsyncHttpResponse[None]:
2352
+ """
2353
+ Update multiple traces
2354
+
2355
+ Parameters
2356
+ ----------
2357
+ ids : typing.Sequence[str]
2358
+ List of trace IDs to update (max 1000)
2359
+
2360
+ update : TraceUpdate
2361
+
2362
+ merge_tags : typing.Optional[bool]
2363
+ If true, merge tags with existing tags instead of replacing them. Default: false
2364
+
2365
+ request_options : typing.Optional[RequestOptions]
2366
+ Request-specific configuration.
2367
+
2368
+ Returns
2369
+ -------
2370
+ AsyncHttpResponse[None]
2371
+ """
2372
+ _response = await self._client_wrapper.httpx_client.request(
2373
+ "v1/private/traces/batch",
2374
+ method="PATCH",
2375
+ json={
2376
+ "ids": ids,
2377
+ "update": convert_and_respect_annotation_metadata(
2378
+ object_=update, annotation=TraceUpdate, direction="write"
2379
+ ),
2380
+ "merge_tags": merge_tags,
2381
+ },
2382
+ headers={
2383
+ "content-type": "application/json",
2384
+ },
2385
+ request_options=request_options,
2386
+ omit=OMIT,
2387
+ )
2388
+ try:
2389
+ if 200 <= _response.status_code < 300:
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
+ )
2402
+ _response_json = _response.json()
2403
+ except JSONDecodeError:
2404
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2405
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2406
+
2407
+ async def batch_update_threads(
2408
+ self,
2409
+ *,
2410
+ ids: typing.Sequence[str],
2411
+ update: TraceThreadUpdate,
2412
+ merge_tags: typing.Optional[bool] = OMIT,
2413
+ request_options: typing.Optional[RequestOptions] = None,
2414
+ ) -> AsyncHttpResponse[None]:
2415
+ """
2416
+ Update multiple threads
2417
+
2418
+ Parameters
2419
+ ----------
2420
+ ids : typing.Sequence[str]
2421
+ List of thread model IDs to update (max 1000)
2422
+
2423
+ update : TraceThreadUpdate
2424
+
2425
+ merge_tags : typing.Optional[bool]
2426
+ If true, merge tags with existing tags instead of replacing them. Default: false
2427
+
2428
+ request_options : typing.Optional[RequestOptions]
2429
+ Request-specific configuration.
2430
+
2431
+ Returns
2432
+ -------
2433
+ AsyncHttpResponse[None]
2434
+ """
2435
+ _response = await self._client_wrapper.httpx_client.request(
2436
+ "v1/private/traces/threads/batch",
2437
+ method="PATCH",
2438
+ json={
2439
+ "ids": ids,
2440
+ "update": convert_and_respect_annotation_metadata(
2441
+ object_=update, annotation=TraceThreadUpdate, direction="write"
2442
+ ),
2443
+ "merge_tags": merge_tags,
2444
+ },
2445
+ headers={
2446
+ "content-type": "application/json",
2447
+ },
2448
+ request_options=request_options,
2449
+ omit=OMIT,
2450
+ )
2451
+ try:
2452
+ if 200 <= _response.status_code < 300:
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
+ )
2465
+ _response_json = _response.json()
2466
+ except JSONDecodeError:
2467
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2468
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2469
+
2470
+ async def close_trace_thread(
2471
+ self,
2472
+ *,
2473
+ project_name: typing.Optional[str] = OMIT,
2474
+ project_id: typing.Optional[str] = OMIT,
2475
+ thread_id: typing.Optional[str] = OMIT,
2476
+ thread_ids: typing.Optional[typing.Sequence[str]] = OMIT,
2477
+ request_options: typing.Optional[RequestOptions] = None,
2478
+ ) -> AsyncHttpResponse[None]:
2479
+ """
2480
+ Close one or multiple trace threads. Supports both single thread_id and multiple thread_ids for batch operations.
2481
+
2482
+ Parameters
2483
+ ----------
2484
+ project_name : typing.Optional[str]
2485
+
2486
+ project_id : typing.Optional[str]
2487
+
2488
+ thread_id : typing.Optional[str]
2489
+
2490
+ thread_ids : typing.Optional[typing.Sequence[str]]
2491
+
2492
+ request_options : typing.Optional[RequestOptions]
2493
+ Request-specific configuration.
2494
+
2495
+ Returns
2496
+ -------
2497
+ AsyncHttpResponse[None]
2498
+ """
2499
+ _response = await self._client_wrapper.httpx_client.request(
2500
+ "v1/private/traces/threads/close",
2501
+ method="PUT",
2502
+ json={
2503
+ "project_name": project_name,
2504
+ "project_id": project_id,
2505
+ "thread_id": thread_id,
2506
+ "thread_ids": thread_ids,
2507
+ },
2508
+ headers={
2509
+ "content-type": "application/json",
2510
+ },
2511
+ request_options=request_options,
2512
+ omit=OMIT,
2513
+ )
2514
+ try:
2515
+ if 200 <= _response.status_code < 300:
2516
+ return AsyncHttpResponse(response=_response, data=None)
2517
+ if _response.status_code == 404:
2518
+ raise NotFoundError(
2519
+ headers=dict(_response.headers),
2520
+ body=typing.cast(
2521
+ typing.Optional[typing.Any],
2522
+ parse_obj_as(
2523
+ type_=typing.Optional[typing.Any], # type: ignore
2524
+ object_=_response.json(),
2525
+ ),
2526
+ ),
2527
+ )
2528
+ _response_json = _response.json()
2529
+ except JSONDecodeError:
2530
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2531
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2532
+
2533
+ async def get_traces_by_project(
2534
+ self,
2535
+ *,
2536
+ page: typing.Optional[int] = None,
2537
+ size: typing.Optional[int] = None,
2538
+ project_name: typing.Optional[str] = None,
2539
+ project_id: typing.Optional[str] = None,
2540
+ filters: typing.Optional[str] = None,
2541
+ truncate: typing.Optional[bool] = None,
2542
+ strip_attachments: typing.Optional[bool] = None,
2543
+ sorting: typing.Optional[str] = None,
2544
+ exclude: typing.Optional[str] = None,
2545
+ from_time: typing.Optional[dt.datetime] = None,
2546
+ to_time: typing.Optional[dt.datetime] = None,
2547
+ request_options: typing.Optional[RequestOptions] = None,
2548
+ ) -> AsyncHttpResponse[TracePagePublic]:
2549
+ """
2550
+ Get traces by project_name or project_id
2551
+
2552
+ Parameters
2553
+ ----------
2554
+ page : typing.Optional[int]
2555
+
2556
+ size : typing.Optional[int]
2557
+
2558
+ project_name : typing.Optional[str]
2559
+
2560
+ project_id : typing.Optional[str]
2561
+
2562
+ filters : typing.Optional[str]
2563
+
2564
+ truncate : typing.Optional[bool]
2565
+
2566
+ strip_attachments : typing.Optional[bool]
2567
+
2568
+ sorting : typing.Optional[str]
2569
+
2570
+ exclude : typing.Optional[str]
2571
+
2572
+ from_time : typing.Optional[dt.datetime]
2573
+
2574
+ to_time : typing.Optional[dt.datetime]
2575
+
2576
+ request_options : typing.Optional[RequestOptions]
2577
+ Request-specific configuration.
2578
+
2579
+ Returns
2580
+ -------
2581
+ AsyncHttpResponse[TracePagePublic]
2582
+ Trace resource
2583
+ """
2584
+ _response = await self._client_wrapper.httpx_client.request(
2585
+ "v1/private/traces",
2586
+ method="GET",
2587
+ params={
2588
+ "page": page,
2589
+ "size": size,
2590
+ "project_name": project_name,
2591
+ "project_id": project_id,
2592
+ "filters": filters,
2593
+ "truncate": truncate,
2594
+ "strip_attachments": strip_attachments,
2595
+ "sorting": sorting,
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,
2599
+ },
2600
+ request_options=request_options,
2601
+ )
2602
+ try:
2603
+ if 200 <= _response.status_code < 300:
2604
+ _data = typing.cast(
2605
+ TracePagePublic,
2606
+ parse_obj_as(
2607
+ type_=TracePagePublic, # type: ignore
2608
+ object_=_response.json(),
2609
+ ),
2610
+ )
2611
+ return AsyncHttpResponse(response=_response, data=_data)
2612
+ _response_json = _response.json()
2613
+ except JSONDecodeError:
2614
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2615
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2616
+
2617
+ async def create_trace(
2618
+ self,
2619
+ *,
2620
+ start_time: dt.datetime,
2621
+ id: typing.Optional[str] = OMIT,
2622
+ project_name: typing.Optional[str] = OMIT,
2623
+ name: typing.Optional[str] = OMIT,
2624
+ end_time: typing.Optional[dt.datetime] = OMIT,
2625
+ input: typing.Optional[JsonListStringWrite] = OMIT,
2626
+ output: typing.Optional[JsonListStringWrite] = OMIT,
2627
+ metadata: typing.Optional[JsonListStringWrite] = OMIT,
2628
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2629
+ error_info: typing.Optional[ErrorInfoWrite] = OMIT,
2630
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
2631
+ thread_id: typing.Optional[str] = OMIT,
2632
+ request_options: typing.Optional[RequestOptions] = None,
2633
+ ) -> AsyncHttpResponse[None]:
2634
+ """
2635
+ Get trace
2636
+
2637
+ Parameters
2638
+ ----------
2639
+ start_time : dt.datetime
2640
+
2641
+ id : typing.Optional[str]
2642
+
2643
+ project_name : typing.Optional[str]
2644
+ If null, the default project is used
2645
+
2646
+ name : typing.Optional[str]
2647
+
2648
+ end_time : typing.Optional[dt.datetime]
2649
+
2650
+ input : typing.Optional[JsonListStringWrite]
2651
+
2652
+ output : typing.Optional[JsonListStringWrite]
2653
+
2654
+ metadata : typing.Optional[JsonListStringWrite]
2655
+
2656
+ tags : typing.Optional[typing.Sequence[str]]
2657
+
2658
+ error_info : typing.Optional[ErrorInfoWrite]
2659
+
2660
+ last_updated_at : typing.Optional[dt.datetime]
2661
+
2662
+ thread_id : typing.Optional[str]
2663
+
2664
+ request_options : typing.Optional[RequestOptions]
2665
+ Request-specific configuration.
2666
+
2667
+ Returns
2668
+ -------
2669
+ AsyncHttpResponse[None]
2670
+ """
2671
+ _response = await self._client_wrapper.httpx_client.request(
2672
+ "v1/private/traces",
2673
+ method="POST",
2674
+ json={
2675
+ "id": id,
2676
+ "project_name": project_name,
2677
+ "name": name,
2678
+ "start_time": start_time,
2679
+ "end_time": end_time,
2680
+ "input": convert_and_respect_annotation_metadata(
2681
+ object_=input, annotation=JsonListStringWrite, direction="write"
2682
+ ),
2683
+ "output": convert_and_respect_annotation_metadata(
2684
+ object_=output, annotation=JsonListStringWrite, direction="write"
2685
+ ),
2686
+ "metadata": convert_and_respect_annotation_metadata(
2687
+ object_=metadata, annotation=JsonListStringWrite, direction="write"
2688
+ ),
2689
+ "tags": tags,
2690
+ "error_info": convert_and_respect_annotation_metadata(
2691
+ object_=error_info, annotation=ErrorInfoWrite, direction="write"
2692
+ ),
2693
+ "last_updated_at": last_updated_at,
2694
+ "thread_id": thread_id,
2695
+ },
2696
+ headers={
2697
+ "content-type": "application/json",
2698
+ },
2699
+ request_options=request_options,
2700
+ omit=OMIT,
2701
+ )
2702
+ try:
2703
+ if 200 <= _response.status_code < 300:
2704
+ return AsyncHttpResponse(response=_response, data=None)
2705
+ _response_json = _response.json()
2706
+ except JSONDecodeError:
2707
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2708
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2709
+
2710
+ async def get_trace_by_id(
2711
+ self,
2712
+ id: str,
2713
+ *,
2714
+ strip_attachments: typing.Optional[bool] = None,
2715
+ request_options: typing.Optional[RequestOptions] = None,
2716
+ ) -> AsyncHttpResponse[TracePublic]:
2717
+ """
2718
+ Get trace by id
2719
+
2720
+ Parameters
2721
+ ----------
2722
+ id : str
2723
+
2724
+ strip_attachments : typing.Optional[bool]
2725
+
2726
+ request_options : typing.Optional[RequestOptions]
2727
+ Request-specific configuration.
2728
+
2729
+ Returns
2730
+ -------
2731
+ AsyncHttpResponse[TracePublic]
2732
+ Trace resource
2733
+ """
2734
+ _response = await self._client_wrapper.httpx_client.request(
2735
+ f"v1/private/traces/{jsonable_encoder(id)}",
2736
+ method="GET",
2737
+ params={
2738
+ "strip_attachments": strip_attachments,
2739
+ },
2740
+ request_options=request_options,
2741
+ )
2742
+ try:
2743
+ if 200 <= _response.status_code < 300:
2744
+ _data = typing.cast(
2745
+ TracePublic,
2746
+ parse_obj_as(
2747
+ type_=TracePublic, # type: ignore
2748
+ object_=_response.json(),
2749
+ ),
2750
+ )
2751
+ return AsyncHttpResponse(response=_response, data=_data)
2752
+ _response_json = _response.json()
2753
+ except JSONDecodeError:
2754
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2755
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2756
+
2757
+ async def delete_trace_by_id(
2758
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2759
+ ) -> AsyncHttpResponse[None]:
2760
+ """
2761
+ Delete trace by id
2762
+
2763
+ Parameters
2764
+ ----------
2765
+ id : str
2766
+
2767
+ request_options : typing.Optional[RequestOptions]
2768
+ Request-specific configuration.
2769
+
2770
+ Returns
2771
+ -------
2772
+ AsyncHttpResponse[None]
2773
+ """
2774
+ _response = await self._client_wrapper.httpx_client.request(
2775
+ f"v1/private/traces/{jsonable_encoder(id)}",
2776
+ method="DELETE",
2777
+ request_options=request_options,
2778
+ )
2779
+ try:
2780
+ if 200 <= _response.status_code < 300:
2781
+ return AsyncHttpResponse(response=_response, data=None)
2782
+ _response_json = _response.json()
2783
+ except JSONDecodeError:
2784
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2785
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2786
+
2787
+ async def update_trace(
2788
+ self,
2789
+ id: str,
2790
+ *,
2791
+ project_name: typing.Optional[str] = OMIT,
2792
+ project_id: typing.Optional[str] = OMIT,
2793
+ name: typing.Optional[str] = OMIT,
2794
+ end_time: typing.Optional[dt.datetime] = OMIT,
2795
+ input: typing.Optional[JsonListString] = OMIT,
2796
+ output: typing.Optional[JsonListString] = OMIT,
2797
+ metadata: typing.Optional[JsonListString] = OMIT,
2798
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
2799
+ error_info: typing.Optional[ErrorInfo] = OMIT,
2800
+ thread_id: typing.Optional[str] = OMIT,
2801
+ request_options: typing.Optional[RequestOptions] = None,
2802
+ ) -> AsyncHttpResponse[None]:
2803
+ """
2804
+ Update trace by id
2805
+
2806
+ Parameters
2807
+ ----------
2808
+ id : str
2809
+
2810
+ project_name : typing.Optional[str]
2811
+ If null and project_id not specified, Default Project is assumed
2812
+
2813
+ project_id : typing.Optional[str]
2814
+ If null and project_name not specified, Default Project is assumed
2815
+
2816
+ name : typing.Optional[str]
2817
+
2818
+ end_time : typing.Optional[dt.datetime]
2819
+
2820
+ input : typing.Optional[JsonListString]
2821
+
2822
+ output : typing.Optional[JsonListString]
2823
+
2824
+ metadata : typing.Optional[JsonListString]
2825
+
2826
+ tags : typing.Optional[typing.Sequence[str]]
2827
+
2828
+ error_info : typing.Optional[ErrorInfo]
2829
+
2830
+ thread_id : typing.Optional[str]
2831
+
2832
+ request_options : typing.Optional[RequestOptions]
2833
+ Request-specific configuration.
2834
+
2835
+ Returns
2836
+ -------
2837
+ AsyncHttpResponse[None]
2838
+ """
2839
+ _response = await self._client_wrapper.httpx_client.request(
2840
+ f"v1/private/traces/{jsonable_encoder(id)}",
2841
+ method="PATCH",
2842
+ json={
2843
+ "project_name": project_name,
2844
+ "project_id": project_id,
2845
+ "name": name,
2846
+ "end_time": end_time,
2847
+ "input": convert_and_respect_annotation_metadata(
2848
+ object_=input, annotation=JsonListString, direction="write"
2849
+ ),
2850
+ "output": convert_and_respect_annotation_metadata(
2851
+ object_=output, annotation=JsonListString, direction="write"
2852
+ ),
2853
+ "metadata": convert_and_respect_annotation_metadata(
2854
+ object_=metadata, annotation=JsonListString, direction="write"
2855
+ ),
2856
+ "tags": tags,
2857
+ "error_info": convert_and_respect_annotation_metadata(
2858
+ object_=error_info, annotation=ErrorInfo, direction="write"
2859
+ ),
2860
+ "thread_id": thread_id,
2861
+ },
2862
+ headers={
2863
+ "content-type": "application/json",
2864
+ },
2865
+ request_options=request_options,
2866
+ omit=OMIT,
2867
+ )
2868
+ try:
2869
+ if 200 <= _response.status_code < 300:
2870
+ return AsyncHttpResponse(response=_response, data=None)
2871
+ _response_json = _response.json()
2872
+ except JSONDecodeError:
2873
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2874
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2875
+
2876
+ async def delete_thread_comments(
2877
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
2878
+ ) -> AsyncHttpResponse[None]:
2879
+ """
2880
+ Delete thread comments
2881
+
2882
+ Parameters
2883
+ ----------
2884
+ ids : typing.Sequence[str]
2885
+
2886
+ request_options : typing.Optional[RequestOptions]
2887
+ Request-specific configuration.
2888
+
2889
+ Returns
2890
+ -------
2891
+ AsyncHttpResponse[None]
2892
+ """
2893
+ _response = await self._client_wrapper.httpx_client.request(
2894
+ "v1/private/traces/threads/comments/delete",
2895
+ method="POST",
2896
+ json={
2897
+ "ids": ids,
2898
+ },
2899
+ headers={
2900
+ "content-type": "application/json",
2901
+ },
2902
+ request_options=request_options,
2903
+ omit=OMIT,
2904
+ )
2905
+ try:
2906
+ if 200 <= _response.status_code < 300:
2907
+ return AsyncHttpResponse(response=_response, data=None)
2908
+ _response_json = _response.json()
2909
+ except JSONDecodeError:
2910
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2911
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2912
+
2913
+ async def delete_thread_feedback_scores(
2914
+ self,
2915
+ *,
2916
+ project_name: str,
2917
+ thread_id: str,
2918
+ names: typing.Sequence[str],
2919
+ author: typing.Optional[str] = OMIT,
2920
+ request_options: typing.Optional[RequestOptions] = None,
2921
+ ) -> AsyncHttpResponse[None]:
2922
+ """
2923
+ Delete thread feedback scores
2924
+
2925
+ Parameters
2926
+ ----------
2927
+ project_name : str
2928
+
2929
+ thread_id : str
2930
+
2931
+ names : typing.Sequence[str]
2932
+
2933
+ author : typing.Optional[str]
2934
+
2935
+ request_options : typing.Optional[RequestOptions]
2936
+ Request-specific configuration.
2937
+
2938
+ Returns
2939
+ -------
2940
+ AsyncHttpResponse[None]
2941
+ """
2942
+ _response = await self._client_wrapper.httpx_client.request(
2943
+ "v1/private/traces/threads/feedback-scores/delete",
2944
+ method="POST",
2945
+ json={
2946
+ "project_name": project_name,
2947
+ "thread_id": thread_id,
2948
+ "names": names,
2949
+ "author": author,
2950
+ },
2951
+ headers={
2952
+ "content-type": "application/json",
2953
+ },
2954
+ request_options=request_options,
2955
+ omit=OMIT,
2956
+ )
2957
+ try:
2958
+ if 200 <= _response.status_code < 300:
2959
+ return AsyncHttpResponse(response=_response, data=None)
2960
+ _response_json = _response.json()
2961
+ except JSONDecodeError:
2962
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2963
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2964
+
2965
+ async def delete_trace_comments(
2966
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
2967
+ ) -> AsyncHttpResponse[None]:
2968
+ """
2969
+ Delete trace comments
2970
+
2971
+ Parameters
2972
+ ----------
2973
+ ids : typing.Sequence[str]
2974
+
2975
+ request_options : typing.Optional[RequestOptions]
2976
+ Request-specific configuration.
2977
+
2978
+ Returns
2979
+ -------
2980
+ AsyncHttpResponse[None]
2981
+ """
2982
+ _response = await self._client_wrapper.httpx_client.request(
2983
+ "v1/private/traces/comments/delete",
2984
+ method="POST",
2985
+ json={
2986
+ "ids": ids,
2987
+ },
2988
+ headers={
2989
+ "content-type": "application/json",
2990
+ },
2991
+ request_options=request_options,
2992
+ omit=OMIT,
2993
+ )
2994
+ try:
2995
+ if 200 <= _response.status_code < 300:
2996
+ return AsyncHttpResponse(response=_response, data=None)
2997
+ _response_json = _response.json()
2998
+ except JSONDecodeError:
2999
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3000
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3001
+
3002
+ async def delete_trace_feedback_score(
3003
+ self,
3004
+ id: str,
3005
+ *,
3006
+ name: str,
3007
+ author: typing.Optional[str] = OMIT,
3008
+ request_options: typing.Optional[RequestOptions] = None,
3009
+ ) -> AsyncHttpResponse[None]:
3010
+ """
3011
+ Delete trace feedback score
3012
+
3013
+ Parameters
3014
+ ----------
3015
+ id : str
3016
+
3017
+ name : str
3018
+
3019
+ author : typing.Optional[str]
3020
+
3021
+ request_options : typing.Optional[RequestOptions]
3022
+ Request-specific configuration.
3023
+
3024
+ Returns
3025
+ -------
3026
+ AsyncHttpResponse[None]
3027
+ """
3028
+ _response = await self._client_wrapper.httpx_client.request(
3029
+ f"v1/private/traces/{jsonable_encoder(id)}/feedback-scores/delete",
3030
+ method="POST",
3031
+ json={
3032
+ "name": name,
3033
+ "author": author,
3034
+ },
3035
+ headers={
3036
+ "content-type": "application/json",
3037
+ },
3038
+ request_options=request_options,
3039
+ omit=OMIT,
3040
+ )
3041
+ try:
3042
+ if 200 <= _response.status_code < 300:
3043
+ return AsyncHttpResponse(response=_response, data=None)
3044
+ _response_json = _response.json()
3045
+ except JSONDecodeError:
3046
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3047
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3048
+
3049
+ async def delete_trace_threads(
3050
+ self,
3051
+ *,
3052
+ thread_ids: typing.Sequence[str],
3053
+ project_name: typing.Optional[str] = OMIT,
3054
+ project_id: typing.Optional[str] = OMIT,
3055
+ request_options: typing.Optional[RequestOptions] = None,
3056
+ ) -> AsyncHttpResponse[None]:
3057
+ """
3058
+ Delete trace threads
3059
+
3060
+ Parameters
3061
+ ----------
3062
+ thread_ids : typing.Sequence[str]
3063
+
3064
+ project_name : typing.Optional[str]
3065
+ If null, project_id must be provided
3066
+
3067
+ project_id : typing.Optional[str]
3068
+ If null, project_name must be provided
3069
+
3070
+ request_options : typing.Optional[RequestOptions]
3071
+ Request-specific configuration.
3072
+
3073
+ Returns
3074
+ -------
3075
+ AsyncHttpResponse[None]
3076
+ """
3077
+ _response = await self._client_wrapper.httpx_client.request(
3078
+ "v1/private/traces/threads/delete",
3079
+ method="POST",
3080
+ json={
3081
+ "project_name": project_name,
3082
+ "project_id": project_id,
3083
+ "thread_ids": thread_ids,
3084
+ },
3085
+ headers={
3086
+ "content-type": "application/json",
3087
+ },
3088
+ request_options=request_options,
3089
+ omit=OMIT,
3090
+ )
3091
+ try:
3092
+ if 200 <= _response.status_code < 300:
3093
+ return AsyncHttpResponse(response=_response, data=None)
3094
+ _response_json = _response.json()
3095
+ except JSONDecodeError:
3096
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3097
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3098
+
3099
+ async def delete_traces(
3100
+ self, *, ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
3101
+ ) -> AsyncHttpResponse[None]:
3102
+ """
3103
+ Delete traces
3104
+
3105
+ Parameters
3106
+ ----------
3107
+ ids : typing.Sequence[str]
3108
+
3109
+ request_options : typing.Optional[RequestOptions]
3110
+ Request-specific configuration.
3111
+
3112
+ Returns
3113
+ -------
3114
+ AsyncHttpResponse[None]
3115
+ """
3116
+ _response = await self._client_wrapper.httpx_client.request(
3117
+ "v1/private/traces/delete",
3118
+ method="POST",
3119
+ json={
3120
+ "ids": ids,
3121
+ },
3122
+ headers={
3123
+ "content-type": "application/json",
3124
+ },
3125
+ request_options=request_options,
3126
+ omit=OMIT,
3127
+ )
3128
+ try:
3129
+ if 200 <= _response.status_code < 300:
3130
+ return AsyncHttpResponse(response=_response, data=None)
3131
+ _response_json = _response.json()
3132
+ except JSONDecodeError:
3133
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3134
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3135
+
3136
+ async def find_feedback_score_names_2(
3137
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
3138
+ ) -> AsyncHttpResponse[typing.List[str]]:
3139
+ """
3140
+ Find Feedback Score names
3141
+
3142
+ Parameters
3143
+ ----------
3144
+ project_id : typing.Optional[str]
3145
+
3146
+ request_options : typing.Optional[RequestOptions]
3147
+ Request-specific configuration.
3148
+
3149
+ Returns
3150
+ -------
3151
+ AsyncHttpResponse[typing.List[str]]
3152
+ Feedback Scores resource
3153
+ """
3154
+ _response = await self._client_wrapper.httpx_client.request(
3155
+ "v1/private/traces/feedback-scores/names",
3156
+ method="GET",
3157
+ params={
3158
+ "project_id": project_id,
3159
+ },
3160
+ request_options=request_options,
3161
+ )
3162
+ try:
3163
+ if 200 <= _response.status_code < 300:
3164
+ _data = typing.cast(
3165
+ typing.List[str],
3166
+ parse_obj_as(
3167
+ type_=typing.List[str], # type: ignore
3168
+ object_=_response.json(),
3169
+ ),
3170
+ )
3171
+ return AsyncHttpResponse(response=_response, data=_data)
3172
+ _response_json = _response.json()
3173
+ except JSONDecodeError:
3174
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3175
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3176
+
3177
+ async def find_trace_threads_feedback_score_names(
3178
+ self, *, project_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
3179
+ ) -> AsyncHttpResponse[typing.List[str]]:
3180
+ """
3181
+ Find Trace Threads Feedback Score names
3182
+
3183
+ Parameters
3184
+ ----------
3185
+ project_id : typing.Optional[str]
3186
+
3187
+ request_options : typing.Optional[RequestOptions]
3188
+ Request-specific configuration.
3189
+
3190
+ Returns
3191
+ -------
3192
+ AsyncHttpResponse[typing.List[str]]
3193
+ Find Trace Threads Feedback Score names
3194
+ """
3195
+ _response = await self._client_wrapper.httpx_client.request(
3196
+ "v1/private/traces/threads/feedback-scores/names",
3197
+ method="GET",
3198
+ params={
3199
+ "project_id": project_id,
3200
+ },
3201
+ request_options=request_options,
3202
+ )
3203
+ try:
3204
+ if 200 <= _response.status_code < 300:
3205
+ _data = typing.cast(
3206
+ typing.List[str],
3207
+ parse_obj_as(
3208
+ type_=typing.List[str], # type: ignore
3209
+ object_=_response.json(),
3210
+ ),
3211
+ )
3212
+ return AsyncHttpResponse(response=_response, data=_data)
3213
+ _response_json = _response.json()
3214
+ except JSONDecodeError:
3215
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3216
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3217
+
3218
+ async def get_trace_stats(
3219
+ self,
3220
+ *,
3221
+ project_id: typing.Optional[str] = None,
3222
+ project_name: typing.Optional[str] = None,
3223
+ filters: typing.Optional[str] = None,
3224
+ from_time: typing.Optional[dt.datetime] = None,
3225
+ to_time: typing.Optional[dt.datetime] = None,
3226
+ request_options: typing.Optional[RequestOptions] = None,
3227
+ ) -> AsyncHttpResponse[ProjectStatsPublic]:
3228
+ """
3229
+ Get trace stats
3230
+
3231
+ Parameters
3232
+ ----------
3233
+ project_id : typing.Optional[str]
3234
+
3235
+ project_name : typing.Optional[str]
3236
+
3237
+ filters : typing.Optional[str]
3238
+
3239
+ from_time : typing.Optional[dt.datetime]
3240
+
3241
+ to_time : typing.Optional[dt.datetime]
3242
+
3243
+ request_options : typing.Optional[RequestOptions]
3244
+ Request-specific configuration.
3245
+
3246
+ Returns
3247
+ -------
3248
+ AsyncHttpResponse[ProjectStatsPublic]
3249
+ Trace stats resource
3250
+ """
3251
+ _response = await self._client_wrapper.httpx_client.request(
3252
+ "v1/private/traces/stats",
3253
+ method="GET",
3254
+ params={
3255
+ "project_id": project_id,
3256
+ "project_name": project_name,
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,
3260
+ },
3261
+ request_options=request_options,
3262
+ )
3263
+ try:
3264
+ if 200 <= _response.status_code < 300:
3265
+ _data = typing.cast(
3266
+ ProjectStatsPublic,
3267
+ parse_obj_as(
3268
+ type_=ProjectStatsPublic, # type: ignore
3269
+ object_=_response.json(),
3270
+ ),
3271
+ )
3272
+ return AsyncHttpResponse(response=_response, data=_data)
3273
+ _response_json = _response.json()
3274
+ except JSONDecodeError:
3275
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3276
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3277
+
3278
+ async def get_thread_comment(
3279
+ self, comment_id: str, thread_id: str, *, request_options: typing.Optional[RequestOptions] = None
3280
+ ) -> AsyncHttpResponse[Comment]:
3281
+ """
3282
+ Get thread comment
3283
+
3284
+ Parameters
3285
+ ----------
3286
+ comment_id : str
3287
+
3288
+ thread_id : str
3289
+
3290
+ request_options : typing.Optional[RequestOptions]
3291
+ Request-specific configuration.
3292
+
3293
+ Returns
3294
+ -------
3295
+ AsyncHttpResponse[Comment]
3296
+ Comment resource
3297
+ """
3298
+ _response = await self._client_wrapper.httpx_client.request(
3299
+ f"v1/private/traces/threads/{jsonable_encoder(thread_id)}/comments/{jsonable_encoder(comment_id)}",
3300
+ method="GET",
3301
+ request_options=request_options,
3302
+ )
3303
+ try:
3304
+ if 200 <= _response.status_code < 300:
3305
+ _data = typing.cast(
3306
+ Comment,
3307
+ parse_obj_as(
3308
+ type_=Comment, # type: ignore
3309
+ object_=_response.json(),
3310
+ ),
3311
+ )
3312
+ return AsyncHttpResponse(response=_response, data=_data)
3313
+ if _response.status_code == 404:
3314
+ raise NotFoundError(
3315
+ headers=dict(_response.headers),
3316
+ body=typing.cast(
3317
+ typing.Optional[typing.Any],
3318
+ parse_obj_as(
3319
+ type_=typing.Optional[typing.Any], # type: ignore
3320
+ object_=_response.json(),
3321
+ ),
3322
+ ),
3323
+ )
3324
+ _response_json = _response.json()
3325
+ except JSONDecodeError:
3326
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3327
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
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
+
3389
+ async def get_trace_comment(
3390
+ self, comment_id: str, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
3391
+ ) -> AsyncHttpResponse[Comment]:
3392
+ """
3393
+ Get trace comment
3394
+
3395
+ Parameters
3396
+ ----------
3397
+ comment_id : str
3398
+
3399
+ trace_id : str
3400
+
3401
+ request_options : typing.Optional[RequestOptions]
3402
+ Request-specific configuration.
3403
+
3404
+ Returns
3405
+ -------
3406
+ AsyncHttpResponse[Comment]
3407
+ Comment resource
3408
+ """
3409
+ _response = await self._client_wrapper.httpx_client.request(
3410
+ f"v1/private/traces/{jsonable_encoder(trace_id)}/comments/{jsonable_encoder(comment_id)}",
3411
+ method="GET",
3412
+ request_options=request_options,
3413
+ )
3414
+ try:
3415
+ if 200 <= _response.status_code < 300:
3416
+ _data = typing.cast(
3417
+ Comment,
3418
+ parse_obj_as(
3419
+ type_=Comment, # type: ignore
3420
+ object_=_response.json(),
3421
+ ),
3422
+ )
3423
+ return AsyncHttpResponse(response=_response, data=_data)
3424
+ if _response.status_code == 404:
3425
+ raise NotFoundError(
3426
+ headers=dict(_response.headers),
3427
+ body=typing.cast(
3428
+ typing.Optional[typing.Any],
3429
+ parse_obj_as(
3430
+ type_=typing.Optional[typing.Any], # type: ignore
3431
+ object_=_response.json(),
3432
+ ),
3433
+ ),
3434
+ )
3435
+ _response_json = _response.json()
3436
+ except JSONDecodeError:
3437
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3438
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3439
+
3440
+ async def get_trace_thread(
3441
+ self,
3442
+ *,
3443
+ thread_id: str,
3444
+ project_name: typing.Optional[str] = OMIT,
3445
+ project_id: typing.Optional[str] = OMIT,
3446
+ truncate: typing.Optional[bool] = OMIT,
3447
+ request_options: typing.Optional[RequestOptions] = None,
3448
+ ) -> AsyncHttpResponse[TraceThread]:
3449
+ """
3450
+ Get trace thread
3451
+
3452
+ Parameters
3453
+ ----------
3454
+ thread_id : str
3455
+
3456
+ project_name : typing.Optional[str]
3457
+
3458
+ project_id : typing.Optional[str]
3459
+
3460
+ truncate : typing.Optional[bool]
3461
+
3462
+ request_options : typing.Optional[RequestOptions]
3463
+ Request-specific configuration.
3464
+
3465
+ Returns
3466
+ -------
3467
+ AsyncHttpResponse[TraceThread]
3468
+ Trace thread resource
3469
+ """
3470
+ _response = await self._client_wrapper.httpx_client.request(
3471
+ "v1/private/traces/threads/retrieve",
3472
+ method="POST",
3473
+ json={
3474
+ "project_name": project_name,
3475
+ "project_id": project_id,
3476
+ "thread_id": thread_id,
3477
+ "truncate": truncate,
3478
+ },
3479
+ headers={
3480
+ "content-type": "application/json",
3481
+ },
3482
+ request_options=request_options,
3483
+ omit=OMIT,
3484
+ )
3485
+ try:
3486
+ if 200 <= _response.status_code < 300:
3487
+ _data = typing.cast(
3488
+ TraceThread,
3489
+ parse_obj_as(
3490
+ type_=TraceThread, # type: ignore
3491
+ object_=_response.json(),
3492
+ ),
3493
+ )
3494
+ return AsyncHttpResponse(response=_response, data=_data)
3495
+ if _response.status_code == 404:
3496
+ raise NotFoundError(
3497
+ headers=dict(_response.headers),
3498
+ body=typing.cast(
3499
+ typing.Optional[typing.Any],
3500
+ parse_obj_as(
3501
+ type_=typing.Optional[typing.Any], # type: ignore
3502
+ object_=_response.json(),
3503
+ ),
3504
+ ),
3505
+ )
3506
+ _response_json = _response.json()
3507
+ except JSONDecodeError:
3508
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3509
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3510
+
3511
+ async def get_trace_threads(
3512
+ self,
3513
+ *,
3514
+ page: typing.Optional[int] = None,
3515
+ size: typing.Optional[int] = None,
3516
+ project_name: typing.Optional[str] = None,
3517
+ project_id: typing.Optional[str] = None,
3518
+ truncate: typing.Optional[bool] = None,
3519
+ strip_attachments: typing.Optional[bool] = None,
3520
+ filters: typing.Optional[str] = None,
3521
+ sorting: typing.Optional[str] = None,
3522
+ from_time: typing.Optional[dt.datetime] = None,
3523
+ to_time: typing.Optional[dt.datetime] = None,
3524
+ request_options: typing.Optional[RequestOptions] = None,
3525
+ ) -> AsyncHttpResponse[TraceThreadPage]:
3526
+ """
3527
+ Get trace threads
3528
+
3529
+ Parameters
3530
+ ----------
3531
+ page : typing.Optional[int]
3532
+
3533
+ size : typing.Optional[int]
3534
+
3535
+ project_name : typing.Optional[str]
3536
+
3537
+ project_id : typing.Optional[str]
3538
+
3539
+ truncate : typing.Optional[bool]
3540
+
3541
+ strip_attachments : typing.Optional[bool]
3542
+
3543
+ filters : typing.Optional[str]
3544
+
3545
+ sorting : typing.Optional[str]
3546
+
3547
+ from_time : typing.Optional[dt.datetime]
3548
+
3549
+ to_time : typing.Optional[dt.datetime]
3550
+
3551
+ request_options : typing.Optional[RequestOptions]
3552
+ Request-specific configuration.
3553
+
3554
+ Returns
3555
+ -------
3556
+ AsyncHttpResponse[TraceThreadPage]
3557
+ Trace threads resource
3558
+ """
3559
+ _response = await self._client_wrapper.httpx_client.request(
3560
+ "v1/private/traces/threads",
3561
+ method="GET",
3562
+ params={
3563
+ "page": page,
3564
+ "size": size,
3565
+ "project_name": project_name,
3566
+ "project_id": project_id,
3567
+ "truncate": truncate,
3568
+ "strip_attachments": strip_attachments,
3569
+ "filters": filters,
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,
3573
+ },
3574
+ request_options=request_options,
3575
+ )
3576
+ try:
3577
+ if 200 <= _response.status_code < 300:
3578
+ _data = typing.cast(
3579
+ TraceThreadPage,
3580
+ parse_obj_as(
3581
+ type_=TraceThreadPage, # type: ignore
3582
+ object_=_response.json(),
3583
+ ),
3584
+ )
3585
+ return AsyncHttpResponse(response=_response, data=_data)
3586
+ _response_json = _response.json()
3587
+ except JSONDecodeError:
3588
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3589
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3590
+
3591
+ async def open_trace_thread(
3592
+ self,
3593
+ *,
3594
+ thread_id: str,
3595
+ project_name: typing.Optional[str] = OMIT,
3596
+ project_id: typing.Optional[str] = OMIT,
3597
+ truncate: typing.Optional[bool] = OMIT,
3598
+ request_options: typing.Optional[RequestOptions] = None,
3599
+ ) -> AsyncHttpResponse[None]:
3600
+ """
3601
+ Open trace thread
3602
+
3603
+ Parameters
3604
+ ----------
3605
+ thread_id : str
3606
+
3607
+ project_name : typing.Optional[str]
3608
+
3609
+ project_id : typing.Optional[str]
3610
+
3611
+ truncate : typing.Optional[bool]
3612
+
3613
+ request_options : typing.Optional[RequestOptions]
3614
+ Request-specific configuration.
3615
+
3616
+ Returns
3617
+ -------
3618
+ AsyncHttpResponse[None]
3619
+ """
3620
+ _response = await self._client_wrapper.httpx_client.request(
3621
+ "v1/private/traces/threads/open",
3622
+ method="PUT",
3623
+ json={
3624
+ "project_name": project_name,
3625
+ "project_id": project_id,
3626
+ "thread_id": thread_id,
3627
+ "truncate": truncate,
3628
+ },
3629
+ headers={
3630
+ "content-type": "application/json",
3631
+ },
3632
+ request_options=request_options,
3633
+ omit=OMIT,
3634
+ )
3635
+ try:
3636
+ if 200 <= _response.status_code < 300:
3637
+ return AsyncHttpResponse(response=_response, data=None)
3638
+ _response_json = _response.json()
3639
+ except JSONDecodeError:
3640
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3641
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3642
+
3643
+ async def score_batch_of_threads(
3644
+ self,
3645
+ *,
3646
+ scores: typing.Sequence[FeedbackScoreBatchItemThread],
3647
+ request_options: typing.Optional[RequestOptions] = None,
3648
+ ) -> AsyncHttpResponse[None]:
3649
+ """
3650
+ Batch feedback scoring for threads
3651
+
3652
+ Parameters
3653
+ ----------
3654
+ scores : typing.Sequence[FeedbackScoreBatchItemThread]
3655
+
3656
+ request_options : typing.Optional[RequestOptions]
3657
+ Request-specific configuration.
3658
+
3659
+ Returns
3660
+ -------
3661
+ AsyncHttpResponse[None]
3662
+ """
3663
+ _response = await self._client_wrapper.httpx_client.request(
3664
+ "v1/private/traces/threads/feedback-scores",
3665
+ method="PUT",
3666
+ json={
3667
+ "scores": convert_and_respect_annotation_metadata(
3668
+ object_=scores, annotation=typing.Sequence[FeedbackScoreBatchItemThread], direction="write"
3669
+ ),
3670
+ },
3671
+ headers={
3672
+ "content-type": "application/json",
3673
+ },
3674
+ request_options=request_options,
3675
+ omit=OMIT,
3676
+ )
3677
+ try:
3678
+ if 200 <= _response.status_code < 300:
3679
+ return AsyncHttpResponse(response=_response, data=None)
3680
+ _response_json = _response.json()
3681
+ except JSONDecodeError:
3682
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3683
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3684
+
3685
+ async def score_batch_of_traces(
3686
+ self,
3687
+ *,
3688
+ scores: typing.Sequence[FeedbackScoreBatchItem],
3689
+ request_options: typing.Optional[RequestOptions] = None,
3690
+ ) -> AsyncHttpResponse[None]:
3691
+ """
3692
+ Batch feedback scoring for traces
3693
+
3694
+ Parameters
3695
+ ----------
3696
+ scores : typing.Sequence[FeedbackScoreBatchItem]
3697
+
3698
+ request_options : typing.Optional[RequestOptions]
3699
+ Request-specific configuration.
3700
+
3701
+ Returns
3702
+ -------
3703
+ AsyncHttpResponse[None]
3704
+ """
3705
+ _response = await self._client_wrapper.httpx_client.request(
3706
+ "v1/private/traces/feedback-scores",
3707
+ method="PUT",
3708
+ json={
3709
+ "scores": convert_and_respect_annotation_metadata(
3710
+ object_=scores, annotation=typing.Sequence[FeedbackScoreBatchItem], direction="write"
3711
+ ),
3712
+ },
3713
+ headers={
3714
+ "content-type": "application/json",
3715
+ },
3716
+ request_options=request_options,
3717
+ omit=OMIT,
3718
+ )
3719
+ try:
3720
+ if 200 <= _response.status_code < 300:
3721
+ return AsyncHttpResponse(response=_response, data=None)
3722
+ _response_json = _response.json()
3723
+ except JSONDecodeError:
3724
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3725
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3726
+
3727
+ @contextlib.asynccontextmanager
3728
+ async def search_trace_threads(
3729
+ self,
3730
+ *,
3731
+ project_name: typing.Optional[str] = OMIT,
3732
+ project_id: typing.Optional[str] = OMIT,
3733
+ filters: typing.Optional[typing.Sequence[TraceThreadFilter]] = OMIT,
3734
+ last_retrieved_thread_model_id: typing.Optional[str] = OMIT,
3735
+ limit: typing.Optional[int] = OMIT,
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,
3740
+ request_options: typing.Optional[RequestOptions] = None,
3741
+ ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
3742
+ """
3743
+ Search trace threads
3744
+
3745
+ Parameters
3746
+ ----------
3747
+ project_name : typing.Optional[str]
3748
+
3749
+ project_id : typing.Optional[str]
3750
+
3751
+ filters : typing.Optional[typing.Sequence[TraceThreadFilter]]
3752
+
3753
+ last_retrieved_thread_model_id : typing.Optional[str]
3754
+
3755
+ limit : typing.Optional[int]
3756
+ Max number of trace thread to be streamed
3757
+
3758
+ truncate : typing.Optional[bool]
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'.
3769
+
3770
+ request_options : typing.Optional[RequestOptions]
3771
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
3772
+
3773
+ Returns
3774
+ -------
3775
+ typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
3776
+ Trace threads stream or error during process
3777
+ """
3778
+ async with self._client_wrapper.httpx_client.stream(
3779
+ "v1/private/traces/threads/search",
3780
+ method="POST",
3781
+ json={
3782
+ "project_name": project_name,
3783
+ "project_id": project_id,
3784
+ "filters": convert_and_respect_annotation_metadata(
3785
+ object_=filters, annotation=typing.Sequence[TraceThreadFilter], direction="write"
3786
+ ),
3787
+ "last_retrieved_thread_model_id": last_retrieved_thread_model_id,
3788
+ "limit": limit,
3789
+ "truncate": truncate,
3790
+ "strip_attachments": strip_attachments,
3791
+ "from_time": from_time,
3792
+ "to_time": to_time,
3793
+ },
3794
+ headers={
3795
+ "content-type": "application/json",
3796
+ },
3797
+ request_options=request_options,
3798
+ omit=OMIT,
3799
+ ) as _response:
3800
+
3801
+ async def stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
3802
+ try:
3803
+ if 200 <= _response.status_code < 300:
3804
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
3805
+ return AsyncHttpResponse(
3806
+ response=_response,
3807
+ data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
3808
+ )
3809
+ await _response.aread()
3810
+ if _response.status_code == 400:
3811
+ raise BadRequestError(
3812
+ headers=dict(_response.headers),
3813
+ body=typing.cast(
3814
+ typing.Optional[typing.Any],
3815
+ parse_obj_as(
3816
+ type_=typing.Optional[typing.Any], # type: ignore
3817
+ object_=_response.json(),
3818
+ ),
3819
+ ),
3820
+ )
3821
+ _response_json = _response.json()
3822
+ except JSONDecodeError:
3823
+ raise ApiError(
3824
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
3825
+ )
3826
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3827
+
3828
+ yield await stream()
3829
+
3830
+ @contextlib.asynccontextmanager
3831
+ async def search_traces(
3832
+ self,
3833
+ *,
3834
+ project_name: typing.Optional[str] = OMIT,
3835
+ project_id: typing.Optional[str] = OMIT,
3836
+ filters: typing.Optional[typing.Sequence[TraceFilterPublic]] = OMIT,
3837
+ last_retrieved_id: typing.Optional[str] = OMIT,
3838
+ limit: typing.Optional[int] = OMIT,
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,
3843
+ request_options: typing.Optional[RequestOptions] = None,
3844
+ ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
3845
+ """
3846
+ Search traces
3847
+
3848
+ Parameters
3849
+ ----------
3850
+ project_name : typing.Optional[str]
3851
+
3852
+ project_id : typing.Optional[str]
3853
+
3854
+ filters : typing.Optional[typing.Sequence[TraceFilterPublic]]
3855
+
3856
+ last_retrieved_id : typing.Optional[str]
3857
+
3858
+ limit : typing.Optional[int]
3859
+ Max number of traces to be streamed
3860
+
3861
+ truncate : typing.Optional[bool]
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'.
3872
+
3873
+ request_options : typing.Optional[RequestOptions]
3874
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
3875
+
3876
+ Returns
3877
+ -------
3878
+ typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
3879
+ Traces stream or error during process
3880
+ """
3881
+ async with self._client_wrapper.httpx_client.stream(
3882
+ "v1/private/traces/search",
3883
+ method="POST",
3884
+ json={
3885
+ "project_name": project_name,
3886
+ "project_id": project_id,
3887
+ "filters": convert_and_respect_annotation_metadata(
3888
+ object_=filters, annotation=typing.Sequence[TraceFilterPublic], direction="write"
3889
+ ),
3890
+ "last_retrieved_id": last_retrieved_id,
3891
+ "limit": limit,
3892
+ "truncate": truncate,
3893
+ "strip_attachments": strip_attachments,
3894
+ "from_time": from_time,
3895
+ "to_time": to_time,
3896
+ },
3897
+ headers={
3898
+ "content-type": "application/json",
3899
+ },
3900
+ request_options=request_options,
3901
+ omit=OMIT,
3902
+ ) as _response:
3903
+
3904
+ async def stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
3905
+ try:
3906
+ if 200 <= _response.status_code < 300:
3907
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
3908
+ return AsyncHttpResponse(
3909
+ response=_response,
3910
+ data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
3911
+ )
3912
+ await _response.aread()
3913
+ if _response.status_code == 400:
3914
+ raise BadRequestError(
3915
+ headers=dict(_response.headers),
3916
+ body=typing.cast(
3917
+ typing.Optional[typing.Any],
3918
+ parse_obj_as(
3919
+ type_=typing.Optional[typing.Any], # type: ignore
3920
+ object_=_response.json(),
3921
+ ),
3922
+ ),
3923
+ )
3924
+ if _response.status_code == 401:
3925
+ raise UnauthorizedError(
3926
+ headers=dict(_response.headers),
3927
+ body=typing.cast(
3928
+ typing.Optional[typing.Any],
3929
+ parse_obj_as(
3930
+ type_=typing.Optional[typing.Any], # type: ignore
3931
+ object_=_response.json(),
3932
+ ),
3933
+ ),
3934
+ )
3935
+ _response_json = _response.json()
3936
+ except JSONDecodeError:
3937
+ raise ApiError(
3938
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
3939
+ )
3940
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3941
+
3942
+ yield await stream()
3943
+
3944
+ async def update_thread(
3945
+ self,
3946
+ thread_model_id: str,
3947
+ *,
3948
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
3949
+ request_options: typing.Optional[RequestOptions] = None,
3950
+ ) -> AsyncHttpResponse[None]:
3951
+ """
3952
+ Update thread
3953
+
3954
+ Parameters
3955
+ ----------
3956
+ thread_model_id : str
3957
+
3958
+ tags : typing.Optional[typing.Sequence[str]]
3959
+
3960
+ request_options : typing.Optional[RequestOptions]
3961
+ Request-specific configuration.
3962
+
3963
+ Returns
3964
+ -------
3965
+ AsyncHttpResponse[None]
3966
+ """
3967
+ _response = await self._client_wrapper.httpx_client.request(
3968
+ f"v1/private/traces/threads/{jsonable_encoder(thread_model_id)}",
3969
+ method="PATCH",
3970
+ json={
3971
+ "tags": tags,
3972
+ },
3973
+ headers={
3974
+ "content-type": "application/json",
3975
+ },
3976
+ request_options=request_options,
3977
+ omit=OMIT,
3978
+ )
3979
+ try:
3980
+ if 200 <= _response.status_code < 300:
3981
+ return AsyncHttpResponse(response=_response, data=None)
3982
+ if _response.status_code == 404:
3983
+ raise NotFoundError(
3984
+ headers=dict(_response.headers),
3985
+ body=typing.cast(
3986
+ typing.Optional[typing.Any],
3987
+ parse_obj_as(
3988
+ type_=typing.Optional[typing.Any], # type: ignore
3989
+ object_=_response.json(),
3990
+ ),
3991
+ ),
3992
+ )
3993
+ _response_json = _response.json()
3994
+ except JSONDecodeError:
3995
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
3996
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
3997
+
3998
+ async def update_thread_comment(
3999
+ self,
4000
+ comment_id: str,
4001
+ *,
4002
+ text: str,
4003
+ id: typing.Optional[str] = OMIT,
4004
+ created_at: typing.Optional[dt.datetime] = OMIT,
4005
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
4006
+ created_by: typing.Optional[str] = OMIT,
4007
+ last_updated_by: typing.Optional[str] = OMIT,
4008
+ request_options: typing.Optional[RequestOptions] = None,
4009
+ ) -> AsyncHttpResponse[None]:
4010
+ """
4011
+ Update thread comment by id
4012
+
4013
+ Parameters
4014
+ ----------
4015
+ comment_id : str
4016
+
4017
+ text : str
4018
+
4019
+ id : typing.Optional[str]
4020
+
4021
+ created_at : typing.Optional[dt.datetime]
4022
+
4023
+ last_updated_at : typing.Optional[dt.datetime]
4024
+
4025
+ created_by : typing.Optional[str]
4026
+
4027
+ last_updated_by : typing.Optional[str]
4028
+
4029
+ request_options : typing.Optional[RequestOptions]
4030
+ Request-specific configuration.
4031
+
4032
+ Returns
4033
+ -------
4034
+ AsyncHttpResponse[None]
4035
+ """
4036
+ _response = await self._client_wrapper.httpx_client.request(
4037
+ f"v1/private/traces/threads/comments/{jsonable_encoder(comment_id)}",
4038
+ method="PATCH",
4039
+ json={
4040
+ "id": id,
4041
+ "text": text,
4042
+ "created_at": created_at,
4043
+ "last_updated_at": last_updated_at,
4044
+ "created_by": created_by,
4045
+ "last_updated_by": last_updated_by,
4046
+ },
4047
+ headers={
4048
+ "content-type": "application/json",
4049
+ },
4050
+ request_options=request_options,
4051
+ omit=OMIT,
4052
+ )
4053
+ try:
4054
+ if 200 <= _response.status_code < 300:
4055
+ return AsyncHttpResponse(response=_response, data=None)
4056
+ if _response.status_code == 404:
4057
+ raise NotFoundError(
4058
+ headers=dict(_response.headers),
4059
+ body=typing.cast(
4060
+ typing.Optional[typing.Any],
4061
+ parse_obj_as(
4062
+ type_=typing.Optional[typing.Any], # type: ignore
4063
+ object_=_response.json(),
4064
+ ),
4065
+ ),
4066
+ )
4067
+ _response_json = _response.json()
4068
+ except JSONDecodeError:
4069
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
4070
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
4071
+
4072
+ async def update_trace_comment(
4073
+ self,
4074
+ comment_id: str,
4075
+ *,
4076
+ text: str,
4077
+ id: typing.Optional[str] = OMIT,
4078
+ created_at: typing.Optional[dt.datetime] = OMIT,
4079
+ last_updated_at: typing.Optional[dt.datetime] = OMIT,
4080
+ created_by: typing.Optional[str] = OMIT,
4081
+ last_updated_by: typing.Optional[str] = OMIT,
4082
+ request_options: typing.Optional[RequestOptions] = None,
4083
+ ) -> AsyncHttpResponse[None]:
4084
+ """
4085
+ Update trace comment by id
4086
+
4087
+ Parameters
4088
+ ----------
4089
+ comment_id : str
4090
+
4091
+ text : str
4092
+
4093
+ id : typing.Optional[str]
4094
+
4095
+ created_at : typing.Optional[dt.datetime]
4096
+
4097
+ last_updated_at : typing.Optional[dt.datetime]
4098
+
4099
+ created_by : typing.Optional[str]
4100
+
4101
+ last_updated_by : typing.Optional[str]
4102
+
4103
+ request_options : typing.Optional[RequestOptions]
4104
+ Request-specific configuration.
4105
+
4106
+ Returns
4107
+ -------
4108
+ AsyncHttpResponse[None]
4109
+ """
4110
+ _response = await self._client_wrapper.httpx_client.request(
4111
+ f"v1/private/traces/comments/{jsonable_encoder(comment_id)}",
4112
+ method="PATCH",
4113
+ json={
4114
+ "id": id,
4115
+ "text": text,
4116
+ "created_at": created_at,
4117
+ "last_updated_at": last_updated_at,
4118
+ "created_by": created_by,
4119
+ "last_updated_by": last_updated_by,
4120
+ },
4121
+ headers={
4122
+ "content-type": "application/json",
4123
+ },
4124
+ request_options=request_options,
4125
+ omit=OMIT,
4126
+ )
4127
+ try:
4128
+ if 200 <= _response.status_code < 300:
4129
+ return AsyncHttpResponse(response=_response, data=None)
4130
+ if _response.status_code == 404:
4131
+ raise NotFoundError(
4132
+ headers=dict(_response.headers),
4133
+ body=typing.cast(
4134
+ typing.Optional[typing.Any],
4135
+ parse_obj_as(
4136
+ type_=typing.Optional[typing.Any], # type: ignore
4137
+ object_=_response.json(),
4138
+ ),
4139
+ ),
4140
+ )
4141
+ _response_json = _response.json()
4142
+ except JSONDecodeError:
4143
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
4144
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)