calibrate-python-sdk 0.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 (56) hide show
  1. artpark/__init__.py +109 -0
  2. artpark/_default_clients.py +32 -0
  3. artpark/agent_tests/__init__.py +4 -0
  4. artpark/agent_tests/client.py +356 -0
  5. artpark/agent_tests/raw_client.py +455 -0
  6. artpark/agents/__init__.py +4 -0
  7. artpark/agents/client.py +210 -0
  8. artpark/agents/raw_client.py +273 -0
  9. artpark/client.py +268 -0
  10. artpark/core/__init__.py +127 -0
  11. artpark/core/api_error.py +23 -0
  12. artpark/core/client_wrapper.py +163 -0
  13. artpark/core/datetime_utils.py +70 -0
  14. artpark/core/file.py +67 -0
  15. artpark/core/force_multipart.py +18 -0
  16. artpark/core/http_client.py +843 -0
  17. artpark/core/http_response.py +59 -0
  18. artpark/core/http_sse/__init__.py +42 -0
  19. artpark/core/http_sse/_api.py +180 -0
  20. artpark/core/http_sse/_decoders.py +61 -0
  21. artpark/core/http_sse/_exceptions.py +7 -0
  22. artpark/core/http_sse/_models.py +17 -0
  23. artpark/core/jsonable_encoder.py +120 -0
  24. artpark/core/logging.py +107 -0
  25. artpark/core/parse_error.py +36 -0
  26. artpark/core/pydantic_utilities.py +508 -0
  27. artpark/core/query_encoder.py +58 -0
  28. artpark/core/remove_none_from_dict.py +11 -0
  29. artpark/core/request_options.py +37 -0
  30. artpark/core/serialization.py +347 -0
  31. artpark/environment.py +7 -0
  32. artpark/errors/__init__.py +34 -0
  33. artpark/errors/unprocessable_entity_error.py +11 -0
  34. artpark/py.typed +0 -0
  35. artpark/types/__init__.py +83 -0
  36. artpark/types/batch_run_request.py +19 -0
  37. artpark/types/batch_test_run.py +22 -0
  38. artpark/types/batch_test_run_response.py +22 -0
  39. artpark/types/batch_test_skip.py +21 -0
  40. artpark/types/http_validation_error.py +20 -0
  41. artpark/types/judge_result.py +51 -0
  42. artpark/types/resolve_agent_names_response.py +20 -0
  43. artpark/types/routers_agent_tests_agent_response.py +27 -0
  44. artpark/types/routers_agent_tests_agent_response_type.py +5 -0
  45. artpark/types/task_create_response.py +22 -0
  46. artpark/types/test_case_result.py +33 -0
  47. artpark/types/test_output.py +21 -0
  48. artpark/types/test_run_status_response.py +37 -0
  49. artpark/types/tool_call_output.py +21 -0
  50. artpark/types/validation_error.py +22 -0
  51. artpark/types/validation_error_loc_item.py +5 -0
  52. artpark/version.py +3 -0
  53. calibrate_python_sdk-0.0.1.dist-info/LICENSE +21 -0
  54. calibrate_python_sdk-0.0.1.dist-info/METADATA +55 -0
  55. calibrate_python_sdk-0.0.1.dist-info/RECORD +56 -0
  56. calibrate_python_sdk-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,273 @@
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.parse_error import ParsingError
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
13
+ from ..types.http_validation_error import HttpValidationError
14
+ from ..types.resolve_agent_names_response import ResolveAgentNamesResponse
15
+ from ..types.routers_agent_tests_agent_response import RoutersAgentTestsAgentResponse
16
+ from pydantic import ValidationError
17
+
18
+ # this is used as the default value for optional parameters
19
+ OMIT = typing.cast(typing.Any, ...)
20
+
21
+
22
+ class RawAgentsClient:
23
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
24
+ self._client_wrapper = client_wrapper
25
+
26
+ def resolve(
27
+ self, *, names: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
28
+ ) -> HttpResponse[ResolveAgentNamesResponse]:
29
+ """
30
+ Resolve a list of agent names to their UUIDs within the caller's org.
31
+
32
+ Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
33
+ clients) via `get_org_jwt_or_api_key`, so CI tooling can map human-friendly
34
+ agent names to the UUIDs the run/poll endpoints expect. Agent names are
35
+ unique per org, so each name resolves to at most one agent. Names with no
36
+ matching (non-deleted) agent in the org are returned under `not_found`.
37
+
38
+ Parameters
39
+ ----------
40
+ names : typing.Sequence[str]
41
+
42
+ request_options : typing.Optional[RequestOptions]
43
+ Request-specific configuration.
44
+
45
+ Returns
46
+ -------
47
+ HttpResponse[ResolveAgentNamesResponse]
48
+ Successful Response
49
+ """
50
+ _response = self._client_wrapper.httpx_client.request(
51
+ "agents/resolve",
52
+ method="POST",
53
+ json={
54
+ "names": names,
55
+ },
56
+ headers={
57
+ "content-type": "application/json",
58
+ },
59
+ request_options=request_options,
60
+ omit=OMIT,
61
+ )
62
+ try:
63
+ if 200 <= _response.status_code < 300:
64
+ _data = typing.cast(
65
+ ResolveAgentNamesResponse,
66
+ parse_obj_as(
67
+ type_=ResolveAgentNamesResponse, # type: ignore
68
+ object_=_response.json(),
69
+ ),
70
+ )
71
+ return HttpResponse(response=_response, data=_data)
72
+ if _response.status_code == 422:
73
+ raise UnprocessableEntityError(
74
+ headers=dict(_response.headers),
75
+ body=typing.cast(
76
+ HttpValidationError,
77
+ parse_obj_as(
78
+ type_=HttpValidationError, # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ ),
82
+ )
83
+ _response_json = _response.json()
84
+ except JSONDecodeError:
85
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
86
+ except ValidationError as e:
87
+ raise ParsingError(
88
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
89
+ )
90
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
91
+
92
+ def list(
93
+ self, *, request_options: typing.Optional[RequestOptions] = None
94
+ ) -> HttpResponse[typing.List[RoutersAgentTestsAgentResponse]]:
95
+ """
96
+ List all agents for the caller's current org.
97
+
98
+ Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
99
+ clients) via `get_org_jwt_or_api_key`, so CI tooling can enumerate every
100
+ agent UUID in the org without knowing names up front (the run/poll and
101
+ `/resolve` endpoints accept the same key).
102
+
103
+ Parameters
104
+ ----------
105
+ request_options : typing.Optional[RequestOptions]
106
+ Request-specific configuration.
107
+
108
+ Returns
109
+ -------
110
+ HttpResponse[typing.List[RoutersAgentTestsAgentResponse]]
111
+ Successful Response
112
+ """
113
+ _response = self._client_wrapper.httpx_client.request(
114
+ "agents",
115
+ method="GET",
116
+ request_options=request_options,
117
+ )
118
+ try:
119
+ if 200 <= _response.status_code < 300:
120
+ _data = typing.cast(
121
+ typing.List[RoutersAgentTestsAgentResponse],
122
+ parse_obj_as(
123
+ type_=typing.List[RoutersAgentTestsAgentResponse], # type: ignore
124
+ object_=_response.json(),
125
+ ),
126
+ )
127
+ return HttpResponse(response=_response, data=_data)
128
+ if _response.status_code == 422:
129
+ raise UnprocessableEntityError(
130
+ headers=dict(_response.headers),
131
+ body=typing.cast(
132
+ HttpValidationError,
133
+ parse_obj_as(
134
+ type_=HttpValidationError, # type: ignore
135
+ object_=_response.json(),
136
+ ),
137
+ ),
138
+ )
139
+ _response_json = _response.json()
140
+ except JSONDecodeError:
141
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
142
+ except ValidationError as e:
143
+ raise ParsingError(
144
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
145
+ )
146
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
147
+
148
+
149
+ class AsyncRawAgentsClient:
150
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
151
+ self._client_wrapper = client_wrapper
152
+
153
+ async def resolve(
154
+ self, *, names: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
155
+ ) -> AsyncHttpResponse[ResolveAgentNamesResponse]:
156
+ """
157
+ Resolve a list of agent names to their UUIDs within the caller's org.
158
+
159
+ Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
160
+ clients) via `get_org_jwt_or_api_key`, so CI tooling can map human-friendly
161
+ agent names to the UUIDs the run/poll endpoints expect. Agent names are
162
+ unique per org, so each name resolves to at most one agent. Names with no
163
+ matching (non-deleted) agent in the org are returned under `not_found`.
164
+
165
+ Parameters
166
+ ----------
167
+ names : typing.Sequence[str]
168
+
169
+ request_options : typing.Optional[RequestOptions]
170
+ Request-specific configuration.
171
+
172
+ Returns
173
+ -------
174
+ AsyncHttpResponse[ResolveAgentNamesResponse]
175
+ Successful Response
176
+ """
177
+ _response = await self._client_wrapper.httpx_client.request(
178
+ "agents/resolve",
179
+ method="POST",
180
+ json={
181
+ "names": names,
182
+ },
183
+ headers={
184
+ "content-type": "application/json",
185
+ },
186
+ request_options=request_options,
187
+ omit=OMIT,
188
+ )
189
+ try:
190
+ if 200 <= _response.status_code < 300:
191
+ _data = typing.cast(
192
+ ResolveAgentNamesResponse,
193
+ parse_obj_as(
194
+ type_=ResolveAgentNamesResponse, # type: ignore
195
+ object_=_response.json(),
196
+ ),
197
+ )
198
+ return AsyncHttpResponse(response=_response, data=_data)
199
+ if _response.status_code == 422:
200
+ raise UnprocessableEntityError(
201
+ headers=dict(_response.headers),
202
+ body=typing.cast(
203
+ HttpValidationError,
204
+ parse_obj_as(
205
+ type_=HttpValidationError, # type: ignore
206
+ object_=_response.json(),
207
+ ),
208
+ ),
209
+ )
210
+ _response_json = _response.json()
211
+ except JSONDecodeError:
212
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
213
+ except ValidationError as e:
214
+ raise ParsingError(
215
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
216
+ )
217
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
218
+
219
+ async def list(
220
+ self, *, request_options: typing.Optional[RequestOptions] = None
221
+ ) -> AsyncHttpResponse[typing.List[RoutersAgentTestsAgentResponse]]:
222
+ """
223
+ List all agents for the caller's current org.
224
+
225
+ Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
226
+ clients) via `get_org_jwt_or_api_key`, so CI tooling can enumerate every
227
+ agent UUID in the org without knowing names up front (the run/poll and
228
+ `/resolve` endpoints accept the same key).
229
+
230
+ Parameters
231
+ ----------
232
+ request_options : typing.Optional[RequestOptions]
233
+ Request-specific configuration.
234
+
235
+ Returns
236
+ -------
237
+ AsyncHttpResponse[typing.List[RoutersAgentTestsAgentResponse]]
238
+ Successful Response
239
+ """
240
+ _response = await self._client_wrapper.httpx_client.request(
241
+ "agents",
242
+ method="GET",
243
+ request_options=request_options,
244
+ )
245
+ try:
246
+ if 200 <= _response.status_code < 300:
247
+ _data = typing.cast(
248
+ typing.List[RoutersAgentTestsAgentResponse],
249
+ parse_obj_as(
250
+ type_=typing.List[RoutersAgentTestsAgentResponse], # type: ignore
251
+ object_=_response.json(),
252
+ ),
253
+ )
254
+ return AsyncHttpResponse(response=_response, data=_data)
255
+ if _response.status_code == 422:
256
+ raise UnprocessableEntityError(
257
+ headers=dict(_response.headers),
258
+ body=typing.cast(
259
+ HttpValidationError,
260
+ parse_obj_as(
261
+ type_=HttpValidationError, # type: ignore
262
+ object_=_response.json(),
263
+ ),
264
+ ),
265
+ )
266
+ _response_json = _response.json()
267
+ except JSONDecodeError:
268
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
269
+ except ValidationError as e:
270
+ raise ParsingError(
271
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
272
+ )
273
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
artpark/client.py ADDED
@@ -0,0 +1,268 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from .core.logging import LogConfig, Logger
10
+ from .environment import CalibrateEnvironment
11
+
12
+ if typing.TYPE_CHECKING:
13
+ from .agent_tests.client import AgentTestsClient, AsyncAgentTestsClient
14
+ from .agents.client import AgentsClient, AsyncAgentsClient
15
+
16
+
17
+ class Calibrate:
18
+ """
19
+ 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.
20
+
21
+ Parameters
22
+ ----------
23
+ base_url : typing.Optional[str]
24
+ The base url to use for requests from the client.
25
+
26
+ environment : CalibrateEnvironment
27
+ The environment to use for requests from the client. from .environment import CalibrateEnvironment
28
+
29
+
30
+
31
+ Defaults to CalibrateEnvironment.PRODUCTION
32
+
33
+
34
+
35
+ api_key : typing.Optional[str]
36
+ org_uuid : typing.Optional[str]
37
+ token : typing.Union[str, typing.Callable[[], str]]
38
+ headers : typing.Optional[typing.Dict[str, str]]
39
+ Additional headers to send with every request.
40
+
41
+ timeout : typing.Optional[float]
42
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
43
+
44
+ max_retries : typing.Optional[int]
45
+ The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
46
+
47
+ stream_reconnection_enabled : typing.Optional[bool]
48
+ Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
49
+
50
+ max_stream_reconnection_attempts : typing.Optional[int]
51
+ The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
52
+
53
+ follow_redirects : typing.Optional[bool]
54
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
55
+
56
+ httpx_client : typing.Optional[httpx.Client]
57
+ 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.
58
+
59
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
60
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
61
+
62
+ Examples
63
+ --------
64
+ from artpark import Calibrate
65
+
66
+ client = Calibrate(
67
+ api_key="YOUR_API_KEY",
68
+ org_uuid="YOUR_ORG_UUID",
69
+ token="YOUR_TOKEN",
70
+ )
71
+ """
72
+
73
+ def __init__(
74
+ self,
75
+ *,
76
+ base_url: typing.Optional[str] = None,
77
+ environment: CalibrateEnvironment = CalibrateEnvironment.PRODUCTION,
78
+ api_key: typing.Optional[str] = None,
79
+ org_uuid: typing.Optional[str] = None,
80
+ token: typing.Union[str, typing.Callable[[], str]],
81
+ headers: typing.Optional[typing.Dict[str, str]] = None,
82
+ timeout: typing.Optional[float] = None,
83
+ max_retries: typing.Optional[int] = None,
84
+ stream_reconnection_enabled: typing.Optional[bool] = None,
85
+ max_stream_reconnection_attempts: typing.Optional[int] = None,
86
+ follow_redirects: typing.Optional[bool] = True,
87
+ httpx_client: typing.Optional[httpx.Client] = None,
88
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
89
+ ):
90
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
91
+ _defaulted_max_retries = max_retries if max_retries is not None else 2
92
+ self._client_wrapper = SyncClientWrapper(
93
+ base_url=_get_base_url(base_url=base_url, environment=environment),
94
+ api_key=api_key,
95
+ org_uuid=org_uuid,
96
+ token=token,
97
+ headers=headers,
98
+ httpx_client=httpx_client
99
+ if httpx_client is not None
100
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
101
+ if follow_redirects is not None
102
+ else httpx.Client(timeout=_defaulted_timeout),
103
+ timeout=_defaulted_timeout,
104
+ max_retries=_defaulted_max_retries,
105
+ stream_reconnection_enabled=stream_reconnection_enabled,
106
+ max_stream_reconnection_attempts=max_stream_reconnection_attempts,
107
+ logging=logging,
108
+ )
109
+ self._agents: typing.Optional[AgentsClient] = None
110
+ self._agent_tests: typing.Optional[AgentTestsClient] = None
111
+
112
+ @property
113
+ def agents(self):
114
+ if self._agents is None:
115
+ from .agents.client import AgentsClient # noqa: E402
116
+
117
+ self._agents = AgentsClient(client_wrapper=self._client_wrapper)
118
+ return self._agents
119
+
120
+ @property
121
+ def agent_tests(self):
122
+ if self._agent_tests is None:
123
+ from .agent_tests.client import AgentTestsClient # noqa: E402
124
+
125
+ self._agent_tests = AgentTestsClient(client_wrapper=self._client_wrapper)
126
+ return self._agent_tests
127
+
128
+
129
+ def _make_default_async_client(
130
+ timeout: typing.Optional[float],
131
+ follow_redirects: typing.Optional[bool],
132
+ ) -> httpx.AsyncClient:
133
+ try:
134
+ import httpx_aiohttp # type: ignore[import-not-found]
135
+ except ImportError:
136
+ pass
137
+ else:
138
+ if follow_redirects is not None:
139
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
140
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
141
+
142
+ if follow_redirects is not None:
143
+ return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
144
+ return httpx.AsyncClient(timeout=timeout)
145
+
146
+
147
+ class AsyncCalibrate:
148
+ """
149
+ 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.
150
+
151
+ Parameters
152
+ ----------
153
+ base_url : typing.Optional[str]
154
+ The base url to use for requests from the client.
155
+
156
+ environment : CalibrateEnvironment
157
+ The environment to use for requests from the client. from .environment import CalibrateEnvironment
158
+
159
+
160
+
161
+ Defaults to CalibrateEnvironment.PRODUCTION
162
+
163
+
164
+
165
+ api_key : typing.Optional[str]
166
+ org_uuid : typing.Optional[str]
167
+ token : typing.Union[str, typing.Callable[[], str]]
168
+ headers : typing.Optional[typing.Dict[str, str]]
169
+ Additional headers to send with every request.
170
+
171
+ async_token : typing.Optional[typing.Callable[[], typing.Awaitable[str]]]
172
+ An async callable that returns a bearer token. Use this when token acquisition involves async I/O (e.g., refreshing tokens via an async HTTP client). When provided, this is used instead of the synchronous token for async requests.
173
+
174
+ timeout : typing.Optional[float]
175
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
176
+
177
+ max_retries : typing.Optional[int]
178
+ The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
179
+
180
+ stream_reconnection_enabled : typing.Optional[bool]
181
+ Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
182
+
183
+ max_stream_reconnection_attempts : typing.Optional[int]
184
+ The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
185
+
186
+ follow_redirects : typing.Optional[bool]
187
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
188
+
189
+ httpx_client : typing.Optional[httpx.AsyncClient]
190
+ 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.
191
+
192
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
193
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
194
+
195
+ Examples
196
+ --------
197
+ from artpark import AsyncCalibrate
198
+
199
+ client = AsyncCalibrate(
200
+ api_key="YOUR_API_KEY",
201
+ org_uuid="YOUR_ORG_UUID",
202
+ token="YOUR_TOKEN",
203
+ )
204
+ """
205
+
206
+ def __init__(
207
+ self,
208
+ *,
209
+ base_url: typing.Optional[str] = None,
210
+ environment: CalibrateEnvironment = CalibrateEnvironment.PRODUCTION,
211
+ api_key: typing.Optional[str] = None,
212
+ org_uuid: typing.Optional[str] = None,
213
+ token: typing.Union[str, typing.Callable[[], str]],
214
+ headers: typing.Optional[typing.Dict[str, str]] = None,
215
+ async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
216
+ timeout: typing.Optional[float] = None,
217
+ max_retries: typing.Optional[int] = None,
218
+ stream_reconnection_enabled: typing.Optional[bool] = None,
219
+ max_stream_reconnection_attempts: typing.Optional[int] = None,
220
+ follow_redirects: typing.Optional[bool] = True,
221
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
222
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
223
+ ):
224
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
225
+ _defaulted_max_retries = max_retries if max_retries is not None else 2
226
+ self._client_wrapper = AsyncClientWrapper(
227
+ base_url=_get_base_url(base_url=base_url, environment=environment),
228
+ api_key=api_key,
229
+ org_uuid=org_uuid,
230
+ token=token,
231
+ headers=headers,
232
+ async_token=async_token,
233
+ httpx_client=httpx_client
234
+ if httpx_client is not None
235
+ else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
236
+ timeout=_defaulted_timeout,
237
+ max_retries=_defaulted_max_retries,
238
+ stream_reconnection_enabled=stream_reconnection_enabled,
239
+ max_stream_reconnection_attempts=max_stream_reconnection_attempts,
240
+ logging=logging,
241
+ )
242
+ self._agents: typing.Optional[AsyncAgentsClient] = None
243
+ self._agent_tests: typing.Optional[AsyncAgentTestsClient] = None
244
+
245
+ @property
246
+ def agents(self):
247
+ if self._agents is None:
248
+ from .agents.client import AsyncAgentsClient # noqa: E402
249
+
250
+ self._agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
251
+ return self._agents
252
+
253
+ @property
254
+ def agent_tests(self):
255
+ if self._agent_tests is None:
256
+ from .agent_tests.client import AsyncAgentTestsClient # noqa: E402
257
+
258
+ self._agent_tests = AsyncAgentTestsClient(client_wrapper=self._client_wrapper)
259
+ return self._agent_tests
260
+
261
+
262
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: CalibrateEnvironment) -> str:
263
+ if base_url is not None:
264
+ return base_url
265
+ elif environment is not None:
266
+ return environment.value
267
+ else:
268
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,127 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .api_error import ApiError
10
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
11
+ from .datetime_utils import Rfc2822DateTime, parse_rfc2822_datetime, serialize_datetime
12
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
13
+ from .http_client import AsyncHttpClient, HttpClient
14
+ from .http_response import AsyncHttpResponse, HttpResponse
15
+ from .jsonable_encoder import encode_path_param, jsonable_encoder
16
+ from .logging import ConsoleLogger, ILogger, LogConfig, LogLevel, Logger, create_logger
17
+ from .parse_error import ParsingError
18
+ from .pydantic_utilities import (
19
+ IS_PYDANTIC_V2,
20
+ UniversalBaseModel,
21
+ UniversalRootModel,
22
+ parse_obj_as,
23
+ universal_field_validator,
24
+ universal_root_validator,
25
+ update_forward_refs,
26
+ )
27
+ from .query_encoder import encode_query
28
+ from .remove_none_from_dict import remove_none_from_dict
29
+ from .request_options import RequestOptions
30
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
31
+ _dynamic_imports: typing.Dict[str, str] = {
32
+ "ApiError": ".api_error",
33
+ "AsyncClientWrapper": ".client_wrapper",
34
+ "AsyncHttpClient": ".http_client",
35
+ "AsyncHttpResponse": ".http_response",
36
+ "BaseClientWrapper": ".client_wrapper",
37
+ "ConsoleLogger": ".logging",
38
+ "FieldMetadata": ".serialization",
39
+ "File": ".file",
40
+ "HttpClient": ".http_client",
41
+ "HttpResponse": ".http_response",
42
+ "ILogger": ".logging",
43
+ "IS_PYDANTIC_V2": ".pydantic_utilities",
44
+ "LogConfig": ".logging",
45
+ "LogLevel": ".logging",
46
+ "Logger": ".logging",
47
+ "ParsingError": ".parse_error",
48
+ "RequestOptions": ".request_options",
49
+ "Rfc2822DateTime": ".datetime_utils",
50
+ "SyncClientWrapper": ".client_wrapper",
51
+ "UniversalBaseModel": ".pydantic_utilities",
52
+ "UniversalRootModel": ".pydantic_utilities",
53
+ "convert_and_respect_annotation_metadata": ".serialization",
54
+ "convert_file_dict_to_httpx_tuples": ".file",
55
+ "create_logger": ".logging",
56
+ "encode_path_param": ".jsonable_encoder",
57
+ "encode_query": ".query_encoder",
58
+ "jsonable_encoder": ".jsonable_encoder",
59
+ "parse_obj_as": ".pydantic_utilities",
60
+ "parse_rfc2822_datetime": ".datetime_utils",
61
+ "remove_none_from_dict": ".remove_none_from_dict",
62
+ "serialize_datetime": ".datetime_utils",
63
+ "universal_field_validator": ".pydantic_utilities",
64
+ "universal_root_validator": ".pydantic_utilities",
65
+ "update_forward_refs": ".pydantic_utilities",
66
+ "with_content_type": ".file",
67
+ }
68
+
69
+
70
+ def __getattr__(attr_name: str) -> typing.Any:
71
+ module_name = _dynamic_imports.get(attr_name)
72
+ if module_name is None:
73
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
74
+ try:
75
+ module = import_module(module_name, __package__)
76
+ if module_name == f".{attr_name}":
77
+ return module
78
+ else:
79
+ return getattr(module, attr_name)
80
+ except ImportError as e:
81
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
82
+ except AttributeError as e:
83
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
84
+
85
+
86
+ def __dir__():
87
+ lazy_attrs = list(_dynamic_imports.keys())
88
+ return sorted(lazy_attrs)
89
+
90
+
91
+ __all__ = [
92
+ "ApiError",
93
+ "AsyncClientWrapper",
94
+ "AsyncHttpClient",
95
+ "AsyncHttpResponse",
96
+ "BaseClientWrapper",
97
+ "ConsoleLogger",
98
+ "FieldMetadata",
99
+ "File",
100
+ "HttpClient",
101
+ "HttpResponse",
102
+ "ILogger",
103
+ "IS_PYDANTIC_V2",
104
+ "LogConfig",
105
+ "LogLevel",
106
+ "Logger",
107
+ "ParsingError",
108
+ "RequestOptions",
109
+ "Rfc2822DateTime",
110
+ "SyncClientWrapper",
111
+ "UniversalBaseModel",
112
+ "UniversalRootModel",
113
+ "convert_and_respect_annotation_metadata",
114
+ "convert_file_dict_to_httpx_tuples",
115
+ "create_logger",
116
+ "encode_path_param",
117
+ "encode_query",
118
+ "jsonable_encoder",
119
+ "parse_obj_as",
120
+ "parse_rfc2822_datetime",
121
+ "remove_none_from_dict",
122
+ "serialize_datetime",
123
+ "universal_field_validator",
124
+ "universal_root_validator",
125
+ "update_forward_refs",
126
+ "with_content_type",
127
+ ]
@@ -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}"