mirascope 2.0.0a1__py3-none-any.whl → 2.0.0a3__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 (205) hide show
  1. mirascope/__init__.py +2 -2
  2. mirascope/api/__init__.py +6 -0
  3. mirascope/api/_generated/README.md +207 -0
  4. mirascope/api/_generated/__init__.py +85 -0
  5. mirascope/api/_generated/client.py +155 -0
  6. mirascope/api/_generated/core/__init__.py +52 -0
  7. mirascope/api/_generated/core/api_error.py +23 -0
  8. mirascope/api/_generated/core/client_wrapper.py +58 -0
  9. mirascope/api/_generated/core/datetime_utils.py +30 -0
  10. mirascope/api/_generated/core/file.py +70 -0
  11. mirascope/api/_generated/core/force_multipart.py +16 -0
  12. mirascope/api/_generated/core/http_client.py +619 -0
  13. mirascope/api/_generated/core/http_response.py +55 -0
  14. mirascope/api/_generated/core/jsonable_encoder.py +102 -0
  15. mirascope/api/_generated/core/pydantic_utilities.py +310 -0
  16. mirascope/api/_generated/core/query_encoder.py +60 -0
  17. mirascope/api/_generated/core/remove_none_from_dict.py +11 -0
  18. mirascope/api/_generated/core/request_options.py +35 -0
  19. mirascope/api/_generated/core/serialization.py +282 -0
  20. mirascope/api/_generated/docs/__init__.py +4 -0
  21. mirascope/api/_generated/docs/client.py +95 -0
  22. mirascope/api/_generated/docs/raw_client.py +132 -0
  23. mirascope/api/_generated/environment.py +9 -0
  24. mirascope/api/_generated/errors/__init__.py +7 -0
  25. mirascope/api/_generated/errors/bad_request_error.py +15 -0
  26. mirascope/api/_generated/health/__init__.py +7 -0
  27. mirascope/api/_generated/health/client.py +96 -0
  28. mirascope/api/_generated/health/raw_client.py +129 -0
  29. mirascope/api/_generated/health/types/__init__.py +8 -0
  30. mirascope/api/_generated/health/types/health_check_response.py +24 -0
  31. mirascope/api/_generated/health/types/health_check_response_status.py +5 -0
  32. mirascope/api/_generated/reference.md +167 -0
  33. mirascope/api/_generated/traces/__init__.py +55 -0
  34. mirascope/api/_generated/traces/client.py +162 -0
  35. mirascope/api/_generated/traces/raw_client.py +168 -0
  36. mirascope/api/_generated/traces/types/__init__.py +95 -0
  37. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +36 -0
  38. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +31 -0
  39. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +25 -0
  40. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +54 -0
  41. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +23 -0
  42. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +28 -0
  43. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +24 -0
  44. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +35 -0
  45. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +35 -0
  46. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +27 -0
  47. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +54 -0
  48. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +23 -0
  49. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +28 -0
  50. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +24 -0
  51. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +60 -0
  52. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +29 -0
  53. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +54 -0
  54. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +23 -0
  55. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +28 -0
  56. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +24 -0
  57. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +24 -0
  58. mirascope/api/_generated/traces/types/traces_create_response.py +27 -0
  59. mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +28 -0
  60. mirascope/api/_generated/types/__init__.py +21 -0
  61. mirascope/api/_generated/types/http_api_decode_error.py +31 -0
  62. mirascope/api/_generated/types/http_api_decode_error_tag.py +5 -0
  63. mirascope/api/_generated/types/issue.py +44 -0
  64. mirascope/api/_generated/types/issue_tag.py +17 -0
  65. mirascope/api/_generated/types/property_key.py +7 -0
  66. mirascope/api/_generated/types/property_key_tag.py +29 -0
  67. mirascope/api/_generated/types/property_key_tag_tag.py +5 -0
  68. mirascope/api/client.py +255 -0
  69. mirascope/api/settings.py +81 -0
  70. mirascope/llm/__init__.py +41 -11
  71. mirascope/llm/calls/calls.py +81 -57
  72. mirascope/llm/calls/decorator.py +121 -115
  73. mirascope/llm/content/__init__.py +3 -2
  74. mirascope/llm/context/_utils.py +19 -6
  75. mirascope/llm/exceptions.py +30 -16
  76. mirascope/llm/formatting/_utils.py +9 -5
  77. mirascope/llm/formatting/format.py +2 -2
  78. mirascope/llm/formatting/from_call_args.py +2 -2
  79. mirascope/llm/messages/message.py +13 -5
  80. mirascope/llm/models/__init__.py +2 -2
  81. mirascope/llm/models/models.py +189 -81
  82. mirascope/llm/prompts/__init__.py +13 -12
  83. mirascope/llm/prompts/_utils.py +27 -24
  84. mirascope/llm/prompts/decorator.py +133 -204
  85. mirascope/llm/prompts/prompts.py +424 -0
  86. mirascope/llm/prompts/protocols.py +25 -59
  87. mirascope/llm/providers/__init__.py +38 -0
  88. mirascope/llm/{clients → providers}/_missing_import_stubs.py +8 -6
  89. mirascope/llm/providers/anthropic/__init__.py +24 -0
  90. mirascope/llm/{clients → providers}/anthropic/_utils/decode.py +5 -4
  91. mirascope/llm/{clients → providers}/anthropic/_utils/encode.py +31 -10
  92. mirascope/llm/providers/anthropic/model_id.py +40 -0
  93. mirascope/llm/{clients/anthropic/clients.py → providers/anthropic/provider.py} +33 -418
  94. mirascope/llm/{clients → providers}/base/__init__.py +3 -3
  95. mirascope/llm/{clients → providers}/base/_utils.py +10 -7
  96. mirascope/llm/{clients/base/client.py → providers/base/base_provider.py} +255 -126
  97. mirascope/llm/providers/google/__init__.py +21 -0
  98. mirascope/llm/{clients → providers}/google/_utils/decode.py +6 -4
  99. mirascope/llm/{clients → providers}/google/_utils/encode.py +30 -24
  100. mirascope/llm/providers/google/model_id.py +28 -0
  101. mirascope/llm/providers/google/provider.py +438 -0
  102. mirascope/llm/providers/load_provider.py +48 -0
  103. mirascope/llm/providers/mlx/__init__.py +24 -0
  104. mirascope/llm/providers/mlx/_utils.py +107 -0
  105. mirascope/llm/providers/mlx/encoding/__init__.py +8 -0
  106. mirascope/llm/providers/mlx/encoding/base.py +69 -0
  107. mirascope/llm/providers/mlx/encoding/transformers.py +131 -0
  108. mirascope/llm/providers/mlx/mlx.py +237 -0
  109. mirascope/llm/providers/mlx/model_id.py +17 -0
  110. mirascope/llm/providers/mlx/provider.py +411 -0
  111. mirascope/llm/providers/model_id.py +16 -0
  112. mirascope/llm/providers/openai/__init__.py +6 -0
  113. mirascope/llm/providers/openai/completions/__init__.py +20 -0
  114. mirascope/llm/{clients/openai/responses → providers/openai/completions}/_utils/__init__.py +2 -0
  115. mirascope/llm/{clients → providers}/openai/completions/_utils/decode.py +5 -3
  116. mirascope/llm/{clients → providers}/openai/completions/_utils/encode.py +33 -23
  117. mirascope/llm/providers/openai/completions/provider.py +456 -0
  118. mirascope/llm/providers/openai/model_id.py +31 -0
  119. mirascope/llm/providers/openai/model_info.py +246 -0
  120. mirascope/llm/providers/openai/provider.py +386 -0
  121. mirascope/llm/providers/openai/responses/__init__.py +21 -0
  122. mirascope/llm/{clients → providers}/openai/responses/_utils/decode.py +5 -3
  123. mirascope/llm/{clients → providers}/openai/responses/_utils/encode.py +28 -17
  124. mirascope/llm/providers/openai/responses/provider.py +470 -0
  125. mirascope/llm/{clients → providers}/openai/shared/_utils.py +7 -3
  126. mirascope/llm/providers/provider_id.py +13 -0
  127. mirascope/llm/providers/provider_registry.py +167 -0
  128. mirascope/llm/responses/base_response.py +10 -5
  129. mirascope/llm/responses/base_stream_response.py +10 -5
  130. mirascope/llm/responses/response.py +24 -13
  131. mirascope/llm/responses/root_response.py +7 -12
  132. mirascope/llm/responses/stream_response.py +35 -23
  133. mirascope/llm/tools/__init__.py +9 -2
  134. mirascope/llm/tools/_utils.py +12 -3
  135. mirascope/llm/tools/decorator.py +10 -10
  136. mirascope/llm/tools/protocols.py +4 -4
  137. mirascope/llm/tools/tool_schema.py +44 -9
  138. mirascope/llm/tools/tools.py +12 -11
  139. mirascope/ops/__init__.py +156 -0
  140. mirascope/ops/_internal/__init__.py +5 -0
  141. mirascope/ops/_internal/closure.py +1118 -0
  142. mirascope/ops/_internal/configuration.py +126 -0
  143. mirascope/ops/_internal/context.py +76 -0
  144. mirascope/ops/_internal/exporters/__init__.py +26 -0
  145. mirascope/ops/_internal/exporters/exporters.py +342 -0
  146. mirascope/ops/_internal/exporters/processors.py +104 -0
  147. mirascope/ops/_internal/exporters/types.py +165 -0
  148. mirascope/ops/_internal/exporters/utils.py +29 -0
  149. mirascope/ops/_internal/instrumentation/__init__.py +8 -0
  150. mirascope/ops/_internal/instrumentation/llm/__init__.py +8 -0
  151. mirascope/ops/_internal/instrumentation/llm/encode.py +238 -0
  152. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/__init__.py +38 -0
  153. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_input_messages.py +31 -0
  154. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_output_messages.py +38 -0
  155. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_system_instructions.py +18 -0
  156. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/shared.py +100 -0
  157. mirascope/ops/_internal/instrumentation/llm/llm.py +1288 -0
  158. mirascope/ops/_internal/propagation.py +198 -0
  159. mirascope/ops/_internal/protocols.py +51 -0
  160. mirascope/ops/_internal/session.py +139 -0
  161. mirascope/ops/_internal/spans.py +232 -0
  162. mirascope/ops/_internal/traced_calls.py +371 -0
  163. mirascope/ops/_internal/traced_functions.py +394 -0
  164. mirascope/ops/_internal/tracing.py +276 -0
  165. mirascope/ops/_internal/types.py +13 -0
  166. mirascope/ops/_internal/utils.py +75 -0
  167. mirascope/ops/_internal/versioned_calls.py +512 -0
  168. mirascope/ops/_internal/versioned_functions.py +346 -0
  169. mirascope/ops/_internal/versioning.py +303 -0
  170. mirascope/ops/exceptions.py +21 -0
  171. {mirascope-2.0.0a1.dist-info → mirascope-2.0.0a3.dist-info}/METADATA +77 -1
  172. mirascope-2.0.0a3.dist-info/RECORD +206 -0
  173. {mirascope-2.0.0a1.dist-info → mirascope-2.0.0a3.dist-info}/WHEEL +1 -1
  174. mirascope/graphs/__init__.py +0 -22
  175. mirascope/graphs/finite_state_machine.py +0 -625
  176. mirascope/llm/agents/__init__.py +0 -15
  177. mirascope/llm/agents/agent.py +0 -97
  178. mirascope/llm/agents/agent_template.py +0 -45
  179. mirascope/llm/agents/decorator.py +0 -176
  180. mirascope/llm/calls/base_call.py +0 -33
  181. mirascope/llm/clients/__init__.py +0 -34
  182. mirascope/llm/clients/anthropic/__init__.py +0 -25
  183. mirascope/llm/clients/anthropic/model_ids.py +0 -8
  184. mirascope/llm/clients/google/__init__.py +0 -20
  185. mirascope/llm/clients/google/clients.py +0 -853
  186. mirascope/llm/clients/google/model_ids.py +0 -15
  187. mirascope/llm/clients/openai/__init__.py +0 -25
  188. mirascope/llm/clients/openai/completions/__init__.py +0 -28
  189. mirascope/llm/clients/openai/completions/_utils/model_features.py +0 -81
  190. mirascope/llm/clients/openai/completions/clients.py +0 -833
  191. mirascope/llm/clients/openai/completions/model_ids.py +0 -8
  192. mirascope/llm/clients/openai/responses/__init__.py +0 -26
  193. mirascope/llm/clients/openai/responses/_utils/model_features.py +0 -87
  194. mirascope/llm/clients/openai/responses/clients.py +0 -832
  195. mirascope/llm/clients/openai/responses/model_ids.py +0 -8
  196. mirascope/llm/clients/providers.py +0 -175
  197. mirascope-2.0.0a1.dist-info/RECORD +0 -102
  198. /mirascope/llm/{clients → providers}/anthropic/_utils/__init__.py +0 -0
  199. /mirascope/llm/{clients → providers}/base/kwargs.py +0 -0
  200. /mirascope/llm/{clients → providers}/base/params.py +0 -0
  201. /mirascope/llm/{clients → providers}/google/_utils/__init__.py +0 -0
  202. /mirascope/llm/{clients → providers}/google/message.py +0 -0
  203. /mirascope/llm/{clients/openai/completions → providers/openai/responses}/_utils/__init__.py +0 -0
  204. /mirascope/llm/{clients → providers}/openai/shared/__init__.py +0 -0
  205. {mirascope-2.0.0a1.dist-info → mirascope-2.0.0a3.dist-info}/licenses/LICENSE +0 -0
mirascope/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """Mirascope v2 Beta."""
2
2
 
3
- from . import graphs as graphs, llm as llm
3
+ from . import api as api, llm as llm, ops as ops
4
4
 
5
- __all__ = ["graphs", "llm"]
5
+ __all__ = ["api", "llm", "ops"]
@@ -0,0 +1,6 @@
1
+ """The Mirascope Cloud API client."""
2
+
3
+ from .client import AsyncMirascope, Mirascope
4
+ from .settings import get_settings, settings
5
+
6
+ __all__ = ["AsyncMirascope", "Mirascope", "get_settings", "settings"]
@@ -0,0 +1,207 @@
1
+ # Mirascope Python Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Mirascope%2FPython)
4
+ [![pypi](https://img.shields.io/pypi/v/mirascope)](https://pypi.python.org/pypi/mirascope)
5
+
6
+ The Mirascope Python library provides convenient access to the Mirascope APIs from Python.
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [Reference](#reference)
12
+ - [Usage](#usage)
13
+ - [Async Client](#async-client)
14
+ - [Exception Handling](#exception-handling)
15
+ - [Advanced](#advanced)
16
+ - [Access Raw Response Data](#access-raw-response-data)
17
+ - [Retries](#retries)
18
+ - [Timeouts](#timeouts)
19
+ - [Custom Client](#custom-client)
20
+ - [Contributing](#contributing)
21
+
22
+ ## Installation
23
+
24
+ ```sh
25
+ pip install mirascope
26
+ ```
27
+
28
+ ## Reference
29
+
30
+ A full reference for this library is available [here](./reference.md).
31
+
32
+ ## Usage
33
+
34
+ Instantiate and use the client with the following:
35
+
36
+ ```python
37
+ from mirascope.api._generated import Mirascope
38
+ from mirascope.api._generated.traces import (
39
+ TracesCreateRequestResourceSpansItem,
40
+ TracesCreateRequestResourceSpansItemScopeSpansItem,
41
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem,
42
+ )
43
+
44
+ client = Mirascope()
45
+ client.traces.create(
46
+ resource_spans=[
47
+ TracesCreateRequestResourceSpansItem(
48
+ scope_spans=[
49
+ TracesCreateRequestResourceSpansItemScopeSpansItem(
50
+ spans=[
51
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem(
52
+ trace_id="traceId",
53
+ span_id="spanId",
54
+ name="name",
55
+ start_time_unix_nano="startTimeUnixNano",
56
+ end_time_unix_nano="endTimeUnixNano",
57
+ )
58
+ ],
59
+ )
60
+ ],
61
+ )
62
+ ],
63
+ )
64
+ ```
65
+
66
+ ## Async Client
67
+
68
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API.
69
+
70
+ ```python
71
+ import asyncio
72
+
73
+ from mirascope.api._generated import AsyncMirascope
74
+ from mirascope.api._generated.traces import (
75
+ TracesCreateRequestResourceSpansItem,
76
+ TracesCreateRequestResourceSpansItemScopeSpansItem,
77
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem,
78
+ )
79
+
80
+ client = AsyncMirascope()
81
+
82
+
83
+ async def main() -> None:
84
+ await client.traces.create(
85
+ resource_spans=[
86
+ TracesCreateRequestResourceSpansItem(
87
+ scope_spans=[
88
+ TracesCreateRequestResourceSpansItemScopeSpansItem(
89
+ spans=[
90
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem(
91
+ trace_id="traceId",
92
+ span_id="spanId",
93
+ name="name",
94
+ start_time_unix_nano="startTimeUnixNano",
95
+ end_time_unix_nano="endTimeUnixNano",
96
+ )
97
+ ],
98
+ )
99
+ ],
100
+ )
101
+ ],
102
+ )
103
+
104
+
105
+ asyncio.run(main())
106
+ ```
107
+
108
+ ## Exception Handling
109
+
110
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
111
+ will be thrown.
112
+
113
+ ```python
114
+ from mirascope.api._generated.core.api_error import ApiError
115
+
116
+ try:
117
+ client.traces.create(...)
118
+ except ApiError as e:
119
+ print(e.status_code)
120
+ print(e.body)
121
+ ```
122
+
123
+ ## Advanced
124
+
125
+ ### Access Raw Response Data
126
+
127
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
128
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
129
+
130
+ ```python
131
+ from mirascope.api._generated import Mirascope
132
+
133
+ client = Mirascope(
134
+ ...,
135
+ )
136
+ response = client.traces.with_raw_response.create(...)
137
+ print(response.headers) # access the response headers
138
+ print(response.data) # access the underlying object
139
+ ```
140
+
141
+ ### Retries
142
+
143
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
144
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
145
+ retry limit (default: 2).
146
+
147
+ A request is deemed retryable when any of the following HTTP status codes is returned:
148
+
149
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
150
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
151
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
152
+
153
+ Use the `max_retries` request option to configure this behavior.
154
+
155
+ ```python
156
+ client.traces.create(..., request_options={
157
+ "max_retries": 1
158
+ })
159
+ ```
160
+
161
+ ### Timeouts
162
+
163
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
164
+
165
+ ```python
166
+
167
+ from mirascope.api._generated import Mirascope
168
+
169
+ client = Mirascope(
170
+ ...,
171
+ timeout=20.0,
172
+ )
173
+
174
+
175
+ # Override timeout for a specific method
176
+ client.traces.create(..., request_options={
177
+ "timeout_in_seconds": 1
178
+ })
179
+ ```
180
+
181
+ ### Custom Client
182
+
183
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
184
+ and transports.
185
+
186
+ ```python
187
+ import httpx
188
+ from mirascope.api._generated import Mirascope
189
+
190
+ client = Mirascope(
191
+ ...,
192
+ httpx_client=httpx.Client(
193
+ proxies="http://my.test.proxy.example.com",
194
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
195
+ ),
196
+ )
197
+ ```
198
+
199
+ ## Contributing
200
+
201
+ While we value open-source contributions to this SDK, this library is generated programmatically.
202
+ Additions made directly to this library would have to be moved over to our generation code,
203
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
204
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
205
+ an issue first to discuss with us!
206
+
207
+ On the other hand, contributions to the README are always very welcome!
@@ -0,0 +1,85 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .types import (
6
+ HttpApiDecodeError,
7
+ HttpApiDecodeErrorTag,
8
+ Issue,
9
+ IssueTag,
10
+ PropertyKey,
11
+ PropertyKeyTag,
12
+ PropertyKeyTagTag,
13
+ )
14
+ from .errors import BadRequestError
15
+ from . import docs, health, traces
16
+ from .client import AsyncMirascope, Mirascope
17
+ from .environment import MirascopeEnvironment
18
+ from .health import HealthCheckResponse, HealthCheckResponseStatus
19
+ from .traces import (
20
+ TracesCreateRequestResourceSpansItem,
21
+ TracesCreateRequestResourceSpansItemResource,
22
+ TracesCreateRequestResourceSpansItemResourceAttributesItem,
23
+ TracesCreateRequestResourceSpansItemResourceAttributesItemValue,
24
+ TracesCreateRequestResourceSpansItemResourceAttributesItemValueArrayValue,
25
+ TracesCreateRequestResourceSpansItemResourceAttributesItemValueKvlistValue,
26
+ TracesCreateRequestResourceSpansItemResourceAttributesItemValueKvlistValueValuesItem,
27
+ TracesCreateRequestResourceSpansItemScopeSpansItem,
28
+ TracesCreateRequestResourceSpansItemScopeSpansItemScope,
29
+ TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItem,
30
+ TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValue,
31
+ TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueArrayValue,
32
+ TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValue,
33
+ TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValueValuesItem,
34
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem,
35
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItem,
36
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue,
37
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueArrayValue,
38
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValue,
39
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValueValuesItem,
40
+ TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemStatus,
41
+ TracesCreateResponse,
42
+ TracesCreateResponsePartialSuccess,
43
+ )
44
+
45
+ __all__ = [
46
+ "AsyncMirascope",
47
+ "BadRequestError",
48
+ "HealthCheckResponse",
49
+ "HealthCheckResponseStatus",
50
+ "HttpApiDecodeError",
51
+ "HttpApiDecodeErrorTag",
52
+ "Issue",
53
+ "IssueTag",
54
+ "Mirascope",
55
+ "MirascopeEnvironment",
56
+ "PropertyKey",
57
+ "PropertyKeyTag",
58
+ "PropertyKeyTagTag",
59
+ "TracesCreateRequestResourceSpansItem",
60
+ "TracesCreateRequestResourceSpansItemResource",
61
+ "TracesCreateRequestResourceSpansItemResourceAttributesItem",
62
+ "TracesCreateRequestResourceSpansItemResourceAttributesItemValue",
63
+ "TracesCreateRequestResourceSpansItemResourceAttributesItemValueArrayValue",
64
+ "TracesCreateRequestResourceSpansItemResourceAttributesItemValueKvlistValue",
65
+ "TracesCreateRequestResourceSpansItemResourceAttributesItemValueKvlistValueValuesItem",
66
+ "TracesCreateRequestResourceSpansItemScopeSpansItem",
67
+ "TracesCreateRequestResourceSpansItemScopeSpansItemScope",
68
+ "TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItem",
69
+ "TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValue",
70
+ "TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueArrayValue",
71
+ "TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValue",
72
+ "TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValueValuesItem",
73
+ "TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem",
74
+ "TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItem",
75
+ "TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue",
76
+ "TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueArrayValue",
77
+ "TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValue",
78
+ "TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValueValuesItem",
79
+ "TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemStatus",
80
+ "TracesCreateResponse",
81
+ "TracesCreateResponsePartialSuccess",
82
+ "docs",
83
+ "health",
84
+ "traces",
85
+ ]
@@ -0,0 +1,155 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
7
+ from .docs.client import AsyncDocsClient, DocsClient
8
+ from .environment import MirascopeEnvironment
9
+ from .health.client import AsyncHealthClient, HealthClient
10
+ from .traces.client import AsyncTracesClient, TracesClient
11
+
12
+
13
+ class Mirascope:
14
+ """
15
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
16
+
17
+ Parameters
18
+ ----------
19
+ base_url : typing.Optional[str]
20
+ The base url to use for requests from the client.
21
+
22
+ environment : MirascopeEnvironment
23
+ The environment to use for requests from the client. from .environment import MirascopeEnvironment
24
+
25
+
26
+
27
+ Defaults to MirascopeEnvironment.PRODUCTION
28
+
29
+
30
+
31
+ timeout : typing.Optional[float]
32
+ The timeout to be used, in seconds, for requests. By default the timeout is 180 seconds, unless a custom httpx client is used, in which case this default is not enforced.
33
+
34
+ follow_redirects : typing.Optional[bool]
35
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
36
+
37
+ httpx_client : typing.Optional[httpx.Client]
38
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
39
+
40
+ Examples
41
+ --------
42
+ from mirascope.api._generated import Mirascope
43
+
44
+ client = Mirascope()
45
+ """
46
+
47
+ def __init__(
48
+ self,
49
+ *,
50
+ base_url: typing.Optional[str] = None,
51
+ environment: MirascopeEnvironment = MirascopeEnvironment.PRODUCTION,
52
+ timeout: typing.Optional[float] = None,
53
+ follow_redirects: typing.Optional[bool] = True,
54
+ httpx_client: typing.Optional[httpx.Client] = None,
55
+ ):
56
+ _defaulted_timeout = (
57
+ timeout
58
+ if timeout is not None
59
+ else 180
60
+ if httpx_client is None
61
+ else httpx_client.timeout.read
62
+ )
63
+ self._client_wrapper = SyncClientWrapper(
64
+ base_url=_get_base_url(base_url=base_url, environment=environment),
65
+ httpx_client=httpx_client
66
+ if httpx_client is not None
67
+ else httpx.Client(
68
+ timeout=_defaulted_timeout, follow_redirects=follow_redirects
69
+ )
70
+ if follow_redirects is not None
71
+ else httpx.Client(timeout=_defaulted_timeout),
72
+ timeout=_defaulted_timeout,
73
+ )
74
+ self.health = HealthClient(client_wrapper=self._client_wrapper)
75
+ self.traces = TracesClient(client_wrapper=self._client_wrapper)
76
+ self.docs = DocsClient(client_wrapper=self._client_wrapper)
77
+
78
+
79
+ class AsyncMirascope:
80
+ """
81
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
82
+
83
+ Parameters
84
+ ----------
85
+ base_url : typing.Optional[str]
86
+ The base url to use for requests from the client.
87
+
88
+ environment : MirascopeEnvironment
89
+ The environment to use for requests from the client. from .environment import MirascopeEnvironment
90
+
91
+
92
+
93
+ Defaults to MirascopeEnvironment.PRODUCTION
94
+
95
+
96
+
97
+ timeout : typing.Optional[float]
98
+ The timeout to be used, in seconds, for requests. By default the timeout is 180 seconds, unless a custom httpx client is used, in which case this default is not enforced.
99
+
100
+ follow_redirects : typing.Optional[bool]
101
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
102
+
103
+ httpx_client : typing.Optional[httpx.AsyncClient]
104
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
105
+
106
+ Examples
107
+ --------
108
+ from mirascope.api._generated import AsyncMirascope
109
+
110
+ client = AsyncMirascope()
111
+ """
112
+
113
+ def __init__(
114
+ self,
115
+ *,
116
+ base_url: typing.Optional[str] = None,
117
+ environment: MirascopeEnvironment = MirascopeEnvironment.PRODUCTION,
118
+ timeout: typing.Optional[float] = None,
119
+ follow_redirects: typing.Optional[bool] = True,
120
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
121
+ ):
122
+ _defaulted_timeout = (
123
+ timeout
124
+ if timeout is not None
125
+ else 180
126
+ if httpx_client is None
127
+ else httpx_client.timeout.read
128
+ )
129
+ self._client_wrapper = AsyncClientWrapper(
130
+ base_url=_get_base_url(base_url=base_url, environment=environment),
131
+ httpx_client=httpx_client
132
+ if httpx_client is not None
133
+ else httpx.AsyncClient(
134
+ timeout=_defaulted_timeout, follow_redirects=follow_redirects
135
+ )
136
+ if follow_redirects is not None
137
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
138
+ timeout=_defaulted_timeout,
139
+ )
140
+ self.health = AsyncHealthClient(client_wrapper=self._client_wrapper)
141
+ self.traces = AsyncTracesClient(client_wrapper=self._client_wrapper)
142
+ self.docs = AsyncDocsClient(client_wrapper=self._client_wrapper)
143
+
144
+
145
+ def _get_base_url(
146
+ *, base_url: typing.Optional[str] = None, environment: MirascopeEnvironment
147
+ ) -> str:
148
+ if base_url is not None:
149
+ return base_url
150
+ elif environment is not None:
151
+ return environment.value
152
+ else:
153
+ raise Exception(
154
+ "Please pass in either base_url or environment to construct the client"
155
+ )
@@ -0,0 +1,52 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .api_error import ApiError
6
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
7
+ from .datetime_utils import serialize_datetime
8
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
9
+ from .http_client import AsyncHttpClient, HttpClient
10
+ from .http_response import AsyncHttpResponse, HttpResponse
11
+ from .jsonable_encoder import jsonable_encoder
12
+ from .pydantic_utilities import (
13
+ IS_PYDANTIC_V2,
14
+ UniversalBaseModel,
15
+ UniversalRootModel,
16
+ parse_obj_as,
17
+ universal_field_validator,
18
+ universal_root_validator,
19
+ update_forward_refs,
20
+ )
21
+ from .query_encoder import encode_query
22
+ from .remove_none_from_dict import remove_none_from_dict
23
+ from .request_options import RequestOptions
24
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
25
+
26
+ __all__ = [
27
+ "ApiError",
28
+ "AsyncClientWrapper",
29
+ "AsyncHttpClient",
30
+ "AsyncHttpResponse",
31
+ "BaseClientWrapper",
32
+ "FieldMetadata",
33
+ "File",
34
+ "HttpClient",
35
+ "HttpResponse",
36
+ "IS_PYDANTIC_V2",
37
+ "RequestOptions",
38
+ "SyncClientWrapper",
39
+ "UniversalBaseModel",
40
+ "UniversalRootModel",
41
+ "convert_and_respect_annotation_metadata",
42
+ "convert_file_dict_to_httpx_tuples",
43
+ "encode_query",
44
+ "jsonable_encoder",
45
+ "parse_obj_as",
46
+ "remove_none_from_dict",
47
+ "serialize_datetime",
48
+ "universal_field_validator",
49
+ "universal_root_validator",
50
+ "update_forward_refs",
51
+ "with_content_type",
52
+ ]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,58 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .http_client import AsyncHttpClient, HttpClient
7
+
8
+
9
+ class BaseClientWrapper:
10
+ def __init__(self, *, base_url: str, timeout: typing.Optional[float] = None):
11
+ self._base_url = base_url
12
+ self._timeout = timeout
13
+
14
+ def get_headers(self) -> typing.Dict[str, str]:
15
+ headers: typing.Dict[str, str] = {
16
+ "X-Fern-Language": "Python",
17
+ }
18
+ return headers
19
+
20
+ def get_base_url(self) -> str:
21
+ return self._base_url
22
+
23
+ def get_timeout(self) -> typing.Optional[float]:
24
+ return self._timeout
25
+
26
+
27
+ class SyncClientWrapper(BaseClientWrapper):
28
+ def __init__(
29
+ self,
30
+ *,
31
+ base_url: str,
32
+ timeout: typing.Optional[float] = None,
33
+ httpx_client: httpx.Client,
34
+ ):
35
+ super().__init__(base_url=base_url, timeout=timeout)
36
+ self.httpx_client = HttpClient(
37
+ httpx_client=httpx_client,
38
+ base_headers=self.get_headers,
39
+ base_timeout=self.get_timeout,
40
+ base_url=self.get_base_url,
41
+ )
42
+
43
+
44
+ class AsyncClientWrapper(BaseClientWrapper):
45
+ def __init__(
46
+ self,
47
+ *,
48
+ base_url: str,
49
+ timeout: typing.Optional[float] = None,
50
+ httpx_client: httpx.AsyncClient,
51
+ ):
52
+ super().__init__(base_url=base_url, timeout=timeout)
53
+ self.httpx_client = AsyncHttpClient(
54
+ httpx_client=httpx_client,
55
+ base_headers=self.get_headers,
56
+ base_timeout=self.get_timeout,
57
+ base_url=self.get_base_url,
58
+ )
@@ -0,0 +1,30 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+
6
+ def serialize_datetime(v: dt.datetime) -> str:
7
+ """
8
+ Serialize a datetime including timezone info.
9
+
10
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11
+
12
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13
+ """
14
+
15
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
16
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(
17
+ None
18
+ ):
19
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
20
+ return v.isoformat().replace("+00:00", "Z")
21
+ else:
22
+ # Delegate to the typical +/- offset format
23
+ return v.isoformat()
24
+
25
+ if v.tzinfo is not None:
26
+ return _serialize_zoned_datetime(v)
27
+ else:
28
+ local_tz = dt.datetime.now().astimezone().tzinfo
29
+ localized_dt = v.replace(tzinfo=local_tz)
30
+ return _serialize_zoned_datetime(localized_dt)