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
mirascope/llm/__init__.py CHANGED
@@ -51,24 +51,37 @@ from .content import (
51
51
  URLImageSource,
52
52
  UserContentPart,
53
53
  )
54
- from .context import Context
54
+ from .context import Context, DepsT
55
55
  from .exceptions import (
56
56
  APIError,
57
57
  AuthenticationError,
58
58
  BadRequestError,
59
59
  ConnectionError,
60
+ Error,
60
61
  FeatureNotSupportedError,
61
- FormattingModeNotSupportedError,
62
- MirascopeLLMError,
62
+ MissingAPIKeyError,
63
63
  NoRegisteredProviderError,
64
64
  NotFoundError,
65
+ ParseError,
65
66
  PermissionError,
67
+ ProviderError,
66
68
  RateLimitError,
69
+ ResponseValidationError,
67
70
  ServerError,
68
71
  TimeoutError,
72
+ ToolError,
73
+ ToolExecutionError,
69
74
  ToolNotFoundError,
70
75
  )
71
- from .formatting import Format, FormattingMode, Partial, format
76
+ from .formatting import (
77
+ Format,
78
+ FormattableT,
79
+ FormattingMode,
80
+ OutputParser,
81
+ Partial,
82
+ format,
83
+ output_parser,
84
+ )
72
85
  from .messages import (
73
86
  AssistantContent,
74
87
  AssistantMessage,
@@ -78,7 +91,15 @@ from .messages import (
78
91
  UserContent,
79
92
  UserMessage,
80
93
  )
81
- from .models import Model, model, model_from_context, use_model
94
+ from .models import (
95
+ Model,
96
+ Params,
97
+ ThinkingConfig,
98
+ ThinkingLevel,
99
+ model,
100
+ model_from_context,
101
+ use_model,
102
+ )
82
103
  from .prompts import (
83
104
  AsyncContextPrompt,
84
105
  AsyncPrompt,
@@ -89,13 +110,13 @@ from .prompts import (
89
110
  )
90
111
  from .providers import (
91
112
  ModelId,
92
- Params,
93
113
  Provider,
94
114
  ProviderId,
95
115
  register_provider,
96
116
  reset_provider_registry,
97
117
  )
98
118
  from .responses import (
119
+ AnyResponse,
99
120
  AsyncChunkIterator,
100
121
  AsyncContextResponse,
101
122
  AsyncContextStreamResponse,
@@ -111,6 +132,7 @@ from .responses import (
111
132
  FinishReason,
112
133
  RawMessageChunk,
113
134
  Response,
135
+ RootResponse,
114
136
  Stream,
115
137
  StreamResponse,
116
138
  StreamResponseChunk,
@@ -121,19 +143,28 @@ from .responses import (
121
143
  UsageDeltaChunk,
122
144
  )
123
145
  from .tools import (
146
+ AnyToolFn,
147
+ AnyToolSchema,
124
148
  AsyncContextTool,
125
149
  AsyncContextToolkit,
126
150
  AsyncTool,
127
151
  AsyncToolkit,
152
+ BaseToolkit,
128
153
  ContextTool,
129
154
  ContextToolkit,
130
155
  Tool,
131
156
  Toolkit,
157
+ ToolkitT,
158
+ ToolSchema,
132
159
  tool,
133
160
  )
161
+ from .types import Jsonable
134
162
 
135
163
  __all__ = [
136
164
  "APIError",
165
+ "AnyResponse",
166
+ "AnyToolFn",
167
+ "AnyToolSchema",
137
168
  "AssistantContent",
138
169
  "AssistantContentChunk",
139
170
  "AssistantContentPart",
@@ -160,6 +191,7 @@ __all__ = [
160
191
  "BadRequestError",
161
192
  "Base64AudioSource",
162
193
  "Base64ImageSource",
194
+ "BaseToolkit",
163
195
  "Call",
164
196
  "CallDecorator",
165
197
  "ChunkIterator",
@@ -171,29 +203,37 @@ __all__ = [
171
203
  "ContextStreamResponse",
172
204
  "ContextTool",
173
205
  "ContextToolkit",
206
+ "DepsT",
174
207
  "Document",
208
+ "Error",
175
209
  "FeatureNotSupportedError",
176
210
  "FinishReason",
177
211
  "Format",
212
+ "FormattableT",
178
213
  "FormattingMode",
179
- "FormattingModeNotSupportedError",
180
214
  "Image",
215
+ "Jsonable",
181
216
  "Message",
182
- "MirascopeLLMError",
217
+ "MissingAPIKeyError",
183
218
  "Model",
184
219
  "ModelId",
185
220
  "NoRegisteredProviderError",
186
221
  "NotFoundError",
222
+ "OutputParser",
187
223
  "Params",
224
+ "ParseError",
188
225
  "Partial",
189
226
  "PermissionError",
190
227
  "Prompt",
191
228
  "PromptDecorator",
192
229
  "Provider",
230
+ "ProviderError",
193
231
  "ProviderId",
194
232
  "RateLimitError",
195
233
  "RawMessageChunk",
196
234
  "Response",
235
+ "ResponseValidationError",
236
+ "RootResponse",
197
237
  "ServerError",
198
238
  "Stream",
199
239
  "StreamResponse",
@@ -205,6 +245,8 @@ __all__ = [
205
245
  "TextEndChunk",
206
246
  "TextStartChunk",
207
247
  "TextStream",
248
+ "ThinkingConfig",
249
+ "ThinkingLevel",
208
250
  "Thought",
209
251
  "ThoughtChunk",
210
252
  "ThoughtEndChunk",
@@ -217,9 +259,13 @@ __all__ = [
217
259
  "ToolCallEndChunk",
218
260
  "ToolCallStartChunk",
219
261
  "ToolCallStream",
262
+ "ToolError",
263
+ "ToolExecutionError",
220
264
  "ToolNotFoundError",
221
265
  "ToolOutput",
266
+ "ToolSchema",
222
267
  "Toolkit",
268
+ "ToolkitT",
223
269
  "URLImageSource",
224
270
  "Usage",
225
271
  "UsageDeltaChunk",
@@ -237,6 +283,7 @@ __all__ = [
237
283
  "model",
238
284
  "model_from_context",
239
285
  "models",
286
+ "output_parser",
240
287
  "prompt",
241
288
  "prompts",
242
289
  "providers",
@@ -1,6 +1,6 @@
1
1
  """The `llm.calls` module."""
2
2
 
3
- from .calls import AsyncCall, AsyncContextCall, Call, ContextCall
3
+ from .calls import AsyncCall, AsyncContextCall, Call, CallT, ContextCall
4
4
  from .decorator import (
5
5
  CallDecorator,
6
6
  call,
@@ -11,6 +11,7 @@ __all__ = [
11
11
  "AsyncContextCall",
12
12
  "Call",
13
13
  "CallDecorator",
14
+ "CallT",
14
15
  "ContextCall",
15
16
  "call",
16
17
  ]
@@ -1,7 +1,7 @@
1
1
  """The Call module for generating responses using LLMs."""
2
2
 
3
3
  from dataclasses import dataclass
4
- from typing import Generic, overload
4
+ from typing import Generic, TypeVar, overload
5
5
 
6
6
  from ..context import Context, DepsT
7
7
  from ..formatting import FormattableT
@@ -24,6 +24,8 @@ from ..responses import (
24
24
  )
25
25
  from ..types import P
26
26
 
27
+ CallT = TypeVar("CallT", bound="BaseCall")
28
+
27
29
 
28
30
  @dataclass
29
31
  class BaseCall:
@@ -4,11 +4,11 @@ from __future__ import annotations
4
4
 
5
5
  from collections.abc import Sequence
6
6
  from dataclasses import dataclass
7
- from typing import Generic, cast, overload
7
+ from typing import TYPE_CHECKING, Generic, cast, overload
8
8
  from typing_extensions import Unpack
9
9
 
10
10
  from ..context import DepsT
11
- from ..formatting import Format, FormattableT
11
+ from ..formatting import Format, FormattableT, OutputParser
12
12
  from ..models import Model
13
13
  from ..prompts import (
14
14
  AsyncContextMessageTemplate,
@@ -21,7 +21,7 @@ from ..prompts import (
21
21
  Prompt,
22
22
  _utils,
23
23
  )
24
- from ..providers import ModelId, Params
24
+ from ..providers import ModelId
25
25
  from ..tools import (
26
26
  AsyncContextTool,
27
27
  AsyncContextToolkit,
@@ -36,6 +36,9 @@ from ..tools import (
36
36
  from ..types import P
37
37
  from .calls import AsyncCall, AsyncContextCall, Call, ContextCall
38
38
 
39
+ if TYPE_CHECKING:
40
+ from ..models import Params
41
+
39
42
 
40
43
  @dataclass(kw_only=True)
41
44
  class CallDecorator(Generic[ToolT, FormattableT]):
@@ -58,7 +61,9 @@ class CallDecorator(Generic[ToolT, FormattableT]):
58
61
  tools: Sequence[ToolT] | None
59
62
  """The tools that are included in the prompt, if any."""
60
63
 
61
- format: type[FormattableT] | Format[FormattableT] | None
64
+ format: (
65
+ type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None
66
+ )
62
67
  """The structured output format off the prompt, if any."""
63
68
 
64
69
  @overload
@@ -154,7 +159,10 @@ def call(
154
159
  model: ModelId,
155
160
  *,
156
161
  tools: Sequence[ToolT] | None = None,
157
- format: type[FormattableT] | Format[FormattableT] | None = None,
162
+ format: type[FormattableT]
163
+ | Format[FormattableT]
164
+ | OutputParser[FormattableT]
165
+ | None = None,
158
166
  **params: Unpack[Params],
159
167
  ) -> CallDecorator[ToolT, FormattableT]:
160
168
  """Decorator for converting prompt functions into LLM calls.
@@ -169,7 +177,10 @@ def call(
169
177
  model: Model,
170
178
  *,
171
179
  tools: Sequence[ToolT] | None = None,
172
- format: type[FormattableT] | Format[FormattableT] | None = None,
180
+ format: type[FormattableT]
181
+ | Format[FormattableT]
182
+ | OutputParser[FormattableT]
183
+ | None = None,
173
184
  ) -> CallDecorator[ToolT, FormattableT]:
174
185
  """Decorator for converting prompt functions into LLM calls.
175
186
 
@@ -182,7 +193,10 @@ def call(
182
193
  model: ModelId | Model,
183
194
  *,
184
195
  tools: Sequence[ToolT] | None = None,
185
- format: type[FormattableT] | Format[FormattableT] | None = None,
196
+ format: type[FormattableT]
197
+ | Format[FormattableT]
198
+ | OutputParser[FormattableT]
199
+ | None = None,
186
200
  **params: Unpack[Params],
187
201
  ) -> CallDecorator[ToolT, FormattableT]:
188
202
  """Decorates a `MessageTemplate` to create a `Call` that can be invoked directly.
@@ -49,6 +49,9 @@ class ToolCallChunk:
49
49
  content_type: Literal["tool_call"] = "tool_call"
50
50
  """The type of content reconstructed by this chunk."""
51
51
 
52
+ id: str
53
+ """A unique identifier for this tool call."""
54
+
52
55
  delta: str
53
56
  """The incremental json args added in this chunk."""
54
57
 
@@ -61,3 +64,6 @@ class ToolCallEndChunk:
61
64
 
62
65
  content_type: Literal["tool_call"] = "tool_call"
63
66
  """The type of content reconstructed by this chunk."""
67
+
68
+ id: str
69
+ """A unique identifier for this tool call."""
@@ -1,13 +1,14 @@
1
1
  """The `ToolOutput` content class."""
2
2
 
3
3
  from dataclasses import dataclass
4
- from typing import Generic, Literal
4
+ from typing import Generic, Literal, cast
5
5
 
6
- from ..types import JsonableT
6
+ from ..exceptions import ToolError
7
+ from ..types import JsonableCovariantT
7
8
 
8
9
 
9
10
  @dataclass(kw_only=True)
10
- class ToolOutput(Generic[JsonableT]):
11
+ class ToolOutput(Generic[JsonableCovariantT]):
11
12
  """Tool output content for a message.
12
13
 
13
14
  Represents the output from a tool call. This is part of a user message's
@@ -22,5 +23,21 @@ class ToolOutput(Generic[JsonableT]):
22
23
  name: str
23
24
  """The name of the tool that created this output."""
24
25
 
25
- value: JsonableT
26
- """The output value from the tool call."""
26
+ result: JsonableCovariantT | str
27
+ """The result of calling the tool.
28
+
29
+ If the tool executed successfully, this will be the tool output.
30
+ If the tool errored, this will be the error message, as a string.
31
+
32
+ In either case, the result should be passed back to the LLM (so it can
33
+ either process the output, or re-try with awareness of the error.)
34
+ """
35
+
36
+ error: ToolError | None = None
37
+ """The error from calling the tool, if any."""
38
+
39
+ @property
40
+ def output(self) -> JsonableCovariantT:
41
+ if self.error is not None:
42
+ raise self.error
43
+ return cast(JsonableCovariantT, self.result)