agenta 0.30.0a2__py3-none-any.whl → 0.30.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.
Potentially problematic release.
This version of agenta might be problematic. Click here for more details.
- agenta/__init__.py +1 -0
- agenta/client/backend/__init__.py +32 -3
- agenta/client/backend/access_control/__init__.py +1 -0
- agenta/client/backend/access_control/client.py +167 -0
- agenta/client/backend/apps/client.py +70 -10
- agenta/client/backend/client.py +61 -45
- agenta/client/backend/configs/client.py +6 -0
- agenta/client/backend/containers/client.py +6 -0
- agenta/client/backend/core/file.py +13 -8
- agenta/client/backend/environments/client.py +6 -0
- agenta/client/backend/evaluations/client.py +14 -1
- agenta/client/backend/evaluators/client.py +24 -0
- agenta/client/backend/observability/client.py +22 -16
- agenta/client/backend/observability_v_1/__init__.py +2 -2
- agenta/client/backend/observability_v_1/client.py +203 -0
- agenta/client/backend/observability_v_1/types/__init__.py +2 -1
- agenta/client/backend/observability_v_1/types/format.py +1 -1
- agenta/client/backend/observability_v_1/types/query_analytics_response.py +7 -0
- agenta/client/backend/scopes/__init__.py +1 -0
- agenta/client/backend/scopes/client.py +114 -0
- agenta/client/backend/testsets/client.py +305 -121
- agenta/client/backend/types/__init__.py +24 -2
- agenta/client/backend/types/analytics_response.py +24 -0
- agenta/client/backend/types/app.py +2 -1
- agenta/client/backend/types/body_import_testset.py +0 -1
- agenta/client/backend/types/bucket_dto.py +26 -0
- agenta/client/backend/types/header_dto.py +22 -0
- agenta/client/backend/types/legacy_analytics_response.py +29 -0
- agenta/client/backend/types/legacy_data_point.py +27 -0
- agenta/client/backend/types/metrics_dto.py +24 -0
- agenta/client/backend/types/permission.py +1 -0
- agenta/client/backend/types/projects_response.py +28 -0
- agenta/client/backend/types/provider_key_dto.py +23 -0
- agenta/client/backend/types/provider_kind.py +21 -0
- agenta/client/backend/types/secret_dto.py +24 -0
- agenta/client/backend/types/secret_kind.py +5 -0
- agenta/client/backend/types/secret_response_dto.py +27 -0
- agenta/client/backend/variants/client.py +66 -0
- agenta/client/backend/vault/__init__.py +1 -0
- agenta/client/backend/vault/client.py +685 -0
- agenta/client/client.py +1 -1
- agenta/sdk/__init__.py +1 -0
- agenta/sdk/agenta_init.py +47 -118
- agenta/sdk/assets.py +57 -46
- agenta/sdk/context/exporting.py +25 -0
- agenta/sdk/context/routing.py +12 -12
- agenta/sdk/context/tracing.py +26 -1
- agenta/sdk/decorators/routing.py +279 -243
- agenta/sdk/decorators/tracing.py +53 -31
- agenta/sdk/managers/config.py +8 -118
- agenta/sdk/managers/secrets.py +38 -0
- agenta/sdk/middleware/auth.py +128 -93
- agenta/sdk/middleware/cache.py +4 -0
- agenta/sdk/middleware/config.py +254 -0
- agenta/sdk/middleware/cors.py +27 -0
- agenta/sdk/middleware/otel.py +40 -0
- agenta/sdk/middleware/vault.py +158 -0
- agenta/sdk/tracing/exporters.py +40 -2
- agenta/sdk/tracing/inline.py +2 -2
- agenta/sdk/tracing/processors.py +11 -3
- agenta/sdk/tracing/tracing.py +14 -12
- agenta/sdk/utils/constants.py +1 -0
- agenta/sdk/utils/exceptions.py +20 -19
- agenta/sdk/utils/globals.py +4 -8
- agenta/sdk/utils/timing.py +58 -0
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a3.dist-info}/METADATA +3 -2
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a3.dist-info}/RECORD +69 -44
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a3.dist-info}/WHEEL +1 -1
- agenta/client/backend/types/lm_providers_enum.py +0 -21
- agenta/sdk/tracing/context.py +0 -24
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a3.dist-info}/entry_points.txt +0 -0
|
@@ -10,8 +10,8 @@ from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
|
10
10
|
from ..types.http_validation_error import HttpValidationError
|
|
11
11
|
from json.decoder import JSONDecodeError
|
|
12
12
|
from ..core.api_error import ApiError
|
|
13
|
-
from ..core.jsonable_encoder import jsonable_encoder
|
|
14
13
|
from ..types.test_set_output_response import TestSetOutputResponse
|
|
14
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
15
15
|
from ..core.client_wrapper import AsyncClientWrapper
|
|
16
16
|
|
|
17
17
|
# this is used as the default value for optional parameters
|
|
@@ -106,7 +106,11 @@ class TestsetsClient:
|
|
|
106
106
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
107
107
|
|
|
108
108
|
def import_testset(
|
|
109
|
-
self,
|
|
109
|
+
self,
|
|
110
|
+
*,
|
|
111
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
112
|
+
testset_name: typing.Optional[str] = OMIT,
|
|
113
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
110
114
|
) -> TestSetSimpleResponse:
|
|
111
115
|
"""
|
|
112
116
|
Import JSON testset data from an endpoint and save it to MongoDB.
|
|
@@ -120,6 +124,10 @@ class TestsetsClient:
|
|
|
120
124
|
|
|
121
125
|
Parameters
|
|
122
126
|
----------
|
|
127
|
+
endpoint : typing.Optional[str]
|
|
128
|
+
|
|
129
|
+
testset_name : typing.Optional[str]
|
|
130
|
+
|
|
123
131
|
request_options : typing.Optional[RequestOptions]
|
|
124
132
|
Request-specific configuration.
|
|
125
133
|
|
|
@@ -141,7 +149,12 @@ class TestsetsClient:
|
|
|
141
149
|
_response = self._client_wrapper.httpx_client.request(
|
|
142
150
|
"testsets/endpoint",
|
|
143
151
|
method="POST",
|
|
152
|
+
json={
|
|
153
|
+
"endpoint": endpoint,
|
|
154
|
+
"testset_name": testset_name,
|
|
155
|
+
},
|
|
144
156
|
request_options=request_options,
|
|
157
|
+
omit=OMIT,
|
|
145
158
|
)
|
|
146
159
|
try:
|
|
147
160
|
if 200 <= _response.status_code < 300:
|
|
@@ -167,6 +180,59 @@ class TestsetsClient:
|
|
|
167
180
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
168
181
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
169
182
|
|
|
183
|
+
def get_testsets(
|
|
184
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
185
|
+
) -> typing.List[TestSetOutputResponse]:
|
|
186
|
+
"""
|
|
187
|
+
Get all testsets.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
|
|
191
|
+
- A list of testset objects.
|
|
192
|
+
|
|
193
|
+
Raises:
|
|
194
|
+
|
|
195
|
+
- `HTTPException` with status code 404 if no testsets are found.
|
|
196
|
+
|
|
197
|
+
Parameters
|
|
198
|
+
----------
|
|
199
|
+
request_options : typing.Optional[RequestOptions]
|
|
200
|
+
Request-specific configuration.
|
|
201
|
+
|
|
202
|
+
Returns
|
|
203
|
+
-------
|
|
204
|
+
typing.List[TestSetOutputResponse]
|
|
205
|
+
Successful Response
|
|
206
|
+
|
|
207
|
+
Examples
|
|
208
|
+
--------
|
|
209
|
+
from agenta import AgentaApi
|
|
210
|
+
|
|
211
|
+
client = AgentaApi(
|
|
212
|
+
api_key="YOUR_API_KEY",
|
|
213
|
+
base_url="https://yourhost.com/path/to/api",
|
|
214
|
+
)
|
|
215
|
+
client.testsets.get_testsets()
|
|
216
|
+
"""
|
|
217
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
218
|
+
"testsets",
|
|
219
|
+
method="GET",
|
|
220
|
+
request_options=request_options,
|
|
221
|
+
)
|
|
222
|
+
try:
|
|
223
|
+
if 200 <= _response.status_code < 300:
|
|
224
|
+
return typing.cast(
|
|
225
|
+
typing.List[TestSetOutputResponse],
|
|
226
|
+
parse_obj_as(
|
|
227
|
+
type_=typing.List[TestSetOutputResponse], # type: ignore
|
|
228
|
+
object_=_response.json(),
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
_response_json = _response.json()
|
|
232
|
+
except JSONDecodeError:
|
|
233
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
234
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
235
|
+
|
|
170
236
|
def create_testset(
|
|
171
237
|
self,
|
|
172
238
|
*,
|
|
@@ -245,31 +311,31 @@ class TestsetsClient:
|
|
|
245
311
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
246
312
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
247
313
|
|
|
248
|
-
def
|
|
314
|
+
def delete_testsets(
|
|
249
315
|
self,
|
|
250
|
-
testset_id: str,
|
|
251
316
|
*,
|
|
317
|
+
testset_ids: typing.Sequence[str],
|
|
252
318
|
request_options: typing.Optional[RequestOptions] = None,
|
|
253
|
-
) -> typing.
|
|
319
|
+
) -> typing.List[str]:
|
|
254
320
|
"""
|
|
255
|
-
|
|
321
|
+
Delete specific testsets based on their unique IDs.
|
|
256
322
|
|
|
257
323
|
Args:
|
|
258
|
-
|
|
324
|
+
testset_ids (List[str]): The unique identifiers of the testsets to delete.
|
|
259
325
|
|
|
260
326
|
Returns:
|
|
261
|
-
|
|
327
|
+
A list of the deleted testsets' IDs.
|
|
262
328
|
|
|
263
329
|
Parameters
|
|
264
330
|
----------
|
|
265
|
-
|
|
331
|
+
testset_ids : typing.Sequence[str]
|
|
266
332
|
|
|
267
333
|
request_options : typing.Optional[RequestOptions]
|
|
268
334
|
Request-specific configuration.
|
|
269
335
|
|
|
270
336
|
Returns
|
|
271
337
|
-------
|
|
272
|
-
typing.
|
|
338
|
+
typing.List[str]
|
|
273
339
|
Successful Response
|
|
274
340
|
|
|
275
341
|
Examples
|
|
@@ -280,21 +346,28 @@ class TestsetsClient:
|
|
|
280
346
|
api_key="YOUR_API_KEY",
|
|
281
347
|
base_url="https://yourhost.com/path/to/api",
|
|
282
348
|
)
|
|
283
|
-
client.testsets.
|
|
284
|
-
|
|
349
|
+
client.testsets.delete_testsets(
|
|
350
|
+
testset_ids=["testset_ids"],
|
|
285
351
|
)
|
|
286
352
|
"""
|
|
287
353
|
_response = self._client_wrapper.httpx_client.request(
|
|
288
|
-
|
|
289
|
-
method="
|
|
354
|
+
"testsets",
|
|
355
|
+
method="DELETE",
|
|
356
|
+
json={
|
|
357
|
+
"testset_ids": testset_ids,
|
|
358
|
+
},
|
|
359
|
+
headers={
|
|
360
|
+
"content-type": "application/json",
|
|
361
|
+
},
|
|
290
362
|
request_options=request_options,
|
|
363
|
+
omit=OMIT,
|
|
291
364
|
)
|
|
292
365
|
try:
|
|
293
366
|
if 200 <= _response.status_code < 300:
|
|
294
367
|
return typing.cast(
|
|
295
|
-
typing.
|
|
368
|
+
typing.List[str],
|
|
296
369
|
parse_obj_as(
|
|
297
|
-
type_=typing.
|
|
370
|
+
type_=typing.List[str], # type: ignore
|
|
298
371
|
object_=_response.json(),
|
|
299
372
|
),
|
|
300
373
|
)
|
|
@@ -313,27 +386,27 @@ class TestsetsClient:
|
|
|
313
386
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
314
387
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
315
388
|
|
|
316
|
-
def
|
|
389
|
+
def deprecating_create_testset(
|
|
317
390
|
self,
|
|
318
|
-
|
|
391
|
+
app_id: str,
|
|
319
392
|
*,
|
|
320
393
|
name: str,
|
|
321
394
|
csvdata: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
322
395
|
request_options: typing.Optional[RequestOptions] = None,
|
|
323
|
-
) ->
|
|
396
|
+
) -> TestSetSimpleResponse:
|
|
324
397
|
"""
|
|
325
|
-
|
|
398
|
+
Create a testset with given name, save the testset to MongoDB.
|
|
326
399
|
|
|
327
400
|
Args:
|
|
328
|
-
|
|
329
|
-
|
|
401
|
+
name (str): name of the test set.
|
|
402
|
+
testset (Dict[str, str]): test set data.
|
|
330
403
|
|
|
331
404
|
Returns:
|
|
332
|
-
str: The id of the test set
|
|
405
|
+
str: The id of the test set created.
|
|
333
406
|
|
|
334
407
|
Parameters
|
|
335
408
|
----------
|
|
336
|
-
|
|
409
|
+
app_id : str
|
|
337
410
|
|
|
338
411
|
name : str
|
|
339
412
|
|
|
@@ -344,7 +417,7 @@ class TestsetsClient:
|
|
|
344
417
|
|
|
345
418
|
Returns
|
|
346
419
|
-------
|
|
347
|
-
|
|
420
|
+
TestSetSimpleResponse
|
|
348
421
|
Successful Response
|
|
349
422
|
|
|
350
423
|
Examples
|
|
@@ -355,15 +428,15 @@ class TestsetsClient:
|
|
|
355
428
|
api_key="YOUR_API_KEY",
|
|
356
429
|
base_url="https://yourhost.com/path/to/api",
|
|
357
430
|
)
|
|
358
|
-
client.testsets.
|
|
359
|
-
|
|
431
|
+
client.testsets.deprecating_create_testset(
|
|
432
|
+
app_id="app_id",
|
|
360
433
|
name="name",
|
|
361
434
|
csvdata=[{"key": "value"}],
|
|
362
435
|
)
|
|
363
436
|
"""
|
|
364
437
|
_response = self._client_wrapper.httpx_client.request(
|
|
365
|
-
f"testsets/{jsonable_encoder(
|
|
366
|
-
method="
|
|
438
|
+
f"testsets/{jsonable_encoder(app_id)}",
|
|
439
|
+
method="POST",
|
|
367
440
|
json={
|
|
368
441
|
"name": name,
|
|
369
442
|
"csvdata": csvdata,
|
|
@@ -374,9 +447,9 @@ class TestsetsClient:
|
|
|
374
447
|
try:
|
|
375
448
|
if 200 <= _response.status_code < 300:
|
|
376
449
|
return typing.cast(
|
|
377
|
-
|
|
450
|
+
TestSetSimpleResponse,
|
|
378
451
|
parse_obj_as(
|
|
379
|
-
type_=
|
|
452
|
+
type_=TestSetSimpleResponse, # type: ignore
|
|
380
453
|
object_=_response.json(),
|
|
381
454
|
),
|
|
382
455
|
)
|
|
@@ -395,28 +468,31 @@ class TestsetsClient:
|
|
|
395
468
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
396
469
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
397
470
|
|
|
398
|
-
def
|
|
399
|
-
self,
|
|
400
|
-
|
|
471
|
+
def get_single_testset(
|
|
472
|
+
self,
|
|
473
|
+
testset_id: str,
|
|
474
|
+
*,
|
|
475
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
476
|
+
) -> typing.Optional[typing.Any]:
|
|
401
477
|
"""
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
Returns:
|
|
405
|
-
|
|
406
|
-
- A list of testset objects.
|
|
478
|
+
Fetch a specific testset in a MongoDB collection using its \_id.
|
|
407
479
|
|
|
408
|
-
|
|
480
|
+
Args:
|
|
481
|
+
testset_id (str): The \_id of the testset to fetch.
|
|
409
482
|
|
|
410
|
-
|
|
483
|
+
Returns:
|
|
484
|
+
The requested testset if found, else an HTTPException.
|
|
411
485
|
|
|
412
486
|
Parameters
|
|
413
487
|
----------
|
|
488
|
+
testset_id : str
|
|
489
|
+
|
|
414
490
|
request_options : typing.Optional[RequestOptions]
|
|
415
491
|
Request-specific configuration.
|
|
416
492
|
|
|
417
493
|
Returns
|
|
418
494
|
-------
|
|
419
|
-
typing.
|
|
495
|
+
typing.Optional[typing.Any]
|
|
420
496
|
Successful Response
|
|
421
497
|
|
|
422
498
|
Examples
|
|
@@ -427,19 +503,21 @@ class TestsetsClient:
|
|
|
427
503
|
api_key="YOUR_API_KEY",
|
|
428
504
|
base_url="https://yourhost.com/path/to/api",
|
|
429
505
|
)
|
|
430
|
-
client.testsets.
|
|
506
|
+
client.testsets.get_single_testset(
|
|
507
|
+
testset_id="testset_id",
|
|
508
|
+
)
|
|
431
509
|
"""
|
|
432
510
|
_response = self._client_wrapper.httpx_client.request(
|
|
433
|
-
"testsets",
|
|
511
|
+
f"testsets/{jsonable_encoder(testset_id)}",
|
|
434
512
|
method="GET",
|
|
435
513
|
request_options=request_options,
|
|
436
514
|
)
|
|
437
515
|
try:
|
|
438
516
|
if 200 <= _response.status_code < 300:
|
|
439
517
|
return typing.cast(
|
|
440
|
-
typing.
|
|
518
|
+
typing.Optional[typing.Any],
|
|
441
519
|
parse_obj_as(
|
|
442
|
-
type_=typing.
|
|
520
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
443
521
|
object_=_response.json(),
|
|
444
522
|
),
|
|
445
523
|
)
|
|
@@ -458,31 +536,38 @@ class TestsetsClient:
|
|
|
458
536
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
459
537
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
460
538
|
|
|
461
|
-
def
|
|
539
|
+
def update_testset(
|
|
462
540
|
self,
|
|
541
|
+
testset_id: str,
|
|
463
542
|
*,
|
|
464
|
-
|
|
543
|
+
name: str,
|
|
544
|
+
csvdata: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
465
545
|
request_options: typing.Optional[RequestOptions] = None,
|
|
466
|
-
) -> typing.
|
|
546
|
+
) -> typing.Optional[typing.Any]:
|
|
467
547
|
"""
|
|
468
|
-
|
|
548
|
+
Update a testset with given id, update the testset in MongoDB.
|
|
469
549
|
|
|
470
550
|
Args:
|
|
471
|
-
|
|
551
|
+
testset_id (str): id of the test set to be updated.
|
|
552
|
+
csvdata (NewTestset): New data to replace the old testset.
|
|
472
553
|
|
|
473
554
|
Returns:
|
|
474
|
-
|
|
555
|
+
str: The id of the test set updated.
|
|
475
556
|
|
|
476
557
|
Parameters
|
|
477
558
|
----------
|
|
478
|
-
|
|
559
|
+
testset_id : str
|
|
560
|
+
|
|
561
|
+
name : str
|
|
562
|
+
|
|
563
|
+
csvdata : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
479
564
|
|
|
480
565
|
request_options : typing.Optional[RequestOptions]
|
|
481
566
|
Request-specific configuration.
|
|
482
567
|
|
|
483
568
|
Returns
|
|
484
569
|
-------
|
|
485
|
-
typing.
|
|
570
|
+
typing.Optional[typing.Any]
|
|
486
571
|
Successful Response
|
|
487
572
|
|
|
488
573
|
Examples
|
|
@@ -493,15 +578,18 @@ class TestsetsClient:
|
|
|
493
578
|
api_key="YOUR_API_KEY",
|
|
494
579
|
base_url="https://yourhost.com/path/to/api",
|
|
495
580
|
)
|
|
496
|
-
client.testsets.
|
|
497
|
-
|
|
581
|
+
client.testsets.update_testset(
|
|
582
|
+
testset_id="testset_id",
|
|
583
|
+
name="name",
|
|
584
|
+
csvdata=[{"key": "value"}],
|
|
498
585
|
)
|
|
499
586
|
"""
|
|
500
587
|
_response = self._client_wrapper.httpx_client.request(
|
|
501
|
-
"testsets",
|
|
502
|
-
method="
|
|
588
|
+
f"testsets/{jsonable_encoder(testset_id)}",
|
|
589
|
+
method="PUT",
|
|
503
590
|
json={
|
|
504
|
-
"
|
|
591
|
+
"name": name,
|
|
592
|
+
"csvdata": csvdata,
|
|
505
593
|
},
|
|
506
594
|
request_options=request_options,
|
|
507
595
|
omit=OMIT,
|
|
@@ -509,9 +597,9 @@ class TestsetsClient:
|
|
|
509
597
|
try:
|
|
510
598
|
if 200 <= _response.status_code < 300:
|
|
511
599
|
return typing.cast(
|
|
512
|
-
typing.
|
|
600
|
+
typing.Optional[typing.Any],
|
|
513
601
|
parse_obj_as(
|
|
514
|
-
type_=typing.
|
|
602
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
515
603
|
object_=_response.json(),
|
|
516
604
|
),
|
|
517
605
|
)
|
|
@@ -627,7 +715,11 @@ class AsyncTestsetsClient:
|
|
|
627
715
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
628
716
|
|
|
629
717
|
async def import_testset(
|
|
630
|
-
self,
|
|
718
|
+
self,
|
|
719
|
+
*,
|
|
720
|
+
endpoint: typing.Optional[str] = OMIT,
|
|
721
|
+
testset_name: typing.Optional[str] = OMIT,
|
|
722
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
631
723
|
) -> TestSetSimpleResponse:
|
|
632
724
|
"""
|
|
633
725
|
Import JSON testset data from an endpoint and save it to MongoDB.
|
|
@@ -641,6 +733,10 @@ class AsyncTestsetsClient:
|
|
|
641
733
|
|
|
642
734
|
Parameters
|
|
643
735
|
----------
|
|
736
|
+
endpoint : typing.Optional[str]
|
|
737
|
+
|
|
738
|
+
testset_name : typing.Optional[str]
|
|
739
|
+
|
|
644
740
|
request_options : typing.Optional[RequestOptions]
|
|
645
741
|
Request-specific configuration.
|
|
646
742
|
|
|
@@ -670,7 +766,12 @@ class AsyncTestsetsClient:
|
|
|
670
766
|
_response = await self._client_wrapper.httpx_client.request(
|
|
671
767
|
"testsets/endpoint",
|
|
672
768
|
method="POST",
|
|
769
|
+
json={
|
|
770
|
+
"endpoint": endpoint,
|
|
771
|
+
"testset_name": testset_name,
|
|
772
|
+
},
|
|
673
773
|
request_options=request_options,
|
|
774
|
+
omit=OMIT,
|
|
674
775
|
)
|
|
675
776
|
try:
|
|
676
777
|
if 200 <= _response.status_code < 300:
|
|
@@ -696,6 +797,67 @@ class AsyncTestsetsClient:
|
|
|
696
797
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
697
798
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
698
799
|
|
|
800
|
+
async def get_testsets(
|
|
801
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
802
|
+
) -> typing.List[TestSetOutputResponse]:
|
|
803
|
+
"""
|
|
804
|
+
Get all testsets.
|
|
805
|
+
|
|
806
|
+
Returns:
|
|
807
|
+
|
|
808
|
+
- A list of testset objects.
|
|
809
|
+
|
|
810
|
+
Raises:
|
|
811
|
+
|
|
812
|
+
- `HTTPException` with status code 404 if no testsets are found.
|
|
813
|
+
|
|
814
|
+
Parameters
|
|
815
|
+
----------
|
|
816
|
+
request_options : typing.Optional[RequestOptions]
|
|
817
|
+
Request-specific configuration.
|
|
818
|
+
|
|
819
|
+
Returns
|
|
820
|
+
-------
|
|
821
|
+
typing.List[TestSetOutputResponse]
|
|
822
|
+
Successful Response
|
|
823
|
+
|
|
824
|
+
Examples
|
|
825
|
+
--------
|
|
826
|
+
import asyncio
|
|
827
|
+
|
|
828
|
+
from agenta import AsyncAgentaApi
|
|
829
|
+
|
|
830
|
+
client = AsyncAgentaApi(
|
|
831
|
+
api_key="YOUR_API_KEY",
|
|
832
|
+
base_url="https://yourhost.com/path/to/api",
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
async def main() -> None:
|
|
837
|
+
await client.testsets.get_testsets()
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
asyncio.run(main())
|
|
841
|
+
"""
|
|
842
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
843
|
+
"testsets",
|
|
844
|
+
method="GET",
|
|
845
|
+
request_options=request_options,
|
|
846
|
+
)
|
|
847
|
+
try:
|
|
848
|
+
if 200 <= _response.status_code < 300:
|
|
849
|
+
return typing.cast(
|
|
850
|
+
typing.List[TestSetOutputResponse],
|
|
851
|
+
parse_obj_as(
|
|
852
|
+
type_=typing.List[TestSetOutputResponse], # type: ignore
|
|
853
|
+
object_=_response.json(),
|
|
854
|
+
),
|
|
855
|
+
)
|
|
856
|
+
_response_json = _response.json()
|
|
857
|
+
except JSONDecodeError:
|
|
858
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
859
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
860
|
+
|
|
699
861
|
async def create_testset(
|
|
700
862
|
self,
|
|
701
863
|
*,
|
|
@@ -782,31 +944,31 @@ class AsyncTestsetsClient:
|
|
|
782
944
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
783
945
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
784
946
|
|
|
785
|
-
async def
|
|
947
|
+
async def delete_testsets(
|
|
786
948
|
self,
|
|
787
|
-
testset_id: str,
|
|
788
949
|
*,
|
|
950
|
+
testset_ids: typing.Sequence[str],
|
|
789
951
|
request_options: typing.Optional[RequestOptions] = None,
|
|
790
|
-
) -> typing.
|
|
952
|
+
) -> typing.List[str]:
|
|
791
953
|
"""
|
|
792
|
-
|
|
954
|
+
Delete specific testsets based on their unique IDs.
|
|
793
955
|
|
|
794
956
|
Args:
|
|
795
|
-
|
|
957
|
+
testset_ids (List[str]): The unique identifiers of the testsets to delete.
|
|
796
958
|
|
|
797
959
|
Returns:
|
|
798
|
-
|
|
960
|
+
A list of the deleted testsets' IDs.
|
|
799
961
|
|
|
800
962
|
Parameters
|
|
801
963
|
----------
|
|
802
|
-
|
|
964
|
+
testset_ids : typing.Sequence[str]
|
|
803
965
|
|
|
804
966
|
request_options : typing.Optional[RequestOptions]
|
|
805
967
|
Request-specific configuration.
|
|
806
968
|
|
|
807
969
|
Returns
|
|
808
970
|
-------
|
|
809
|
-
typing.
|
|
971
|
+
typing.List[str]
|
|
810
972
|
Successful Response
|
|
811
973
|
|
|
812
974
|
Examples
|
|
@@ -822,24 +984,31 @@ class AsyncTestsetsClient:
|
|
|
822
984
|
|
|
823
985
|
|
|
824
986
|
async def main() -> None:
|
|
825
|
-
await client.testsets.
|
|
826
|
-
|
|
987
|
+
await client.testsets.delete_testsets(
|
|
988
|
+
testset_ids=["testset_ids"],
|
|
827
989
|
)
|
|
828
990
|
|
|
829
991
|
|
|
830
992
|
asyncio.run(main())
|
|
831
993
|
"""
|
|
832
994
|
_response = await self._client_wrapper.httpx_client.request(
|
|
833
|
-
|
|
834
|
-
method="
|
|
995
|
+
"testsets",
|
|
996
|
+
method="DELETE",
|
|
997
|
+
json={
|
|
998
|
+
"testset_ids": testset_ids,
|
|
999
|
+
},
|
|
1000
|
+
headers={
|
|
1001
|
+
"content-type": "application/json",
|
|
1002
|
+
},
|
|
835
1003
|
request_options=request_options,
|
|
1004
|
+
omit=OMIT,
|
|
836
1005
|
)
|
|
837
1006
|
try:
|
|
838
1007
|
if 200 <= _response.status_code < 300:
|
|
839
1008
|
return typing.cast(
|
|
840
|
-
typing.
|
|
1009
|
+
typing.List[str],
|
|
841
1010
|
parse_obj_as(
|
|
842
|
-
type_=typing.
|
|
1011
|
+
type_=typing.List[str], # type: ignore
|
|
843
1012
|
object_=_response.json(),
|
|
844
1013
|
),
|
|
845
1014
|
)
|
|
@@ -858,27 +1027,27 @@ class AsyncTestsetsClient:
|
|
|
858
1027
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
859
1028
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
860
1029
|
|
|
861
|
-
async def
|
|
1030
|
+
async def deprecating_create_testset(
|
|
862
1031
|
self,
|
|
863
|
-
|
|
1032
|
+
app_id: str,
|
|
864
1033
|
*,
|
|
865
1034
|
name: str,
|
|
866
1035
|
csvdata: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
867
1036
|
request_options: typing.Optional[RequestOptions] = None,
|
|
868
|
-
) ->
|
|
1037
|
+
) -> TestSetSimpleResponse:
|
|
869
1038
|
"""
|
|
870
|
-
|
|
1039
|
+
Create a testset with given name, save the testset to MongoDB.
|
|
871
1040
|
|
|
872
1041
|
Args:
|
|
873
|
-
|
|
874
|
-
|
|
1042
|
+
name (str): name of the test set.
|
|
1043
|
+
testset (Dict[str, str]): test set data.
|
|
875
1044
|
|
|
876
1045
|
Returns:
|
|
877
|
-
str: The id of the test set
|
|
1046
|
+
str: The id of the test set created.
|
|
878
1047
|
|
|
879
1048
|
Parameters
|
|
880
1049
|
----------
|
|
881
|
-
|
|
1050
|
+
app_id : str
|
|
882
1051
|
|
|
883
1052
|
name : str
|
|
884
1053
|
|
|
@@ -889,7 +1058,7 @@ class AsyncTestsetsClient:
|
|
|
889
1058
|
|
|
890
1059
|
Returns
|
|
891
1060
|
-------
|
|
892
|
-
|
|
1061
|
+
TestSetSimpleResponse
|
|
893
1062
|
Successful Response
|
|
894
1063
|
|
|
895
1064
|
Examples
|
|
@@ -905,8 +1074,8 @@ class AsyncTestsetsClient:
|
|
|
905
1074
|
|
|
906
1075
|
|
|
907
1076
|
async def main() -> None:
|
|
908
|
-
await client.testsets.
|
|
909
|
-
|
|
1077
|
+
await client.testsets.deprecating_create_testset(
|
|
1078
|
+
app_id="app_id",
|
|
910
1079
|
name="name",
|
|
911
1080
|
csvdata=[{"key": "value"}],
|
|
912
1081
|
)
|
|
@@ -915,8 +1084,8 @@ class AsyncTestsetsClient:
|
|
|
915
1084
|
asyncio.run(main())
|
|
916
1085
|
"""
|
|
917
1086
|
_response = await self._client_wrapper.httpx_client.request(
|
|
918
|
-
f"testsets/{jsonable_encoder(
|
|
919
|
-
method="
|
|
1087
|
+
f"testsets/{jsonable_encoder(app_id)}",
|
|
1088
|
+
method="POST",
|
|
920
1089
|
json={
|
|
921
1090
|
"name": name,
|
|
922
1091
|
"csvdata": csvdata,
|
|
@@ -927,9 +1096,9 @@ class AsyncTestsetsClient:
|
|
|
927
1096
|
try:
|
|
928
1097
|
if 200 <= _response.status_code < 300:
|
|
929
1098
|
return typing.cast(
|
|
930
|
-
|
|
1099
|
+
TestSetSimpleResponse,
|
|
931
1100
|
parse_obj_as(
|
|
932
|
-
type_=
|
|
1101
|
+
type_=TestSetSimpleResponse, # type: ignore
|
|
933
1102
|
object_=_response.json(),
|
|
934
1103
|
),
|
|
935
1104
|
)
|
|
@@ -948,28 +1117,31 @@ class AsyncTestsetsClient:
|
|
|
948
1117
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
949
1118
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
950
1119
|
|
|
951
|
-
async def
|
|
952
|
-
self,
|
|
953
|
-
|
|
1120
|
+
async def get_single_testset(
|
|
1121
|
+
self,
|
|
1122
|
+
testset_id: str,
|
|
1123
|
+
*,
|
|
1124
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1125
|
+
) -> typing.Optional[typing.Any]:
|
|
954
1126
|
"""
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
Returns:
|
|
958
|
-
|
|
959
|
-
- A list of testset objects.
|
|
1127
|
+
Fetch a specific testset in a MongoDB collection using its \_id.
|
|
960
1128
|
|
|
961
|
-
|
|
1129
|
+
Args:
|
|
1130
|
+
testset_id (str): The \_id of the testset to fetch.
|
|
962
1131
|
|
|
963
|
-
|
|
1132
|
+
Returns:
|
|
1133
|
+
The requested testset if found, else an HTTPException.
|
|
964
1134
|
|
|
965
1135
|
Parameters
|
|
966
1136
|
----------
|
|
1137
|
+
testset_id : str
|
|
1138
|
+
|
|
967
1139
|
request_options : typing.Optional[RequestOptions]
|
|
968
1140
|
Request-specific configuration.
|
|
969
1141
|
|
|
970
1142
|
Returns
|
|
971
1143
|
-------
|
|
972
|
-
typing.
|
|
1144
|
+
typing.Optional[typing.Any]
|
|
973
1145
|
Successful Response
|
|
974
1146
|
|
|
975
1147
|
Examples
|
|
@@ -985,22 +1157,24 @@ class AsyncTestsetsClient:
|
|
|
985
1157
|
|
|
986
1158
|
|
|
987
1159
|
async def main() -> None:
|
|
988
|
-
await client.testsets.
|
|
1160
|
+
await client.testsets.get_single_testset(
|
|
1161
|
+
testset_id="testset_id",
|
|
1162
|
+
)
|
|
989
1163
|
|
|
990
1164
|
|
|
991
1165
|
asyncio.run(main())
|
|
992
1166
|
"""
|
|
993
1167
|
_response = await self._client_wrapper.httpx_client.request(
|
|
994
|
-
"testsets",
|
|
1168
|
+
f"testsets/{jsonable_encoder(testset_id)}",
|
|
995
1169
|
method="GET",
|
|
996
1170
|
request_options=request_options,
|
|
997
1171
|
)
|
|
998
1172
|
try:
|
|
999
1173
|
if 200 <= _response.status_code < 300:
|
|
1000
1174
|
return typing.cast(
|
|
1001
|
-
typing.
|
|
1175
|
+
typing.Optional[typing.Any],
|
|
1002
1176
|
parse_obj_as(
|
|
1003
|
-
type_=typing.
|
|
1177
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1004
1178
|
object_=_response.json(),
|
|
1005
1179
|
),
|
|
1006
1180
|
)
|
|
@@ -1019,31 +1193,38 @@ class AsyncTestsetsClient:
|
|
|
1019
1193
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1020
1194
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1021
1195
|
|
|
1022
|
-
async def
|
|
1196
|
+
async def update_testset(
|
|
1023
1197
|
self,
|
|
1198
|
+
testset_id: str,
|
|
1024
1199
|
*,
|
|
1025
|
-
|
|
1200
|
+
name: str,
|
|
1201
|
+
csvdata: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
1026
1202
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1027
|
-
) -> typing.
|
|
1203
|
+
) -> typing.Optional[typing.Any]:
|
|
1028
1204
|
"""
|
|
1029
|
-
|
|
1205
|
+
Update a testset with given id, update the testset in MongoDB.
|
|
1030
1206
|
|
|
1031
1207
|
Args:
|
|
1032
|
-
|
|
1208
|
+
testset_id (str): id of the test set to be updated.
|
|
1209
|
+
csvdata (NewTestset): New data to replace the old testset.
|
|
1033
1210
|
|
|
1034
1211
|
Returns:
|
|
1035
|
-
|
|
1212
|
+
str: The id of the test set updated.
|
|
1036
1213
|
|
|
1037
1214
|
Parameters
|
|
1038
1215
|
----------
|
|
1039
|
-
|
|
1216
|
+
testset_id : str
|
|
1217
|
+
|
|
1218
|
+
name : str
|
|
1219
|
+
|
|
1220
|
+
csvdata : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
1040
1221
|
|
|
1041
1222
|
request_options : typing.Optional[RequestOptions]
|
|
1042
1223
|
Request-specific configuration.
|
|
1043
1224
|
|
|
1044
1225
|
Returns
|
|
1045
1226
|
-------
|
|
1046
|
-
typing.
|
|
1227
|
+
typing.Optional[typing.Any]
|
|
1047
1228
|
Successful Response
|
|
1048
1229
|
|
|
1049
1230
|
Examples
|
|
@@ -1059,18 +1240,21 @@ class AsyncTestsetsClient:
|
|
|
1059
1240
|
|
|
1060
1241
|
|
|
1061
1242
|
async def main() -> None:
|
|
1062
|
-
await client.testsets.
|
|
1063
|
-
|
|
1243
|
+
await client.testsets.update_testset(
|
|
1244
|
+
testset_id="testset_id",
|
|
1245
|
+
name="name",
|
|
1246
|
+
csvdata=[{"key": "value"}],
|
|
1064
1247
|
)
|
|
1065
1248
|
|
|
1066
1249
|
|
|
1067
1250
|
asyncio.run(main())
|
|
1068
1251
|
"""
|
|
1069
1252
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1070
|
-
"testsets",
|
|
1071
|
-
method="
|
|
1253
|
+
f"testsets/{jsonable_encoder(testset_id)}",
|
|
1254
|
+
method="PUT",
|
|
1072
1255
|
json={
|
|
1073
|
-
"
|
|
1256
|
+
"name": name,
|
|
1257
|
+
"csvdata": csvdata,
|
|
1074
1258
|
},
|
|
1075
1259
|
request_options=request_options,
|
|
1076
1260
|
omit=OMIT,
|
|
@@ -1078,9 +1262,9 @@ class AsyncTestsetsClient:
|
|
|
1078
1262
|
try:
|
|
1079
1263
|
if 200 <= _response.status_code < 300:
|
|
1080
1264
|
return typing.cast(
|
|
1081
|
-
typing.
|
|
1265
|
+
typing.Optional[typing.Any],
|
|
1082
1266
|
parse_obj_as(
|
|
1083
|
-
type_=typing.
|
|
1267
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1084
1268
|
object_=_response.json(),
|
|
1085
1269
|
),
|
|
1086
1270
|
)
|