agenta 0.31.0__py3-none-any.whl → 0.32.0__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.

@@ -0,0 +1,1696 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from ..core.request_options import RequestOptions
6
+ from ..types.human_evaluation import HumanEvaluation
7
+ from ..core.pydantic_utilities import parse_obj_as
8
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
9
+ from ..types.http_validation_error import HttpValidationError
10
+ from json.decoder import JSONDecodeError
11
+ from ..core.api_error import ApiError
12
+ from ..types.evaluation_type import EvaluationType
13
+ from ..types.simple_evaluation_output import SimpleEvaluationOutput
14
+ from ..core.jsonable_encoder import jsonable_encoder
15
+ from ..types.evaluation_status_enum import EvaluationStatusEnum
16
+ from ..types.human_evaluation_scenario import HumanEvaluationScenario
17
+ from ..types.score import Score
18
+ from ..types.human_evaluation_scenario_output import HumanEvaluationScenarioOutput
19
+ from ..types.human_evaluation_scenario_input import HumanEvaluationScenarioInput
20
+ from ..core.serialization import convert_and_respect_annotation_metadata
21
+ from ..core.client_wrapper import AsyncClientWrapper
22
+
23
+ # this is used as the default value for optional parameters
24
+ OMIT = typing.cast(typing.Any, ...)
25
+
26
+
27
+ class HumanEvaluationsClient:
28
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
29
+ self._client_wrapper = client_wrapper
30
+
31
+ def fetch_list_human_evaluations(
32
+ self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
33
+ ) -> typing.List[HumanEvaluation]:
34
+ """
35
+ Fetches a list of evaluations, optionally filtered by an app ID.
36
+
37
+ Args:
38
+ app_id (Optional[str]): An optional app ID to filter the evaluations.
39
+
40
+ Returns:
41
+ List[HumanEvaluation]: A list of evaluations.
42
+
43
+ Parameters
44
+ ----------
45
+ app_id : str
46
+
47
+ request_options : typing.Optional[RequestOptions]
48
+ Request-specific configuration.
49
+
50
+ Returns
51
+ -------
52
+ typing.List[HumanEvaluation]
53
+ Successful Response
54
+
55
+ Examples
56
+ --------
57
+ from agenta import AgentaApi
58
+
59
+ client = AgentaApi(
60
+ api_key="YOUR_API_KEY",
61
+ base_url="https://yourhost.com/path/to/api",
62
+ )
63
+ client.human_evaluations.fetch_list_human_evaluations(
64
+ app_id="app_id",
65
+ )
66
+ """
67
+ _response = self._client_wrapper.httpx_client.request(
68
+ "human-evaluations",
69
+ method="GET",
70
+ params={
71
+ "app_id": app_id,
72
+ },
73
+ request_options=request_options,
74
+ )
75
+ try:
76
+ if 200 <= _response.status_code < 300:
77
+ return typing.cast(
78
+ typing.List[HumanEvaluation],
79
+ parse_obj_as(
80
+ type_=typing.List[HumanEvaluation], # type: ignore
81
+ object_=_response.json(),
82
+ ),
83
+ )
84
+ if _response.status_code == 422:
85
+ raise UnprocessableEntityError(
86
+ typing.cast(
87
+ HttpValidationError,
88
+ parse_obj_as(
89
+ type_=HttpValidationError, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ )
93
+ )
94
+ _response_json = _response.json()
95
+ except JSONDecodeError:
96
+ raise ApiError(status_code=_response.status_code, body=_response.text)
97
+ raise ApiError(status_code=_response.status_code, body=_response_json)
98
+
99
+ def create_human_evaluation(
100
+ self,
101
+ *,
102
+ app_id: str,
103
+ variant_ids: typing.Sequence[str],
104
+ evaluation_type: EvaluationType,
105
+ inputs: typing.Sequence[str],
106
+ testset_id: str,
107
+ status: str,
108
+ request_options: typing.Optional[RequestOptions] = None,
109
+ ) -> SimpleEvaluationOutput:
110
+ """
111
+ Creates a new comparison table document
112
+ Raises:
113
+ HTTPException: _description_
114
+ Returns:
115
+ _description_
116
+
117
+ Parameters
118
+ ----------
119
+ app_id : str
120
+
121
+ variant_ids : typing.Sequence[str]
122
+
123
+ evaluation_type : EvaluationType
124
+
125
+ inputs : typing.Sequence[str]
126
+
127
+ testset_id : str
128
+
129
+ status : str
130
+
131
+ request_options : typing.Optional[RequestOptions]
132
+ Request-specific configuration.
133
+
134
+ Returns
135
+ -------
136
+ SimpleEvaluationOutput
137
+ Successful Response
138
+
139
+ Examples
140
+ --------
141
+ from agenta import AgentaApi
142
+
143
+ client = AgentaApi(
144
+ api_key="YOUR_API_KEY",
145
+ base_url="https://yourhost.com/path/to/api",
146
+ )
147
+ client.human_evaluations.create_human_evaluation(
148
+ app_id="app_id",
149
+ variant_ids=["variant_ids"],
150
+ evaluation_type="human_a_b_testing",
151
+ inputs=["inputs"],
152
+ testset_id="testset_id",
153
+ status="status",
154
+ )
155
+ """
156
+ _response = self._client_wrapper.httpx_client.request(
157
+ "human-evaluations",
158
+ method="POST",
159
+ json={
160
+ "app_id": app_id,
161
+ "variant_ids": variant_ids,
162
+ "evaluation_type": evaluation_type,
163
+ "inputs": inputs,
164
+ "testset_id": testset_id,
165
+ "status": status,
166
+ },
167
+ headers={
168
+ "content-type": "application/json",
169
+ },
170
+ request_options=request_options,
171
+ omit=OMIT,
172
+ )
173
+ try:
174
+ if 200 <= _response.status_code < 300:
175
+ return typing.cast(
176
+ SimpleEvaluationOutput,
177
+ parse_obj_as(
178
+ type_=SimpleEvaluationOutput, # type: ignore
179
+ object_=_response.json(),
180
+ ),
181
+ )
182
+ if _response.status_code == 422:
183
+ raise UnprocessableEntityError(
184
+ typing.cast(
185
+ HttpValidationError,
186
+ parse_obj_as(
187
+ type_=HttpValidationError, # type: ignore
188
+ object_=_response.json(),
189
+ ),
190
+ )
191
+ )
192
+ _response_json = _response.json()
193
+ except JSONDecodeError:
194
+ raise ApiError(status_code=_response.status_code, body=_response.text)
195
+ raise ApiError(status_code=_response.status_code, body=_response_json)
196
+
197
+ def delete_evaluations(
198
+ self,
199
+ *,
200
+ evaluations_ids: typing.Sequence[str],
201
+ request_options: typing.Optional[RequestOptions] = None,
202
+ ) -> typing.List[str]:
203
+ """
204
+ Delete specific comparison tables based on their unique IDs.
205
+
206
+ Args:
207
+ payload (List[str]): The unique identifiers of the comparison tables to delete.
208
+
209
+ Returns:
210
+ A list of the deleted comparison tables' IDs.
211
+
212
+ Parameters
213
+ ----------
214
+ evaluations_ids : typing.Sequence[str]
215
+
216
+ request_options : typing.Optional[RequestOptions]
217
+ Request-specific configuration.
218
+
219
+ Returns
220
+ -------
221
+ typing.List[str]
222
+ Successful Response
223
+
224
+ Examples
225
+ --------
226
+ from agenta import AgentaApi
227
+
228
+ client = AgentaApi(
229
+ api_key="YOUR_API_KEY",
230
+ base_url="https://yourhost.com/path/to/api",
231
+ )
232
+ client.human_evaluations.delete_evaluations(
233
+ evaluations_ids=["evaluations_ids"],
234
+ )
235
+ """
236
+ _response = self._client_wrapper.httpx_client.request(
237
+ "human-evaluations",
238
+ method="DELETE",
239
+ json={
240
+ "evaluations_ids": evaluations_ids,
241
+ },
242
+ request_options=request_options,
243
+ omit=OMIT,
244
+ )
245
+ try:
246
+ if 200 <= _response.status_code < 300:
247
+ return typing.cast(
248
+ typing.List[str],
249
+ parse_obj_as(
250
+ type_=typing.List[str], # type: ignore
251
+ object_=_response.json(),
252
+ ),
253
+ )
254
+ if _response.status_code == 422:
255
+ raise UnprocessableEntityError(
256
+ typing.cast(
257
+ HttpValidationError,
258
+ parse_obj_as(
259
+ type_=HttpValidationError, # type: ignore
260
+ object_=_response.json(),
261
+ ),
262
+ )
263
+ )
264
+ _response_json = _response.json()
265
+ except JSONDecodeError:
266
+ raise ApiError(status_code=_response.status_code, body=_response.text)
267
+ raise ApiError(status_code=_response.status_code, body=_response_json)
268
+
269
+ def fetch_human_evaluation(
270
+ self,
271
+ evaluation_id: str,
272
+ *,
273
+ request_options: typing.Optional[RequestOptions] = None,
274
+ ) -> HumanEvaluation:
275
+ """
276
+ Fetches a single evaluation based on its ID.
277
+
278
+ Args:
279
+ evaluation_id (str): The ID of the evaluation to fetch.
280
+
281
+ Returns:
282
+ HumanEvaluation: The fetched evaluation.
283
+
284
+ Parameters
285
+ ----------
286
+ evaluation_id : str
287
+
288
+ request_options : typing.Optional[RequestOptions]
289
+ Request-specific configuration.
290
+
291
+ Returns
292
+ -------
293
+ HumanEvaluation
294
+ Successful Response
295
+
296
+ Examples
297
+ --------
298
+ from agenta import AgentaApi
299
+
300
+ client = AgentaApi(
301
+ api_key="YOUR_API_KEY",
302
+ base_url="https://yourhost.com/path/to/api",
303
+ )
304
+ client.human_evaluations.fetch_human_evaluation(
305
+ evaluation_id="evaluation_id",
306
+ )
307
+ """
308
+ _response = self._client_wrapper.httpx_client.request(
309
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}",
310
+ method="GET",
311
+ request_options=request_options,
312
+ )
313
+ try:
314
+ if 200 <= _response.status_code < 300:
315
+ return typing.cast(
316
+ HumanEvaluation,
317
+ parse_obj_as(
318
+ type_=HumanEvaluation, # type: ignore
319
+ object_=_response.json(),
320
+ ),
321
+ )
322
+ if _response.status_code == 422:
323
+ raise UnprocessableEntityError(
324
+ typing.cast(
325
+ HttpValidationError,
326
+ parse_obj_as(
327
+ type_=HttpValidationError, # type: ignore
328
+ object_=_response.json(),
329
+ ),
330
+ )
331
+ )
332
+ _response_json = _response.json()
333
+ except JSONDecodeError:
334
+ raise ApiError(status_code=_response.status_code, body=_response.text)
335
+ raise ApiError(status_code=_response.status_code, body=_response_json)
336
+
337
+ def update_human_evaluation(
338
+ self,
339
+ evaluation_id: str,
340
+ *,
341
+ status: typing.Optional[EvaluationStatusEnum] = OMIT,
342
+ request_options: typing.Optional[RequestOptions] = None,
343
+ ) -> typing.Optional[typing.Any]:
344
+ """
345
+ Updates an evaluation's status.
346
+
347
+ Raises:
348
+ HTTPException: If the columns in the test set do not match with the inputs in the variant.
349
+
350
+ Returns:
351
+ None: A 204 No Content status code, indicating that the update was successful.
352
+
353
+ Parameters
354
+ ----------
355
+ evaluation_id : str
356
+
357
+ status : typing.Optional[EvaluationStatusEnum]
358
+
359
+ request_options : typing.Optional[RequestOptions]
360
+ Request-specific configuration.
361
+
362
+ Returns
363
+ -------
364
+ typing.Optional[typing.Any]
365
+ Successful Response
366
+
367
+ Examples
368
+ --------
369
+ from agenta import AgentaApi
370
+
371
+ client = AgentaApi(
372
+ api_key="YOUR_API_KEY",
373
+ base_url="https://yourhost.com/path/to/api",
374
+ )
375
+ client.human_evaluations.update_human_evaluation(
376
+ evaluation_id="evaluation_id",
377
+ )
378
+ """
379
+ _response = self._client_wrapper.httpx_client.request(
380
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}",
381
+ method="PUT",
382
+ json={
383
+ "status": status,
384
+ },
385
+ headers={
386
+ "content-type": "application/json",
387
+ },
388
+ request_options=request_options,
389
+ omit=OMIT,
390
+ )
391
+ try:
392
+ if 200 <= _response.status_code < 300:
393
+ return typing.cast(
394
+ typing.Optional[typing.Any],
395
+ parse_obj_as(
396
+ type_=typing.Optional[typing.Any], # type: ignore
397
+ object_=_response.json(),
398
+ ),
399
+ )
400
+ if _response.status_code == 422:
401
+ raise UnprocessableEntityError(
402
+ typing.cast(
403
+ HttpValidationError,
404
+ parse_obj_as(
405
+ type_=HttpValidationError, # type: ignore
406
+ object_=_response.json(),
407
+ ),
408
+ )
409
+ )
410
+ _response_json = _response.json()
411
+ except JSONDecodeError:
412
+ raise ApiError(status_code=_response.status_code, body=_response.text)
413
+ raise ApiError(status_code=_response.status_code, body=_response_json)
414
+
415
+ def fetch_human_evaluation_scenarios(
416
+ self,
417
+ evaluation_id: str,
418
+ *,
419
+ request_options: typing.Optional[RequestOptions] = None,
420
+ ) -> typing.List[HumanEvaluationScenario]:
421
+ """
422
+ Fetches evaluation scenarios for a given evaluation ID.
423
+
424
+ Arguments:
425
+ evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
426
+
427
+ Raises:
428
+ HTTPException: If the evaluation is not found or access is denied.
429
+
430
+ Returns:
431
+ List[EvaluationScenario]: A list of evaluation scenarios.
432
+
433
+ Parameters
434
+ ----------
435
+ evaluation_id : str
436
+
437
+ request_options : typing.Optional[RequestOptions]
438
+ Request-specific configuration.
439
+
440
+ Returns
441
+ -------
442
+ typing.List[HumanEvaluationScenario]
443
+ Successful Response
444
+
445
+ Examples
446
+ --------
447
+ from agenta import AgentaApi
448
+
449
+ client = AgentaApi(
450
+ api_key="YOUR_API_KEY",
451
+ base_url="https://yourhost.com/path/to/api",
452
+ )
453
+ client.human_evaluations.fetch_human_evaluation_scenarios(
454
+ evaluation_id="evaluation_id",
455
+ )
456
+ """
457
+ _response = self._client_wrapper.httpx_client.request(
458
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenarios",
459
+ method="GET",
460
+ request_options=request_options,
461
+ )
462
+ try:
463
+ if 200 <= _response.status_code < 300:
464
+ return typing.cast(
465
+ typing.List[HumanEvaluationScenario],
466
+ parse_obj_as(
467
+ type_=typing.List[HumanEvaluationScenario], # type: ignore
468
+ object_=_response.json(),
469
+ ),
470
+ )
471
+ if _response.status_code == 422:
472
+ raise UnprocessableEntityError(
473
+ typing.cast(
474
+ HttpValidationError,
475
+ parse_obj_as(
476
+ type_=HttpValidationError, # type: ignore
477
+ object_=_response.json(),
478
+ ),
479
+ )
480
+ )
481
+ _response_json = _response.json()
482
+ except JSONDecodeError:
483
+ raise ApiError(status_code=_response.status_code, body=_response.text)
484
+ raise ApiError(status_code=_response.status_code, body=_response_json)
485
+
486
+ def update_evaluation_scenario_router(
487
+ self,
488
+ evaluation_id: str,
489
+ evaluation_scenario_id: str,
490
+ evaluation_type: EvaluationType,
491
+ *,
492
+ vote: typing.Optional[str] = OMIT,
493
+ score: typing.Optional[Score] = OMIT,
494
+ correct_answer: typing.Optional[str] = OMIT,
495
+ outputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]] = OMIT,
496
+ inputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]] = OMIT,
497
+ is_pinned: typing.Optional[bool] = OMIT,
498
+ note: typing.Optional[str] = OMIT,
499
+ request_options: typing.Optional[RequestOptions] = None,
500
+ ) -> typing.Optional[typing.Any]:
501
+ """
502
+ Updates an evaluation scenario's vote or score based on its type.
503
+
504
+ Raises:
505
+ HTTPException: If update fails or unauthorized.
506
+
507
+ Returns:
508
+ None: 204 No Content status code upon successful update.
509
+
510
+ Parameters
511
+ ----------
512
+ evaluation_id : str
513
+
514
+ evaluation_scenario_id : str
515
+
516
+ evaluation_type : EvaluationType
517
+
518
+ vote : typing.Optional[str]
519
+
520
+ score : typing.Optional[Score]
521
+
522
+ correct_answer : typing.Optional[str]
523
+
524
+ outputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]]
525
+
526
+ inputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]]
527
+
528
+ is_pinned : typing.Optional[bool]
529
+
530
+ note : typing.Optional[str]
531
+
532
+ request_options : typing.Optional[RequestOptions]
533
+ Request-specific configuration.
534
+
535
+ Returns
536
+ -------
537
+ typing.Optional[typing.Any]
538
+ Successful Response
539
+
540
+ Examples
541
+ --------
542
+ from agenta import AgentaApi
543
+
544
+ client = AgentaApi(
545
+ api_key="YOUR_API_KEY",
546
+ base_url="https://yourhost.com/path/to/api",
547
+ )
548
+ client.human_evaluations.update_evaluation_scenario_router(
549
+ evaluation_id="evaluation_id",
550
+ evaluation_scenario_id="evaluation_scenario_id",
551
+ evaluation_type="human_a_b_testing",
552
+ )
553
+ """
554
+ _response = self._client_wrapper.httpx_client.request(
555
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/{jsonable_encoder(evaluation_type)}",
556
+ method="PUT",
557
+ json={
558
+ "vote": vote,
559
+ "score": convert_and_respect_annotation_metadata(
560
+ object_=score, annotation=Score, direction="write"
561
+ ),
562
+ "correct_answer": correct_answer,
563
+ "outputs": convert_and_respect_annotation_metadata(
564
+ object_=outputs,
565
+ annotation=typing.Sequence[HumanEvaluationScenarioOutput],
566
+ direction="write",
567
+ ),
568
+ "inputs": convert_and_respect_annotation_metadata(
569
+ object_=inputs,
570
+ annotation=typing.Sequence[HumanEvaluationScenarioInput],
571
+ direction="write",
572
+ ),
573
+ "is_pinned": is_pinned,
574
+ "note": note,
575
+ },
576
+ headers={
577
+ "content-type": "application/json",
578
+ },
579
+ request_options=request_options,
580
+ omit=OMIT,
581
+ )
582
+ try:
583
+ if 200 <= _response.status_code < 300:
584
+ return typing.cast(
585
+ typing.Optional[typing.Any],
586
+ parse_obj_as(
587
+ type_=typing.Optional[typing.Any], # type: ignore
588
+ object_=_response.json(),
589
+ ),
590
+ )
591
+ if _response.status_code == 422:
592
+ raise UnprocessableEntityError(
593
+ typing.cast(
594
+ HttpValidationError,
595
+ parse_obj_as(
596
+ type_=HttpValidationError, # type: ignore
597
+ object_=_response.json(),
598
+ ),
599
+ )
600
+ )
601
+ _response_json = _response.json()
602
+ except JSONDecodeError:
603
+ raise ApiError(status_code=_response.status_code, body=_response.text)
604
+ raise ApiError(status_code=_response.status_code, body=_response_json)
605
+
606
+ def get_evaluation_scenario_score_router(
607
+ self,
608
+ evaluation_scenario_id: str,
609
+ *,
610
+ request_options: typing.Optional[RequestOptions] = None,
611
+ ) -> typing.Dict[str, str]:
612
+ """
613
+ Fetch the score of a specific evaluation scenario.
614
+
615
+ Args:
616
+ evaluation_scenario_id: The ID of the evaluation scenario to fetch.
617
+ stoken_session: Session data, verified by `verify_session`.
618
+
619
+ Returns:
620
+ Dictionary containing the scenario ID and its score.
621
+
622
+ Parameters
623
+ ----------
624
+ evaluation_scenario_id : str
625
+
626
+ request_options : typing.Optional[RequestOptions]
627
+ Request-specific configuration.
628
+
629
+ Returns
630
+ -------
631
+ typing.Dict[str, str]
632
+ Successful Response
633
+
634
+ Examples
635
+ --------
636
+ from agenta import AgentaApi
637
+
638
+ client = AgentaApi(
639
+ api_key="YOUR_API_KEY",
640
+ base_url="https://yourhost.com/path/to/api",
641
+ )
642
+ client.human_evaluations.get_evaluation_scenario_score_router(
643
+ evaluation_scenario_id="evaluation_scenario_id",
644
+ )
645
+ """
646
+ _response = self._client_wrapper.httpx_client.request(
647
+ f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
648
+ method="GET",
649
+ request_options=request_options,
650
+ )
651
+ try:
652
+ if 200 <= _response.status_code < 300:
653
+ return typing.cast(
654
+ typing.Dict[str, str],
655
+ parse_obj_as(
656
+ type_=typing.Dict[str, str], # type: ignore
657
+ object_=_response.json(),
658
+ ),
659
+ )
660
+ if _response.status_code == 422:
661
+ raise UnprocessableEntityError(
662
+ typing.cast(
663
+ HttpValidationError,
664
+ parse_obj_as(
665
+ type_=HttpValidationError, # type: ignore
666
+ object_=_response.json(),
667
+ ),
668
+ )
669
+ )
670
+ _response_json = _response.json()
671
+ except JSONDecodeError:
672
+ raise ApiError(status_code=_response.status_code, body=_response.text)
673
+ raise ApiError(status_code=_response.status_code, body=_response_json)
674
+
675
+ def update_evaluation_scenario_score_router(
676
+ self,
677
+ evaluation_scenario_id: str,
678
+ *,
679
+ score: float,
680
+ request_options: typing.Optional[RequestOptions] = None,
681
+ ) -> typing.Optional[typing.Any]:
682
+ """
683
+ Updates the score of an evaluation scenario.
684
+
685
+ Raises:
686
+ HTTPException: Server error if the evaluation update fails.
687
+
688
+ Returns:
689
+ None: 204 No Content status code upon successful update.
690
+
691
+ Parameters
692
+ ----------
693
+ evaluation_scenario_id : str
694
+
695
+ score : float
696
+
697
+ request_options : typing.Optional[RequestOptions]
698
+ Request-specific configuration.
699
+
700
+ Returns
701
+ -------
702
+ typing.Optional[typing.Any]
703
+ Successful Response
704
+
705
+ Examples
706
+ --------
707
+ from agenta import AgentaApi
708
+
709
+ client = AgentaApi(
710
+ api_key="YOUR_API_KEY",
711
+ base_url="https://yourhost.com/path/to/api",
712
+ )
713
+ client.human_evaluations.update_evaluation_scenario_score_router(
714
+ evaluation_scenario_id="evaluation_scenario_id",
715
+ score=1.1,
716
+ )
717
+ """
718
+ _response = self._client_wrapper.httpx_client.request(
719
+ f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
720
+ method="PUT",
721
+ json={
722
+ "score": score,
723
+ },
724
+ headers={
725
+ "content-type": "application/json",
726
+ },
727
+ request_options=request_options,
728
+ omit=OMIT,
729
+ )
730
+ try:
731
+ if 200 <= _response.status_code < 300:
732
+ return typing.cast(
733
+ typing.Optional[typing.Any],
734
+ parse_obj_as(
735
+ type_=typing.Optional[typing.Any], # type: ignore
736
+ object_=_response.json(),
737
+ ),
738
+ )
739
+ if _response.status_code == 422:
740
+ raise UnprocessableEntityError(
741
+ typing.cast(
742
+ HttpValidationError,
743
+ parse_obj_as(
744
+ type_=HttpValidationError, # type: ignore
745
+ object_=_response.json(),
746
+ ),
747
+ )
748
+ )
749
+ _response_json = _response.json()
750
+ except JSONDecodeError:
751
+ raise ApiError(status_code=_response.status_code, body=_response.text)
752
+ raise ApiError(status_code=_response.status_code, body=_response_json)
753
+
754
+ def fetch_results(
755
+ self,
756
+ evaluation_id: str,
757
+ *,
758
+ request_options: typing.Optional[RequestOptions] = None,
759
+ ) -> typing.Optional[typing.Any]:
760
+ """
761
+ Fetch all the results for one the comparison table
762
+
763
+ Arguments:
764
+ evaluation_id -- _description_
765
+
766
+ Returns:
767
+ _description_
768
+
769
+ Parameters
770
+ ----------
771
+ evaluation_id : str
772
+
773
+ request_options : typing.Optional[RequestOptions]
774
+ Request-specific configuration.
775
+
776
+ Returns
777
+ -------
778
+ typing.Optional[typing.Any]
779
+ Successful Response
780
+
781
+ Examples
782
+ --------
783
+ from agenta import AgentaApi
784
+
785
+ client = AgentaApi(
786
+ api_key="YOUR_API_KEY",
787
+ base_url="https://yourhost.com/path/to/api",
788
+ )
789
+ client.human_evaluations.fetch_results(
790
+ evaluation_id="evaluation_id",
791
+ )
792
+ """
793
+ _response = self._client_wrapper.httpx_client.request(
794
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}/results",
795
+ method="GET",
796
+ request_options=request_options,
797
+ )
798
+ try:
799
+ if 200 <= _response.status_code < 300:
800
+ return typing.cast(
801
+ typing.Optional[typing.Any],
802
+ parse_obj_as(
803
+ type_=typing.Optional[typing.Any], # type: ignore
804
+ object_=_response.json(),
805
+ ),
806
+ )
807
+ if _response.status_code == 422:
808
+ raise UnprocessableEntityError(
809
+ typing.cast(
810
+ HttpValidationError,
811
+ parse_obj_as(
812
+ type_=HttpValidationError, # type: ignore
813
+ object_=_response.json(),
814
+ ),
815
+ )
816
+ )
817
+ _response_json = _response.json()
818
+ except JSONDecodeError:
819
+ raise ApiError(status_code=_response.status_code, body=_response.text)
820
+ raise ApiError(status_code=_response.status_code, body=_response_json)
821
+
822
+
823
+ class AsyncHumanEvaluationsClient:
824
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
825
+ self._client_wrapper = client_wrapper
826
+
827
+ async def fetch_list_human_evaluations(
828
+ self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
829
+ ) -> typing.List[HumanEvaluation]:
830
+ """
831
+ Fetches a list of evaluations, optionally filtered by an app ID.
832
+
833
+ Args:
834
+ app_id (Optional[str]): An optional app ID to filter the evaluations.
835
+
836
+ Returns:
837
+ List[HumanEvaluation]: A list of evaluations.
838
+
839
+ Parameters
840
+ ----------
841
+ app_id : str
842
+
843
+ request_options : typing.Optional[RequestOptions]
844
+ Request-specific configuration.
845
+
846
+ Returns
847
+ -------
848
+ typing.List[HumanEvaluation]
849
+ Successful Response
850
+
851
+ Examples
852
+ --------
853
+ import asyncio
854
+
855
+ from agenta import AsyncAgentaApi
856
+
857
+ client = AsyncAgentaApi(
858
+ api_key="YOUR_API_KEY",
859
+ base_url="https://yourhost.com/path/to/api",
860
+ )
861
+
862
+
863
+ async def main() -> None:
864
+ await client.human_evaluations.fetch_list_human_evaluations(
865
+ app_id="app_id",
866
+ )
867
+
868
+
869
+ asyncio.run(main())
870
+ """
871
+ _response = await self._client_wrapper.httpx_client.request(
872
+ "human-evaluations",
873
+ method="GET",
874
+ params={
875
+ "app_id": app_id,
876
+ },
877
+ request_options=request_options,
878
+ )
879
+ try:
880
+ if 200 <= _response.status_code < 300:
881
+ return typing.cast(
882
+ typing.List[HumanEvaluation],
883
+ parse_obj_as(
884
+ type_=typing.List[HumanEvaluation], # type: ignore
885
+ object_=_response.json(),
886
+ ),
887
+ )
888
+ if _response.status_code == 422:
889
+ raise UnprocessableEntityError(
890
+ typing.cast(
891
+ HttpValidationError,
892
+ parse_obj_as(
893
+ type_=HttpValidationError, # type: ignore
894
+ object_=_response.json(),
895
+ ),
896
+ )
897
+ )
898
+ _response_json = _response.json()
899
+ except JSONDecodeError:
900
+ raise ApiError(status_code=_response.status_code, body=_response.text)
901
+ raise ApiError(status_code=_response.status_code, body=_response_json)
902
+
903
+ async def create_human_evaluation(
904
+ self,
905
+ *,
906
+ app_id: str,
907
+ variant_ids: typing.Sequence[str],
908
+ evaluation_type: EvaluationType,
909
+ inputs: typing.Sequence[str],
910
+ testset_id: str,
911
+ status: str,
912
+ request_options: typing.Optional[RequestOptions] = None,
913
+ ) -> SimpleEvaluationOutput:
914
+ """
915
+ Creates a new comparison table document
916
+ Raises:
917
+ HTTPException: _description_
918
+ Returns:
919
+ _description_
920
+
921
+ Parameters
922
+ ----------
923
+ app_id : str
924
+
925
+ variant_ids : typing.Sequence[str]
926
+
927
+ evaluation_type : EvaluationType
928
+
929
+ inputs : typing.Sequence[str]
930
+
931
+ testset_id : str
932
+
933
+ status : str
934
+
935
+ request_options : typing.Optional[RequestOptions]
936
+ Request-specific configuration.
937
+
938
+ Returns
939
+ -------
940
+ SimpleEvaluationOutput
941
+ Successful Response
942
+
943
+ Examples
944
+ --------
945
+ import asyncio
946
+
947
+ from agenta import AsyncAgentaApi
948
+
949
+ client = AsyncAgentaApi(
950
+ api_key="YOUR_API_KEY",
951
+ base_url="https://yourhost.com/path/to/api",
952
+ )
953
+
954
+
955
+ async def main() -> None:
956
+ await client.human_evaluations.create_human_evaluation(
957
+ app_id="app_id",
958
+ variant_ids=["variant_ids"],
959
+ evaluation_type="human_a_b_testing",
960
+ inputs=["inputs"],
961
+ testset_id="testset_id",
962
+ status="status",
963
+ )
964
+
965
+
966
+ asyncio.run(main())
967
+ """
968
+ _response = await self._client_wrapper.httpx_client.request(
969
+ "human-evaluations",
970
+ method="POST",
971
+ json={
972
+ "app_id": app_id,
973
+ "variant_ids": variant_ids,
974
+ "evaluation_type": evaluation_type,
975
+ "inputs": inputs,
976
+ "testset_id": testset_id,
977
+ "status": status,
978
+ },
979
+ headers={
980
+ "content-type": "application/json",
981
+ },
982
+ request_options=request_options,
983
+ omit=OMIT,
984
+ )
985
+ try:
986
+ if 200 <= _response.status_code < 300:
987
+ return typing.cast(
988
+ SimpleEvaluationOutput,
989
+ parse_obj_as(
990
+ type_=SimpleEvaluationOutput, # type: ignore
991
+ object_=_response.json(),
992
+ ),
993
+ )
994
+ if _response.status_code == 422:
995
+ raise UnprocessableEntityError(
996
+ typing.cast(
997
+ HttpValidationError,
998
+ parse_obj_as(
999
+ type_=HttpValidationError, # type: ignore
1000
+ object_=_response.json(),
1001
+ ),
1002
+ )
1003
+ )
1004
+ _response_json = _response.json()
1005
+ except JSONDecodeError:
1006
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1007
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1008
+
1009
+ async def delete_evaluations(
1010
+ self,
1011
+ *,
1012
+ evaluations_ids: typing.Sequence[str],
1013
+ request_options: typing.Optional[RequestOptions] = None,
1014
+ ) -> typing.List[str]:
1015
+ """
1016
+ Delete specific comparison tables based on their unique IDs.
1017
+
1018
+ Args:
1019
+ payload (List[str]): The unique identifiers of the comparison tables to delete.
1020
+
1021
+ Returns:
1022
+ A list of the deleted comparison tables' IDs.
1023
+
1024
+ Parameters
1025
+ ----------
1026
+ evaluations_ids : typing.Sequence[str]
1027
+
1028
+ request_options : typing.Optional[RequestOptions]
1029
+ Request-specific configuration.
1030
+
1031
+ Returns
1032
+ -------
1033
+ typing.List[str]
1034
+ Successful Response
1035
+
1036
+ Examples
1037
+ --------
1038
+ import asyncio
1039
+
1040
+ from agenta import AsyncAgentaApi
1041
+
1042
+ client = AsyncAgentaApi(
1043
+ api_key="YOUR_API_KEY",
1044
+ base_url="https://yourhost.com/path/to/api",
1045
+ )
1046
+
1047
+
1048
+ async def main() -> None:
1049
+ await client.human_evaluations.delete_evaluations(
1050
+ evaluations_ids=["evaluations_ids"],
1051
+ )
1052
+
1053
+
1054
+ asyncio.run(main())
1055
+ """
1056
+ _response = await self._client_wrapper.httpx_client.request(
1057
+ "human-evaluations",
1058
+ method="DELETE",
1059
+ json={
1060
+ "evaluations_ids": evaluations_ids,
1061
+ },
1062
+ request_options=request_options,
1063
+ omit=OMIT,
1064
+ )
1065
+ try:
1066
+ if 200 <= _response.status_code < 300:
1067
+ return typing.cast(
1068
+ typing.List[str],
1069
+ parse_obj_as(
1070
+ type_=typing.List[str], # type: ignore
1071
+ object_=_response.json(),
1072
+ ),
1073
+ )
1074
+ if _response.status_code == 422:
1075
+ raise UnprocessableEntityError(
1076
+ typing.cast(
1077
+ HttpValidationError,
1078
+ parse_obj_as(
1079
+ type_=HttpValidationError, # type: ignore
1080
+ object_=_response.json(),
1081
+ ),
1082
+ )
1083
+ )
1084
+ _response_json = _response.json()
1085
+ except JSONDecodeError:
1086
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1087
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1088
+
1089
+ async def fetch_human_evaluation(
1090
+ self,
1091
+ evaluation_id: str,
1092
+ *,
1093
+ request_options: typing.Optional[RequestOptions] = None,
1094
+ ) -> HumanEvaluation:
1095
+ """
1096
+ Fetches a single evaluation based on its ID.
1097
+
1098
+ Args:
1099
+ evaluation_id (str): The ID of the evaluation to fetch.
1100
+
1101
+ Returns:
1102
+ HumanEvaluation: The fetched evaluation.
1103
+
1104
+ Parameters
1105
+ ----------
1106
+ evaluation_id : str
1107
+
1108
+ request_options : typing.Optional[RequestOptions]
1109
+ Request-specific configuration.
1110
+
1111
+ Returns
1112
+ -------
1113
+ HumanEvaluation
1114
+ Successful Response
1115
+
1116
+ Examples
1117
+ --------
1118
+ import asyncio
1119
+
1120
+ from agenta import AsyncAgentaApi
1121
+
1122
+ client = AsyncAgentaApi(
1123
+ api_key="YOUR_API_KEY",
1124
+ base_url="https://yourhost.com/path/to/api",
1125
+ )
1126
+
1127
+
1128
+ async def main() -> None:
1129
+ await client.human_evaluations.fetch_human_evaluation(
1130
+ evaluation_id="evaluation_id",
1131
+ )
1132
+
1133
+
1134
+ asyncio.run(main())
1135
+ """
1136
+ _response = await self._client_wrapper.httpx_client.request(
1137
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}",
1138
+ method="GET",
1139
+ request_options=request_options,
1140
+ )
1141
+ try:
1142
+ if 200 <= _response.status_code < 300:
1143
+ return typing.cast(
1144
+ HumanEvaluation,
1145
+ parse_obj_as(
1146
+ type_=HumanEvaluation, # type: ignore
1147
+ object_=_response.json(),
1148
+ ),
1149
+ )
1150
+ if _response.status_code == 422:
1151
+ raise UnprocessableEntityError(
1152
+ typing.cast(
1153
+ HttpValidationError,
1154
+ parse_obj_as(
1155
+ type_=HttpValidationError, # type: ignore
1156
+ object_=_response.json(),
1157
+ ),
1158
+ )
1159
+ )
1160
+ _response_json = _response.json()
1161
+ except JSONDecodeError:
1162
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1163
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1164
+
1165
+ async def update_human_evaluation(
1166
+ self,
1167
+ evaluation_id: str,
1168
+ *,
1169
+ status: typing.Optional[EvaluationStatusEnum] = OMIT,
1170
+ request_options: typing.Optional[RequestOptions] = None,
1171
+ ) -> typing.Optional[typing.Any]:
1172
+ """
1173
+ Updates an evaluation's status.
1174
+
1175
+ Raises:
1176
+ HTTPException: If the columns in the test set do not match with the inputs in the variant.
1177
+
1178
+ Returns:
1179
+ None: A 204 No Content status code, indicating that the update was successful.
1180
+
1181
+ Parameters
1182
+ ----------
1183
+ evaluation_id : str
1184
+
1185
+ status : typing.Optional[EvaluationStatusEnum]
1186
+
1187
+ request_options : typing.Optional[RequestOptions]
1188
+ Request-specific configuration.
1189
+
1190
+ Returns
1191
+ -------
1192
+ typing.Optional[typing.Any]
1193
+ Successful Response
1194
+
1195
+ Examples
1196
+ --------
1197
+ import asyncio
1198
+
1199
+ from agenta import AsyncAgentaApi
1200
+
1201
+ client = AsyncAgentaApi(
1202
+ api_key="YOUR_API_KEY",
1203
+ base_url="https://yourhost.com/path/to/api",
1204
+ )
1205
+
1206
+
1207
+ async def main() -> None:
1208
+ await client.human_evaluations.update_human_evaluation(
1209
+ evaluation_id="evaluation_id",
1210
+ )
1211
+
1212
+
1213
+ asyncio.run(main())
1214
+ """
1215
+ _response = await self._client_wrapper.httpx_client.request(
1216
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}",
1217
+ method="PUT",
1218
+ json={
1219
+ "status": status,
1220
+ },
1221
+ headers={
1222
+ "content-type": "application/json",
1223
+ },
1224
+ request_options=request_options,
1225
+ omit=OMIT,
1226
+ )
1227
+ try:
1228
+ if 200 <= _response.status_code < 300:
1229
+ return typing.cast(
1230
+ typing.Optional[typing.Any],
1231
+ parse_obj_as(
1232
+ type_=typing.Optional[typing.Any], # type: ignore
1233
+ object_=_response.json(),
1234
+ ),
1235
+ )
1236
+ if _response.status_code == 422:
1237
+ raise UnprocessableEntityError(
1238
+ typing.cast(
1239
+ HttpValidationError,
1240
+ parse_obj_as(
1241
+ type_=HttpValidationError, # type: ignore
1242
+ object_=_response.json(),
1243
+ ),
1244
+ )
1245
+ )
1246
+ _response_json = _response.json()
1247
+ except JSONDecodeError:
1248
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1249
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1250
+
1251
+ async def fetch_human_evaluation_scenarios(
1252
+ self,
1253
+ evaluation_id: str,
1254
+ *,
1255
+ request_options: typing.Optional[RequestOptions] = None,
1256
+ ) -> typing.List[HumanEvaluationScenario]:
1257
+ """
1258
+ Fetches evaluation scenarios for a given evaluation ID.
1259
+
1260
+ Arguments:
1261
+ evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
1262
+
1263
+ Raises:
1264
+ HTTPException: If the evaluation is not found or access is denied.
1265
+
1266
+ Returns:
1267
+ List[EvaluationScenario]: A list of evaluation scenarios.
1268
+
1269
+ Parameters
1270
+ ----------
1271
+ evaluation_id : str
1272
+
1273
+ request_options : typing.Optional[RequestOptions]
1274
+ Request-specific configuration.
1275
+
1276
+ Returns
1277
+ -------
1278
+ typing.List[HumanEvaluationScenario]
1279
+ Successful Response
1280
+
1281
+ Examples
1282
+ --------
1283
+ import asyncio
1284
+
1285
+ from agenta import AsyncAgentaApi
1286
+
1287
+ client = AsyncAgentaApi(
1288
+ api_key="YOUR_API_KEY",
1289
+ base_url="https://yourhost.com/path/to/api",
1290
+ )
1291
+
1292
+
1293
+ async def main() -> None:
1294
+ await client.human_evaluations.fetch_human_evaluation_scenarios(
1295
+ evaluation_id="evaluation_id",
1296
+ )
1297
+
1298
+
1299
+ asyncio.run(main())
1300
+ """
1301
+ _response = await self._client_wrapper.httpx_client.request(
1302
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenarios",
1303
+ method="GET",
1304
+ request_options=request_options,
1305
+ )
1306
+ try:
1307
+ if 200 <= _response.status_code < 300:
1308
+ return typing.cast(
1309
+ typing.List[HumanEvaluationScenario],
1310
+ parse_obj_as(
1311
+ type_=typing.List[HumanEvaluationScenario], # type: ignore
1312
+ object_=_response.json(),
1313
+ ),
1314
+ )
1315
+ if _response.status_code == 422:
1316
+ raise UnprocessableEntityError(
1317
+ typing.cast(
1318
+ HttpValidationError,
1319
+ parse_obj_as(
1320
+ type_=HttpValidationError, # type: ignore
1321
+ object_=_response.json(),
1322
+ ),
1323
+ )
1324
+ )
1325
+ _response_json = _response.json()
1326
+ except JSONDecodeError:
1327
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1328
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1329
+
1330
+ async def update_evaluation_scenario_router(
1331
+ self,
1332
+ evaluation_id: str,
1333
+ evaluation_scenario_id: str,
1334
+ evaluation_type: EvaluationType,
1335
+ *,
1336
+ vote: typing.Optional[str] = OMIT,
1337
+ score: typing.Optional[Score] = OMIT,
1338
+ correct_answer: typing.Optional[str] = OMIT,
1339
+ outputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]] = OMIT,
1340
+ inputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]] = OMIT,
1341
+ is_pinned: typing.Optional[bool] = OMIT,
1342
+ note: typing.Optional[str] = OMIT,
1343
+ request_options: typing.Optional[RequestOptions] = None,
1344
+ ) -> typing.Optional[typing.Any]:
1345
+ """
1346
+ Updates an evaluation scenario's vote or score based on its type.
1347
+
1348
+ Raises:
1349
+ HTTPException: If update fails or unauthorized.
1350
+
1351
+ Returns:
1352
+ None: 204 No Content status code upon successful update.
1353
+
1354
+ Parameters
1355
+ ----------
1356
+ evaluation_id : str
1357
+
1358
+ evaluation_scenario_id : str
1359
+
1360
+ evaluation_type : EvaluationType
1361
+
1362
+ vote : typing.Optional[str]
1363
+
1364
+ score : typing.Optional[Score]
1365
+
1366
+ correct_answer : typing.Optional[str]
1367
+
1368
+ outputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]]
1369
+
1370
+ inputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]]
1371
+
1372
+ is_pinned : typing.Optional[bool]
1373
+
1374
+ note : typing.Optional[str]
1375
+
1376
+ request_options : typing.Optional[RequestOptions]
1377
+ Request-specific configuration.
1378
+
1379
+ Returns
1380
+ -------
1381
+ typing.Optional[typing.Any]
1382
+ Successful Response
1383
+
1384
+ Examples
1385
+ --------
1386
+ import asyncio
1387
+
1388
+ from agenta import AsyncAgentaApi
1389
+
1390
+ client = AsyncAgentaApi(
1391
+ api_key="YOUR_API_KEY",
1392
+ base_url="https://yourhost.com/path/to/api",
1393
+ )
1394
+
1395
+
1396
+ async def main() -> None:
1397
+ await client.human_evaluations.update_evaluation_scenario_router(
1398
+ evaluation_id="evaluation_id",
1399
+ evaluation_scenario_id="evaluation_scenario_id",
1400
+ evaluation_type="human_a_b_testing",
1401
+ )
1402
+
1403
+
1404
+ asyncio.run(main())
1405
+ """
1406
+ _response = await self._client_wrapper.httpx_client.request(
1407
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/{jsonable_encoder(evaluation_type)}",
1408
+ method="PUT",
1409
+ json={
1410
+ "vote": vote,
1411
+ "score": convert_and_respect_annotation_metadata(
1412
+ object_=score, annotation=Score, direction="write"
1413
+ ),
1414
+ "correct_answer": correct_answer,
1415
+ "outputs": convert_and_respect_annotation_metadata(
1416
+ object_=outputs,
1417
+ annotation=typing.Sequence[HumanEvaluationScenarioOutput],
1418
+ direction="write",
1419
+ ),
1420
+ "inputs": convert_and_respect_annotation_metadata(
1421
+ object_=inputs,
1422
+ annotation=typing.Sequence[HumanEvaluationScenarioInput],
1423
+ direction="write",
1424
+ ),
1425
+ "is_pinned": is_pinned,
1426
+ "note": note,
1427
+ },
1428
+ headers={
1429
+ "content-type": "application/json",
1430
+ },
1431
+ request_options=request_options,
1432
+ omit=OMIT,
1433
+ )
1434
+ try:
1435
+ if 200 <= _response.status_code < 300:
1436
+ return typing.cast(
1437
+ typing.Optional[typing.Any],
1438
+ parse_obj_as(
1439
+ type_=typing.Optional[typing.Any], # type: ignore
1440
+ object_=_response.json(),
1441
+ ),
1442
+ )
1443
+ if _response.status_code == 422:
1444
+ raise UnprocessableEntityError(
1445
+ typing.cast(
1446
+ HttpValidationError,
1447
+ parse_obj_as(
1448
+ type_=HttpValidationError, # type: ignore
1449
+ object_=_response.json(),
1450
+ ),
1451
+ )
1452
+ )
1453
+ _response_json = _response.json()
1454
+ except JSONDecodeError:
1455
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1456
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1457
+
1458
+ async def get_evaluation_scenario_score_router(
1459
+ self,
1460
+ evaluation_scenario_id: str,
1461
+ *,
1462
+ request_options: typing.Optional[RequestOptions] = None,
1463
+ ) -> typing.Dict[str, str]:
1464
+ """
1465
+ Fetch the score of a specific evaluation scenario.
1466
+
1467
+ Args:
1468
+ evaluation_scenario_id: The ID of the evaluation scenario to fetch.
1469
+ stoken_session: Session data, verified by `verify_session`.
1470
+
1471
+ Returns:
1472
+ Dictionary containing the scenario ID and its score.
1473
+
1474
+ Parameters
1475
+ ----------
1476
+ evaluation_scenario_id : str
1477
+
1478
+ request_options : typing.Optional[RequestOptions]
1479
+ Request-specific configuration.
1480
+
1481
+ Returns
1482
+ -------
1483
+ typing.Dict[str, str]
1484
+ Successful Response
1485
+
1486
+ Examples
1487
+ --------
1488
+ import asyncio
1489
+
1490
+ from agenta import AsyncAgentaApi
1491
+
1492
+ client = AsyncAgentaApi(
1493
+ api_key="YOUR_API_KEY",
1494
+ base_url="https://yourhost.com/path/to/api",
1495
+ )
1496
+
1497
+
1498
+ async def main() -> None:
1499
+ await client.human_evaluations.get_evaluation_scenario_score_router(
1500
+ evaluation_scenario_id="evaluation_scenario_id",
1501
+ )
1502
+
1503
+
1504
+ asyncio.run(main())
1505
+ """
1506
+ _response = await self._client_wrapper.httpx_client.request(
1507
+ f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
1508
+ method="GET",
1509
+ request_options=request_options,
1510
+ )
1511
+ try:
1512
+ if 200 <= _response.status_code < 300:
1513
+ return typing.cast(
1514
+ typing.Dict[str, str],
1515
+ parse_obj_as(
1516
+ type_=typing.Dict[str, str], # type: ignore
1517
+ object_=_response.json(),
1518
+ ),
1519
+ )
1520
+ if _response.status_code == 422:
1521
+ raise UnprocessableEntityError(
1522
+ typing.cast(
1523
+ HttpValidationError,
1524
+ parse_obj_as(
1525
+ type_=HttpValidationError, # type: ignore
1526
+ object_=_response.json(),
1527
+ ),
1528
+ )
1529
+ )
1530
+ _response_json = _response.json()
1531
+ except JSONDecodeError:
1532
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1533
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1534
+
1535
+ async def update_evaluation_scenario_score_router(
1536
+ self,
1537
+ evaluation_scenario_id: str,
1538
+ *,
1539
+ score: float,
1540
+ request_options: typing.Optional[RequestOptions] = None,
1541
+ ) -> typing.Optional[typing.Any]:
1542
+ """
1543
+ Updates the score of an evaluation scenario.
1544
+
1545
+ Raises:
1546
+ HTTPException: Server error if the evaluation update fails.
1547
+
1548
+ Returns:
1549
+ None: 204 No Content status code upon successful update.
1550
+
1551
+ Parameters
1552
+ ----------
1553
+ evaluation_scenario_id : str
1554
+
1555
+ score : float
1556
+
1557
+ request_options : typing.Optional[RequestOptions]
1558
+ Request-specific configuration.
1559
+
1560
+ Returns
1561
+ -------
1562
+ typing.Optional[typing.Any]
1563
+ Successful Response
1564
+
1565
+ Examples
1566
+ --------
1567
+ import asyncio
1568
+
1569
+ from agenta import AsyncAgentaApi
1570
+
1571
+ client = AsyncAgentaApi(
1572
+ api_key="YOUR_API_KEY",
1573
+ base_url="https://yourhost.com/path/to/api",
1574
+ )
1575
+
1576
+
1577
+ async def main() -> None:
1578
+ await client.human_evaluations.update_evaluation_scenario_score_router(
1579
+ evaluation_scenario_id="evaluation_scenario_id",
1580
+ score=1.1,
1581
+ )
1582
+
1583
+
1584
+ asyncio.run(main())
1585
+ """
1586
+ _response = await self._client_wrapper.httpx_client.request(
1587
+ f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
1588
+ method="PUT",
1589
+ json={
1590
+ "score": score,
1591
+ },
1592
+ headers={
1593
+ "content-type": "application/json",
1594
+ },
1595
+ request_options=request_options,
1596
+ omit=OMIT,
1597
+ )
1598
+ try:
1599
+ if 200 <= _response.status_code < 300:
1600
+ return typing.cast(
1601
+ typing.Optional[typing.Any],
1602
+ parse_obj_as(
1603
+ type_=typing.Optional[typing.Any], # type: ignore
1604
+ object_=_response.json(),
1605
+ ),
1606
+ )
1607
+ if _response.status_code == 422:
1608
+ raise UnprocessableEntityError(
1609
+ typing.cast(
1610
+ HttpValidationError,
1611
+ parse_obj_as(
1612
+ type_=HttpValidationError, # type: ignore
1613
+ object_=_response.json(),
1614
+ ),
1615
+ )
1616
+ )
1617
+ _response_json = _response.json()
1618
+ except JSONDecodeError:
1619
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1620
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1621
+
1622
+ async def fetch_results(
1623
+ self,
1624
+ evaluation_id: str,
1625
+ *,
1626
+ request_options: typing.Optional[RequestOptions] = None,
1627
+ ) -> typing.Optional[typing.Any]:
1628
+ """
1629
+ Fetch all the results for one the comparison table
1630
+
1631
+ Arguments:
1632
+ evaluation_id -- _description_
1633
+
1634
+ Returns:
1635
+ _description_
1636
+
1637
+ Parameters
1638
+ ----------
1639
+ evaluation_id : str
1640
+
1641
+ request_options : typing.Optional[RequestOptions]
1642
+ Request-specific configuration.
1643
+
1644
+ Returns
1645
+ -------
1646
+ typing.Optional[typing.Any]
1647
+ Successful Response
1648
+
1649
+ Examples
1650
+ --------
1651
+ import asyncio
1652
+
1653
+ from agenta import AsyncAgentaApi
1654
+
1655
+ client = AsyncAgentaApi(
1656
+ api_key="YOUR_API_KEY",
1657
+ base_url="https://yourhost.com/path/to/api",
1658
+ )
1659
+
1660
+
1661
+ async def main() -> None:
1662
+ await client.human_evaluations.fetch_results(
1663
+ evaluation_id="evaluation_id",
1664
+ )
1665
+
1666
+
1667
+ asyncio.run(main())
1668
+ """
1669
+ _response = await self._client_wrapper.httpx_client.request(
1670
+ f"human-evaluations/{jsonable_encoder(evaluation_id)}/results",
1671
+ method="GET",
1672
+ request_options=request_options,
1673
+ )
1674
+ try:
1675
+ if 200 <= _response.status_code < 300:
1676
+ return typing.cast(
1677
+ typing.Optional[typing.Any],
1678
+ parse_obj_as(
1679
+ type_=typing.Optional[typing.Any], # type: ignore
1680
+ object_=_response.json(),
1681
+ ),
1682
+ )
1683
+ if _response.status_code == 422:
1684
+ raise UnprocessableEntityError(
1685
+ typing.cast(
1686
+ HttpValidationError,
1687
+ parse_obj_as(
1688
+ type_=HttpValidationError, # type: ignore
1689
+ object_=_response.json(),
1690
+ ),
1691
+ )
1692
+ )
1693
+ _response_json = _response.json()
1694
+ except JSONDecodeError:
1695
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1696
+ raise ApiError(status_code=_response.status_code, body=_response_json)