agenta 0.32.0a1__py3-none-any.whl → 0.33.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.
Files changed (80) hide show
  1. agenta/__init__.py +2 -0
  2. agenta/client/backend/__init__.py +39 -31
  3. agenta/client/backend/admin/__init__.py +1 -0
  4. agenta/client/backend/admin/client.py +576 -0
  5. agenta/client/backend/apps/client.py +450 -68
  6. agenta/client/backend/bases/client.py +10 -10
  7. agenta/client/backend/client.py +112 -122
  8. agenta/client/backend/containers/client.py +70 -28
  9. agenta/client/backend/core/http_client.py +3 -3
  10. agenta/client/backend/environments/client.py +8 -8
  11. agenta/client/backend/evaluations/client.py +46 -52
  12. agenta/client/backend/evaluators/client.py +32 -32
  13. agenta/client/backend/human_evaluations/__init__.py +1 -0
  14. agenta/client/backend/human_evaluations/client.py +1692 -0
  15. agenta/client/backend/observability/__init__.py +4 -0
  16. agenta/client/backend/observability/client.py +221 -744
  17. agenta/client/backend/testsets/client.py +38 -202
  18. agenta/client/backend/types/__init__.py +34 -28
  19. agenta/client/backend/types/account_response.py +24 -0
  20. agenta/client/backend/types/app_variant_revision.py +2 -1
  21. agenta/client/backend/types/{create_trace_response.py → delete_evaluation.py} +2 -3
  22. agenta/client/backend/types/{evaluation_scenario_score_update.py → legacy_scope_request.py} +2 -2
  23. agenta/client/backend/types/legacy_scopes_response.py +29 -0
  24. agenta/client/backend/types/{human_evaluation_update.py → legacy_user_request.py} +4 -4
  25. agenta/client/backend/types/{span_variant.py → legacy_user_response.py} +2 -4
  26. agenta/client/backend/types/organization_membership_request.py +25 -0
  27. agenta/client/backend/types/organization_request.py +23 -0
  28. agenta/client/backend/types/permission.py +4 -0
  29. agenta/client/backend/types/{llm_tokens.py → project_membership_request.py} +8 -5
  30. agenta/client/backend/types/project_request.py +26 -0
  31. agenta/client/backend/types/project_scope.py +29 -0
  32. agenta/client/backend/types/provider_kind.py +1 -1
  33. agenta/client/backend/types/reference.py +22 -0
  34. agenta/client/backend/types/role.py +15 -0
  35. agenta/client/backend/types/scopes_response_model.py +22 -0
  36. agenta/client/backend/types/score.py +1 -1
  37. agenta/client/backend/types/secret_response_dto.py +2 -2
  38. agenta/client/backend/types/user_request.py +22 -0
  39. agenta/client/backend/types/workspace_membership_request.py +26 -0
  40. agenta/client/backend/types/workspace_request.py +25 -0
  41. agenta/client/backend/variants/client.py +208 -42
  42. agenta/client/backend/vault/client.py +11 -9
  43. agenta/sdk/__init__.py +3 -0
  44. agenta/sdk/agenta_init.py +3 -1
  45. agenta/sdk/assets.py +4 -4
  46. agenta/sdk/decorators/routing.py +129 -23
  47. agenta/sdk/decorators/tracing.py +16 -4
  48. agenta/sdk/litellm/litellm.py +44 -8
  49. agenta/sdk/litellm/mockllm.py +2 -2
  50. agenta/sdk/litellm/mocks/__init__.py +9 -3
  51. agenta/sdk/managers/apps.py +64 -0
  52. agenta/sdk/managers/shared.py +2 -2
  53. agenta/sdk/middleware/auth.py +156 -53
  54. agenta/sdk/middleware/config.py +28 -16
  55. agenta/sdk/middleware/inline.py +1 -1
  56. agenta/sdk/middleware/mock.py +1 -1
  57. agenta/sdk/middleware/otel.py +1 -1
  58. agenta/sdk/middleware/vault.py +1 -1
  59. agenta/sdk/tracing/exporters.py +0 -1
  60. agenta/sdk/tracing/inline.py +26 -30
  61. agenta/sdk/types.py +12 -9
  62. {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/METADATA +23 -20
  63. {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/RECORD +69 -63
  64. agenta/client/backend/observability_v_1/__init__.py +0 -5
  65. agenta/client/backend/observability_v_1/client.py +0 -763
  66. agenta/client/backend/types/create_span.py +0 -45
  67. agenta/client/backend/types/human_evaluation_scenario_update.py +0 -30
  68. agenta/client/backend/types/new_human_evaluation.py +0 -27
  69. agenta/client/backend/types/outputs.py +0 -5
  70. agenta/client/backend/types/span.py +0 -42
  71. agenta/client/backend/types/span_detail.py +0 -44
  72. agenta/client/backend/types/span_status_code.py +0 -5
  73. agenta/client/backend/types/trace_detail.py +0 -44
  74. agenta/client/backend/types/with_pagination.py +0 -26
  75. /agenta/client/backend/{observability_v_1 → observability}/types/__init__.py +0 -0
  76. /agenta/client/backend/{observability_v_1 → observability}/types/format.py +0 -0
  77. /agenta/client/backend/{observability_v_1 → observability}/types/query_analytics_response.py +0 -0
  78. /agenta/client/backend/{observability_v_1 → observability}/types/query_traces_response.py +0 -0
  79. {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/WHEEL +0 -0
  80. {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/entry_points.txt +0 -0
@@ -32,11 +32,11 @@ class AppsClient:
32
32
  Retrieve a list of app variants for a given app ID.
33
33
 
34
34
  Args:
35
- app_id (str): The ID of the app to retrieve variants for.
36
- stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
35
+ app_id (str): The ID of the app to retrieve variants for.
36
+ stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
37
37
 
38
38
  Returns:
39
- List[AppVariantResponse]: A list of app variants for the given app ID.
39
+ List[AppVariantResponse]: A list of app variants for the given app ID.
40
40
 
41
41
  Parameters
42
42
  ----------
@@ -102,15 +102,15 @@ class AppsClient:
102
102
  Retrieve the app variant based on the provided app_id and environment.
103
103
 
104
104
  Args:
105
- app_id (str): The ID of the app to retrieve the variant for.
106
- environment (str): The environment of the app variant to retrieve.
107
- stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
105
+ app_id (str): The ID of the app to retrieve the variant for.
106
+ environment (str): The environment of the app variant to retrieve.
107
+ stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
108
108
 
109
109
  Raises:
110
- HTTPException: If the app variant is not found (status_code=500), or if a ValueError is raised (status_code=400), or if any other exception is raised (status_code=500).
110
+ HTTPException: If the app variant is not found (status_code=500), or if a ValueError is raised (status_code=400), or if any other exception is raised (status_code=500).
111
111
 
112
112
  Returns:
113
- AppVariantResponse: The retrieved app variant.
113
+ AppVariantResponse: The retrieved app variant.
114
114
 
115
115
  Parameters
116
116
  ----------
@@ -182,14 +182,14 @@ class AppsClient:
182
182
  Retrieve a list of apps filtered by app_name.
183
183
 
184
184
  Args:
185
- app_name (Optional[str]): The name of the app to filter by.
186
- stoken_session (SessionContainer): The session container.
185
+ app_name (Optional[str]): The name of the app to filter by.
186
+ stoken_session (SessionContainer): The session container.
187
187
 
188
188
  Returns:
189
- List[App]: A list of apps filtered by app_name.
189
+ List[App]: A list of apps filtered by app_name.
190
190
 
191
191
  Raises:
192
- HTTPException: If there was an error retrieving the list of apps.
192
+ HTTPException: If there was an error retrieving the list of apps.
193
193
 
194
194
  Parameters
195
195
  ----------
@@ -249,6 +249,7 @@ class AppsClient:
249
249
  self,
250
250
  *,
251
251
  app_name: str,
252
+ template_key: typing.Optional[str] = OMIT,
252
253
  project_id: typing.Optional[str] = OMIT,
253
254
  workspace_id: typing.Optional[str] = OMIT,
254
255
  organization_id: typing.Optional[str] = OMIT,
@@ -258,19 +259,21 @@ class AppsClient:
258
259
  Create a new app for a user or organization.
259
260
 
260
261
  Args:
261
- payload (CreateApp): The payload containing the app name and organization ID (optional).
262
- stoken_session (SessionContainer): The session container containing the user's session token.
262
+ payload (CreateApp): The payload containing the app name and organization ID (optional).
263
+ stoken_session (SessionContainer): The session container containing the user's session token.
263
264
 
264
265
  Returns:
265
- CreateAppOutput: The output containing the newly created app's ID and name.
266
+ CreateAppOutput: The output containing the newly created app's ID and name.
266
267
 
267
268
  Raises:
268
- HTTPException: If there is an error creating the app or the user does not have permission to access the app.
269
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
269
270
 
270
271
  Parameters
271
272
  ----------
272
273
  app_name : str
273
274
 
275
+ template_key : typing.Optional[str]
276
+
274
277
  project_id : typing.Optional[str]
275
278
 
276
279
  workspace_id : typing.Optional[str]
@@ -302,6 +305,7 @@ class AppsClient:
302
305
  method="POST",
303
306
  json={
304
307
  "app_name": app_name,
308
+ "template_key": template_key,
305
309
  "project_id": project_id,
306
310
  "workspace_id": workspace_id,
307
311
  "organization_id": organization_id,
@@ -343,7 +347,7 @@ class AppsClient:
343
347
  Remove app, all its variant, containers and images
344
348
 
345
349
  Arguments:
346
- app -- App to remove
350
+ app -- App to remove
347
351
 
348
352
  Parameters
349
353
  ----------
@@ -409,15 +413,15 @@ class AppsClient:
409
413
  Update an app for a user or organization.
410
414
 
411
415
  Args:
412
- app_id (str): The ID of the app.
413
- payload (UpdateApp): The payload containing the app name.
414
- stoken_session (SessionContainer): The session container containing the user's session token.
416
+ app_id (str): The ID of the app.
417
+ payload (UpdateApp): The payload containing the app name.
418
+ stoken_session (SessionContainer): The session container containing the user's session token.
415
419
 
416
420
  Returns:
417
- UpdateAppOuput: The output containing the newly created app's ID and name.
421
+ UpdateAppOuput: The output containing the newly created app's ID and name.
418
422
 
419
423
  Raises:
420
- HTTPException: If there is an error creating the app or the user does not have permission to access the app.
424
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
421
425
 
422
426
  Parameters
423
427
  ----------
@@ -497,15 +501,14 @@ class AppsClient:
497
501
  Add a new variant to an app based on a Docker image.
498
502
 
499
503
  Args:
500
- app_id (str): The ID of the app to add the variant to.
501
- payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
502
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
504
+ app_id (str): The ID of the app to add the variant to.
505
+ payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
503
506
 
504
507
  Raises:
505
- HTTPException: If the feature flag is set to "demo" or if the image does not have a tag starting with the registry name (agenta-server) or if the image is not found or if the user does not have access to the app.
508
+ HTTPException: If the feature flag is set to "demo" or if the image does not have a tag starting with the registry name (agenta-server) or if the image is not found or if the user does not have access to the app.
506
509
 
507
510
  Returns:
508
- dict: The newly added variant.
511
+ dict: The newly added variant.
509
512
 
510
513
  Parameters
511
514
  ----------
@@ -584,6 +587,186 @@ class AppsClient:
584
587
  raise ApiError(status_code=_response.status_code, body=_response.text)
585
588
  raise ApiError(status_code=_response.status_code, body=_response_json)
586
589
 
590
+ def add_variant_from_url(
591
+ self,
592
+ app_id: str,
593
+ *,
594
+ variant_name: str,
595
+ url: str,
596
+ base_name: typing.Optional[str] = OMIT,
597
+ config_name: typing.Optional[str] = OMIT,
598
+ request_options: typing.Optional[RequestOptions] = None,
599
+ ) -> typing.Optional[typing.Any]:
600
+ """
601
+ Add a new variant to an app based on a URL.
602
+
603
+ Args:
604
+ app_id (str): The ID of the app to add the variant to.
605
+ payload (AddVariantFromURLPayload): The payload containing information about the variant to add.
606
+
607
+ Raises:
608
+ HTTPException: If the user does not have access to the app or if there is an error adding the variant.
609
+
610
+ Returns:
611
+ dict: The newly added variant.
612
+
613
+ Parameters
614
+ ----------
615
+ app_id : str
616
+
617
+ variant_name : str
618
+
619
+ url : str
620
+
621
+ base_name : typing.Optional[str]
622
+
623
+ config_name : typing.Optional[str]
624
+
625
+ request_options : typing.Optional[RequestOptions]
626
+ Request-specific configuration.
627
+
628
+ Returns
629
+ -------
630
+ typing.Optional[typing.Any]
631
+ Successful Response
632
+
633
+ Examples
634
+ --------
635
+ from agenta import AgentaApi
636
+
637
+ client = AgentaApi(
638
+ api_key="YOUR_API_KEY",
639
+ base_url="https://yourhost.com/path/to/api",
640
+ )
641
+ client.apps.add_variant_from_url(
642
+ app_id="app_id",
643
+ variant_name="variant_name",
644
+ url="url",
645
+ )
646
+ """
647
+ _response = self._client_wrapper.httpx_client.request(
648
+ f"apps/{jsonable_encoder(app_id)}/variant/from-service",
649
+ method="POST",
650
+ json={
651
+ "variant_name": variant_name,
652
+ "url": url,
653
+ "base_name": base_name,
654
+ "config_name": config_name,
655
+ },
656
+ headers={
657
+ "content-type": "application/json",
658
+ },
659
+ request_options=request_options,
660
+ omit=OMIT,
661
+ )
662
+ try:
663
+ if 200 <= _response.status_code < 300:
664
+ return typing.cast(
665
+ typing.Optional[typing.Any],
666
+ parse_obj_as(
667
+ type_=typing.Optional[typing.Any], # type: ignore
668
+ object_=_response.json(),
669
+ ),
670
+ )
671
+ if _response.status_code == 422:
672
+ raise UnprocessableEntityError(
673
+ typing.cast(
674
+ HttpValidationError,
675
+ parse_obj_as(
676
+ type_=HttpValidationError, # type: ignore
677
+ object_=_response.json(),
678
+ ),
679
+ )
680
+ )
681
+ _response_json = _response.json()
682
+ except JSONDecodeError:
683
+ raise ApiError(status_code=_response.status_code, body=_response.text)
684
+ raise ApiError(status_code=_response.status_code, body=_response_json)
685
+
686
+ def add_variant_from_key(
687
+ self,
688
+ app_id: str,
689
+ *,
690
+ variant_name: str,
691
+ key: str,
692
+ base_name: typing.Optional[str] = OMIT,
693
+ config_name: typing.Optional[str] = OMIT,
694
+ request_options: typing.Optional[RequestOptions] = None,
695
+ ) -> typing.Optional[typing.Any]:
696
+ """
697
+ Parameters
698
+ ----------
699
+ app_id : str
700
+
701
+ variant_name : str
702
+
703
+ key : str
704
+
705
+ base_name : typing.Optional[str]
706
+
707
+ config_name : typing.Optional[str]
708
+
709
+ request_options : typing.Optional[RequestOptions]
710
+ Request-specific configuration.
711
+
712
+ Returns
713
+ -------
714
+ typing.Optional[typing.Any]
715
+ Successful Response
716
+
717
+ Examples
718
+ --------
719
+ from agenta import AgentaApi
720
+
721
+ client = AgentaApi(
722
+ api_key="YOUR_API_KEY",
723
+ base_url="https://yourhost.com/path/to/api",
724
+ )
725
+ client.apps.add_variant_from_key(
726
+ app_id="app_id",
727
+ variant_name="variant_name",
728
+ key="key",
729
+ )
730
+ """
731
+ _response = self._client_wrapper.httpx_client.request(
732
+ f"apps/{jsonable_encoder(app_id)}/variant/from-template",
733
+ method="POST",
734
+ json={
735
+ "variant_name": variant_name,
736
+ "key": key,
737
+ "base_name": base_name,
738
+ "config_name": config_name,
739
+ },
740
+ headers={
741
+ "content-type": "application/json",
742
+ },
743
+ request_options=request_options,
744
+ omit=OMIT,
745
+ )
746
+ try:
747
+ if 200 <= _response.status_code < 300:
748
+ return typing.cast(
749
+ typing.Optional[typing.Any],
750
+ parse_obj_as(
751
+ type_=typing.Optional[typing.Any], # type: ignore
752
+ object_=_response.json(),
753
+ ),
754
+ )
755
+ if _response.status_code == 422:
756
+ raise UnprocessableEntityError(
757
+ typing.cast(
758
+ HttpValidationError,
759
+ parse_obj_as(
760
+ type_=HttpValidationError, # type: ignore
761
+ object_=_response.json(),
762
+ ),
763
+ )
764
+ )
765
+ _response_json = _response.json()
766
+ except JSONDecodeError:
767
+ raise ApiError(status_code=_response.status_code, body=_response.text)
768
+ raise ApiError(status_code=_response.status_code, body=_response_json)
769
+
587
770
  def create_app_and_variant_from_template(
588
771
  self,
589
772
  *,
@@ -599,14 +782,14 @@ class AppsClient:
599
782
  Create an app and variant from a template.
600
783
 
601
784
  Args:
602
- payload (CreateAppVariant): The payload containing the app and variant information.
603
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
785
+ payload (CreateAppVariant): The payload containing the app and variant information.
786
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
604
787
 
605
788
  Raises:
606
- HTTPException: If the user has reached the app limit or if an app with the same name already exists.
789
+ HTTPException: If the user has reached the app limit or if an app with the same name already exists.
607
790
 
608
791
  Returns:
609
- AppVariantResponse: The output of the created app variant.
792
+ AppVariantResponse: The output of the created app variant.
610
793
 
611
794
  Parameters
612
795
  ----------
@@ -692,11 +875,11 @@ class AppsClient:
692
875
  Retrieve a list of environments for a given app ID.
693
876
 
694
877
  Args:
695
- app_id (str): The ID of the app to retrieve environments for.
696
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
878
+ app_id (str): The ID of the app to retrieve environments for.
879
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
697
880
 
698
881
  Returns:
699
- List[EnvironmentOutput]: A list of environment objects.
882
+ List[EnvironmentOutput]: A list of environment objects.
700
883
 
701
884
  Parameters
702
885
  ----------
@@ -827,11 +1010,11 @@ class AsyncAppsClient:
827
1010
  Retrieve a list of app variants for a given app ID.
828
1011
 
829
1012
  Args:
830
- app_id (str): The ID of the app to retrieve variants for.
831
- stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
1013
+ app_id (str): The ID of the app to retrieve variants for.
1014
+ stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
832
1015
 
833
1016
  Returns:
834
- List[AppVariantResponse]: A list of app variants for the given app ID.
1017
+ List[AppVariantResponse]: A list of app variants for the given app ID.
835
1018
 
836
1019
  Parameters
837
1020
  ----------
@@ -905,15 +1088,15 @@ class AsyncAppsClient:
905
1088
  Retrieve the app variant based on the provided app_id and environment.
906
1089
 
907
1090
  Args:
908
- app_id (str): The ID of the app to retrieve the variant for.
909
- environment (str): The environment of the app variant to retrieve.
910
- stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
1091
+ app_id (str): The ID of the app to retrieve the variant for.
1092
+ environment (str): The environment of the app variant to retrieve.
1093
+ stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
911
1094
 
912
1095
  Raises:
913
- HTTPException: If the app variant is not found (status_code=500), or if a ValueError is raised (status_code=400), or if any other exception is raised (status_code=500).
1096
+ HTTPException: If the app variant is not found (status_code=500), or if a ValueError is raised (status_code=400), or if any other exception is raised (status_code=500).
914
1097
 
915
1098
  Returns:
916
- AppVariantResponse: The retrieved app variant.
1099
+ AppVariantResponse: The retrieved app variant.
917
1100
 
918
1101
  Parameters
919
1102
  ----------
@@ -993,14 +1176,14 @@ class AsyncAppsClient:
993
1176
  Retrieve a list of apps filtered by app_name.
994
1177
 
995
1178
  Args:
996
- app_name (Optional[str]): The name of the app to filter by.
997
- stoken_session (SessionContainer): The session container.
1179
+ app_name (Optional[str]): The name of the app to filter by.
1180
+ stoken_session (SessionContainer): The session container.
998
1181
 
999
1182
  Returns:
1000
- List[App]: A list of apps filtered by app_name.
1183
+ List[App]: A list of apps filtered by app_name.
1001
1184
 
1002
1185
  Raises:
1003
- HTTPException: If there was an error retrieving the list of apps.
1186
+ HTTPException: If there was an error retrieving the list of apps.
1004
1187
 
1005
1188
  Parameters
1006
1189
  ----------
@@ -1068,6 +1251,7 @@ class AsyncAppsClient:
1068
1251
  self,
1069
1252
  *,
1070
1253
  app_name: str,
1254
+ template_key: typing.Optional[str] = OMIT,
1071
1255
  project_id: typing.Optional[str] = OMIT,
1072
1256
  workspace_id: typing.Optional[str] = OMIT,
1073
1257
  organization_id: typing.Optional[str] = OMIT,
@@ -1077,19 +1261,21 @@ class AsyncAppsClient:
1077
1261
  Create a new app for a user or organization.
1078
1262
 
1079
1263
  Args:
1080
- payload (CreateApp): The payload containing the app name and organization ID (optional).
1081
- stoken_session (SessionContainer): The session container containing the user's session token.
1264
+ payload (CreateApp): The payload containing the app name and organization ID (optional).
1265
+ stoken_session (SessionContainer): The session container containing the user's session token.
1082
1266
 
1083
1267
  Returns:
1084
- CreateAppOutput: The output containing the newly created app's ID and name.
1268
+ CreateAppOutput: The output containing the newly created app's ID and name.
1085
1269
 
1086
1270
  Raises:
1087
- HTTPException: If there is an error creating the app or the user does not have permission to access the app.
1271
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
1088
1272
 
1089
1273
  Parameters
1090
1274
  ----------
1091
1275
  app_name : str
1092
1276
 
1277
+ template_key : typing.Optional[str]
1278
+
1093
1279
  project_id : typing.Optional[str]
1094
1280
 
1095
1281
  workspace_id : typing.Optional[str]
@@ -1129,6 +1315,7 @@ class AsyncAppsClient:
1129
1315
  method="POST",
1130
1316
  json={
1131
1317
  "app_name": app_name,
1318
+ "template_key": template_key,
1132
1319
  "project_id": project_id,
1133
1320
  "workspace_id": workspace_id,
1134
1321
  "organization_id": organization_id,
@@ -1170,7 +1357,7 @@ class AsyncAppsClient:
1170
1357
  Remove app, all its variant, containers and images
1171
1358
 
1172
1359
  Arguments:
1173
- app -- App to remove
1360
+ app -- App to remove
1174
1361
 
1175
1362
  Parameters
1176
1363
  ----------
@@ -1244,15 +1431,15 @@ class AsyncAppsClient:
1244
1431
  Update an app for a user or organization.
1245
1432
 
1246
1433
  Args:
1247
- app_id (str): The ID of the app.
1248
- payload (UpdateApp): The payload containing the app name.
1249
- stoken_session (SessionContainer): The session container containing the user's session token.
1434
+ app_id (str): The ID of the app.
1435
+ payload (UpdateApp): The payload containing the app name.
1436
+ stoken_session (SessionContainer): The session container containing the user's session token.
1250
1437
 
1251
1438
  Returns:
1252
- UpdateAppOuput: The output containing the newly created app's ID and name.
1439
+ UpdateAppOuput: The output containing the newly created app's ID and name.
1253
1440
 
1254
1441
  Raises:
1255
- HTTPException: If there is an error creating the app or the user does not have permission to access the app.
1442
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
1256
1443
 
1257
1444
  Parameters
1258
1445
  ----------
@@ -1340,15 +1527,14 @@ class AsyncAppsClient:
1340
1527
  Add a new variant to an app based on a Docker image.
1341
1528
 
1342
1529
  Args:
1343
- app_id (str): The ID of the app to add the variant to.
1344
- payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
1345
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1530
+ app_id (str): The ID of the app to add the variant to.
1531
+ payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
1346
1532
 
1347
1533
  Raises:
1348
- HTTPException: If the feature flag is set to "demo" or if the image does not have a tag starting with the registry name (agenta-server) or if the image is not found or if the user does not have access to the app.
1534
+ HTTPException: If the feature flag is set to "demo" or if the image does not have a tag starting with the registry name (agenta-server) or if the image is not found or if the user does not have access to the app.
1349
1535
 
1350
1536
  Returns:
1351
- dict: The newly added variant.
1537
+ dict: The newly added variant.
1352
1538
 
1353
1539
  Parameters
1354
1540
  ----------
@@ -1435,6 +1621,202 @@ class AsyncAppsClient:
1435
1621
  raise ApiError(status_code=_response.status_code, body=_response.text)
1436
1622
  raise ApiError(status_code=_response.status_code, body=_response_json)
1437
1623
 
1624
+ async def add_variant_from_url(
1625
+ self,
1626
+ app_id: str,
1627
+ *,
1628
+ variant_name: str,
1629
+ url: str,
1630
+ base_name: typing.Optional[str] = OMIT,
1631
+ config_name: typing.Optional[str] = OMIT,
1632
+ request_options: typing.Optional[RequestOptions] = None,
1633
+ ) -> typing.Optional[typing.Any]:
1634
+ """
1635
+ Add a new variant to an app based on a URL.
1636
+
1637
+ Args:
1638
+ app_id (str): The ID of the app to add the variant to.
1639
+ payload (AddVariantFromURLPayload): The payload containing information about the variant to add.
1640
+
1641
+ Raises:
1642
+ HTTPException: If the user does not have access to the app or if there is an error adding the variant.
1643
+
1644
+ Returns:
1645
+ dict: The newly added variant.
1646
+
1647
+ Parameters
1648
+ ----------
1649
+ app_id : str
1650
+
1651
+ variant_name : str
1652
+
1653
+ url : str
1654
+
1655
+ base_name : typing.Optional[str]
1656
+
1657
+ config_name : typing.Optional[str]
1658
+
1659
+ request_options : typing.Optional[RequestOptions]
1660
+ Request-specific configuration.
1661
+
1662
+ Returns
1663
+ -------
1664
+ typing.Optional[typing.Any]
1665
+ Successful Response
1666
+
1667
+ Examples
1668
+ --------
1669
+ import asyncio
1670
+
1671
+ from agenta import AsyncAgentaApi
1672
+
1673
+ client = AsyncAgentaApi(
1674
+ api_key="YOUR_API_KEY",
1675
+ base_url="https://yourhost.com/path/to/api",
1676
+ )
1677
+
1678
+
1679
+ async def main() -> None:
1680
+ await client.apps.add_variant_from_url(
1681
+ app_id="app_id",
1682
+ variant_name="variant_name",
1683
+ url="url",
1684
+ )
1685
+
1686
+
1687
+ asyncio.run(main())
1688
+ """
1689
+ _response = await self._client_wrapper.httpx_client.request(
1690
+ f"apps/{jsonable_encoder(app_id)}/variant/from-service",
1691
+ method="POST",
1692
+ json={
1693
+ "variant_name": variant_name,
1694
+ "url": url,
1695
+ "base_name": base_name,
1696
+ "config_name": config_name,
1697
+ },
1698
+ headers={
1699
+ "content-type": "application/json",
1700
+ },
1701
+ request_options=request_options,
1702
+ omit=OMIT,
1703
+ )
1704
+ try:
1705
+ if 200 <= _response.status_code < 300:
1706
+ return typing.cast(
1707
+ typing.Optional[typing.Any],
1708
+ parse_obj_as(
1709
+ type_=typing.Optional[typing.Any], # type: ignore
1710
+ object_=_response.json(),
1711
+ ),
1712
+ )
1713
+ if _response.status_code == 422:
1714
+ raise UnprocessableEntityError(
1715
+ typing.cast(
1716
+ HttpValidationError,
1717
+ parse_obj_as(
1718
+ type_=HttpValidationError, # type: ignore
1719
+ object_=_response.json(),
1720
+ ),
1721
+ )
1722
+ )
1723
+ _response_json = _response.json()
1724
+ except JSONDecodeError:
1725
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1726
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1727
+
1728
+ async def add_variant_from_key(
1729
+ self,
1730
+ app_id: str,
1731
+ *,
1732
+ variant_name: str,
1733
+ key: str,
1734
+ base_name: typing.Optional[str] = OMIT,
1735
+ config_name: typing.Optional[str] = OMIT,
1736
+ request_options: typing.Optional[RequestOptions] = None,
1737
+ ) -> typing.Optional[typing.Any]:
1738
+ """
1739
+ Parameters
1740
+ ----------
1741
+ app_id : str
1742
+
1743
+ variant_name : str
1744
+
1745
+ key : str
1746
+
1747
+ base_name : typing.Optional[str]
1748
+
1749
+ config_name : typing.Optional[str]
1750
+
1751
+ request_options : typing.Optional[RequestOptions]
1752
+ Request-specific configuration.
1753
+
1754
+ Returns
1755
+ -------
1756
+ typing.Optional[typing.Any]
1757
+ Successful Response
1758
+
1759
+ Examples
1760
+ --------
1761
+ import asyncio
1762
+
1763
+ from agenta import AsyncAgentaApi
1764
+
1765
+ client = AsyncAgentaApi(
1766
+ api_key="YOUR_API_KEY",
1767
+ base_url="https://yourhost.com/path/to/api",
1768
+ )
1769
+
1770
+
1771
+ async def main() -> None:
1772
+ await client.apps.add_variant_from_key(
1773
+ app_id="app_id",
1774
+ variant_name="variant_name",
1775
+ key="key",
1776
+ )
1777
+
1778
+
1779
+ asyncio.run(main())
1780
+ """
1781
+ _response = await self._client_wrapper.httpx_client.request(
1782
+ f"apps/{jsonable_encoder(app_id)}/variant/from-template",
1783
+ method="POST",
1784
+ json={
1785
+ "variant_name": variant_name,
1786
+ "key": key,
1787
+ "base_name": base_name,
1788
+ "config_name": config_name,
1789
+ },
1790
+ headers={
1791
+ "content-type": "application/json",
1792
+ },
1793
+ request_options=request_options,
1794
+ omit=OMIT,
1795
+ )
1796
+ try:
1797
+ if 200 <= _response.status_code < 300:
1798
+ return typing.cast(
1799
+ typing.Optional[typing.Any],
1800
+ parse_obj_as(
1801
+ type_=typing.Optional[typing.Any], # type: ignore
1802
+ object_=_response.json(),
1803
+ ),
1804
+ )
1805
+ if _response.status_code == 422:
1806
+ raise UnprocessableEntityError(
1807
+ typing.cast(
1808
+ HttpValidationError,
1809
+ parse_obj_as(
1810
+ type_=HttpValidationError, # type: ignore
1811
+ object_=_response.json(),
1812
+ ),
1813
+ )
1814
+ )
1815
+ _response_json = _response.json()
1816
+ except JSONDecodeError:
1817
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1818
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1819
+
1438
1820
  async def create_app_and_variant_from_template(
1439
1821
  self,
1440
1822
  *,
@@ -1450,14 +1832,14 @@ class AsyncAppsClient:
1450
1832
  Create an app and variant from a template.
1451
1833
 
1452
1834
  Args:
1453
- payload (CreateAppVariant): The payload containing the app and variant information.
1454
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1835
+ payload (CreateAppVariant): The payload containing the app and variant information.
1836
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1455
1837
 
1456
1838
  Raises:
1457
- HTTPException: If the user has reached the app limit or if an app with the same name already exists.
1839
+ HTTPException: If the user has reached the app limit or if an app with the same name already exists.
1458
1840
 
1459
1841
  Returns:
1460
- AppVariantResponse: The output of the created app variant.
1842
+ AppVariantResponse: The output of the created app variant.
1461
1843
 
1462
1844
  Parameters
1463
1845
  ----------
@@ -1551,11 +1933,11 @@ class AsyncAppsClient:
1551
1933
  Retrieve a list of environments for a given app ID.
1552
1934
 
1553
1935
  Args:
1554
- app_id (str): The ID of the app to retrieve environments for.
1555
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1936
+ app_id (str): The ID of the app to retrieve environments for.
1937
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1556
1938
 
1557
1939
  Returns:
1558
- List[EnvironmentOutput]: A list of environment objects.
1940
+ List[EnvironmentOutput]: A list of environment objects.
1559
1941
 
1560
1942
  Parameters
1561
1943
  ----------