agenta 0.27.7a2__py3-none-any.whl → 0.28.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.
- agenta/cli/main.py +4 -51
- agenta/client/backend/apps/client.py +12 -58
- agenta/client/backend/evaluations/client.py +0 -11
- agenta/client/backend/testsets/client.py +8 -40
- agenta/sdk/agenta_init.py +4 -9
- agenta/sdk/decorators/routing.py +24 -42
- agenta/sdk/litellm/litellm.py +30 -75
- agenta/sdk/middleware/auth.py +9 -6
- agenta/sdk/tracing/context.py +6 -6
- agenta/sdk/tracing/inline.py +19 -11
- agenta/sdk/tracing/processors.py +1 -3
- agenta/sdk/tracing/tracing.py +1 -5
- agenta/sdk/utils/exceptions.py +15 -9
- agenta/sdk/utils/logging.py +5 -1
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/METADATA +1 -1
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/RECORD +18 -19
- agenta/sdk/utils/debug.py +0 -68
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/WHEEL +0 -0
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/entry_points.txt +0 -0
agenta/cli/main.py
CHANGED
|
@@ -80,16 +80,11 @@ def cli():
|
|
|
80
80
|
@click.command()
|
|
81
81
|
@click.option("--app-name", "--app_name", default=None)
|
|
82
82
|
@click.option("--backend-host", "backend_host", default=None)
|
|
83
|
-
|
|
84
|
-
"--organisation-name",
|
|
85
|
-
"organisation_name",
|
|
86
|
-
default=None,
|
|
87
|
-
help="The name of the organisation",
|
|
88
|
-
)
|
|
89
|
-
def init(app_name: str, backend_host: str, organisation_name: str):
|
|
90
|
-
init_option = "Blank App" if backend_host != "" and app_name != "" else ""
|
|
83
|
+
def init(app_name: str, backend_host: str):
|
|
91
84
|
"""Initialize a new Agenta app with the template files."""
|
|
92
85
|
|
|
86
|
+
init_option = "Blank App" if backend_host != "" and app_name != "" else ""
|
|
87
|
+
|
|
93
88
|
api_key = os.getenv("AGENTA_API_KEY")
|
|
94
89
|
|
|
95
90
|
if not app_name:
|
|
@@ -151,51 +146,9 @@ def init(app_name: str, backend_host: str, organisation_name: str):
|
|
|
151
146
|
api_key=api_key if where_question == "On agenta cloud" else "",
|
|
152
147
|
)
|
|
153
148
|
|
|
154
|
-
# list of user organizations
|
|
155
|
-
user_organizations = []
|
|
156
|
-
|
|
157
|
-
# validate the api key if it is provided
|
|
158
|
-
if where_question == "On agenta cloud":
|
|
159
|
-
try:
|
|
160
|
-
key_prefix = api_key.split(".")[0]
|
|
161
|
-
client.validate_api_key(key_prefix=key_prefix)
|
|
162
|
-
except Exception as ex:
|
|
163
|
-
click.echo(
|
|
164
|
-
click.style(
|
|
165
|
-
f"Error: Unable to validate API key.\nError: {ex}", fg="red"
|
|
166
|
-
)
|
|
167
|
-
)
|
|
168
|
-
sys.exit(1)
|
|
169
|
-
# Make request to fetch user organizations after api key validation
|
|
170
|
-
try:
|
|
171
|
-
organizations = client.list_organizations()
|
|
172
|
-
if len(organizations) >= 1:
|
|
173
|
-
user_organizations = organizations
|
|
174
|
-
except Exception as ex:
|
|
175
|
-
click.echo(click.style(f"Error: {ex}", fg="red"))
|
|
176
|
-
sys.exit(1)
|
|
177
|
-
|
|
178
|
-
organization = None
|
|
179
|
-
organization_choices = {}
|
|
180
|
-
if where_question == "On agenta cloud":
|
|
181
|
-
if not organisation_name:
|
|
182
|
-
organization_choices = {
|
|
183
|
-
f"{org.name}": org for org in user_organizations
|
|
184
|
-
}
|
|
185
|
-
which_organization = questionary.select(
|
|
186
|
-
"Which organization do you want to create the app for?",
|
|
187
|
-
choices=list(organization_choices.keys()),
|
|
188
|
-
).ask()
|
|
189
|
-
organisation_name = which_organization
|
|
190
|
-
|
|
191
|
-
organization = organization_choices.get(organisation_name)
|
|
192
|
-
|
|
193
149
|
# Get app_id after creating new app in the backend server
|
|
194
150
|
try:
|
|
195
|
-
app_id = client.apps.create_app(
|
|
196
|
-
app_name=app_name,
|
|
197
|
-
organization_id=organization.id if organization else None,
|
|
198
|
-
).app_id
|
|
151
|
+
app_id = client.apps.create_app(app_name=app_name).app_id
|
|
199
152
|
except Exception as ex:
|
|
200
153
|
click.echo(click.style(f"Error: {ex}", fg="red"))
|
|
201
154
|
sys.exit(1)
|
|
@@ -176,19 +176,17 @@ class AppsClient:
|
|
|
176
176
|
self,
|
|
177
177
|
*,
|
|
178
178
|
app_name: typing.Optional[str] = None,
|
|
179
|
-
workspace_id: typing.Optional[str] = None,
|
|
180
179
|
request_options: typing.Optional[RequestOptions] = None,
|
|
181
180
|
) -> typing.List[App]:
|
|
182
181
|
"""
|
|
183
|
-
Retrieve a list of apps filtered by app_name
|
|
182
|
+
Retrieve a list of apps filtered by app_name.
|
|
184
183
|
|
|
185
184
|
Args:
|
|
186
185
|
app_name (Optional[str]): The name of the app to filter by.
|
|
187
|
-
org_id (Optional[str]): The ID of the organization to filter by.
|
|
188
186
|
stoken_session (SessionContainer): The session container.
|
|
189
187
|
|
|
190
188
|
Returns:
|
|
191
|
-
List[App]: A list of apps filtered by app_name
|
|
189
|
+
List[App]: A list of apps filtered by app_name.
|
|
192
190
|
|
|
193
191
|
Raises:
|
|
194
192
|
HTTPException: If there was an error retrieving the list of apps.
|
|
@@ -197,8 +195,6 @@ class AppsClient:
|
|
|
197
195
|
----------
|
|
198
196
|
app_name : typing.Optional[str]
|
|
199
197
|
|
|
200
|
-
workspace_id : typing.Optional[str]
|
|
201
|
-
|
|
202
198
|
request_options : typing.Optional[RequestOptions]
|
|
203
199
|
Request-specific configuration.
|
|
204
200
|
|
|
@@ -220,10 +216,7 @@ class AppsClient:
|
|
|
220
216
|
_response = self._client_wrapper.httpx_client.request(
|
|
221
217
|
"apps",
|
|
222
218
|
method="GET",
|
|
223
|
-
params={
|
|
224
|
-
"app_name": app_name,
|
|
225
|
-
"workspace_id": workspace_id,
|
|
226
|
-
},
|
|
219
|
+
params={"app_name": app_name},
|
|
227
220
|
request_options=request_options,
|
|
228
221
|
)
|
|
229
222
|
try:
|
|
@@ -255,15 +248,13 @@ class AppsClient:
|
|
|
255
248
|
*,
|
|
256
249
|
app_name: str,
|
|
257
250
|
project_id: typing.Optional[str] = OMIT,
|
|
258
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
259
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
260
251
|
request_options: typing.Optional[RequestOptions] = None,
|
|
261
252
|
) -> CreateAppOutput:
|
|
262
253
|
"""
|
|
263
|
-
Create a new app for a user
|
|
254
|
+
Create a new app for a user.
|
|
264
255
|
|
|
265
256
|
Args:
|
|
266
|
-
payload (CreateApp): The payload containing the app name
|
|
257
|
+
payload (CreateApp): The payload containing the app name.
|
|
267
258
|
stoken_session (SessionContainer): The session container containing the user's session token.
|
|
268
259
|
|
|
269
260
|
Returns:
|
|
@@ -278,10 +269,6 @@ class AppsClient:
|
|
|
278
269
|
|
|
279
270
|
project_id : typing.Optional[str]
|
|
280
271
|
|
|
281
|
-
workspace_id : typing.Optional[str]
|
|
282
|
-
|
|
283
|
-
organization_id : typing.Optional[str]
|
|
284
|
-
|
|
285
272
|
request_options : typing.Optional[RequestOptions]
|
|
286
273
|
Request-specific configuration.
|
|
287
274
|
|
|
@@ -308,8 +295,6 @@ class AppsClient:
|
|
|
308
295
|
json={
|
|
309
296
|
"app_name": app_name,
|
|
310
297
|
"project_id": project_id,
|
|
311
|
-
"workspace_id": workspace_id,
|
|
312
|
-
"organization_id": organization_id,
|
|
313
298
|
},
|
|
314
299
|
request_options=request_options,
|
|
315
300
|
omit=OMIT,
|
|
@@ -408,7 +393,7 @@ class AppsClient:
|
|
|
408
393
|
request_options: typing.Optional[RequestOptions] = None,
|
|
409
394
|
) -> UpdateAppOutput:
|
|
410
395
|
"""
|
|
411
|
-
Update an app for a user
|
|
396
|
+
Update an app for a user.
|
|
412
397
|
|
|
413
398
|
Args:
|
|
414
399
|
app_id (str): The ID of the app.
|
|
@@ -587,8 +572,6 @@ class AppsClient:
|
|
|
587
572
|
template_id: str,
|
|
588
573
|
env_vars: typing.Dict[str, str],
|
|
589
574
|
project_id: typing.Optional[str] = OMIT,
|
|
590
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
591
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
592
575
|
request_options: typing.Optional[RequestOptions] = None,
|
|
593
576
|
) -> AppVariantResponse:
|
|
594
577
|
"""
|
|
@@ -614,10 +597,6 @@ class AppsClient:
|
|
|
614
597
|
|
|
615
598
|
project_id : typing.Optional[str]
|
|
616
599
|
|
|
617
|
-
workspace_id : typing.Optional[str]
|
|
618
|
-
|
|
619
|
-
organization_id : typing.Optional[str]
|
|
620
|
-
|
|
621
600
|
request_options : typing.Optional[RequestOptions]
|
|
622
601
|
Request-specific configuration.
|
|
623
602
|
|
|
@@ -647,9 +626,7 @@ class AppsClient:
|
|
|
647
626
|
"app_name": app_name,
|
|
648
627
|
"template_id": template_id,
|
|
649
628
|
"project_id": project_id,
|
|
650
|
-
"workspace_id": workspace_id,
|
|
651
629
|
"env_vars": env_vars,
|
|
652
|
-
"organization_id": organization_id,
|
|
653
630
|
},
|
|
654
631
|
request_options=request_options,
|
|
655
632
|
omit=OMIT,
|
|
@@ -980,19 +957,17 @@ class AsyncAppsClient:
|
|
|
980
957
|
self,
|
|
981
958
|
*,
|
|
982
959
|
app_name: typing.Optional[str] = None,
|
|
983
|
-
workspace_id: typing.Optional[str] = None,
|
|
984
960
|
request_options: typing.Optional[RequestOptions] = None,
|
|
985
961
|
) -> typing.List[App]:
|
|
986
962
|
"""
|
|
987
|
-
Retrieve a list of apps filtered by app_name
|
|
963
|
+
Retrieve a list of apps filtered by app_name.
|
|
988
964
|
|
|
989
965
|
Args:
|
|
990
966
|
app_name (Optional[str]): The name of the app to filter by.
|
|
991
|
-
org_id (Optional[str]): The ID of the organization to filter by.
|
|
992
967
|
stoken_session (SessionContainer): The session container.
|
|
993
968
|
|
|
994
969
|
Returns:
|
|
995
|
-
List[App]: A list of apps filtered by app_name
|
|
970
|
+
List[App]: A list of apps filtered by app_name.
|
|
996
971
|
|
|
997
972
|
Raises:
|
|
998
973
|
HTTPException: If there was an error retrieving the list of apps.
|
|
@@ -1001,8 +976,6 @@ class AsyncAppsClient:
|
|
|
1001
976
|
----------
|
|
1002
977
|
app_name : typing.Optional[str]
|
|
1003
978
|
|
|
1004
|
-
workspace_id : typing.Optional[str]
|
|
1005
|
-
|
|
1006
979
|
request_options : typing.Optional[RequestOptions]
|
|
1007
980
|
Request-specific configuration.
|
|
1008
981
|
|
|
@@ -1032,10 +1005,7 @@ class AsyncAppsClient:
|
|
|
1032
1005
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1033
1006
|
"apps",
|
|
1034
1007
|
method="GET",
|
|
1035
|
-
params={
|
|
1036
|
-
"app_name": app_name,
|
|
1037
|
-
"workspace_id": workspace_id,
|
|
1038
|
-
},
|
|
1008
|
+
params={"app_name": app_name},
|
|
1039
1009
|
request_options=request_options,
|
|
1040
1010
|
)
|
|
1041
1011
|
try:
|
|
@@ -1067,15 +1037,13 @@ class AsyncAppsClient:
|
|
|
1067
1037
|
*,
|
|
1068
1038
|
app_name: str,
|
|
1069
1039
|
project_id: typing.Optional[str] = OMIT,
|
|
1070
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
1071
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
1072
1040
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1073
1041
|
) -> CreateAppOutput:
|
|
1074
1042
|
"""
|
|
1075
|
-
Create a new app for a user
|
|
1043
|
+
Create a new app for a user.
|
|
1076
1044
|
|
|
1077
1045
|
Args:
|
|
1078
|
-
payload (CreateApp): The payload containing the app name
|
|
1046
|
+
payload (CreateApp): The payload containing the app name.
|
|
1079
1047
|
stoken_session (SessionContainer): The session container containing the user's session token.
|
|
1080
1048
|
|
|
1081
1049
|
Returns:
|
|
@@ -1090,10 +1058,6 @@ class AsyncAppsClient:
|
|
|
1090
1058
|
|
|
1091
1059
|
project_id : typing.Optional[str]
|
|
1092
1060
|
|
|
1093
|
-
workspace_id : typing.Optional[str]
|
|
1094
|
-
|
|
1095
|
-
organization_id : typing.Optional[str]
|
|
1096
|
-
|
|
1097
1061
|
request_options : typing.Optional[RequestOptions]
|
|
1098
1062
|
Request-specific configuration.
|
|
1099
1063
|
|
|
@@ -1128,8 +1092,6 @@ class AsyncAppsClient:
|
|
|
1128
1092
|
json={
|
|
1129
1093
|
"app_name": app_name,
|
|
1130
1094
|
"project_id": project_id,
|
|
1131
|
-
"workspace_id": workspace_id,
|
|
1132
|
-
"organization_id": organization_id,
|
|
1133
1095
|
},
|
|
1134
1096
|
request_options=request_options,
|
|
1135
1097
|
omit=OMIT,
|
|
@@ -1236,7 +1198,7 @@ class AsyncAppsClient:
|
|
|
1236
1198
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1237
1199
|
) -> UpdateAppOutput:
|
|
1238
1200
|
"""
|
|
1239
|
-
Update an app for a user
|
|
1201
|
+
Update an app for a user.
|
|
1240
1202
|
|
|
1241
1203
|
Args:
|
|
1242
1204
|
app_id (str): The ID of the app.
|
|
@@ -1431,8 +1393,6 @@ class AsyncAppsClient:
|
|
|
1431
1393
|
template_id: str,
|
|
1432
1394
|
env_vars: typing.Dict[str, str],
|
|
1433
1395
|
project_id: typing.Optional[str] = OMIT,
|
|
1434
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
1435
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
1436
1396
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1437
1397
|
) -> AppVariantResponse:
|
|
1438
1398
|
"""
|
|
@@ -1458,10 +1418,6 @@ class AsyncAppsClient:
|
|
|
1458
1418
|
|
|
1459
1419
|
project_id : typing.Optional[str]
|
|
1460
1420
|
|
|
1461
|
-
workspace_id : typing.Optional[str]
|
|
1462
|
-
|
|
1463
|
-
organization_id : typing.Optional[str]
|
|
1464
|
-
|
|
1465
1421
|
request_options : typing.Optional[RequestOptions]
|
|
1466
1422
|
Request-specific configuration.
|
|
1467
1423
|
|
|
@@ -1499,9 +1455,7 @@ class AsyncAppsClient:
|
|
|
1499
1455
|
"app_name": app_name,
|
|
1500
1456
|
"template_id": template_id,
|
|
1501
1457
|
"project_id": project_id,
|
|
1502
|
-
"workspace_id": workspace_id,
|
|
1503
1458
|
"env_vars": env_vars,
|
|
1504
|
-
"organization_id": organization_id,
|
|
1505
1459
|
},
|
|
1506
1460
|
request_options=request_options,
|
|
1507
1461
|
omit=OMIT,
|
|
@@ -26,7 +26,6 @@ class EvaluationsClient:
|
|
|
26
26
|
def fetch_evaluation_ids(
|
|
27
27
|
self,
|
|
28
28
|
*,
|
|
29
|
-
app_id: str,
|
|
30
29
|
resource_type: str,
|
|
31
30
|
resource_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
32
31
|
request_options: typing.Optional[RequestOptions] = None,
|
|
@@ -35,7 +34,6 @@ class EvaluationsClient:
|
|
|
35
34
|
Fetches evaluation ids for a given resource type and id.
|
|
36
35
|
|
|
37
36
|
Arguments:
|
|
38
|
-
app_id (str): The ID of the app for which to fetch evaluations.
|
|
39
37
|
resource_type (str): The type of resource for which to fetch evaluations.
|
|
40
38
|
resource_ids List[ObjectId]: The IDs of resource for which to fetch evaluations.
|
|
41
39
|
|
|
@@ -47,8 +45,6 @@ class EvaluationsClient:
|
|
|
47
45
|
|
|
48
46
|
Parameters
|
|
49
47
|
----------
|
|
50
|
-
app_id : str
|
|
51
|
-
|
|
52
48
|
resource_type : str
|
|
53
49
|
|
|
54
50
|
resource_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
@@ -70,7 +66,6 @@ class EvaluationsClient:
|
|
|
70
66
|
base_url="https://yourhost.com/path/to/api",
|
|
71
67
|
)
|
|
72
68
|
client.evaluations.fetch_evaluation_ids(
|
|
73
|
-
app_id="app_id",
|
|
74
69
|
resource_type="resource_type",
|
|
75
70
|
)
|
|
76
71
|
"""
|
|
@@ -78,7 +73,6 @@ class EvaluationsClient:
|
|
|
78
73
|
"evaluations/by_resource",
|
|
79
74
|
method="GET",
|
|
80
75
|
params={
|
|
81
|
-
"app_id": app_id,
|
|
82
76
|
"resource_type": resource_type,
|
|
83
77
|
"resource_ids": resource_ids,
|
|
84
78
|
},
|
|
@@ -714,7 +708,6 @@ class AsyncEvaluationsClient:
|
|
|
714
708
|
async def fetch_evaluation_ids(
|
|
715
709
|
self,
|
|
716
710
|
*,
|
|
717
|
-
app_id: str,
|
|
718
711
|
resource_type: str,
|
|
719
712
|
resource_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
720
713
|
request_options: typing.Optional[RequestOptions] = None,
|
|
@@ -723,7 +716,6 @@ class AsyncEvaluationsClient:
|
|
|
723
716
|
Fetches evaluation ids for a given resource type and id.
|
|
724
717
|
|
|
725
718
|
Arguments:
|
|
726
|
-
app_id (str): The ID of the app for which to fetch evaluations.
|
|
727
719
|
resource_type (str): The type of resource for which to fetch evaluations.
|
|
728
720
|
resource_ids List[ObjectId]: The IDs of resource for which to fetch evaluations.
|
|
729
721
|
|
|
@@ -735,7 +727,6 @@ class AsyncEvaluationsClient:
|
|
|
735
727
|
|
|
736
728
|
Parameters
|
|
737
729
|
----------
|
|
738
|
-
app_id : str
|
|
739
730
|
|
|
740
731
|
resource_type : str
|
|
741
732
|
|
|
@@ -763,7 +754,6 @@ class AsyncEvaluationsClient:
|
|
|
763
754
|
|
|
764
755
|
async def main() -> None:
|
|
765
756
|
await client.evaluations.fetch_evaluation_ids(
|
|
766
|
-
app_id="app_id",
|
|
767
757
|
resource_type="resource_type",
|
|
768
758
|
)
|
|
769
759
|
|
|
@@ -774,7 +764,6 @@ class AsyncEvaluationsClient:
|
|
|
774
764
|
"evaluations/by_resource",
|
|
775
765
|
method="GET",
|
|
776
766
|
params={
|
|
777
|
-
"app_id": app_id,
|
|
778
767
|
"resource_type": resource_type,
|
|
779
768
|
"resource_ids": resource_ids,
|
|
780
769
|
},
|
|
@@ -28,7 +28,6 @@ class TestsetsClient:
|
|
|
28
28
|
file: core.File,
|
|
29
29
|
upload_type: typing.Optional[str] = OMIT,
|
|
30
30
|
testset_name: typing.Optional[str] = OMIT,
|
|
31
|
-
app_id: typing.Optional[str] = OMIT,
|
|
32
31
|
request_options: typing.Optional[RequestOptions] = None,
|
|
33
32
|
) -> TestSetSimpleResponse:
|
|
34
33
|
"""
|
|
@@ -51,8 +50,6 @@ class TestsetsClient:
|
|
|
51
50
|
|
|
52
51
|
testset_name : typing.Optional[str]
|
|
53
52
|
|
|
54
|
-
app_id : typing.Optional[str]
|
|
55
|
-
|
|
56
53
|
request_options : typing.Optional[RequestOptions]
|
|
57
54
|
Request-specific configuration.
|
|
58
55
|
|
|
@@ -77,7 +74,6 @@ class TestsetsClient:
|
|
|
77
74
|
data={
|
|
78
75
|
"upload_type": upload_type,
|
|
79
76
|
"testset_name": testset_name,
|
|
80
|
-
"app_id": app_id,
|
|
81
77
|
},
|
|
82
78
|
files={
|
|
83
79
|
"file": file,
|
|
@@ -173,18 +169,16 @@ class TestsetsClient:
|
|
|
173
169
|
|
|
174
170
|
def create_testset(
|
|
175
171
|
self,
|
|
176
|
-
app_id: str,
|
|
177
172
|
*,
|
|
178
173
|
name: str,
|
|
179
174
|
csvdata: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
180
175
|
request_options: typing.Optional[RequestOptions] = None,
|
|
181
176
|
) -> TestSetSimpleResponse:
|
|
182
177
|
"""
|
|
183
|
-
Create a testset with given name
|
|
178
|
+
Create a testset with given name, save the testset to MongoDB.
|
|
184
179
|
|
|
185
180
|
Args:
|
|
186
181
|
name (str): name of the test set.
|
|
187
|
-
app_name (str): name of the application.
|
|
188
182
|
testset (Dict[str, str]): test set data.
|
|
189
183
|
|
|
190
184
|
Returns:
|
|
@@ -192,8 +186,6 @@ class TestsetsClient:
|
|
|
192
186
|
|
|
193
187
|
Parameters
|
|
194
188
|
----------
|
|
195
|
-
app_id : str
|
|
196
|
-
|
|
197
189
|
name : str
|
|
198
190
|
|
|
199
191
|
csvdata : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
@@ -215,13 +207,12 @@ class TestsetsClient:
|
|
|
215
207
|
base_url="https://yourhost.com/path/to/api",
|
|
216
208
|
)
|
|
217
209
|
client.testsets.create_testset(
|
|
218
|
-
app_id="app_id",
|
|
219
210
|
name="name",
|
|
220
211
|
csvdata=[{"key": "value"}],
|
|
221
212
|
)
|
|
222
213
|
"""
|
|
223
214
|
_response = self._client_wrapper.httpx_client.request(
|
|
224
|
-
|
|
215
|
+
"testsets",
|
|
225
216
|
method="POST",
|
|
226
217
|
json={
|
|
227
218
|
"name": name,
|
|
@@ -405,7 +396,7 @@ class TestsetsClient:
|
|
|
405
396
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
406
397
|
|
|
407
398
|
def get_testsets(
|
|
408
|
-
self, *,
|
|
399
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
409
400
|
) -> typing.List[TestSetOutputResponse]:
|
|
410
401
|
"""
|
|
411
402
|
Get all testsets.
|
|
@@ -420,8 +411,6 @@ class TestsetsClient:
|
|
|
420
411
|
|
|
421
412
|
Parameters
|
|
422
413
|
----------
|
|
423
|
-
app_id : str
|
|
424
|
-
|
|
425
414
|
request_options : typing.Optional[RequestOptions]
|
|
426
415
|
Request-specific configuration.
|
|
427
416
|
|
|
@@ -438,16 +427,11 @@ class TestsetsClient:
|
|
|
438
427
|
api_key="YOUR_API_KEY",
|
|
439
428
|
base_url="https://yourhost.com/path/to/api",
|
|
440
429
|
)
|
|
441
|
-
client.testsets.get_testsets(
|
|
442
|
-
app_id="app_id",
|
|
443
|
-
)
|
|
430
|
+
client.testsets.get_testsets()
|
|
444
431
|
"""
|
|
445
432
|
_response = self._client_wrapper.httpx_client.request(
|
|
446
433
|
"testsets",
|
|
447
434
|
method="GET",
|
|
448
|
-
params={
|
|
449
|
-
"app_id": app_id,
|
|
450
|
-
},
|
|
451
435
|
request_options=request_options,
|
|
452
436
|
)
|
|
453
437
|
try:
|
|
@@ -557,7 +541,6 @@ class AsyncTestsetsClient:
|
|
|
557
541
|
file: core.File,
|
|
558
542
|
upload_type: typing.Optional[str] = OMIT,
|
|
559
543
|
testset_name: typing.Optional[str] = OMIT,
|
|
560
|
-
app_id: typing.Optional[str] = OMIT,
|
|
561
544
|
request_options: typing.Optional[RequestOptions] = None,
|
|
562
545
|
) -> TestSetSimpleResponse:
|
|
563
546
|
"""
|
|
@@ -580,8 +563,6 @@ class AsyncTestsetsClient:
|
|
|
580
563
|
|
|
581
564
|
testset_name : typing.Optional[str]
|
|
582
565
|
|
|
583
|
-
app_id : typing.Optional[str]
|
|
584
|
-
|
|
585
566
|
request_options : typing.Optional[RequestOptions]
|
|
586
567
|
Request-specific configuration.
|
|
587
568
|
|
|
@@ -614,7 +595,6 @@ class AsyncTestsetsClient:
|
|
|
614
595
|
data={
|
|
615
596
|
"upload_type": upload_type,
|
|
616
597
|
"testset_name": testset_name,
|
|
617
|
-
"app_id": app_id,
|
|
618
598
|
},
|
|
619
599
|
files={
|
|
620
600
|
"file": file,
|
|
@@ -718,18 +698,16 @@ class AsyncTestsetsClient:
|
|
|
718
698
|
|
|
719
699
|
async def create_testset(
|
|
720
700
|
self,
|
|
721
|
-
app_id: str,
|
|
722
701
|
*,
|
|
723
702
|
name: str,
|
|
724
703
|
csvdata: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
725
704
|
request_options: typing.Optional[RequestOptions] = None,
|
|
726
705
|
) -> TestSetSimpleResponse:
|
|
727
706
|
"""
|
|
728
|
-
Create a testset with given name
|
|
707
|
+
Create a testset with given name, save the testset to MongoDB.
|
|
729
708
|
|
|
730
709
|
Args:
|
|
731
710
|
name (str): name of the test set.
|
|
732
|
-
app_name (str): name of the application.
|
|
733
711
|
testset (Dict[str, str]): test set data.
|
|
734
712
|
|
|
735
713
|
Returns:
|
|
@@ -737,8 +715,6 @@ class AsyncTestsetsClient:
|
|
|
737
715
|
|
|
738
716
|
Parameters
|
|
739
717
|
----------
|
|
740
|
-
app_id : str
|
|
741
|
-
|
|
742
718
|
name : str
|
|
743
719
|
|
|
744
720
|
csvdata : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
@@ -765,7 +741,6 @@ class AsyncTestsetsClient:
|
|
|
765
741
|
|
|
766
742
|
async def main() -> None:
|
|
767
743
|
await client.testsets.create_testset(
|
|
768
|
-
app_id="app_id",
|
|
769
744
|
name="name",
|
|
770
745
|
csvdata=[{"key": "value"}],
|
|
771
746
|
)
|
|
@@ -774,7 +749,7 @@ class AsyncTestsetsClient:
|
|
|
774
749
|
asyncio.run(main())
|
|
775
750
|
"""
|
|
776
751
|
_response = await self._client_wrapper.httpx_client.request(
|
|
777
|
-
|
|
752
|
+
"testsets",
|
|
778
753
|
method="POST",
|
|
779
754
|
json={
|
|
780
755
|
"name": name,
|
|
@@ -974,7 +949,7 @@ class AsyncTestsetsClient:
|
|
|
974
949
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
975
950
|
|
|
976
951
|
async def get_testsets(
|
|
977
|
-
self, *,
|
|
952
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
978
953
|
) -> typing.List[TestSetOutputResponse]:
|
|
979
954
|
"""
|
|
980
955
|
Get all testsets.
|
|
@@ -989,8 +964,6 @@ class AsyncTestsetsClient:
|
|
|
989
964
|
|
|
990
965
|
Parameters
|
|
991
966
|
----------
|
|
992
|
-
app_id : str
|
|
993
|
-
|
|
994
967
|
request_options : typing.Optional[RequestOptions]
|
|
995
968
|
Request-specific configuration.
|
|
996
969
|
|
|
@@ -1012,9 +985,7 @@ class AsyncTestsetsClient:
|
|
|
1012
985
|
|
|
1013
986
|
|
|
1014
987
|
async def main() -> None:
|
|
1015
|
-
await client.testsets.get_testsets(
|
|
1016
|
-
app_id="app_id",
|
|
1017
|
-
)
|
|
988
|
+
await client.testsets.get_testsets()
|
|
1018
989
|
|
|
1019
990
|
|
|
1020
991
|
asyncio.run(main())
|
|
@@ -1022,9 +993,6 @@ class AsyncTestsetsClient:
|
|
|
1022
993
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1023
994
|
"testsets",
|
|
1024
995
|
method="GET",
|
|
1025
|
-
params={
|
|
1026
|
-
"app_id": app_id,
|
|
1027
|
-
},
|
|
1028
996
|
request_options=request_options,
|
|
1029
997
|
)
|
|
1030
998
|
try:
|
agenta/sdk/agenta_init.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import logging
|
|
2
1
|
import toml
|
|
3
2
|
from os import getenv
|
|
4
3
|
from typing import Optional, Callable, Any
|
|
@@ -11,10 +10,6 @@ from agenta.sdk.tracing import Tracing
|
|
|
11
10
|
from agenta.client.exceptions import APIRequestError
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
logger = logging.getLogger(__name__)
|
|
15
|
-
logger.setLevel(logging.DEBUG)
|
|
16
|
-
|
|
17
|
-
|
|
18
13
|
class AgentaSingleton:
|
|
19
14
|
"""Singleton class to save all the "global variables" for the sdk."""
|
|
20
15
|
|
|
@@ -164,7 +159,7 @@ class Config:
|
|
|
164
159
|
try:
|
|
165
160
|
self.push(config_name="default", overwrite=overwrite, **kwargs)
|
|
166
161
|
except Exception as ex:
|
|
167
|
-
|
|
162
|
+
log.warning(
|
|
168
163
|
"Unable to push the default configuration to the server. %s", str(ex)
|
|
169
164
|
)
|
|
170
165
|
|
|
@@ -185,7 +180,7 @@ class Config:
|
|
|
185
180
|
overwrite=overwrite,
|
|
186
181
|
)
|
|
187
182
|
except Exception as ex:
|
|
188
|
-
|
|
183
|
+
log.warning(
|
|
189
184
|
"Failed to push the configuration to the server with error: %s", ex
|
|
190
185
|
)
|
|
191
186
|
|
|
@@ -212,14 +207,14 @@ class Config:
|
|
|
212
207
|
config_name=config_name,
|
|
213
208
|
)
|
|
214
209
|
except Exception as ex:
|
|
215
|
-
|
|
210
|
+
log.warning(
|
|
216
211
|
"Failed to pull the configuration from the server with error: %s",
|
|
217
212
|
str(ex),
|
|
218
213
|
)
|
|
219
214
|
try:
|
|
220
215
|
self.set(**{"current_version": config.current_version, **config.parameters})
|
|
221
216
|
except Exception as ex:
|
|
222
|
-
|
|
217
|
+
log.warning("Failed to set the configuration with error: %s", str(ex))
|
|
223
218
|
|
|
224
219
|
def all(self):
|
|
225
220
|
"""Returns all the parameters for the app variant"""
|