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.
- artpark/__init__.py +109 -0
- artpark/_default_clients.py +32 -0
- artpark/agent_tests/__init__.py +4 -0
- artpark/agent_tests/client.py +356 -0
- artpark/agent_tests/raw_client.py +455 -0
- artpark/agents/__init__.py +4 -0
- artpark/agents/client.py +210 -0
- artpark/agents/raw_client.py +273 -0
- artpark/client.py +268 -0
- artpark/core/__init__.py +127 -0
- artpark/core/api_error.py +23 -0
- artpark/core/client_wrapper.py +163 -0
- artpark/core/datetime_utils.py +70 -0
- artpark/core/file.py +67 -0
- artpark/core/force_multipart.py +18 -0
- artpark/core/http_client.py +843 -0
- artpark/core/http_response.py +59 -0
- artpark/core/http_sse/__init__.py +42 -0
- artpark/core/http_sse/_api.py +180 -0
- artpark/core/http_sse/_decoders.py +61 -0
- artpark/core/http_sse/_exceptions.py +7 -0
- artpark/core/http_sse/_models.py +17 -0
- artpark/core/jsonable_encoder.py +120 -0
- artpark/core/logging.py +107 -0
- artpark/core/parse_error.py +36 -0
- artpark/core/pydantic_utilities.py +508 -0
- artpark/core/query_encoder.py +58 -0
- artpark/core/remove_none_from_dict.py +11 -0
- artpark/core/request_options.py +37 -0
- artpark/core/serialization.py +347 -0
- artpark/environment.py +7 -0
- artpark/errors/__init__.py +34 -0
- artpark/errors/unprocessable_entity_error.py +11 -0
- artpark/py.typed +0 -0
- artpark/types/__init__.py +83 -0
- artpark/types/batch_run_request.py +19 -0
- artpark/types/batch_test_run.py +22 -0
- artpark/types/batch_test_run_response.py +22 -0
- artpark/types/batch_test_skip.py +21 -0
- artpark/types/http_validation_error.py +20 -0
- artpark/types/judge_result.py +51 -0
- artpark/types/resolve_agent_names_response.py +20 -0
- artpark/types/routers_agent_tests_agent_response.py +27 -0
- artpark/types/routers_agent_tests_agent_response_type.py +5 -0
- artpark/types/task_create_response.py +22 -0
- artpark/types/test_case_result.py +33 -0
- artpark/types/test_output.py +21 -0
- artpark/types/test_run_status_response.py +37 -0
- artpark/types/tool_call_output.py +21 -0
- artpark/types/validation_error.py +22 -0
- artpark/types/validation_error_loc_item.py +5 -0
- artpark/version.py +3 -0
- calibrate_python_sdk-0.0.1.dist-info/LICENSE +21 -0
- calibrate_python_sdk-0.0.1.dist-info/METADATA +55 -0
- calibrate_python_sdk-0.0.1.dist-info/RECORD +56 -0
- calibrate_python_sdk-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.jsonable_encoder import encode_path_param
|
|
10
|
+
from ..core.parse_error import ParsingError
|
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
12
|
+
from ..core.request_options import RequestOptions
|
|
13
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
14
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
15
|
+
from ..types.batch_run_request import BatchRunRequest
|
|
16
|
+
from ..types.batch_test_run_response import BatchTestRunResponse
|
|
17
|
+
from ..types.http_validation_error import HttpValidationError
|
|
18
|
+
from ..types.task_create_response import TaskCreateResponse
|
|
19
|
+
from ..types.test_run_status_response import TestRunStatusResponse
|
|
20
|
+
from pydantic import ValidationError
|
|
21
|
+
|
|
22
|
+
# this is used as the default value for optional parameters
|
|
23
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class RawAgentTestsClient:
|
|
27
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
28
|
+
self._client_wrapper = client_wrapper
|
|
29
|
+
|
|
30
|
+
def run(
|
|
31
|
+
self,
|
|
32
|
+
agent_uuid: str,
|
|
33
|
+
*,
|
|
34
|
+
test_uuids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
35
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
36
|
+
) -> HttpResponse[TaskCreateResponse]:
|
|
37
|
+
"""
|
|
38
|
+
Run one or more tests for an agent.
|
|
39
|
+
|
|
40
|
+
This starts a background task that runs the calibrate LLM tests command
|
|
41
|
+
with the agent's config and the combined test cases from all specified tests.
|
|
42
|
+
|
|
43
|
+
Returns a task ID that can be used to poll for status and results.
|
|
44
|
+
|
|
45
|
+
Auth: requires either a JWT (frontend) or an `sk_` API key. The agent
|
|
46
|
+
must belong to the caller's org or this 404s.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
agent_uuid : str
|
|
51
|
+
|
|
52
|
+
test_uuids : typing.Optional[typing.Sequence[str]]
|
|
53
|
+
|
|
54
|
+
request_options : typing.Optional[RequestOptions]
|
|
55
|
+
Request-specific configuration.
|
|
56
|
+
|
|
57
|
+
Returns
|
|
58
|
+
-------
|
|
59
|
+
HttpResponse[TaskCreateResponse]
|
|
60
|
+
Successful Response
|
|
61
|
+
"""
|
|
62
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
63
|
+
f"agent-tests/agent/{encode_path_param(agent_uuid)}/run",
|
|
64
|
+
method="POST",
|
|
65
|
+
json={
|
|
66
|
+
"test_uuids": test_uuids,
|
|
67
|
+
},
|
|
68
|
+
headers={
|
|
69
|
+
"content-type": "application/json",
|
|
70
|
+
},
|
|
71
|
+
request_options=request_options,
|
|
72
|
+
omit=OMIT,
|
|
73
|
+
)
|
|
74
|
+
try:
|
|
75
|
+
if 200 <= _response.status_code < 300:
|
|
76
|
+
_data = typing.cast(
|
|
77
|
+
TaskCreateResponse,
|
|
78
|
+
parse_obj_as(
|
|
79
|
+
type_=TaskCreateResponse, # type: ignore
|
|
80
|
+
object_=_response.json(),
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
return HttpResponse(response=_response, data=_data)
|
|
84
|
+
if _response.status_code == 422:
|
|
85
|
+
raise UnprocessableEntityError(
|
|
86
|
+
headers=dict(_response.headers),
|
|
87
|
+
body=typing.cast(
|
|
88
|
+
HttpValidationError,
|
|
89
|
+
parse_obj_as(
|
|
90
|
+
type_=HttpValidationError, # type: ignore
|
|
91
|
+
object_=_response.json(),
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
)
|
|
95
|
+
_response_json = _response.json()
|
|
96
|
+
except JSONDecodeError:
|
|
97
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
98
|
+
except ValidationError as e:
|
|
99
|
+
raise ParsingError(
|
|
100
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
101
|
+
)
|
|
102
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
103
|
+
|
|
104
|
+
def run_batch(
|
|
105
|
+
self,
|
|
106
|
+
*,
|
|
107
|
+
request: typing.Optional[BatchRunRequest] = None,
|
|
108
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
109
|
+
) -> HttpResponse[BatchTestRunResponse]:
|
|
110
|
+
"""
|
|
111
|
+
Run every linked test for a set of agents, one ``llm-unit-test`` job per agent.
|
|
112
|
+
|
|
113
|
+
Scope is driven by the optional ``agent_names`` payload:
|
|
114
|
+
|
|
115
|
+
- **Provided (non-empty)** — run only those agents. Names are unique per org
|
|
116
|
+
and **all are validated up front**: if any doesn't resolve to a
|
|
117
|
+
(non-deleted) agent in the caller's org, the call 404s with the offending
|
|
118
|
+
names and NO jobs are created.
|
|
119
|
+
- **Omitted / null / empty** — run every agent in the caller's org.
|
|
120
|
+
|
|
121
|
+
For each selected agent, its linked tests are launched as one job. Agents
|
|
122
|
+
with no linked tests or an unverified connection are reported under
|
|
123
|
+
``skipped`` instead of failing the batch. Subject to the normal per-org
|
|
124
|
+
concurrency queue, so over-limit jobs come back ``queued``.
|
|
125
|
+
|
|
126
|
+
Auth accepts a JWT (frontend) or an `sk_` API key (programmatic clients).
|
|
127
|
+
Returns one ``runs`` entry per launched agent with ``agent_name``,
|
|
128
|
+
``agent_uuid``, ``task_id``, and ``status``.
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
request : typing.Optional[BatchRunRequest]
|
|
133
|
+
|
|
134
|
+
request_options : typing.Optional[RequestOptions]
|
|
135
|
+
Request-specific configuration.
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
HttpResponse[BatchTestRunResponse]
|
|
140
|
+
Successful Response
|
|
141
|
+
"""
|
|
142
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
143
|
+
"agent-tests/run",
|
|
144
|
+
method="POST",
|
|
145
|
+
json=convert_and_respect_annotation_metadata(
|
|
146
|
+
object_=request, annotation=typing.Optional[BatchRunRequest], direction="write"
|
|
147
|
+
),
|
|
148
|
+
request_options=request_options,
|
|
149
|
+
omit=OMIT,
|
|
150
|
+
)
|
|
151
|
+
try:
|
|
152
|
+
if 200 <= _response.status_code < 300:
|
|
153
|
+
_data = typing.cast(
|
|
154
|
+
BatchTestRunResponse,
|
|
155
|
+
parse_obj_as(
|
|
156
|
+
type_=BatchTestRunResponse, # type: ignore
|
|
157
|
+
object_=_response.json(),
|
|
158
|
+
),
|
|
159
|
+
)
|
|
160
|
+
return HttpResponse(response=_response, data=_data)
|
|
161
|
+
if _response.status_code == 422:
|
|
162
|
+
raise UnprocessableEntityError(
|
|
163
|
+
headers=dict(_response.headers),
|
|
164
|
+
body=typing.cast(
|
|
165
|
+
HttpValidationError,
|
|
166
|
+
parse_obj_as(
|
|
167
|
+
type_=HttpValidationError, # type: ignore
|
|
168
|
+
object_=_response.json(),
|
|
169
|
+
),
|
|
170
|
+
),
|
|
171
|
+
)
|
|
172
|
+
_response_json = _response.json()
|
|
173
|
+
except JSONDecodeError:
|
|
174
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
175
|
+
except ValidationError as e:
|
|
176
|
+
raise ParsingError(
|
|
177
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
178
|
+
)
|
|
179
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
180
|
+
|
|
181
|
+
def get_run(
|
|
182
|
+
self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
183
|
+
) -> HttpResponse[TestRunStatusResponse]:
|
|
184
|
+
"""
|
|
185
|
+
Get the status of an agent test run.
|
|
186
|
+
|
|
187
|
+
Requires either a JWT (frontend) or an `sk_` API key, plus org
|
|
188
|
+
ownership of the run. Unauthenticated access to a completed run is only
|
|
189
|
+
possible once it is made public, via the share-token endpoint in the public
|
|
190
|
+
router.
|
|
191
|
+
|
|
192
|
+
Returns the current status and, if done, the test results.
|
|
193
|
+
|
|
194
|
+
Parameters
|
|
195
|
+
----------
|
|
196
|
+
task_id : str
|
|
197
|
+
|
|
198
|
+
request_options : typing.Optional[RequestOptions]
|
|
199
|
+
Request-specific configuration.
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
HttpResponse[TestRunStatusResponse]
|
|
204
|
+
Successful Response
|
|
205
|
+
"""
|
|
206
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
207
|
+
f"agent-tests/run/{encode_path_param(task_id)}",
|
|
208
|
+
method="GET",
|
|
209
|
+
request_options=request_options,
|
|
210
|
+
)
|
|
211
|
+
try:
|
|
212
|
+
if 200 <= _response.status_code < 300:
|
|
213
|
+
_data = typing.cast(
|
|
214
|
+
TestRunStatusResponse,
|
|
215
|
+
parse_obj_as(
|
|
216
|
+
type_=TestRunStatusResponse, # type: ignore
|
|
217
|
+
object_=_response.json(),
|
|
218
|
+
),
|
|
219
|
+
)
|
|
220
|
+
return HttpResponse(response=_response, data=_data)
|
|
221
|
+
if _response.status_code == 422:
|
|
222
|
+
raise UnprocessableEntityError(
|
|
223
|
+
headers=dict(_response.headers),
|
|
224
|
+
body=typing.cast(
|
|
225
|
+
HttpValidationError,
|
|
226
|
+
parse_obj_as(
|
|
227
|
+
type_=HttpValidationError, # type: ignore
|
|
228
|
+
object_=_response.json(),
|
|
229
|
+
),
|
|
230
|
+
),
|
|
231
|
+
)
|
|
232
|
+
_response_json = _response.json()
|
|
233
|
+
except JSONDecodeError:
|
|
234
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
235
|
+
except ValidationError as e:
|
|
236
|
+
raise ParsingError(
|
|
237
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
238
|
+
)
|
|
239
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class AsyncRawAgentTestsClient:
|
|
243
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
244
|
+
self._client_wrapper = client_wrapper
|
|
245
|
+
|
|
246
|
+
async def run(
|
|
247
|
+
self,
|
|
248
|
+
agent_uuid: str,
|
|
249
|
+
*,
|
|
250
|
+
test_uuids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
251
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
252
|
+
) -> AsyncHttpResponse[TaskCreateResponse]:
|
|
253
|
+
"""
|
|
254
|
+
Run one or more tests for an agent.
|
|
255
|
+
|
|
256
|
+
This starts a background task that runs the calibrate LLM tests command
|
|
257
|
+
with the agent's config and the combined test cases from all specified tests.
|
|
258
|
+
|
|
259
|
+
Returns a task ID that can be used to poll for status and results.
|
|
260
|
+
|
|
261
|
+
Auth: requires either a JWT (frontend) or an `sk_` API key. The agent
|
|
262
|
+
must belong to the caller's org or this 404s.
|
|
263
|
+
|
|
264
|
+
Parameters
|
|
265
|
+
----------
|
|
266
|
+
agent_uuid : str
|
|
267
|
+
|
|
268
|
+
test_uuids : typing.Optional[typing.Sequence[str]]
|
|
269
|
+
|
|
270
|
+
request_options : typing.Optional[RequestOptions]
|
|
271
|
+
Request-specific configuration.
|
|
272
|
+
|
|
273
|
+
Returns
|
|
274
|
+
-------
|
|
275
|
+
AsyncHttpResponse[TaskCreateResponse]
|
|
276
|
+
Successful Response
|
|
277
|
+
"""
|
|
278
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
279
|
+
f"agent-tests/agent/{encode_path_param(agent_uuid)}/run",
|
|
280
|
+
method="POST",
|
|
281
|
+
json={
|
|
282
|
+
"test_uuids": test_uuids,
|
|
283
|
+
},
|
|
284
|
+
headers={
|
|
285
|
+
"content-type": "application/json",
|
|
286
|
+
},
|
|
287
|
+
request_options=request_options,
|
|
288
|
+
omit=OMIT,
|
|
289
|
+
)
|
|
290
|
+
try:
|
|
291
|
+
if 200 <= _response.status_code < 300:
|
|
292
|
+
_data = typing.cast(
|
|
293
|
+
TaskCreateResponse,
|
|
294
|
+
parse_obj_as(
|
|
295
|
+
type_=TaskCreateResponse, # type: ignore
|
|
296
|
+
object_=_response.json(),
|
|
297
|
+
),
|
|
298
|
+
)
|
|
299
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
300
|
+
if _response.status_code == 422:
|
|
301
|
+
raise UnprocessableEntityError(
|
|
302
|
+
headers=dict(_response.headers),
|
|
303
|
+
body=typing.cast(
|
|
304
|
+
HttpValidationError,
|
|
305
|
+
parse_obj_as(
|
|
306
|
+
type_=HttpValidationError, # type: ignore
|
|
307
|
+
object_=_response.json(),
|
|
308
|
+
),
|
|
309
|
+
),
|
|
310
|
+
)
|
|
311
|
+
_response_json = _response.json()
|
|
312
|
+
except JSONDecodeError:
|
|
313
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
314
|
+
except ValidationError as e:
|
|
315
|
+
raise ParsingError(
|
|
316
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
317
|
+
)
|
|
318
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
319
|
+
|
|
320
|
+
async def run_batch(
|
|
321
|
+
self,
|
|
322
|
+
*,
|
|
323
|
+
request: typing.Optional[BatchRunRequest] = None,
|
|
324
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
325
|
+
) -> AsyncHttpResponse[BatchTestRunResponse]:
|
|
326
|
+
"""
|
|
327
|
+
Run every linked test for a set of agents, one ``llm-unit-test`` job per agent.
|
|
328
|
+
|
|
329
|
+
Scope is driven by the optional ``agent_names`` payload:
|
|
330
|
+
|
|
331
|
+
- **Provided (non-empty)** — run only those agents. Names are unique per org
|
|
332
|
+
and **all are validated up front**: if any doesn't resolve to a
|
|
333
|
+
(non-deleted) agent in the caller's org, the call 404s with the offending
|
|
334
|
+
names and NO jobs are created.
|
|
335
|
+
- **Omitted / null / empty** — run every agent in the caller's org.
|
|
336
|
+
|
|
337
|
+
For each selected agent, its linked tests are launched as one job. Agents
|
|
338
|
+
with no linked tests or an unverified connection are reported under
|
|
339
|
+
``skipped`` instead of failing the batch. Subject to the normal per-org
|
|
340
|
+
concurrency queue, so over-limit jobs come back ``queued``.
|
|
341
|
+
|
|
342
|
+
Auth accepts a JWT (frontend) or an `sk_` API key (programmatic clients).
|
|
343
|
+
Returns one ``runs`` entry per launched agent with ``agent_name``,
|
|
344
|
+
``agent_uuid``, ``task_id``, and ``status``.
|
|
345
|
+
|
|
346
|
+
Parameters
|
|
347
|
+
----------
|
|
348
|
+
request : typing.Optional[BatchRunRequest]
|
|
349
|
+
|
|
350
|
+
request_options : typing.Optional[RequestOptions]
|
|
351
|
+
Request-specific configuration.
|
|
352
|
+
|
|
353
|
+
Returns
|
|
354
|
+
-------
|
|
355
|
+
AsyncHttpResponse[BatchTestRunResponse]
|
|
356
|
+
Successful Response
|
|
357
|
+
"""
|
|
358
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
359
|
+
"agent-tests/run",
|
|
360
|
+
method="POST",
|
|
361
|
+
json=convert_and_respect_annotation_metadata(
|
|
362
|
+
object_=request, annotation=typing.Optional[BatchRunRequest], direction="write"
|
|
363
|
+
),
|
|
364
|
+
request_options=request_options,
|
|
365
|
+
omit=OMIT,
|
|
366
|
+
)
|
|
367
|
+
try:
|
|
368
|
+
if 200 <= _response.status_code < 300:
|
|
369
|
+
_data = typing.cast(
|
|
370
|
+
BatchTestRunResponse,
|
|
371
|
+
parse_obj_as(
|
|
372
|
+
type_=BatchTestRunResponse, # type: ignore
|
|
373
|
+
object_=_response.json(),
|
|
374
|
+
),
|
|
375
|
+
)
|
|
376
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
377
|
+
if _response.status_code == 422:
|
|
378
|
+
raise UnprocessableEntityError(
|
|
379
|
+
headers=dict(_response.headers),
|
|
380
|
+
body=typing.cast(
|
|
381
|
+
HttpValidationError,
|
|
382
|
+
parse_obj_as(
|
|
383
|
+
type_=HttpValidationError, # type: ignore
|
|
384
|
+
object_=_response.json(),
|
|
385
|
+
),
|
|
386
|
+
),
|
|
387
|
+
)
|
|
388
|
+
_response_json = _response.json()
|
|
389
|
+
except JSONDecodeError:
|
|
390
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
391
|
+
except ValidationError as e:
|
|
392
|
+
raise ParsingError(
|
|
393
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
394
|
+
)
|
|
395
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
396
|
+
|
|
397
|
+
async def get_run(
|
|
398
|
+
self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
399
|
+
) -> AsyncHttpResponse[TestRunStatusResponse]:
|
|
400
|
+
"""
|
|
401
|
+
Get the status of an agent test run.
|
|
402
|
+
|
|
403
|
+
Requires either a JWT (frontend) or an `sk_` API key, plus org
|
|
404
|
+
ownership of the run. Unauthenticated access to a completed run is only
|
|
405
|
+
possible once it is made public, via the share-token endpoint in the public
|
|
406
|
+
router.
|
|
407
|
+
|
|
408
|
+
Returns the current status and, if done, the test results.
|
|
409
|
+
|
|
410
|
+
Parameters
|
|
411
|
+
----------
|
|
412
|
+
task_id : str
|
|
413
|
+
|
|
414
|
+
request_options : typing.Optional[RequestOptions]
|
|
415
|
+
Request-specific configuration.
|
|
416
|
+
|
|
417
|
+
Returns
|
|
418
|
+
-------
|
|
419
|
+
AsyncHttpResponse[TestRunStatusResponse]
|
|
420
|
+
Successful Response
|
|
421
|
+
"""
|
|
422
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
423
|
+
f"agent-tests/run/{encode_path_param(task_id)}",
|
|
424
|
+
method="GET",
|
|
425
|
+
request_options=request_options,
|
|
426
|
+
)
|
|
427
|
+
try:
|
|
428
|
+
if 200 <= _response.status_code < 300:
|
|
429
|
+
_data = typing.cast(
|
|
430
|
+
TestRunStatusResponse,
|
|
431
|
+
parse_obj_as(
|
|
432
|
+
type_=TestRunStatusResponse, # type: ignore
|
|
433
|
+
object_=_response.json(),
|
|
434
|
+
),
|
|
435
|
+
)
|
|
436
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
437
|
+
if _response.status_code == 422:
|
|
438
|
+
raise UnprocessableEntityError(
|
|
439
|
+
headers=dict(_response.headers),
|
|
440
|
+
body=typing.cast(
|
|
441
|
+
HttpValidationError,
|
|
442
|
+
parse_obj_as(
|
|
443
|
+
type_=HttpValidationError, # type: ignore
|
|
444
|
+
object_=_response.json(),
|
|
445
|
+
),
|
|
446
|
+
),
|
|
447
|
+
)
|
|
448
|
+
_response_json = _response.json()
|
|
449
|
+
except JSONDecodeError:
|
|
450
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
451
|
+
except ValidationError as e:
|
|
452
|
+
raise ParsingError(
|
|
453
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
454
|
+
)
|
|
455
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
artpark/agents/client.py
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
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.resolve_agent_names_response import ResolveAgentNamesResponse
|
|
8
|
+
from ..types.routers_agent_tests_agent_response import RoutersAgentTestsAgentResponse
|
|
9
|
+
from .raw_client import AsyncRawAgentsClient, RawAgentsClient
|
|
10
|
+
|
|
11
|
+
# this is used as the default value for optional parameters
|
|
12
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AgentsClient:
|
|
16
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
17
|
+
self._raw_client = RawAgentsClient(client_wrapper=client_wrapper)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def with_raw_response(self) -> RawAgentsClient:
|
|
21
|
+
"""
|
|
22
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
RawAgentsClient
|
|
27
|
+
"""
|
|
28
|
+
return self._raw_client
|
|
29
|
+
|
|
30
|
+
def resolve(
|
|
31
|
+
self, *, names: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
|
32
|
+
) -> ResolveAgentNamesResponse:
|
|
33
|
+
"""
|
|
34
|
+
Resolve a list of agent names to their UUIDs within the caller's org.
|
|
35
|
+
|
|
36
|
+
Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
|
|
37
|
+
clients) via `get_org_jwt_or_api_key`, so CI tooling can map human-friendly
|
|
38
|
+
agent names to the UUIDs the run/poll endpoints expect. Agent names are
|
|
39
|
+
unique per org, so each name resolves to at most one agent. Names with no
|
|
40
|
+
matching (non-deleted) agent in the org are returned under `not_found`.
|
|
41
|
+
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
names : typing.Sequence[str]
|
|
45
|
+
|
|
46
|
+
request_options : typing.Optional[RequestOptions]
|
|
47
|
+
Request-specific configuration.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
ResolveAgentNamesResponse
|
|
52
|
+
Successful Response
|
|
53
|
+
|
|
54
|
+
Examples
|
|
55
|
+
--------
|
|
56
|
+
from artpark import Calibrate
|
|
57
|
+
|
|
58
|
+
client = Calibrate(
|
|
59
|
+
api_key="YOUR_API_KEY",
|
|
60
|
+
org_uuid="YOUR_ORG_UUID",
|
|
61
|
+
token="YOUR_TOKEN",
|
|
62
|
+
)
|
|
63
|
+
client.agents.resolve(
|
|
64
|
+
names=["names"],
|
|
65
|
+
)
|
|
66
|
+
"""
|
|
67
|
+
_response = self._raw_client.resolve(names=names, request_options=request_options)
|
|
68
|
+
return _response.data
|
|
69
|
+
|
|
70
|
+
def list(
|
|
71
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
72
|
+
) -> typing.List[RoutersAgentTestsAgentResponse]:
|
|
73
|
+
"""
|
|
74
|
+
List all agents for the caller's current org.
|
|
75
|
+
|
|
76
|
+
Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
|
|
77
|
+
clients) via `get_org_jwt_or_api_key`, so CI tooling can enumerate every
|
|
78
|
+
agent UUID in the org without knowing names up front (the run/poll and
|
|
79
|
+
`/resolve` endpoints accept the same key).
|
|
80
|
+
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
request_options : typing.Optional[RequestOptions]
|
|
84
|
+
Request-specific configuration.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
typing.List[RoutersAgentTestsAgentResponse]
|
|
89
|
+
Successful Response
|
|
90
|
+
|
|
91
|
+
Examples
|
|
92
|
+
--------
|
|
93
|
+
from artpark import Calibrate
|
|
94
|
+
|
|
95
|
+
client = Calibrate(
|
|
96
|
+
api_key="YOUR_API_KEY",
|
|
97
|
+
org_uuid="YOUR_ORG_UUID",
|
|
98
|
+
token="YOUR_TOKEN",
|
|
99
|
+
)
|
|
100
|
+
client.agents.list()
|
|
101
|
+
"""
|
|
102
|
+
_response = self._raw_client.list(request_options=request_options)
|
|
103
|
+
return _response.data
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class AsyncAgentsClient:
|
|
107
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
108
|
+
self._raw_client = AsyncRawAgentsClient(client_wrapper=client_wrapper)
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def with_raw_response(self) -> AsyncRawAgentsClient:
|
|
112
|
+
"""
|
|
113
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
AsyncRawAgentsClient
|
|
118
|
+
"""
|
|
119
|
+
return self._raw_client
|
|
120
|
+
|
|
121
|
+
async def resolve(
|
|
122
|
+
self, *, names: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
|
123
|
+
) -> ResolveAgentNamesResponse:
|
|
124
|
+
"""
|
|
125
|
+
Resolve a list of agent names to their UUIDs within the caller's org.
|
|
126
|
+
|
|
127
|
+
Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
|
|
128
|
+
clients) via `get_org_jwt_or_api_key`, so CI tooling can map human-friendly
|
|
129
|
+
agent names to the UUIDs the run/poll endpoints expect. Agent names are
|
|
130
|
+
unique per org, so each name resolves to at most one agent. Names with no
|
|
131
|
+
matching (non-deleted) agent in the org are returned under `not_found`.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
names : typing.Sequence[str]
|
|
136
|
+
|
|
137
|
+
request_options : typing.Optional[RequestOptions]
|
|
138
|
+
Request-specific configuration.
|
|
139
|
+
|
|
140
|
+
Returns
|
|
141
|
+
-------
|
|
142
|
+
ResolveAgentNamesResponse
|
|
143
|
+
Successful Response
|
|
144
|
+
|
|
145
|
+
Examples
|
|
146
|
+
--------
|
|
147
|
+
import asyncio
|
|
148
|
+
|
|
149
|
+
from artpark import AsyncCalibrate
|
|
150
|
+
|
|
151
|
+
client = AsyncCalibrate(
|
|
152
|
+
api_key="YOUR_API_KEY",
|
|
153
|
+
org_uuid="YOUR_ORG_UUID",
|
|
154
|
+
token="YOUR_TOKEN",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
async def main() -> None:
|
|
159
|
+
await client.agents.resolve(
|
|
160
|
+
names=["names"],
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
asyncio.run(main())
|
|
165
|
+
"""
|
|
166
|
+
_response = await self._raw_client.resolve(names=names, request_options=request_options)
|
|
167
|
+
return _response.data
|
|
168
|
+
|
|
169
|
+
async def list(
|
|
170
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
171
|
+
) -> typing.List[RoutersAgentTestsAgentResponse]:
|
|
172
|
+
"""
|
|
173
|
+
List all agents for the caller's current org.
|
|
174
|
+
|
|
175
|
+
Auth accepts either a JWT (frontend) or an `sk_` API key (programmatic
|
|
176
|
+
clients) via `get_org_jwt_or_api_key`, so CI tooling can enumerate every
|
|
177
|
+
agent UUID in the org without knowing names up front (the run/poll and
|
|
178
|
+
`/resolve` endpoints accept the same key).
|
|
179
|
+
|
|
180
|
+
Parameters
|
|
181
|
+
----------
|
|
182
|
+
request_options : typing.Optional[RequestOptions]
|
|
183
|
+
Request-specific configuration.
|
|
184
|
+
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
typing.List[RoutersAgentTestsAgentResponse]
|
|
188
|
+
Successful Response
|
|
189
|
+
|
|
190
|
+
Examples
|
|
191
|
+
--------
|
|
192
|
+
import asyncio
|
|
193
|
+
|
|
194
|
+
from artpark import AsyncCalibrate
|
|
195
|
+
|
|
196
|
+
client = AsyncCalibrate(
|
|
197
|
+
api_key="YOUR_API_KEY",
|
|
198
|
+
org_uuid="YOUR_ORG_UUID",
|
|
199
|
+
token="YOUR_TOKEN",
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
async def main() -> None:
|
|
204
|
+
await client.agents.list()
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
asyncio.run(main())
|
|
208
|
+
"""
|
|
209
|
+
_response = await self._raw_client.list(request_options=request_options)
|
|
210
|
+
return _response.data
|