mirascope 2.0.0a5__py3-none-any.whl → 2.0.1__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 (349) hide show
  1. mirascope/__init__.py +10 -1
  2. mirascope/_stubs.py +363 -0
  3. mirascope/api/__init__.py +8 -0
  4. mirascope/api/_generated/__init__.py +285 -2
  5. mirascope/api/_generated/annotations/__init__.py +33 -0
  6. mirascope/api/_generated/annotations/client.py +506 -0
  7. mirascope/api/_generated/annotations/raw_client.py +1414 -0
  8. mirascope/api/_generated/annotations/types/__init__.py +31 -0
  9. mirascope/api/_generated/annotations/types/annotations_create_request_label.py +5 -0
  10. mirascope/api/_generated/annotations/types/annotations_create_response.py +48 -0
  11. mirascope/api/_generated/annotations/types/annotations_create_response_label.py +5 -0
  12. mirascope/api/_generated/annotations/types/annotations_get_response.py +48 -0
  13. mirascope/api/_generated/annotations/types/annotations_get_response_label.py +5 -0
  14. mirascope/api/_generated/annotations/types/annotations_list_request_label.py +5 -0
  15. mirascope/api/_generated/annotations/types/annotations_list_response.py +21 -0
  16. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item.py +50 -0
  17. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item_label.py +5 -0
  18. mirascope/api/_generated/annotations/types/annotations_update_request_label.py +5 -0
  19. mirascope/api/_generated/annotations/types/annotations_update_response.py +48 -0
  20. mirascope/api/_generated/annotations/types/annotations_update_response_label.py +5 -0
  21. mirascope/api/_generated/api_keys/__init__.py +12 -2
  22. mirascope/api/_generated/api_keys/client.py +77 -0
  23. mirascope/api/_generated/api_keys/raw_client.py +422 -39
  24. mirascope/api/_generated/api_keys/types/__init__.py +7 -1
  25. mirascope/api/_generated/api_keys/types/api_keys_create_response.py +4 -12
  26. mirascope/api/_generated/api_keys/types/api_keys_get_response.py +4 -12
  27. mirascope/api/_generated/api_keys/types/api_keys_list_all_for_org_response_item.py +40 -0
  28. mirascope/api/_generated/api_keys/types/api_keys_list_response_item.py +4 -12
  29. mirascope/api/_generated/client.py +42 -0
  30. mirascope/api/_generated/core/client_wrapper.py +2 -14
  31. mirascope/api/_generated/core/datetime_utils.py +1 -3
  32. mirascope/api/_generated/core/file.py +2 -5
  33. mirascope/api/_generated/core/http_client.py +36 -112
  34. mirascope/api/_generated/core/jsonable_encoder.py +1 -3
  35. mirascope/api/_generated/core/pydantic_utilities.py +19 -74
  36. mirascope/api/_generated/core/query_encoder.py +1 -3
  37. mirascope/api/_generated/core/serialization.py +4 -10
  38. mirascope/api/_generated/docs/client.py +2 -6
  39. mirascope/api/_generated/docs/raw_client.py +51 -5
  40. mirascope/api/_generated/environment.py +3 -3
  41. mirascope/api/_generated/environments/__init__.py +6 -0
  42. mirascope/api/_generated/environments/client.py +117 -0
  43. mirascope/api/_generated/environments/raw_client.py +530 -51
  44. mirascope/api/_generated/environments/types/__init__.py +10 -0
  45. mirascope/api/_generated/environments/types/environments_create_response.py +1 -3
  46. mirascope/api/_generated/environments/types/environments_get_analytics_response.py +60 -0
  47. mirascope/api/_generated/environments/types/environments_get_analytics_response_top_functions_item.py +24 -0
  48. mirascope/api/_generated/environments/types/environments_get_analytics_response_top_models_item.py +22 -0
  49. mirascope/api/_generated/environments/types/environments_get_response.py +1 -3
  50. mirascope/api/_generated/environments/types/environments_list_response_item.py +1 -3
  51. mirascope/api/_generated/environments/types/environments_update_response.py +1 -3
  52. mirascope/api/_generated/errors/__init__.py +8 -0
  53. mirascope/api/_generated/errors/bad_request_error.py +1 -2
  54. mirascope/api/_generated/errors/conflict_error.py +1 -2
  55. mirascope/api/_generated/errors/forbidden_error.py +1 -5
  56. mirascope/api/_generated/errors/internal_server_error.py +1 -6
  57. mirascope/api/_generated/errors/not_found_error.py +1 -5
  58. mirascope/api/_generated/errors/payment_required_error.py +15 -0
  59. mirascope/api/_generated/errors/service_unavailable_error.py +14 -0
  60. mirascope/api/_generated/errors/too_many_requests_error.py +15 -0
  61. mirascope/api/_generated/errors/unauthorized_error.py +11 -0
  62. mirascope/api/_generated/functions/__init__.py +39 -0
  63. mirascope/api/_generated/functions/client.py +647 -0
  64. mirascope/api/_generated/functions/raw_client.py +1890 -0
  65. mirascope/api/_generated/functions/types/__init__.py +53 -0
  66. mirascope/api/_generated/functions/types/functions_create_request_dependencies_value.py +20 -0
  67. mirascope/api/_generated/functions/types/functions_create_response.py +37 -0
  68. mirascope/api/_generated/functions/types/functions_create_response_dependencies_value.py +20 -0
  69. mirascope/api/_generated/functions/types/functions_find_by_hash_response.py +39 -0
  70. mirascope/api/_generated/functions/types/functions_find_by_hash_response_dependencies_value.py +20 -0
  71. mirascope/api/_generated/functions/types/functions_get_by_env_response.py +53 -0
  72. mirascope/api/_generated/functions/types/functions_get_by_env_response_dependencies_value.py +22 -0
  73. mirascope/api/_generated/functions/types/functions_get_response.py +37 -0
  74. mirascope/api/_generated/functions/types/functions_get_response_dependencies_value.py +20 -0
  75. mirascope/api/_generated/functions/types/functions_list_by_env_response.py +25 -0
  76. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item.py +56 -0
  77. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item_dependencies_value.py +22 -0
  78. mirascope/api/_generated/functions/types/functions_list_response.py +21 -0
  79. mirascope/api/_generated/functions/types/functions_list_response_functions_item.py +41 -0
  80. mirascope/api/_generated/functions/types/functions_list_response_functions_item_dependencies_value.py +20 -0
  81. mirascope/api/_generated/health/client.py +2 -6
  82. mirascope/api/_generated/health/raw_client.py +51 -5
  83. mirascope/api/_generated/health/types/health_check_response.py +1 -3
  84. mirascope/api/_generated/organization_invitations/__init__.py +33 -0
  85. mirascope/api/_generated/organization_invitations/client.py +546 -0
  86. mirascope/api/_generated/organization_invitations/raw_client.py +1519 -0
  87. mirascope/api/_generated/organization_invitations/types/__init__.py +53 -0
  88. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response.py +34 -0
  89. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response_role.py +7 -0
  90. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_request_role.py +7 -0
  91. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response.py +48 -0
  92. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_role.py +7 -0
  93. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_status.py +7 -0
  94. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response.py +48 -0
  95. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_role.py +7 -0
  96. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_status.py +7 -0
  97. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item.py +48 -0
  98. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_role.py +7 -0
  99. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_status.py +7 -0
  100. mirascope/api/_generated/organization_memberships/__init__.py +19 -0
  101. mirascope/api/_generated/organization_memberships/client.py +302 -0
  102. mirascope/api/_generated/organization_memberships/raw_client.py +736 -0
  103. mirascope/api/_generated/organization_memberships/types/__init__.py +27 -0
  104. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item.py +33 -0
  105. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item_role.py +7 -0
  106. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_request_role.py +7 -0
  107. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response.py +31 -0
  108. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response_role.py +7 -0
  109. mirascope/api/_generated/organizations/__init__.py +26 -0
  110. mirascope/api/_generated/organizations/client.py +465 -0
  111. mirascope/api/_generated/organizations/raw_client.py +1799 -108
  112. mirascope/api/_generated/organizations/types/__init__.py +48 -0
  113. mirascope/api/_generated/organizations/types/organizations_create_payment_intent_response.py +24 -0
  114. mirascope/api/_generated/organizations/types/organizations_create_response.py +4 -3
  115. mirascope/api/_generated/organizations/types/organizations_create_response_role.py +1 -3
  116. mirascope/api/_generated/organizations/types/organizations_get_response.py +4 -3
  117. mirascope/api/_generated/organizations/types/organizations_get_response_role.py +1 -3
  118. mirascope/api/_generated/organizations/types/organizations_list_response_item.py +4 -3
  119. mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +1 -3
  120. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_request_target_plan.py +7 -0
  121. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response.py +47 -0
  122. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item.py +33 -0
  123. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item_resource.py +7 -0
  124. mirascope/api/_generated/organizations/types/organizations_router_balance_response.py +24 -0
  125. mirascope/api/_generated/organizations/types/organizations_subscription_response.py +53 -0
  126. mirascope/api/_generated/organizations/types/organizations_subscription_response_current_plan.py +7 -0
  127. mirascope/api/_generated/organizations/types/organizations_subscription_response_payment_method.py +26 -0
  128. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change.py +34 -0
  129. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change_target_plan.py +7 -0
  130. mirascope/api/_generated/organizations/types/organizations_update_response.py +4 -3
  131. mirascope/api/_generated/organizations/types/organizations_update_response_role.py +1 -3
  132. mirascope/api/_generated/organizations/types/organizations_update_subscription_request_target_plan.py +7 -0
  133. mirascope/api/_generated/organizations/types/organizations_update_subscription_response.py +35 -0
  134. mirascope/api/_generated/project_memberships/__init__.py +25 -0
  135. mirascope/api/_generated/project_memberships/client.py +437 -0
  136. mirascope/api/_generated/project_memberships/raw_client.py +1039 -0
  137. mirascope/api/_generated/project_memberships/types/__init__.py +29 -0
  138. mirascope/api/_generated/project_memberships/types/project_memberships_create_request_role.py +7 -0
  139. mirascope/api/_generated/project_memberships/types/project_memberships_create_response.py +35 -0
  140. mirascope/api/_generated/project_memberships/types/project_memberships_create_response_role.py +7 -0
  141. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item.py +33 -0
  142. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item_role.py +7 -0
  143. mirascope/api/_generated/project_memberships/types/project_memberships_update_request_role.py +7 -0
  144. mirascope/api/_generated/project_memberships/types/project_memberships_update_response.py +35 -0
  145. mirascope/api/_generated/project_memberships/types/project_memberships_update_response_role.py +7 -0
  146. mirascope/api/_generated/projects/__init__.py +2 -12
  147. mirascope/api/_generated/projects/client.py +17 -71
  148. mirascope/api/_generated/projects/raw_client.py +295 -51
  149. mirascope/api/_generated/projects/types/__init__.py +1 -6
  150. mirascope/api/_generated/projects/types/projects_create_response.py +3 -9
  151. mirascope/api/_generated/projects/types/projects_get_response.py +3 -9
  152. mirascope/api/_generated/projects/types/projects_list_response_item.py +3 -9
  153. mirascope/api/_generated/projects/types/projects_update_response.py +3 -9
  154. mirascope/api/_generated/reference.md +3619 -182
  155. mirascope/api/_generated/tags/__init__.py +19 -0
  156. mirascope/api/_generated/tags/client.py +504 -0
  157. mirascope/api/_generated/tags/raw_client.py +1288 -0
  158. mirascope/api/_generated/tags/types/__init__.py +17 -0
  159. mirascope/api/_generated/tags/types/tags_create_response.py +41 -0
  160. mirascope/api/_generated/tags/types/tags_get_response.py +41 -0
  161. mirascope/api/_generated/tags/types/tags_list_response.py +23 -0
  162. mirascope/api/_generated/tags/types/tags_list_response_tags_item.py +41 -0
  163. mirascope/api/_generated/tags/types/tags_update_response.py +41 -0
  164. mirascope/api/_generated/token_cost/__init__.py +7 -0
  165. mirascope/api/_generated/token_cost/client.py +160 -0
  166. mirascope/api/_generated/token_cost/raw_client.py +264 -0
  167. mirascope/api/_generated/token_cost/types/__init__.py +8 -0
  168. mirascope/api/_generated/token_cost/types/token_cost_calculate_request_usage.py +54 -0
  169. mirascope/api/_generated/token_cost/types/token_cost_calculate_response.py +52 -0
  170. mirascope/api/_generated/traces/__init__.py +42 -0
  171. mirascope/api/_generated/traces/client.py +941 -0
  172. mirascope/api/_generated/traces/raw_client.py +2177 -23
  173. mirascope/api/_generated/traces/types/__init__.py +60 -0
  174. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +4 -11
  175. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +2 -6
  176. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +1 -3
  177. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +8 -24
  178. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +2 -6
  179. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +3 -9
  180. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +2 -6
  181. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +3 -9
  182. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +4 -8
  183. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +2 -6
  184. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +8 -24
  185. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +2 -6
  186. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +3 -9
  187. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +1 -3
  188. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +6 -18
  189. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +3 -9
  190. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +8 -24
  191. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +2 -6
  192. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +2 -6
  193. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +1 -3
  194. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +2 -6
  195. mirascope/api/_generated/traces/types/traces_create_response.py +2 -5
  196. mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +3 -9
  197. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response.py +60 -0
  198. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_functions_item.py +24 -0
  199. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_models_item.py +22 -0
  200. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response.py +33 -0
  201. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response_spans_item.py +88 -0
  202. mirascope/api/_generated/traces/types/traces_get_trace_detail_response.py +33 -0
  203. mirascope/api/_generated/traces/types/traces_get_trace_detail_response_spans_item.py +88 -0
  204. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response.py +25 -0
  205. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response_traces_item.py +44 -0
  206. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item.py +26 -0
  207. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item_operator.py +7 -0
  208. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_by.py +7 -0
  209. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_order.py +7 -0
  210. mirascope/api/_generated/traces/types/traces_search_by_env_response.py +26 -0
  211. mirascope/api/_generated/traces/types/traces_search_by_env_response_spans_item.py +50 -0
  212. mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item.py +26 -0
  213. mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item_operator.py +7 -0
  214. mirascope/api/_generated/traces/types/traces_search_request_sort_by.py +7 -0
  215. mirascope/api/_generated/traces/types/traces_search_request_sort_order.py +5 -0
  216. mirascope/api/_generated/traces/types/traces_search_response.py +26 -0
  217. mirascope/api/_generated/traces/types/traces_search_response_spans_item.py +50 -0
  218. mirascope/api/_generated/types/__init__.py +48 -0
  219. mirascope/api/_generated/types/already_exists_error.py +1 -3
  220. mirascope/api/_generated/types/bad_request_error_body.py +50 -0
  221. mirascope/api/_generated/types/click_house_error.py +22 -0
  222. mirascope/api/_generated/types/database_error.py +1 -3
  223. mirascope/api/_generated/types/date.py +3 -0
  224. mirascope/api/_generated/types/http_api_decode_error.py +1 -3
  225. mirascope/api/_generated/types/immutable_resource_error.py +22 -0
  226. mirascope/api/_generated/types/internal_server_error_body.py +49 -0
  227. mirascope/api/_generated/types/issue.py +1 -3
  228. mirascope/api/_generated/types/issue_tag.py +1 -8
  229. mirascope/api/_generated/types/not_found_error_body.py +1 -3
  230. mirascope/api/_generated/types/number_from_string.py +3 -0
  231. mirascope/api/_generated/types/permission_denied_error.py +1 -3
  232. mirascope/api/_generated/types/permission_denied_error_tag.py +1 -3
  233. mirascope/api/_generated/types/plan_limit_exceeded_error.py +32 -0
  234. mirascope/api/_generated/types/plan_limit_exceeded_error_tag.py +7 -0
  235. mirascope/api/_generated/types/pricing_unavailable_error.py +23 -0
  236. mirascope/api/_generated/types/property_key_key.py +1 -3
  237. mirascope/api/_generated/types/rate_limit_error.py +31 -0
  238. mirascope/api/_generated/types/rate_limit_error_tag.py +5 -0
  239. mirascope/api/_generated/types/service_unavailable_error_body.py +24 -0
  240. mirascope/api/_generated/types/service_unavailable_error_tag.py +7 -0
  241. mirascope/api/_generated/types/stripe_error.py +20 -0
  242. mirascope/api/_generated/types/subscription_past_due_error.py +31 -0
  243. mirascope/api/_generated/types/subscription_past_due_error_tag.py +7 -0
  244. mirascope/api/_generated/types/unauthorized_error_body.py +21 -0
  245. mirascope/api/_generated/types/unauthorized_error_tag.py +5 -0
  246. mirascope/api/settings.py +19 -1
  247. mirascope/llm/__init__.py +55 -8
  248. mirascope/llm/calls/__init__.py +2 -1
  249. mirascope/llm/calls/calls.py +3 -1
  250. mirascope/llm/calls/decorator.py +21 -7
  251. mirascope/llm/content/tool_call.py +6 -0
  252. mirascope/llm/content/tool_output.py +22 -5
  253. mirascope/llm/exceptions.py +284 -71
  254. mirascope/llm/formatting/__init__.py +19 -2
  255. mirascope/llm/formatting/format.py +219 -30
  256. mirascope/llm/formatting/output_parser.py +178 -0
  257. mirascope/llm/formatting/partial.py +80 -7
  258. mirascope/llm/formatting/primitives.py +192 -0
  259. mirascope/llm/formatting/types.py +21 -64
  260. mirascope/llm/mcp/__init__.py +2 -2
  261. mirascope/llm/mcp/mcp_client.py +130 -0
  262. mirascope/llm/messages/__init__.py +3 -0
  263. mirascope/llm/messages/_utils.py +34 -0
  264. mirascope/llm/models/__init__.py +5 -0
  265. mirascope/llm/models/models.py +137 -69
  266. mirascope/llm/{providers/base → models}/params.py +16 -37
  267. mirascope/llm/models/thinking_config.py +61 -0
  268. mirascope/llm/prompts/_utils.py +0 -32
  269. mirascope/llm/prompts/decorator.py +16 -5
  270. mirascope/llm/prompts/prompts.py +131 -68
  271. mirascope/llm/providers/__init__.py +18 -2
  272. mirascope/llm/providers/anthropic/__init__.py +3 -21
  273. mirascope/llm/providers/anthropic/_utils/__init__.py +2 -0
  274. mirascope/llm/providers/anthropic/_utils/beta_decode.py +22 -11
  275. mirascope/llm/providers/anthropic/_utils/beta_encode.py +75 -25
  276. mirascope/llm/providers/anthropic/_utils/decode.py +22 -11
  277. mirascope/llm/providers/anthropic/_utils/encode.py +82 -20
  278. mirascope/llm/providers/anthropic/_utils/errors.py +2 -2
  279. mirascope/llm/providers/anthropic/beta_provider.py +64 -18
  280. mirascope/llm/providers/anthropic/provider.py +91 -33
  281. mirascope/llm/providers/base/__init__.py +0 -2
  282. mirascope/llm/providers/base/_utils.py +55 -11
  283. mirascope/llm/providers/base/base_provider.py +116 -37
  284. mirascope/llm/providers/google/__init__.py +2 -17
  285. mirascope/llm/providers/google/_utils/__init__.py +2 -0
  286. mirascope/llm/providers/google/_utils/decode.py +37 -15
  287. mirascope/llm/providers/google/_utils/encode.py +127 -19
  288. mirascope/llm/providers/google/_utils/errors.py +3 -2
  289. mirascope/llm/providers/google/model_info.py +1 -0
  290. mirascope/llm/providers/google/provider.py +68 -19
  291. mirascope/llm/providers/mirascope/__init__.py +5 -0
  292. mirascope/llm/providers/mirascope/_utils.py +73 -0
  293. mirascope/llm/providers/mirascope/provider.py +349 -0
  294. mirascope/llm/providers/mlx/__init__.py +2 -17
  295. mirascope/llm/providers/mlx/_utils.py +8 -3
  296. mirascope/llm/providers/mlx/encoding/base.py +5 -2
  297. mirascope/llm/providers/mlx/encoding/transformers.py +5 -2
  298. mirascope/llm/providers/mlx/mlx.py +23 -6
  299. mirascope/llm/providers/mlx/provider.py +42 -13
  300. mirascope/llm/providers/ollama/__init__.py +1 -13
  301. mirascope/llm/providers/openai/_utils/errors.py +2 -2
  302. mirascope/llm/providers/openai/completions/__init__.py +2 -20
  303. mirascope/llm/providers/openai/completions/_utils/decode.py +14 -3
  304. mirascope/llm/providers/openai/completions/_utils/encode.py +35 -28
  305. mirascope/llm/providers/openai/completions/base_provider.py +40 -11
  306. mirascope/llm/providers/openai/provider.py +40 -10
  307. mirascope/llm/providers/openai/responses/__init__.py +1 -17
  308. mirascope/llm/providers/openai/responses/_utils/__init__.py +2 -0
  309. mirascope/llm/providers/openai/responses/_utils/decode.py +21 -8
  310. mirascope/llm/providers/openai/responses/_utils/encode.py +59 -19
  311. mirascope/llm/providers/openai/responses/provider.py +56 -18
  312. mirascope/llm/providers/provider_id.py +1 -0
  313. mirascope/llm/providers/provider_registry.py +96 -19
  314. mirascope/llm/providers/together/__init__.py +1 -13
  315. mirascope/llm/responses/__init__.py +6 -1
  316. mirascope/llm/responses/_utils.py +102 -12
  317. mirascope/llm/responses/base_response.py +5 -2
  318. mirascope/llm/responses/base_stream_response.py +139 -45
  319. mirascope/llm/responses/response.py +2 -1
  320. mirascope/llm/responses/root_response.py +89 -17
  321. mirascope/llm/responses/stream_response.py +6 -9
  322. mirascope/llm/tools/decorator.py +17 -8
  323. mirascope/llm/tools/tool_schema.py +43 -10
  324. mirascope/llm/tools/toolkit.py +35 -27
  325. mirascope/llm/tools/tools.py +123 -30
  326. mirascope/ops/__init__.py +64 -109
  327. mirascope/ops/_internal/configuration.py +82 -31
  328. mirascope/ops/_internal/exporters/exporters.py +64 -11
  329. mirascope/ops/_internal/instrumentation/llm/common.py +530 -0
  330. mirascope/ops/_internal/instrumentation/llm/cost.py +190 -0
  331. mirascope/ops/_internal/instrumentation/llm/encode.py +1 -1
  332. mirascope/ops/_internal/instrumentation/llm/llm.py +116 -1243
  333. mirascope/ops/_internal/instrumentation/llm/model.py +1798 -0
  334. mirascope/ops/_internal/instrumentation/llm/response.py +521 -0
  335. mirascope/ops/_internal/instrumentation/llm/serialize.py +300 -0
  336. mirascope/ops/_internal/protocols.py +83 -1
  337. mirascope/ops/_internal/traced_calls.py +4 -0
  338. mirascope/ops/_internal/traced_functions.py +141 -12
  339. mirascope/ops/_internal/tracing.py +78 -1
  340. mirascope/ops/_internal/utils.py +52 -4
  341. mirascope/ops/_internal/versioned_functions.py +54 -43
  342. {mirascope-2.0.0a5.dist-info → mirascope-2.0.1.dist-info}/METADATA +14 -13
  343. mirascope-2.0.1.dist-info/RECORD +423 -0
  344. {mirascope-2.0.0a5.dist-info → mirascope-2.0.1.dist-info}/licenses/LICENSE +1 -1
  345. mirascope/llm/formatting/_utils.py +0 -78
  346. mirascope/llm/mcp/client.py +0 -118
  347. mirascope/llm/providers/_missing_import_stubs.py +0 -49
  348. mirascope-2.0.0a5.dist-info/RECORD +0 -265
  349. {mirascope-2.0.0a5.dist-info → mirascope-2.0.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1414 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..errors.conflict_error import ConflictError
14
+ from ..errors.forbidden_error import ForbiddenError
15
+ from ..errors.internal_server_error import InternalServerError
16
+ from ..errors.not_found_error import NotFoundError
17
+ from ..errors.service_unavailable_error import ServiceUnavailableError
18
+ from ..errors.too_many_requests_error import TooManyRequestsError
19
+ from ..errors.unauthorized_error import UnauthorizedError
20
+ from ..types.not_found_error_body import NotFoundErrorBody
21
+ from ..types.number_from_string import NumberFromString
22
+ from ..types.permission_denied_error import PermissionDeniedError
23
+ from ..types.rate_limit_error import RateLimitError
24
+ from ..types.unauthorized_error_body import UnauthorizedErrorBody
25
+ from .types.annotations_create_request_label import AnnotationsCreateRequestLabel
26
+ from .types.annotations_create_response import AnnotationsCreateResponse
27
+ from .types.annotations_get_response import AnnotationsGetResponse
28
+ from .types.annotations_list_request_label import AnnotationsListRequestLabel
29
+ from .types.annotations_list_response import AnnotationsListResponse
30
+ from .types.annotations_update_request_label import AnnotationsUpdateRequestLabel
31
+ from .types.annotations_update_response import AnnotationsUpdateResponse
32
+
33
+ # this is used as the default value for optional parameters
34
+ OMIT = typing.cast(typing.Any, ...)
35
+
36
+
37
+ class RawAnnotationsClient:
38
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
39
+ self._client_wrapper = client_wrapper
40
+
41
+ def list(
42
+ self,
43
+ *,
44
+ otel_trace_id: typing.Optional[str] = None,
45
+ otel_span_id: typing.Optional[str] = None,
46
+ label: typing.Optional[AnnotationsListRequestLabel] = None,
47
+ limit: typing.Optional[NumberFromString] = None,
48
+ offset: typing.Optional[NumberFromString] = None,
49
+ request_options: typing.Optional[RequestOptions] = None,
50
+ ) -> HttpResponse[AnnotationsListResponse]:
51
+ """
52
+ Parameters
53
+ ----------
54
+ otel_trace_id : typing.Optional[str]
55
+
56
+ otel_span_id : typing.Optional[str]
57
+
58
+ label : typing.Optional[AnnotationsListRequestLabel]
59
+
60
+ limit : typing.Optional[NumberFromString]
61
+
62
+ offset : typing.Optional[NumberFromString]
63
+
64
+ request_options : typing.Optional[RequestOptions]
65
+ Request-specific configuration.
66
+
67
+ Returns
68
+ -------
69
+ HttpResponse[AnnotationsListResponse]
70
+ Success
71
+ """
72
+ _response = self._client_wrapper.httpx_client.request(
73
+ "annotations",
74
+ method="GET",
75
+ params={
76
+ "otelTraceId": otel_trace_id,
77
+ "otelSpanId": otel_span_id,
78
+ "label": label,
79
+ "limit": limit,
80
+ "offset": offset,
81
+ },
82
+ request_options=request_options,
83
+ )
84
+ try:
85
+ if 200 <= _response.status_code < 300:
86
+ _data = typing.cast(
87
+ AnnotationsListResponse,
88
+ parse_obj_as(
89
+ type_=AnnotationsListResponse, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ )
93
+ return HttpResponse(response=_response, data=_data)
94
+ if _response.status_code == 400:
95
+ raise BadRequestError(
96
+ headers=dict(_response.headers),
97
+ body=typing.cast(
98
+ typing.Optional[typing.Any],
99
+ parse_obj_as(
100
+ type_=typing.Optional[typing.Any], # type: ignore
101
+ object_=_response.json(),
102
+ ),
103
+ ),
104
+ )
105
+ if _response.status_code == 401:
106
+ raise UnauthorizedError(
107
+ headers=dict(_response.headers),
108
+ body=typing.cast(
109
+ UnauthorizedErrorBody,
110
+ parse_obj_as(
111
+ type_=UnauthorizedErrorBody, # type: ignore
112
+ object_=_response.json(),
113
+ ),
114
+ ),
115
+ )
116
+ if _response.status_code == 403:
117
+ raise ForbiddenError(
118
+ headers=dict(_response.headers),
119
+ body=typing.cast(
120
+ PermissionDeniedError,
121
+ parse_obj_as(
122
+ type_=PermissionDeniedError, # type: ignore
123
+ object_=_response.json(),
124
+ ),
125
+ ),
126
+ )
127
+ if _response.status_code == 404:
128
+ raise NotFoundError(
129
+ headers=dict(_response.headers),
130
+ body=typing.cast(
131
+ NotFoundErrorBody,
132
+ parse_obj_as(
133
+ type_=NotFoundErrorBody, # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ ),
137
+ )
138
+ if _response.status_code == 429:
139
+ raise TooManyRequestsError(
140
+ headers=dict(_response.headers),
141
+ body=typing.cast(
142
+ RateLimitError,
143
+ parse_obj_as(
144
+ type_=RateLimitError, # type: ignore
145
+ object_=_response.json(),
146
+ ),
147
+ ),
148
+ )
149
+ if _response.status_code == 500:
150
+ raise InternalServerError(
151
+ headers=dict(_response.headers),
152
+ body=typing.cast(
153
+ typing.Optional[typing.Any],
154
+ parse_obj_as(
155
+ type_=typing.Optional[typing.Any], # type: ignore
156
+ object_=_response.json(),
157
+ ),
158
+ ),
159
+ )
160
+ if _response.status_code == 503:
161
+ raise ServiceUnavailableError(
162
+ headers=dict(_response.headers),
163
+ body=typing.cast(
164
+ typing.Optional[typing.Any],
165
+ parse_obj_as(
166
+ type_=typing.Optional[typing.Any], # type: ignore
167
+ object_=_response.json(),
168
+ ),
169
+ ),
170
+ )
171
+ _response_json = _response.json()
172
+ except JSONDecodeError:
173
+ raise ApiError(
174
+ status_code=_response.status_code,
175
+ headers=dict(_response.headers),
176
+ body=_response.text,
177
+ )
178
+ raise ApiError(
179
+ status_code=_response.status_code,
180
+ headers=dict(_response.headers),
181
+ body=_response_json,
182
+ )
183
+
184
+ def create(
185
+ self,
186
+ *,
187
+ otel_span_id: str,
188
+ otel_trace_id: str,
189
+ label: typing.Optional[AnnotationsCreateRequestLabel] = OMIT,
190
+ reasoning: typing.Optional[str] = OMIT,
191
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
192
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
193
+ request_options: typing.Optional[RequestOptions] = None,
194
+ ) -> HttpResponse[AnnotationsCreateResponse]:
195
+ """
196
+ Parameters
197
+ ----------
198
+ otel_span_id : str
199
+
200
+ otel_trace_id : str
201
+
202
+ label : typing.Optional[AnnotationsCreateRequestLabel]
203
+
204
+ reasoning : typing.Optional[str]
205
+
206
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
207
+
208
+ tags : typing.Optional[typing.Sequence[str]]
209
+
210
+ request_options : typing.Optional[RequestOptions]
211
+ Request-specific configuration.
212
+
213
+ Returns
214
+ -------
215
+ HttpResponse[AnnotationsCreateResponse]
216
+ Success
217
+ """
218
+ _response = self._client_wrapper.httpx_client.request(
219
+ "annotations",
220
+ method="POST",
221
+ json={
222
+ "otelSpanId": otel_span_id,
223
+ "otelTraceId": otel_trace_id,
224
+ "label": label,
225
+ "reasoning": reasoning,
226
+ "metadata": metadata,
227
+ "tags": tags,
228
+ },
229
+ headers={
230
+ "content-type": "application/json",
231
+ },
232
+ request_options=request_options,
233
+ omit=OMIT,
234
+ )
235
+ try:
236
+ if 200 <= _response.status_code < 300:
237
+ _data = typing.cast(
238
+ AnnotationsCreateResponse,
239
+ parse_obj_as(
240
+ type_=AnnotationsCreateResponse, # type: ignore
241
+ object_=_response.json(),
242
+ ),
243
+ )
244
+ return HttpResponse(response=_response, data=_data)
245
+ if _response.status_code == 400:
246
+ raise BadRequestError(
247
+ headers=dict(_response.headers),
248
+ body=typing.cast(
249
+ typing.Optional[typing.Any],
250
+ parse_obj_as(
251
+ type_=typing.Optional[typing.Any], # type: ignore
252
+ object_=_response.json(),
253
+ ),
254
+ ),
255
+ )
256
+ if _response.status_code == 401:
257
+ raise UnauthorizedError(
258
+ headers=dict(_response.headers),
259
+ body=typing.cast(
260
+ UnauthorizedErrorBody,
261
+ parse_obj_as(
262
+ type_=UnauthorizedErrorBody, # type: ignore
263
+ object_=_response.json(),
264
+ ),
265
+ ),
266
+ )
267
+ if _response.status_code == 403:
268
+ raise ForbiddenError(
269
+ headers=dict(_response.headers),
270
+ body=typing.cast(
271
+ PermissionDeniedError,
272
+ parse_obj_as(
273
+ type_=PermissionDeniedError, # type: ignore
274
+ object_=_response.json(),
275
+ ),
276
+ ),
277
+ )
278
+ if _response.status_code == 404:
279
+ raise NotFoundError(
280
+ headers=dict(_response.headers),
281
+ body=typing.cast(
282
+ NotFoundErrorBody,
283
+ parse_obj_as(
284
+ type_=NotFoundErrorBody, # type: ignore
285
+ object_=_response.json(),
286
+ ),
287
+ ),
288
+ )
289
+ if _response.status_code == 409:
290
+ raise ConflictError(
291
+ headers=dict(_response.headers),
292
+ body=typing.cast(
293
+ typing.Optional[typing.Any],
294
+ parse_obj_as(
295
+ type_=typing.Optional[typing.Any], # type: ignore
296
+ object_=_response.json(),
297
+ ),
298
+ ),
299
+ )
300
+ if _response.status_code == 429:
301
+ raise TooManyRequestsError(
302
+ headers=dict(_response.headers),
303
+ body=typing.cast(
304
+ RateLimitError,
305
+ parse_obj_as(
306
+ type_=RateLimitError, # type: ignore
307
+ object_=_response.json(),
308
+ ),
309
+ ),
310
+ )
311
+ if _response.status_code == 500:
312
+ raise InternalServerError(
313
+ headers=dict(_response.headers),
314
+ body=typing.cast(
315
+ typing.Optional[typing.Any],
316
+ parse_obj_as(
317
+ type_=typing.Optional[typing.Any], # type: ignore
318
+ object_=_response.json(),
319
+ ),
320
+ ),
321
+ )
322
+ if _response.status_code == 503:
323
+ raise ServiceUnavailableError(
324
+ headers=dict(_response.headers),
325
+ body=typing.cast(
326
+ typing.Optional[typing.Any],
327
+ parse_obj_as(
328
+ type_=typing.Optional[typing.Any], # type: ignore
329
+ object_=_response.json(),
330
+ ),
331
+ ),
332
+ )
333
+ _response_json = _response.json()
334
+ except JSONDecodeError:
335
+ raise ApiError(
336
+ status_code=_response.status_code,
337
+ headers=dict(_response.headers),
338
+ body=_response.text,
339
+ )
340
+ raise ApiError(
341
+ status_code=_response.status_code,
342
+ headers=dict(_response.headers),
343
+ body=_response_json,
344
+ )
345
+
346
+ def get(
347
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
348
+ ) -> HttpResponse[AnnotationsGetResponse]:
349
+ """
350
+ Parameters
351
+ ----------
352
+ id : str
353
+
354
+ request_options : typing.Optional[RequestOptions]
355
+ Request-specific configuration.
356
+
357
+ Returns
358
+ -------
359
+ HttpResponse[AnnotationsGetResponse]
360
+ Success
361
+ """
362
+ _response = self._client_wrapper.httpx_client.request(
363
+ f"annotations/{jsonable_encoder(id)}",
364
+ method="GET",
365
+ request_options=request_options,
366
+ )
367
+ try:
368
+ if 200 <= _response.status_code < 300:
369
+ _data = typing.cast(
370
+ AnnotationsGetResponse,
371
+ parse_obj_as(
372
+ type_=AnnotationsGetResponse, # type: ignore
373
+ object_=_response.json(),
374
+ ),
375
+ )
376
+ return HttpResponse(response=_response, data=_data)
377
+ if _response.status_code == 400:
378
+ raise BadRequestError(
379
+ headers=dict(_response.headers),
380
+ body=typing.cast(
381
+ typing.Optional[typing.Any],
382
+ parse_obj_as(
383
+ type_=typing.Optional[typing.Any], # type: ignore
384
+ object_=_response.json(),
385
+ ),
386
+ ),
387
+ )
388
+ if _response.status_code == 401:
389
+ raise UnauthorizedError(
390
+ headers=dict(_response.headers),
391
+ body=typing.cast(
392
+ UnauthorizedErrorBody,
393
+ parse_obj_as(
394
+ type_=UnauthorizedErrorBody, # type: ignore
395
+ object_=_response.json(),
396
+ ),
397
+ ),
398
+ )
399
+ if _response.status_code == 403:
400
+ raise ForbiddenError(
401
+ headers=dict(_response.headers),
402
+ body=typing.cast(
403
+ PermissionDeniedError,
404
+ parse_obj_as(
405
+ type_=PermissionDeniedError, # type: ignore
406
+ object_=_response.json(),
407
+ ),
408
+ ),
409
+ )
410
+ if _response.status_code == 404:
411
+ raise NotFoundError(
412
+ headers=dict(_response.headers),
413
+ body=typing.cast(
414
+ NotFoundErrorBody,
415
+ parse_obj_as(
416
+ type_=NotFoundErrorBody, # type: ignore
417
+ object_=_response.json(),
418
+ ),
419
+ ),
420
+ )
421
+ if _response.status_code == 429:
422
+ raise TooManyRequestsError(
423
+ headers=dict(_response.headers),
424
+ body=typing.cast(
425
+ RateLimitError,
426
+ parse_obj_as(
427
+ type_=RateLimitError, # type: ignore
428
+ object_=_response.json(),
429
+ ),
430
+ ),
431
+ )
432
+ if _response.status_code == 500:
433
+ raise InternalServerError(
434
+ headers=dict(_response.headers),
435
+ body=typing.cast(
436
+ typing.Optional[typing.Any],
437
+ parse_obj_as(
438
+ type_=typing.Optional[typing.Any], # type: ignore
439
+ object_=_response.json(),
440
+ ),
441
+ ),
442
+ )
443
+ if _response.status_code == 503:
444
+ raise ServiceUnavailableError(
445
+ headers=dict(_response.headers),
446
+ body=typing.cast(
447
+ typing.Optional[typing.Any],
448
+ parse_obj_as(
449
+ type_=typing.Optional[typing.Any], # type: ignore
450
+ object_=_response.json(),
451
+ ),
452
+ ),
453
+ )
454
+ _response_json = _response.json()
455
+ except JSONDecodeError:
456
+ raise ApiError(
457
+ status_code=_response.status_code,
458
+ headers=dict(_response.headers),
459
+ body=_response.text,
460
+ )
461
+ raise ApiError(
462
+ status_code=_response.status_code,
463
+ headers=dict(_response.headers),
464
+ body=_response_json,
465
+ )
466
+
467
+ def update(
468
+ self,
469
+ id: str,
470
+ *,
471
+ label: typing.Optional[AnnotationsUpdateRequestLabel] = OMIT,
472
+ reasoning: typing.Optional[str] = OMIT,
473
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
474
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
475
+ request_options: typing.Optional[RequestOptions] = None,
476
+ ) -> HttpResponse[AnnotationsUpdateResponse]:
477
+ """
478
+ Parameters
479
+ ----------
480
+ id : str
481
+
482
+ label : typing.Optional[AnnotationsUpdateRequestLabel]
483
+
484
+ reasoning : typing.Optional[str]
485
+
486
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
487
+
488
+ tags : typing.Optional[typing.Sequence[str]]
489
+
490
+ request_options : typing.Optional[RequestOptions]
491
+ Request-specific configuration.
492
+
493
+ Returns
494
+ -------
495
+ HttpResponse[AnnotationsUpdateResponse]
496
+ Success
497
+ """
498
+ _response = self._client_wrapper.httpx_client.request(
499
+ f"annotations/{jsonable_encoder(id)}",
500
+ method="PUT",
501
+ json={
502
+ "label": label,
503
+ "reasoning": reasoning,
504
+ "metadata": metadata,
505
+ "tags": tags,
506
+ },
507
+ headers={
508
+ "content-type": "application/json",
509
+ },
510
+ request_options=request_options,
511
+ omit=OMIT,
512
+ )
513
+ try:
514
+ if 200 <= _response.status_code < 300:
515
+ _data = typing.cast(
516
+ AnnotationsUpdateResponse,
517
+ parse_obj_as(
518
+ type_=AnnotationsUpdateResponse, # type: ignore
519
+ object_=_response.json(),
520
+ ),
521
+ )
522
+ return HttpResponse(response=_response, data=_data)
523
+ if _response.status_code == 400:
524
+ raise BadRequestError(
525
+ headers=dict(_response.headers),
526
+ body=typing.cast(
527
+ typing.Optional[typing.Any],
528
+ parse_obj_as(
529
+ type_=typing.Optional[typing.Any], # type: ignore
530
+ object_=_response.json(),
531
+ ),
532
+ ),
533
+ )
534
+ if _response.status_code == 401:
535
+ raise UnauthorizedError(
536
+ headers=dict(_response.headers),
537
+ body=typing.cast(
538
+ UnauthorizedErrorBody,
539
+ parse_obj_as(
540
+ type_=UnauthorizedErrorBody, # type: ignore
541
+ object_=_response.json(),
542
+ ),
543
+ ),
544
+ )
545
+ if _response.status_code == 403:
546
+ raise ForbiddenError(
547
+ headers=dict(_response.headers),
548
+ body=typing.cast(
549
+ PermissionDeniedError,
550
+ parse_obj_as(
551
+ type_=PermissionDeniedError, # type: ignore
552
+ object_=_response.json(),
553
+ ),
554
+ ),
555
+ )
556
+ if _response.status_code == 404:
557
+ raise NotFoundError(
558
+ headers=dict(_response.headers),
559
+ body=typing.cast(
560
+ NotFoundErrorBody,
561
+ parse_obj_as(
562
+ type_=NotFoundErrorBody, # type: ignore
563
+ object_=_response.json(),
564
+ ),
565
+ ),
566
+ )
567
+ if _response.status_code == 429:
568
+ raise TooManyRequestsError(
569
+ headers=dict(_response.headers),
570
+ body=typing.cast(
571
+ RateLimitError,
572
+ parse_obj_as(
573
+ type_=RateLimitError, # type: ignore
574
+ object_=_response.json(),
575
+ ),
576
+ ),
577
+ )
578
+ if _response.status_code == 500:
579
+ raise InternalServerError(
580
+ headers=dict(_response.headers),
581
+ body=typing.cast(
582
+ typing.Optional[typing.Any],
583
+ parse_obj_as(
584
+ type_=typing.Optional[typing.Any], # type: ignore
585
+ object_=_response.json(),
586
+ ),
587
+ ),
588
+ )
589
+ if _response.status_code == 503:
590
+ raise ServiceUnavailableError(
591
+ headers=dict(_response.headers),
592
+ body=typing.cast(
593
+ typing.Optional[typing.Any],
594
+ parse_obj_as(
595
+ type_=typing.Optional[typing.Any], # type: ignore
596
+ object_=_response.json(),
597
+ ),
598
+ ),
599
+ )
600
+ _response_json = _response.json()
601
+ except JSONDecodeError:
602
+ raise ApiError(
603
+ status_code=_response.status_code,
604
+ headers=dict(_response.headers),
605
+ body=_response.text,
606
+ )
607
+ raise ApiError(
608
+ status_code=_response.status_code,
609
+ headers=dict(_response.headers),
610
+ body=_response_json,
611
+ )
612
+
613
+ def delete(
614
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
615
+ ) -> HttpResponse[None]:
616
+ """
617
+ Parameters
618
+ ----------
619
+ id : str
620
+
621
+ request_options : typing.Optional[RequestOptions]
622
+ Request-specific configuration.
623
+
624
+ Returns
625
+ -------
626
+ HttpResponse[None]
627
+ """
628
+ _response = self._client_wrapper.httpx_client.request(
629
+ f"annotations/{jsonable_encoder(id)}",
630
+ method="DELETE",
631
+ request_options=request_options,
632
+ )
633
+ try:
634
+ if 200 <= _response.status_code < 300:
635
+ return HttpResponse(response=_response, data=None)
636
+ if _response.status_code == 400:
637
+ raise BadRequestError(
638
+ headers=dict(_response.headers),
639
+ body=typing.cast(
640
+ typing.Optional[typing.Any],
641
+ parse_obj_as(
642
+ type_=typing.Optional[typing.Any], # type: ignore
643
+ object_=_response.json(),
644
+ ),
645
+ ),
646
+ )
647
+ if _response.status_code == 401:
648
+ raise UnauthorizedError(
649
+ headers=dict(_response.headers),
650
+ body=typing.cast(
651
+ UnauthorizedErrorBody,
652
+ parse_obj_as(
653
+ type_=UnauthorizedErrorBody, # type: ignore
654
+ object_=_response.json(),
655
+ ),
656
+ ),
657
+ )
658
+ if _response.status_code == 403:
659
+ raise ForbiddenError(
660
+ headers=dict(_response.headers),
661
+ body=typing.cast(
662
+ PermissionDeniedError,
663
+ parse_obj_as(
664
+ type_=PermissionDeniedError, # type: ignore
665
+ object_=_response.json(),
666
+ ),
667
+ ),
668
+ )
669
+ if _response.status_code == 404:
670
+ raise NotFoundError(
671
+ headers=dict(_response.headers),
672
+ body=typing.cast(
673
+ NotFoundErrorBody,
674
+ parse_obj_as(
675
+ type_=NotFoundErrorBody, # type: ignore
676
+ object_=_response.json(),
677
+ ),
678
+ ),
679
+ )
680
+ if _response.status_code == 429:
681
+ raise TooManyRequestsError(
682
+ headers=dict(_response.headers),
683
+ body=typing.cast(
684
+ RateLimitError,
685
+ parse_obj_as(
686
+ type_=RateLimitError, # type: ignore
687
+ object_=_response.json(),
688
+ ),
689
+ ),
690
+ )
691
+ if _response.status_code == 500:
692
+ raise InternalServerError(
693
+ headers=dict(_response.headers),
694
+ body=typing.cast(
695
+ typing.Optional[typing.Any],
696
+ parse_obj_as(
697
+ type_=typing.Optional[typing.Any], # type: ignore
698
+ object_=_response.json(),
699
+ ),
700
+ ),
701
+ )
702
+ if _response.status_code == 503:
703
+ raise ServiceUnavailableError(
704
+ headers=dict(_response.headers),
705
+ body=typing.cast(
706
+ typing.Optional[typing.Any],
707
+ parse_obj_as(
708
+ type_=typing.Optional[typing.Any], # type: ignore
709
+ object_=_response.json(),
710
+ ),
711
+ ),
712
+ )
713
+ _response_json = _response.json()
714
+ except JSONDecodeError:
715
+ raise ApiError(
716
+ status_code=_response.status_code,
717
+ headers=dict(_response.headers),
718
+ body=_response.text,
719
+ )
720
+ raise ApiError(
721
+ status_code=_response.status_code,
722
+ headers=dict(_response.headers),
723
+ body=_response_json,
724
+ )
725
+
726
+
727
+ class AsyncRawAnnotationsClient:
728
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
729
+ self._client_wrapper = client_wrapper
730
+
731
+ async def list(
732
+ self,
733
+ *,
734
+ otel_trace_id: typing.Optional[str] = None,
735
+ otel_span_id: typing.Optional[str] = None,
736
+ label: typing.Optional[AnnotationsListRequestLabel] = None,
737
+ limit: typing.Optional[NumberFromString] = None,
738
+ offset: typing.Optional[NumberFromString] = None,
739
+ request_options: typing.Optional[RequestOptions] = None,
740
+ ) -> AsyncHttpResponse[AnnotationsListResponse]:
741
+ """
742
+ Parameters
743
+ ----------
744
+ otel_trace_id : typing.Optional[str]
745
+
746
+ otel_span_id : typing.Optional[str]
747
+
748
+ label : typing.Optional[AnnotationsListRequestLabel]
749
+
750
+ limit : typing.Optional[NumberFromString]
751
+
752
+ offset : typing.Optional[NumberFromString]
753
+
754
+ request_options : typing.Optional[RequestOptions]
755
+ Request-specific configuration.
756
+
757
+ Returns
758
+ -------
759
+ AsyncHttpResponse[AnnotationsListResponse]
760
+ Success
761
+ """
762
+ _response = await self._client_wrapper.httpx_client.request(
763
+ "annotations",
764
+ method="GET",
765
+ params={
766
+ "otelTraceId": otel_trace_id,
767
+ "otelSpanId": otel_span_id,
768
+ "label": label,
769
+ "limit": limit,
770
+ "offset": offset,
771
+ },
772
+ request_options=request_options,
773
+ )
774
+ try:
775
+ if 200 <= _response.status_code < 300:
776
+ _data = typing.cast(
777
+ AnnotationsListResponse,
778
+ parse_obj_as(
779
+ type_=AnnotationsListResponse, # type: ignore
780
+ object_=_response.json(),
781
+ ),
782
+ )
783
+ return AsyncHttpResponse(response=_response, data=_data)
784
+ if _response.status_code == 400:
785
+ raise BadRequestError(
786
+ headers=dict(_response.headers),
787
+ body=typing.cast(
788
+ typing.Optional[typing.Any],
789
+ parse_obj_as(
790
+ type_=typing.Optional[typing.Any], # type: ignore
791
+ object_=_response.json(),
792
+ ),
793
+ ),
794
+ )
795
+ if _response.status_code == 401:
796
+ raise UnauthorizedError(
797
+ headers=dict(_response.headers),
798
+ body=typing.cast(
799
+ UnauthorizedErrorBody,
800
+ parse_obj_as(
801
+ type_=UnauthorizedErrorBody, # type: ignore
802
+ object_=_response.json(),
803
+ ),
804
+ ),
805
+ )
806
+ if _response.status_code == 403:
807
+ raise ForbiddenError(
808
+ headers=dict(_response.headers),
809
+ body=typing.cast(
810
+ PermissionDeniedError,
811
+ parse_obj_as(
812
+ type_=PermissionDeniedError, # type: ignore
813
+ object_=_response.json(),
814
+ ),
815
+ ),
816
+ )
817
+ if _response.status_code == 404:
818
+ raise NotFoundError(
819
+ headers=dict(_response.headers),
820
+ body=typing.cast(
821
+ NotFoundErrorBody,
822
+ parse_obj_as(
823
+ type_=NotFoundErrorBody, # type: ignore
824
+ object_=_response.json(),
825
+ ),
826
+ ),
827
+ )
828
+ if _response.status_code == 429:
829
+ raise TooManyRequestsError(
830
+ headers=dict(_response.headers),
831
+ body=typing.cast(
832
+ RateLimitError,
833
+ parse_obj_as(
834
+ type_=RateLimitError, # type: ignore
835
+ object_=_response.json(),
836
+ ),
837
+ ),
838
+ )
839
+ if _response.status_code == 500:
840
+ raise InternalServerError(
841
+ headers=dict(_response.headers),
842
+ body=typing.cast(
843
+ typing.Optional[typing.Any],
844
+ parse_obj_as(
845
+ type_=typing.Optional[typing.Any], # type: ignore
846
+ object_=_response.json(),
847
+ ),
848
+ ),
849
+ )
850
+ if _response.status_code == 503:
851
+ raise ServiceUnavailableError(
852
+ headers=dict(_response.headers),
853
+ body=typing.cast(
854
+ typing.Optional[typing.Any],
855
+ parse_obj_as(
856
+ type_=typing.Optional[typing.Any], # type: ignore
857
+ object_=_response.json(),
858
+ ),
859
+ ),
860
+ )
861
+ _response_json = _response.json()
862
+ except JSONDecodeError:
863
+ raise ApiError(
864
+ status_code=_response.status_code,
865
+ headers=dict(_response.headers),
866
+ body=_response.text,
867
+ )
868
+ raise ApiError(
869
+ status_code=_response.status_code,
870
+ headers=dict(_response.headers),
871
+ body=_response_json,
872
+ )
873
+
874
+ async def create(
875
+ self,
876
+ *,
877
+ otel_span_id: str,
878
+ otel_trace_id: str,
879
+ label: typing.Optional[AnnotationsCreateRequestLabel] = OMIT,
880
+ reasoning: typing.Optional[str] = OMIT,
881
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
882
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
883
+ request_options: typing.Optional[RequestOptions] = None,
884
+ ) -> AsyncHttpResponse[AnnotationsCreateResponse]:
885
+ """
886
+ Parameters
887
+ ----------
888
+ otel_span_id : str
889
+
890
+ otel_trace_id : str
891
+
892
+ label : typing.Optional[AnnotationsCreateRequestLabel]
893
+
894
+ reasoning : typing.Optional[str]
895
+
896
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
897
+
898
+ tags : typing.Optional[typing.Sequence[str]]
899
+
900
+ request_options : typing.Optional[RequestOptions]
901
+ Request-specific configuration.
902
+
903
+ Returns
904
+ -------
905
+ AsyncHttpResponse[AnnotationsCreateResponse]
906
+ Success
907
+ """
908
+ _response = await self._client_wrapper.httpx_client.request(
909
+ "annotations",
910
+ method="POST",
911
+ json={
912
+ "otelSpanId": otel_span_id,
913
+ "otelTraceId": otel_trace_id,
914
+ "label": label,
915
+ "reasoning": reasoning,
916
+ "metadata": metadata,
917
+ "tags": tags,
918
+ },
919
+ headers={
920
+ "content-type": "application/json",
921
+ },
922
+ request_options=request_options,
923
+ omit=OMIT,
924
+ )
925
+ try:
926
+ if 200 <= _response.status_code < 300:
927
+ _data = typing.cast(
928
+ AnnotationsCreateResponse,
929
+ parse_obj_as(
930
+ type_=AnnotationsCreateResponse, # type: ignore
931
+ object_=_response.json(),
932
+ ),
933
+ )
934
+ return AsyncHttpResponse(response=_response, data=_data)
935
+ if _response.status_code == 400:
936
+ raise BadRequestError(
937
+ headers=dict(_response.headers),
938
+ body=typing.cast(
939
+ typing.Optional[typing.Any],
940
+ parse_obj_as(
941
+ type_=typing.Optional[typing.Any], # type: ignore
942
+ object_=_response.json(),
943
+ ),
944
+ ),
945
+ )
946
+ if _response.status_code == 401:
947
+ raise UnauthorizedError(
948
+ headers=dict(_response.headers),
949
+ body=typing.cast(
950
+ UnauthorizedErrorBody,
951
+ parse_obj_as(
952
+ type_=UnauthorizedErrorBody, # type: ignore
953
+ object_=_response.json(),
954
+ ),
955
+ ),
956
+ )
957
+ if _response.status_code == 403:
958
+ raise ForbiddenError(
959
+ headers=dict(_response.headers),
960
+ body=typing.cast(
961
+ PermissionDeniedError,
962
+ parse_obj_as(
963
+ type_=PermissionDeniedError, # type: ignore
964
+ object_=_response.json(),
965
+ ),
966
+ ),
967
+ )
968
+ if _response.status_code == 404:
969
+ raise NotFoundError(
970
+ headers=dict(_response.headers),
971
+ body=typing.cast(
972
+ NotFoundErrorBody,
973
+ parse_obj_as(
974
+ type_=NotFoundErrorBody, # type: ignore
975
+ object_=_response.json(),
976
+ ),
977
+ ),
978
+ )
979
+ if _response.status_code == 409:
980
+ raise ConflictError(
981
+ headers=dict(_response.headers),
982
+ body=typing.cast(
983
+ typing.Optional[typing.Any],
984
+ parse_obj_as(
985
+ type_=typing.Optional[typing.Any], # type: ignore
986
+ object_=_response.json(),
987
+ ),
988
+ ),
989
+ )
990
+ if _response.status_code == 429:
991
+ raise TooManyRequestsError(
992
+ headers=dict(_response.headers),
993
+ body=typing.cast(
994
+ RateLimitError,
995
+ parse_obj_as(
996
+ type_=RateLimitError, # type: ignore
997
+ object_=_response.json(),
998
+ ),
999
+ ),
1000
+ )
1001
+ if _response.status_code == 500:
1002
+ raise InternalServerError(
1003
+ headers=dict(_response.headers),
1004
+ body=typing.cast(
1005
+ typing.Optional[typing.Any],
1006
+ parse_obj_as(
1007
+ type_=typing.Optional[typing.Any], # type: ignore
1008
+ object_=_response.json(),
1009
+ ),
1010
+ ),
1011
+ )
1012
+ if _response.status_code == 503:
1013
+ raise ServiceUnavailableError(
1014
+ headers=dict(_response.headers),
1015
+ body=typing.cast(
1016
+ typing.Optional[typing.Any],
1017
+ parse_obj_as(
1018
+ type_=typing.Optional[typing.Any], # type: ignore
1019
+ object_=_response.json(),
1020
+ ),
1021
+ ),
1022
+ )
1023
+ _response_json = _response.json()
1024
+ except JSONDecodeError:
1025
+ raise ApiError(
1026
+ status_code=_response.status_code,
1027
+ headers=dict(_response.headers),
1028
+ body=_response.text,
1029
+ )
1030
+ raise ApiError(
1031
+ status_code=_response.status_code,
1032
+ headers=dict(_response.headers),
1033
+ body=_response_json,
1034
+ )
1035
+
1036
+ async def get(
1037
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1038
+ ) -> AsyncHttpResponse[AnnotationsGetResponse]:
1039
+ """
1040
+ Parameters
1041
+ ----------
1042
+ id : str
1043
+
1044
+ request_options : typing.Optional[RequestOptions]
1045
+ Request-specific configuration.
1046
+
1047
+ Returns
1048
+ -------
1049
+ AsyncHttpResponse[AnnotationsGetResponse]
1050
+ Success
1051
+ """
1052
+ _response = await self._client_wrapper.httpx_client.request(
1053
+ f"annotations/{jsonable_encoder(id)}",
1054
+ method="GET",
1055
+ request_options=request_options,
1056
+ )
1057
+ try:
1058
+ if 200 <= _response.status_code < 300:
1059
+ _data = typing.cast(
1060
+ AnnotationsGetResponse,
1061
+ parse_obj_as(
1062
+ type_=AnnotationsGetResponse, # type: ignore
1063
+ object_=_response.json(),
1064
+ ),
1065
+ )
1066
+ return AsyncHttpResponse(response=_response, data=_data)
1067
+ if _response.status_code == 400:
1068
+ raise BadRequestError(
1069
+ headers=dict(_response.headers),
1070
+ body=typing.cast(
1071
+ typing.Optional[typing.Any],
1072
+ parse_obj_as(
1073
+ type_=typing.Optional[typing.Any], # type: ignore
1074
+ object_=_response.json(),
1075
+ ),
1076
+ ),
1077
+ )
1078
+ if _response.status_code == 401:
1079
+ raise UnauthorizedError(
1080
+ headers=dict(_response.headers),
1081
+ body=typing.cast(
1082
+ UnauthorizedErrorBody,
1083
+ parse_obj_as(
1084
+ type_=UnauthorizedErrorBody, # type: ignore
1085
+ object_=_response.json(),
1086
+ ),
1087
+ ),
1088
+ )
1089
+ if _response.status_code == 403:
1090
+ raise ForbiddenError(
1091
+ headers=dict(_response.headers),
1092
+ body=typing.cast(
1093
+ PermissionDeniedError,
1094
+ parse_obj_as(
1095
+ type_=PermissionDeniedError, # type: ignore
1096
+ object_=_response.json(),
1097
+ ),
1098
+ ),
1099
+ )
1100
+ if _response.status_code == 404:
1101
+ raise NotFoundError(
1102
+ headers=dict(_response.headers),
1103
+ body=typing.cast(
1104
+ NotFoundErrorBody,
1105
+ parse_obj_as(
1106
+ type_=NotFoundErrorBody, # type: ignore
1107
+ object_=_response.json(),
1108
+ ),
1109
+ ),
1110
+ )
1111
+ if _response.status_code == 429:
1112
+ raise TooManyRequestsError(
1113
+ headers=dict(_response.headers),
1114
+ body=typing.cast(
1115
+ RateLimitError,
1116
+ parse_obj_as(
1117
+ type_=RateLimitError, # type: ignore
1118
+ object_=_response.json(),
1119
+ ),
1120
+ ),
1121
+ )
1122
+ if _response.status_code == 500:
1123
+ raise InternalServerError(
1124
+ headers=dict(_response.headers),
1125
+ body=typing.cast(
1126
+ typing.Optional[typing.Any],
1127
+ parse_obj_as(
1128
+ type_=typing.Optional[typing.Any], # type: ignore
1129
+ object_=_response.json(),
1130
+ ),
1131
+ ),
1132
+ )
1133
+ if _response.status_code == 503:
1134
+ raise ServiceUnavailableError(
1135
+ headers=dict(_response.headers),
1136
+ body=typing.cast(
1137
+ typing.Optional[typing.Any],
1138
+ parse_obj_as(
1139
+ type_=typing.Optional[typing.Any], # type: ignore
1140
+ object_=_response.json(),
1141
+ ),
1142
+ ),
1143
+ )
1144
+ _response_json = _response.json()
1145
+ except JSONDecodeError:
1146
+ raise ApiError(
1147
+ status_code=_response.status_code,
1148
+ headers=dict(_response.headers),
1149
+ body=_response.text,
1150
+ )
1151
+ raise ApiError(
1152
+ status_code=_response.status_code,
1153
+ headers=dict(_response.headers),
1154
+ body=_response_json,
1155
+ )
1156
+
1157
+ async def update(
1158
+ self,
1159
+ id: str,
1160
+ *,
1161
+ label: typing.Optional[AnnotationsUpdateRequestLabel] = OMIT,
1162
+ reasoning: typing.Optional[str] = OMIT,
1163
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1164
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1165
+ request_options: typing.Optional[RequestOptions] = None,
1166
+ ) -> AsyncHttpResponse[AnnotationsUpdateResponse]:
1167
+ """
1168
+ Parameters
1169
+ ----------
1170
+ id : str
1171
+
1172
+ label : typing.Optional[AnnotationsUpdateRequestLabel]
1173
+
1174
+ reasoning : typing.Optional[str]
1175
+
1176
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1177
+
1178
+ tags : typing.Optional[typing.Sequence[str]]
1179
+
1180
+ request_options : typing.Optional[RequestOptions]
1181
+ Request-specific configuration.
1182
+
1183
+ Returns
1184
+ -------
1185
+ AsyncHttpResponse[AnnotationsUpdateResponse]
1186
+ Success
1187
+ """
1188
+ _response = await self._client_wrapper.httpx_client.request(
1189
+ f"annotations/{jsonable_encoder(id)}",
1190
+ method="PUT",
1191
+ json={
1192
+ "label": label,
1193
+ "reasoning": reasoning,
1194
+ "metadata": metadata,
1195
+ "tags": tags,
1196
+ },
1197
+ headers={
1198
+ "content-type": "application/json",
1199
+ },
1200
+ request_options=request_options,
1201
+ omit=OMIT,
1202
+ )
1203
+ try:
1204
+ if 200 <= _response.status_code < 300:
1205
+ _data = typing.cast(
1206
+ AnnotationsUpdateResponse,
1207
+ parse_obj_as(
1208
+ type_=AnnotationsUpdateResponse, # type: ignore
1209
+ object_=_response.json(),
1210
+ ),
1211
+ )
1212
+ return AsyncHttpResponse(response=_response, data=_data)
1213
+ if _response.status_code == 400:
1214
+ raise BadRequestError(
1215
+ headers=dict(_response.headers),
1216
+ body=typing.cast(
1217
+ typing.Optional[typing.Any],
1218
+ parse_obj_as(
1219
+ type_=typing.Optional[typing.Any], # type: ignore
1220
+ object_=_response.json(),
1221
+ ),
1222
+ ),
1223
+ )
1224
+ if _response.status_code == 401:
1225
+ raise UnauthorizedError(
1226
+ headers=dict(_response.headers),
1227
+ body=typing.cast(
1228
+ UnauthorizedErrorBody,
1229
+ parse_obj_as(
1230
+ type_=UnauthorizedErrorBody, # type: ignore
1231
+ object_=_response.json(),
1232
+ ),
1233
+ ),
1234
+ )
1235
+ if _response.status_code == 403:
1236
+ raise ForbiddenError(
1237
+ headers=dict(_response.headers),
1238
+ body=typing.cast(
1239
+ PermissionDeniedError,
1240
+ parse_obj_as(
1241
+ type_=PermissionDeniedError, # type: ignore
1242
+ object_=_response.json(),
1243
+ ),
1244
+ ),
1245
+ )
1246
+ if _response.status_code == 404:
1247
+ raise NotFoundError(
1248
+ headers=dict(_response.headers),
1249
+ body=typing.cast(
1250
+ NotFoundErrorBody,
1251
+ parse_obj_as(
1252
+ type_=NotFoundErrorBody, # type: ignore
1253
+ object_=_response.json(),
1254
+ ),
1255
+ ),
1256
+ )
1257
+ if _response.status_code == 429:
1258
+ raise TooManyRequestsError(
1259
+ headers=dict(_response.headers),
1260
+ body=typing.cast(
1261
+ RateLimitError,
1262
+ parse_obj_as(
1263
+ type_=RateLimitError, # type: ignore
1264
+ object_=_response.json(),
1265
+ ),
1266
+ ),
1267
+ )
1268
+ if _response.status_code == 500:
1269
+ raise InternalServerError(
1270
+ headers=dict(_response.headers),
1271
+ body=typing.cast(
1272
+ typing.Optional[typing.Any],
1273
+ parse_obj_as(
1274
+ type_=typing.Optional[typing.Any], # type: ignore
1275
+ object_=_response.json(),
1276
+ ),
1277
+ ),
1278
+ )
1279
+ if _response.status_code == 503:
1280
+ raise ServiceUnavailableError(
1281
+ headers=dict(_response.headers),
1282
+ body=typing.cast(
1283
+ typing.Optional[typing.Any],
1284
+ parse_obj_as(
1285
+ type_=typing.Optional[typing.Any], # type: ignore
1286
+ object_=_response.json(),
1287
+ ),
1288
+ ),
1289
+ )
1290
+ _response_json = _response.json()
1291
+ except JSONDecodeError:
1292
+ raise ApiError(
1293
+ status_code=_response.status_code,
1294
+ headers=dict(_response.headers),
1295
+ body=_response.text,
1296
+ )
1297
+ raise ApiError(
1298
+ status_code=_response.status_code,
1299
+ headers=dict(_response.headers),
1300
+ body=_response_json,
1301
+ )
1302
+
1303
+ async def delete(
1304
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1305
+ ) -> AsyncHttpResponse[None]:
1306
+ """
1307
+ Parameters
1308
+ ----------
1309
+ id : str
1310
+
1311
+ request_options : typing.Optional[RequestOptions]
1312
+ Request-specific configuration.
1313
+
1314
+ Returns
1315
+ -------
1316
+ AsyncHttpResponse[None]
1317
+ """
1318
+ _response = await self._client_wrapper.httpx_client.request(
1319
+ f"annotations/{jsonable_encoder(id)}",
1320
+ method="DELETE",
1321
+ request_options=request_options,
1322
+ )
1323
+ try:
1324
+ if 200 <= _response.status_code < 300:
1325
+ return AsyncHttpResponse(response=_response, data=None)
1326
+ if _response.status_code == 400:
1327
+ raise BadRequestError(
1328
+ headers=dict(_response.headers),
1329
+ body=typing.cast(
1330
+ typing.Optional[typing.Any],
1331
+ parse_obj_as(
1332
+ type_=typing.Optional[typing.Any], # type: ignore
1333
+ object_=_response.json(),
1334
+ ),
1335
+ ),
1336
+ )
1337
+ if _response.status_code == 401:
1338
+ raise UnauthorizedError(
1339
+ headers=dict(_response.headers),
1340
+ body=typing.cast(
1341
+ UnauthorizedErrorBody,
1342
+ parse_obj_as(
1343
+ type_=UnauthorizedErrorBody, # type: ignore
1344
+ object_=_response.json(),
1345
+ ),
1346
+ ),
1347
+ )
1348
+ if _response.status_code == 403:
1349
+ raise ForbiddenError(
1350
+ headers=dict(_response.headers),
1351
+ body=typing.cast(
1352
+ PermissionDeniedError,
1353
+ parse_obj_as(
1354
+ type_=PermissionDeniedError, # type: ignore
1355
+ object_=_response.json(),
1356
+ ),
1357
+ ),
1358
+ )
1359
+ if _response.status_code == 404:
1360
+ raise NotFoundError(
1361
+ headers=dict(_response.headers),
1362
+ body=typing.cast(
1363
+ NotFoundErrorBody,
1364
+ parse_obj_as(
1365
+ type_=NotFoundErrorBody, # type: ignore
1366
+ object_=_response.json(),
1367
+ ),
1368
+ ),
1369
+ )
1370
+ if _response.status_code == 429:
1371
+ raise TooManyRequestsError(
1372
+ headers=dict(_response.headers),
1373
+ body=typing.cast(
1374
+ RateLimitError,
1375
+ parse_obj_as(
1376
+ type_=RateLimitError, # type: ignore
1377
+ object_=_response.json(),
1378
+ ),
1379
+ ),
1380
+ )
1381
+ if _response.status_code == 500:
1382
+ raise InternalServerError(
1383
+ headers=dict(_response.headers),
1384
+ body=typing.cast(
1385
+ typing.Optional[typing.Any],
1386
+ parse_obj_as(
1387
+ type_=typing.Optional[typing.Any], # type: ignore
1388
+ object_=_response.json(),
1389
+ ),
1390
+ ),
1391
+ )
1392
+ if _response.status_code == 503:
1393
+ raise ServiceUnavailableError(
1394
+ headers=dict(_response.headers),
1395
+ body=typing.cast(
1396
+ typing.Optional[typing.Any],
1397
+ parse_obj_as(
1398
+ type_=typing.Optional[typing.Any], # type: ignore
1399
+ object_=_response.json(),
1400
+ ),
1401
+ ),
1402
+ )
1403
+ _response_json = _response.json()
1404
+ except JSONDecodeError:
1405
+ raise ApiError(
1406
+ status_code=_response.status_code,
1407
+ headers=dict(_response.headers),
1408
+ body=_response.text,
1409
+ )
1410
+ raise ApiError(
1411
+ status_code=_response.status_code,
1412
+ headers=dict(_response.headers),
1413
+ body=_response_json,
1414
+ )