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
artpark/__init__.py ADDED
@@ -0,0 +1,109 @@
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 .types import (
10
+ BatchRunRequest,
11
+ BatchTestRun,
12
+ BatchTestRunResponse,
13
+ BatchTestSkip,
14
+ HttpValidationError,
15
+ JudgeResult,
16
+ ResolveAgentNamesResponse,
17
+ RoutersAgentTestsAgentResponse,
18
+ RoutersAgentTestsAgentResponseType,
19
+ TaskCreateResponse,
20
+ TestCaseResult,
21
+ TestOutput,
22
+ TestRunStatusResponse,
23
+ ToolCallOutput,
24
+ ValidationError,
25
+ ValidationErrorLocItem,
26
+ )
27
+ from .errors import UnprocessableEntityError
28
+ from . import agent_tests, agents
29
+ from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
30
+ from .client import AsyncCalibrate, Calibrate
31
+ from .environment import CalibrateEnvironment
32
+ from .version import __version__
33
+ _dynamic_imports: typing.Dict[str, str] = {
34
+ "AsyncCalibrate": ".client",
35
+ "BatchRunRequest": ".types",
36
+ "BatchTestRun": ".types",
37
+ "BatchTestRunResponse": ".types",
38
+ "BatchTestSkip": ".types",
39
+ "Calibrate": ".client",
40
+ "CalibrateEnvironment": ".environment",
41
+ "DefaultAioHttpClient": "._default_clients",
42
+ "DefaultAsyncHttpxClient": "._default_clients",
43
+ "HttpValidationError": ".types",
44
+ "JudgeResult": ".types",
45
+ "ResolveAgentNamesResponse": ".types",
46
+ "RoutersAgentTestsAgentResponse": ".types",
47
+ "RoutersAgentTestsAgentResponseType": ".types",
48
+ "TaskCreateResponse": ".types",
49
+ "TestCaseResult": ".types",
50
+ "TestOutput": ".types",
51
+ "TestRunStatusResponse": ".types",
52
+ "ToolCallOutput": ".types",
53
+ "UnprocessableEntityError": ".errors",
54
+ "ValidationError": ".types",
55
+ "ValidationErrorLocItem": ".types",
56
+ "__version__": ".version",
57
+ "agent_tests": ".agent_tests",
58
+ "agents": ".agents",
59
+ }
60
+
61
+
62
+ def __getattr__(attr_name: str) -> typing.Any:
63
+ module_name = _dynamic_imports.get(attr_name)
64
+ if module_name is None:
65
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
66
+ try:
67
+ module = import_module(module_name, __package__)
68
+ if module_name == f".{attr_name}":
69
+ return module
70
+ else:
71
+ return getattr(module, attr_name)
72
+ except ImportError as e:
73
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
74
+ except AttributeError as e:
75
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
76
+
77
+
78
+ def __dir__():
79
+ lazy_attrs = list(_dynamic_imports.keys())
80
+ return sorted(lazy_attrs)
81
+
82
+
83
+ __all__ = [
84
+ "AsyncCalibrate",
85
+ "BatchRunRequest",
86
+ "BatchTestRun",
87
+ "BatchTestRunResponse",
88
+ "BatchTestSkip",
89
+ "Calibrate",
90
+ "CalibrateEnvironment",
91
+ "DefaultAioHttpClient",
92
+ "DefaultAsyncHttpxClient",
93
+ "HttpValidationError",
94
+ "JudgeResult",
95
+ "ResolveAgentNamesResponse",
96
+ "RoutersAgentTestsAgentResponse",
97
+ "RoutersAgentTestsAgentResponseType",
98
+ "TaskCreateResponse",
99
+ "TestCaseResult",
100
+ "TestOutput",
101
+ "TestRunStatusResponse",
102
+ "ToolCallOutput",
103
+ "UnprocessableEntityError",
104
+ "ValidationError",
105
+ "ValidationErrorLocItem",
106
+ "__version__",
107
+ "agent_tests",
108
+ "agents",
109
+ ]
@@ -0,0 +1,32 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+
7
+ SDK_DEFAULT_TIMEOUT = 60
8
+
9
+ try:
10
+ import httpx_aiohttp # type: ignore[import-not-found]
11
+ except ImportError:
12
+
13
+ class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
14
+ def __init__(self, **kwargs: typing.Any) -> None:
15
+ raise RuntimeError(
16
+ "To use the aiohttp client, install the aiohttp extra: pip install calibrate-python-sdk[aiohttp]"
17
+ )
18
+
19
+ else:
20
+
21
+ class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
22
+ def __init__(self, **kwargs: typing.Any) -> None:
23
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
24
+ kwargs.setdefault("follow_redirects", True)
25
+ super().__init__(**kwargs)
26
+
27
+
28
+ class DefaultAsyncHttpxClient(httpx.AsyncClient):
29
+ def __init__(self, **kwargs: typing.Any) -> None:
30
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
31
+ kwargs.setdefault("follow_redirects", True)
32
+ super().__init__(**kwargs)
@@ -0,0 +1,4 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
@@ -0,0 +1,356 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from ..types.batch_run_request import BatchRunRequest
8
+ from ..types.batch_test_run_response import BatchTestRunResponse
9
+ from ..types.task_create_response import TaskCreateResponse
10
+ from ..types.test_run_status_response import TestRunStatusResponse
11
+ from .raw_client import AsyncRawAgentTestsClient, RawAgentTestsClient
12
+
13
+ # this is used as the default value for optional parameters
14
+ OMIT = typing.cast(typing.Any, ...)
15
+
16
+
17
+ class AgentTestsClient:
18
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
19
+ self._raw_client = RawAgentTestsClient(client_wrapper=client_wrapper)
20
+
21
+ @property
22
+ def with_raw_response(self) -> RawAgentTestsClient:
23
+ """
24
+ Retrieves a raw implementation of this client that returns raw responses.
25
+
26
+ Returns
27
+ -------
28
+ RawAgentTestsClient
29
+ """
30
+ return self._raw_client
31
+
32
+ def run(
33
+ self,
34
+ agent_uuid: str,
35
+ *,
36
+ test_uuids: typing.Optional[typing.Sequence[str]] = OMIT,
37
+ request_options: typing.Optional[RequestOptions] = None,
38
+ ) -> TaskCreateResponse:
39
+ """
40
+ Run one or more tests for an agent.
41
+
42
+ This starts a background task that runs the calibrate LLM tests command
43
+ with the agent's config and the combined test cases from all specified tests.
44
+
45
+ Returns a task ID that can be used to poll for status and results.
46
+
47
+ Auth: requires either a JWT (frontend) or an `sk_` API key. The agent
48
+ must belong to the caller's org or this 404s.
49
+
50
+ Parameters
51
+ ----------
52
+ agent_uuid : str
53
+
54
+ test_uuids : typing.Optional[typing.Sequence[str]]
55
+
56
+ request_options : typing.Optional[RequestOptions]
57
+ Request-specific configuration.
58
+
59
+ Returns
60
+ -------
61
+ TaskCreateResponse
62
+ Successful Response
63
+
64
+ Examples
65
+ --------
66
+ from artpark import Calibrate
67
+
68
+ client = Calibrate(
69
+ api_key="YOUR_API_KEY",
70
+ org_uuid="YOUR_ORG_UUID",
71
+ token="YOUR_TOKEN",
72
+ )
73
+ client.agent_tests.run(
74
+ agent_uuid="agent_uuid",
75
+ )
76
+ """
77
+ _response = self._raw_client.run(agent_uuid, test_uuids=test_uuids, request_options=request_options)
78
+ return _response.data
79
+
80
+ def run_batch(
81
+ self,
82
+ *,
83
+ request: typing.Optional[BatchRunRequest] = None,
84
+ request_options: typing.Optional[RequestOptions] = None,
85
+ ) -> BatchTestRunResponse:
86
+ """
87
+ Run every linked test for a set of agents, one ``llm-unit-test`` job per agent.
88
+
89
+ Scope is driven by the optional ``agent_names`` payload:
90
+
91
+ - **Provided (non-empty)** — run only those agents. Names are unique per org
92
+ and **all are validated up front**: if any doesn't resolve to a
93
+ (non-deleted) agent in the caller's org, the call 404s with the offending
94
+ names and NO jobs are created.
95
+ - **Omitted / null / empty** — run every agent in the caller's org.
96
+
97
+ For each selected agent, its linked tests are launched as one job. Agents
98
+ with no linked tests or an unverified connection are reported under
99
+ ``skipped`` instead of failing the batch. Subject to the normal per-org
100
+ concurrency queue, so over-limit jobs come back ``queued``.
101
+
102
+ Auth accepts a JWT (frontend) or an `sk_` API key (programmatic clients).
103
+ Returns one ``runs`` entry per launched agent with ``agent_name``,
104
+ ``agent_uuid``, ``task_id``, and ``status``.
105
+
106
+ Parameters
107
+ ----------
108
+ request : typing.Optional[BatchRunRequest]
109
+
110
+ request_options : typing.Optional[RequestOptions]
111
+ Request-specific configuration.
112
+
113
+ Returns
114
+ -------
115
+ BatchTestRunResponse
116
+ Successful Response
117
+
118
+ Examples
119
+ --------
120
+ from artpark import BatchRunRequest, Calibrate
121
+
122
+ client = Calibrate(
123
+ api_key="YOUR_API_KEY",
124
+ org_uuid="YOUR_ORG_UUID",
125
+ token="YOUR_TOKEN",
126
+ )
127
+ client.agent_tests.run_batch(
128
+ request=BatchRunRequest(),
129
+ )
130
+ """
131
+ _response = self._raw_client.run_batch(request=request, request_options=request_options)
132
+ return _response.data
133
+
134
+ def get_run(
135
+ self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
136
+ ) -> TestRunStatusResponse:
137
+ """
138
+ Get the status of an agent test run.
139
+
140
+ Requires either a JWT (frontend) or an `sk_` API key, plus org
141
+ ownership of the run. Unauthenticated access to a completed run is only
142
+ possible once it is made public, via the share-token endpoint in the public
143
+ router.
144
+
145
+ Returns the current status and, if done, the test results.
146
+
147
+ Parameters
148
+ ----------
149
+ task_id : str
150
+
151
+ request_options : typing.Optional[RequestOptions]
152
+ Request-specific configuration.
153
+
154
+ Returns
155
+ -------
156
+ TestRunStatusResponse
157
+ Successful Response
158
+
159
+ Examples
160
+ --------
161
+ from artpark import Calibrate
162
+
163
+ client = Calibrate(
164
+ api_key="YOUR_API_KEY",
165
+ org_uuid="YOUR_ORG_UUID",
166
+ token="YOUR_TOKEN",
167
+ )
168
+ client.agent_tests.get_run(
169
+ task_id="task_id",
170
+ )
171
+ """
172
+ _response = self._raw_client.get_run(task_id, request_options=request_options)
173
+ return _response.data
174
+
175
+
176
+ class AsyncAgentTestsClient:
177
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
178
+ self._raw_client = AsyncRawAgentTestsClient(client_wrapper=client_wrapper)
179
+
180
+ @property
181
+ def with_raw_response(self) -> AsyncRawAgentTestsClient:
182
+ """
183
+ Retrieves a raw implementation of this client that returns raw responses.
184
+
185
+ Returns
186
+ -------
187
+ AsyncRawAgentTestsClient
188
+ """
189
+ return self._raw_client
190
+
191
+ async def run(
192
+ self,
193
+ agent_uuid: str,
194
+ *,
195
+ test_uuids: typing.Optional[typing.Sequence[str]] = OMIT,
196
+ request_options: typing.Optional[RequestOptions] = None,
197
+ ) -> TaskCreateResponse:
198
+ """
199
+ Run one or more tests for an agent.
200
+
201
+ This starts a background task that runs the calibrate LLM tests command
202
+ with the agent's config and the combined test cases from all specified tests.
203
+
204
+ Returns a task ID that can be used to poll for status and results.
205
+
206
+ Auth: requires either a JWT (frontend) or an `sk_` API key. The agent
207
+ must belong to the caller's org or this 404s.
208
+
209
+ Parameters
210
+ ----------
211
+ agent_uuid : str
212
+
213
+ test_uuids : typing.Optional[typing.Sequence[str]]
214
+
215
+ request_options : typing.Optional[RequestOptions]
216
+ Request-specific configuration.
217
+
218
+ Returns
219
+ -------
220
+ TaskCreateResponse
221
+ Successful Response
222
+
223
+ Examples
224
+ --------
225
+ import asyncio
226
+
227
+ from artpark import AsyncCalibrate
228
+
229
+ client = AsyncCalibrate(
230
+ api_key="YOUR_API_KEY",
231
+ org_uuid="YOUR_ORG_UUID",
232
+ token="YOUR_TOKEN",
233
+ )
234
+
235
+
236
+ async def main() -> None:
237
+ await client.agent_tests.run(
238
+ agent_uuid="agent_uuid",
239
+ )
240
+
241
+
242
+ asyncio.run(main())
243
+ """
244
+ _response = await self._raw_client.run(agent_uuid, test_uuids=test_uuids, request_options=request_options)
245
+ return _response.data
246
+
247
+ async def run_batch(
248
+ self,
249
+ *,
250
+ request: typing.Optional[BatchRunRequest] = None,
251
+ request_options: typing.Optional[RequestOptions] = None,
252
+ ) -> BatchTestRunResponse:
253
+ """
254
+ Run every linked test for a set of agents, one ``llm-unit-test`` job per agent.
255
+
256
+ Scope is driven by the optional ``agent_names`` payload:
257
+
258
+ - **Provided (non-empty)** — run only those agents. Names are unique per org
259
+ and **all are validated up front**: if any doesn't resolve to a
260
+ (non-deleted) agent in the caller's org, the call 404s with the offending
261
+ names and NO jobs are created.
262
+ - **Omitted / null / empty** — run every agent in the caller's org.
263
+
264
+ For each selected agent, its linked tests are launched as one job. Agents
265
+ with no linked tests or an unverified connection are reported under
266
+ ``skipped`` instead of failing the batch. Subject to the normal per-org
267
+ concurrency queue, so over-limit jobs come back ``queued``.
268
+
269
+ Auth accepts a JWT (frontend) or an `sk_` API key (programmatic clients).
270
+ Returns one ``runs`` entry per launched agent with ``agent_name``,
271
+ ``agent_uuid``, ``task_id``, and ``status``.
272
+
273
+ Parameters
274
+ ----------
275
+ request : typing.Optional[BatchRunRequest]
276
+
277
+ request_options : typing.Optional[RequestOptions]
278
+ Request-specific configuration.
279
+
280
+ Returns
281
+ -------
282
+ BatchTestRunResponse
283
+ Successful Response
284
+
285
+ Examples
286
+ --------
287
+ import asyncio
288
+
289
+ from artpark import AsyncCalibrate, BatchRunRequest
290
+
291
+ client = AsyncCalibrate(
292
+ api_key="YOUR_API_KEY",
293
+ org_uuid="YOUR_ORG_UUID",
294
+ token="YOUR_TOKEN",
295
+ )
296
+
297
+
298
+ async def main() -> None:
299
+ await client.agent_tests.run_batch(
300
+ request=BatchRunRequest(),
301
+ )
302
+
303
+
304
+ asyncio.run(main())
305
+ """
306
+ _response = await self._raw_client.run_batch(request=request, request_options=request_options)
307
+ return _response.data
308
+
309
+ async def get_run(
310
+ self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
311
+ ) -> TestRunStatusResponse:
312
+ """
313
+ Get the status of an agent test run.
314
+
315
+ Requires either a JWT (frontend) or an `sk_` API key, plus org
316
+ ownership of the run. Unauthenticated access to a completed run is only
317
+ possible once it is made public, via the share-token endpoint in the public
318
+ router.
319
+
320
+ Returns the current status and, if done, the test results.
321
+
322
+ Parameters
323
+ ----------
324
+ task_id : str
325
+
326
+ request_options : typing.Optional[RequestOptions]
327
+ Request-specific configuration.
328
+
329
+ Returns
330
+ -------
331
+ TestRunStatusResponse
332
+ Successful Response
333
+
334
+ Examples
335
+ --------
336
+ import asyncio
337
+
338
+ from artpark import AsyncCalibrate
339
+
340
+ client = AsyncCalibrate(
341
+ api_key="YOUR_API_KEY",
342
+ org_uuid="YOUR_ORG_UUID",
343
+ token="YOUR_TOKEN",
344
+ )
345
+
346
+
347
+ async def main() -> None:
348
+ await client.agent_tests.get_run(
349
+ task_id="task_id",
350
+ )
351
+
352
+
353
+ asyncio.run(main())
354
+ """
355
+ _response = await self._raw_client.get_run(task_id, request_options=request_options)
356
+ return _response.data