agenta 0.27.0a8__py3-none-any.whl → 0.27.0a12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of agenta might be problematic. Click here for more details.
- agenta/__init__.py +21 -3
- agenta/client/backend/__init__.py +14 -0
- agenta/client/backend/apps/client.py +28 -20
- agenta/client/backend/client.py +25 -2
- agenta/client/backend/containers/client.py +5 -1
- agenta/client/backend/core/__init__.py +2 -1
- agenta/client/backend/core/client_wrapper.py +6 -6
- agenta/client/backend/core/file.py +33 -11
- agenta/client/backend/core/http_client.py +24 -18
- agenta/client/backend/core/pydantic_utilities.py +144 -29
- agenta/client/backend/core/request_options.py +3 -0
- agenta/client/backend/core/serialization.py +139 -42
- agenta/client/backend/evaluations/client.py +7 -2
- agenta/client/backend/evaluators/client.py +349 -1
- agenta/client/backend/observability/client.py +11 -2
- agenta/client/backend/testsets/client.py +10 -10
- agenta/client/backend/types/__init__.py +14 -0
- agenta/client/backend/types/app.py +1 -0
- agenta/client/backend/types/app_variant_response.py +3 -1
- agenta/client/backend/types/config_dto.py +32 -0
- agenta/client/backend/types/config_response_model.py +32 -0
- agenta/client/backend/types/create_span.py +3 -2
- agenta/client/backend/types/environment_output.py +1 -0
- agenta/client/backend/types/environment_output_extended.py +1 -0
- agenta/client/backend/types/evaluation.py +1 -2
- agenta/client/backend/types/evaluator.py +2 -0
- agenta/client/backend/types/evaluator_config.py +1 -0
- agenta/client/backend/types/evaluator_mapping_output_interface.py +21 -0
- agenta/client/backend/types/evaluator_output_interface.py +21 -0
- agenta/client/backend/types/human_evaluation.py +1 -2
- agenta/client/backend/types/lifecycle_dto.py +24 -0
- agenta/client/backend/types/llm_tokens.py +2 -2
- agenta/client/backend/types/reference_dto.py +23 -0
- agenta/client/backend/types/reference_request_model.py +23 -0
- agenta/client/backend/types/span.py +1 -0
- agenta/client/backend/types/span_detail.py +7 -1
- agenta/client/backend/types/test_set_output_response.py +5 -2
- agenta/client/backend/types/trace_detail.py +7 -1
- agenta/client/backend/types/with_pagination.py +4 -2
- agenta/client/backend/variants/client.py +1565 -272
- agenta/sdk/__init__.py +19 -5
- agenta/sdk/agenta_init.py +21 -7
- agenta/sdk/context/routing.py +6 -5
- agenta/sdk/decorators/routing.py +16 -5
- agenta/sdk/decorators/tracing.py +16 -9
- agenta/sdk/litellm/litellm.py +47 -36
- agenta/sdk/managers/__init__.py +6 -0
- agenta/sdk/managers/config.py +318 -0
- agenta/sdk/managers/deployment.py +45 -0
- agenta/sdk/managers/shared.py +639 -0
- agenta/sdk/managers/variant.py +182 -0
- agenta/sdk/tracing/exporters.py +10 -1
- agenta/sdk/tracing/inline.py +45 -0
- agenta/sdk/tracing/processors.py +34 -7
- agenta/sdk/tracing/tracing.py +0 -10
- agenta/sdk/types.py +47 -2
- agenta/sdk/utils/exceptions.py +31 -1
- {agenta-0.27.0a8.dist-info → agenta-0.27.0a12.dist-info}/METADATA +1 -1
- {agenta-0.27.0a8.dist-info → agenta-0.27.0a12.dist-info}/RECORD +61 -50
- agenta/sdk/config_manager.py +0 -205
- {agenta-0.27.0a8.dist-info → agenta-0.27.0a12.dist-info}/WHEEL +0 -0
- {agenta-0.27.0a8.dist-info → agenta-0.27.0a12.dist-info}/entry_points.txt +0 -0
agenta/__init__.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
from .sdk.utils.preinit import PreInitObject
|
|
2
|
+
|
|
3
|
+
import agenta.client.backend.types as client_types # pylint: disable=wrong-import-order
|
|
4
|
+
|
|
2
5
|
from .sdk.types import (
|
|
3
6
|
DictInput,
|
|
4
7
|
MultipleChoice,
|
|
@@ -18,14 +21,29 @@ from .sdk.tracing import Tracing
|
|
|
18
21
|
from .sdk.decorators.tracing import instrument
|
|
19
22
|
from .sdk.tracing.conventions import Reference
|
|
20
23
|
from .sdk.decorators.routing import entrypoint, app, route
|
|
21
|
-
from .sdk.agenta_init import Config, AgentaSingleton, init
|
|
24
|
+
from .sdk.agenta_init import Config, AgentaSingleton, init as _init
|
|
22
25
|
from .sdk.utils.costs import calculate_token_usage
|
|
23
26
|
from .sdk.client import Agenta
|
|
24
27
|
from .sdk.litellm import litellm as callbacks
|
|
25
|
-
from .sdk.
|
|
28
|
+
from .sdk.managers.config import ConfigManager
|
|
29
|
+
from .sdk.managers.variant import VariantManager
|
|
30
|
+
from .sdk.managers.deployment import DeploymentManager
|
|
26
31
|
from .sdk import assets as assets
|
|
27
32
|
from .sdk import tracer
|
|
28
33
|
|
|
29
34
|
config = PreInitObject("agenta.config", Config)
|
|
30
35
|
DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
|
|
31
|
-
|
|
36
|
+
|
|
37
|
+
types = client_types
|
|
38
|
+
tracing = None
|
|
39
|
+
api = None
|
|
40
|
+
async_api = None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def init(*args, **kwargs):
|
|
44
|
+
global api, async_api, tracing, config
|
|
45
|
+
_init(*args, **kwargs)
|
|
46
|
+
|
|
47
|
+
tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
|
|
48
|
+
api = DEFAULT_AGENTA_SINGLETON_INSTANCE.api # type: ignore
|
|
49
|
+
async_api = DEFAULT_AGENTA_SINGLETON_INSTANCE.async_api # type: ignore
|
|
@@ -9,6 +9,8 @@ from .types import (
|
|
|
9
9
|
BaseOutput,
|
|
10
10
|
BodyImportTestset,
|
|
11
11
|
ConfigDb,
|
|
12
|
+
ConfigDto,
|
|
13
|
+
ConfigResponseModel,
|
|
12
14
|
CorrectAnswer,
|
|
13
15
|
CreateAppOutput,
|
|
14
16
|
CreateSpan,
|
|
@@ -28,6 +30,8 @@ from .types import (
|
|
|
28
30
|
EvaluationType,
|
|
29
31
|
Evaluator,
|
|
30
32
|
EvaluatorConfig,
|
|
33
|
+
EvaluatorMappingOutputInterface,
|
|
34
|
+
EvaluatorOutputInterface,
|
|
31
35
|
GetConfigResponse,
|
|
32
36
|
HttpValidationError,
|
|
33
37
|
HumanEvaluation,
|
|
@@ -38,6 +42,7 @@ from .types import (
|
|
|
38
42
|
HumanEvaluationUpdate,
|
|
39
43
|
Image,
|
|
40
44
|
InviteRequest,
|
|
45
|
+
LifecycleDto,
|
|
41
46
|
ListApiKeysResponse,
|
|
42
47
|
LlmRunRateLimit,
|
|
43
48
|
LlmTokens,
|
|
@@ -48,6 +53,8 @@ from .types import (
|
|
|
48
53
|
OrganizationOutput,
|
|
49
54
|
Outputs,
|
|
50
55
|
Permission,
|
|
56
|
+
ReferenceDto,
|
|
57
|
+
ReferenceRequestModel,
|
|
51
58
|
Result,
|
|
52
59
|
Score,
|
|
53
60
|
SimpleEvaluationOutput,
|
|
@@ -102,6 +109,8 @@ __all__ = [
|
|
|
102
109
|
"BaseOutput",
|
|
103
110
|
"BodyImportTestset",
|
|
104
111
|
"ConfigDb",
|
|
112
|
+
"ConfigDto",
|
|
113
|
+
"ConfigResponseModel",
|
|
105
114
|
"ContainerTemplatesResponse",
|
|
106
115
|
"CorrectAnswer",
|
|
107
116
|
"CreateAppOutput",
|
|
@@ -122,6 +131,8 @@ __all__ = [
|
|
|
122
131
|
"EvaluationType",
|
|
123
132
|
"Evaluator",
|
|
124
133
|
"EvaluatorConfig",
|
|
134
|
+
"EvaluatorMappingOutputInterface",
|
|
135
|
+
"EvaluatorOutputInterface",
|
|
125
136
|
"GetConfigResponse",
|
|
126
137
|
"HttpValidationError",
|
|
127
138
|
"HumanEvaluation",
|
|
@@ -132,6 +143,7 @@ __all__ = [
|
|
|
132
143
|
"HumanEvaluationUpdate",
|
|
133
144
|
"Image",
|
|
134
145
|
"InviteRequest",
|
|
146
|
+
"LifecycleDto",
|
|
135
147
|
"ListApiKeysResponse",
|
|
136
148
|
"LlmRunRateLimit",
|
|
137
149
|
"LlmTokens",
|
|
@@ -142,6 +154,8 @@ __all__ = [
|
|
|
142
154
|
"OrganizationOutput",
|
|
143
155
|
"Outputs",
|
|
144
156
|
"Permission",
|
|
157
|
+
"ReferenceDto",
|
|
158
|
+
"ReferenceRequestModel",
|
|
145
159
|
"Result",
|
|
146
160
|
"Score",
|
|
147
161
|
"SimpleEvaluationOutput",
|
|
@@ -176,7 +176,6 @@ class AppsClient:
|
|
|
176
176
|
self,
|
|
177
177
|
*,
|
|
178
178
|
app_name: typing.Optional[str] = None,
|
|
179
|
-
org_id: typing.Optional[str] = None,
|
|
180
179
|
workspace_id: typing.Optional[str] = None,
|
|
181
180
|
request_options: typing.Optional[RequestOptions] = None,
|
|
182
181
|
) -> typing.List[App]:
|
|
@@ -198,8 +197,6 @@ class AppsClient:
|
|
|
198
197
|
----------
|
|
199
198
|
app_name : typing.Optional[str]
|
|
200
199
|
|
|
201
|
-
org_id : typing.Optional[str]
|
|
202
|
-
|
|
203
200
|
workspace_id : typing.Optional[str]
|
|
204
201
|
|
|
205
202
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -225,7 +222,6 @@ class AppsClient:
|
|
|
225
222
|
method="GET",
|
|
226
223
|
params={
|
|
227
224
|
"app_name": app_name,
|
|
228
|
-
"org_id": org_id,
|
|
229
225
|
"workspace_id": workspace_id,
|
|
230
226
|
},
|
|
231
227
|
request_options=request_options,
|
|
@@ -258,8 +254,9 @@ class AppsClient:
|
|
|
258
254
|
self,
|
|
259
255
|
*,
|
|
260
256
|
app_name: str,
|
|
261
|
-
|
|
257
|
+
project_id: typing.Optional[str] = OMIT,
|
|
262
258
|
workspace_id: typing.Optional[str] = OMIT,
|
|
259
|
+
organization_id: typing.Optional[str] = OMIT,
|
|
263
260
|
request_options: typing.Optional[RequestOptions] = None,
|
|
264
261
|
) -> CreateAppOutput:
|
|
265
262
|
"""
|
|
@@ -279,10 +276,12 @@ class AppsClient:
|
|
|
279
276
|
----------
|
|
280
277
|
app_name : str
|
|
281
278
|
|
|
282
|
-
|
|
279
|
+
project_id : typing.Optional[str]
|
|
283
280
|
|
|
284
281
|
workspace_id : typing.Optional[str]
|
|
285
282
|
|
|
283
|
+
organization_id : typing.Optional[str]
|
|
284
|
+
|
|
286
285
|
request_options : typing.Optional[RequestOptions]
|
|
287
286
|
Request-specific configuration.
|
|
288
287
|
|
|
@@ -308,8 +307,9 @@ class AppsClient:
|
|
|
308
307
|
method="POST",
|
|
309
308
|
json={
|
|
310
309
|
"app_name": app_name,
|
|
311
|
-
"
|
|
310
|
+
"project_id": project_id,
|
|
312
311
|
"workspace_id": workspace_id,
|
|
312
|
+
"organization_id": organization_id,
|
|
313
313
|
},
|
|
314
314
|
request_options=request_options,
|
|
315
315
|
omit=OMIT,
|
|
@@ -586,8 +586,9 @@ class AppsClient:
|
|
|
586
586
|
app_name: str,
|
|
587
587
|
template_id: str,
|
|
588
588
|
env_vars: typing.Dict[str, str],
|
|
589
|
-
|
|
589
|
+
project_id: typing.Optional[str] = OMIT,
|
|
590
590
|
workspace_id: typing.Optional[str] = OMIT,
|
|
591
|
+
organization_id: typing.Optional[str] = OMIT,
|
|
591
592
|
request_options: typing.Optional[RequestOptions] = None,
|
|
592
593
|
) -> AppVariantResponse:
|
|
593
594
|
"""
|
|
@@ -611,10 +612,12 @@ class AppsClient:
|
|
|
611
612
|
|
|
612
613
|
env_vars : typing.Dict[str, str]
|
|
613
614
|
|
|
614
|
-
|
|
615
|
+
project_id : typing.Optional[str]
|
|
615
616
|
|
|
616
617
|
workspace_id : typing.Optional[str]
|
|
617
618
|
|
|
619
|
+
organization_id : typing.Optional[str]
|
|
620
|
+
|
|
618
621
|
request_options : typing.Optional[RequestOptions]
|
|
619
622
|
Request-specific configuration.
|
|
620
623
|
|
|
@@ -643,9 +646,10 @@ class AppsClient:
|
|
|
643
646
|
json={
|
|
644
647
|
"app_name": app_name,
|
|
645
648
|
"template_id": template_id,
|
|
649
|
+
"project_id": project_id,
|
|
650
|
+
"workspace_id": workspace_id,
|
|
646
651
|
"env_vars": env_vars,
|
|
647
652
|
"organization_id": organization_id,
|
|
648
|
-
"workspace_id": workspace_id,
|
|
649
653
|
},
|
|
650
654
|
request_options=request_options,
|
|
651
655
|
omit=OMIT,
|
|
@@ -976,7 +980,6 @@ class AsyncAppsClient:
|
|
|
976
980
|
self,
|
|
977
981
|
*,
|
|
978
982
|
app_name: typing.Optional[str] = None,
|
|
979
|
-
org_id: typing.Optional[str] = None,
|
|
980
983
|
workspace_id: typing.Optional[str] = None,
|
|
981
984
|
request_options: typing.Optional[RequestOptions] = None,
|
|
982
985
|
) -> typing.List[App]:
|
|
@@ -998,8 +1001,6 @@ class AsyncAppsClient:
|
|
|
998
1001
|
----------
|
|
999
1002
|
app_name : typing.Optional[str]
|
|
1000
1003
|
|
|
1001
|
-
org_id : typing.Optional[str]
|
|
1002
|
-
|
|
1003
1004
|
workspace_id : typing.Optional[str]
|
|
1004
1005
|
|
|
1005
1006
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -1033,7 +1034,6 @@ class AsyncAppsClient:
|
|
|
1033
1034
|
method="GET",
|
|
1034
1035
|
params={
|
|
1035
1036
|
"app_name": app_name,
|
|
1036
|
-
"org_id": org_id,
|
|
1037
1037
|
"workspace_id": workspace_id,
|
|
1038
1038
|
},
|
|
1039
1039
|
request_options=request_options,
|
|
@@ -1066,8 +1066,9 @@ class AsyncAppsClient:
|
|
|
1066
1066
|
self,
|
|
1067
1067
|
*,
|
|
1068
1068
|
app_name: str,
|
|
1069
|
-
|
|
1069
|
+
project_id: typing.Optional[str] = OMIT,
|
|
1070
1070
|
workspace_id: typing.Optional[str] = OMIT,
|
|
1071
|
+
organization_id: typing.Optional[str] = OMIT,
|
|
1071
1072
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1072
1073
|
) -> CreateAppOutput:
|
|
1073
1074
|
"""
|
|
@@ -1087,10 +1088,12 @@ class AsyncAppsClient:
|
|
|
1087
1088
|
----------
|
|
1088
1089
|
app_name : str
|
|
1089
1090
|
|
|
1090
|
-
|
|
1091
|
+
project_id : typing.Optional[str]
|
|
1091
1092
|
|
|
1092
1093
|
workspace_id : typing.Optional[str]
|
|
1093
1094
|
|
|
1095
|
+
organization_id : typing.Optional[str]
|
|
1096
|
+
|
|
1094
1097
|
request_options : typing.Optional[RequestOptions]
|
|
1095
1098
|
Request-specific configuration.
|
|
1096
1099
|
|
|
@@ -1124,8 +1127,9 @@ class AsyncAppsClient:
|
|
|
1124
1127
|
method="POST",
|
|
1125
1128
|
json={
|
|
1126
1129
|
"app_name": app_name,
|
|
1127
|
-
"
|
|
1130
|
+
"project_id": project_id,
|
|
1128
1131
|
"workspace_id": workspace_id,
|
|
1132
|
+
"organization_id": organization_id,
|
|
1129
1133
|
},
|
|
1130
1134
|
request_options=request_options,
|
|
1131
1135
|
omit=OMIT,
|
|
@@ -1426,8 +1430,9 @@ class AsyncAppsClient:
|
|
|
1426
1430
|
app_name: str,
|
|
1427
1431
|
template_id: str,
|
|
1428
1432
|
env_vars: typing.Dict[str, str],
|
|
1429
|
-
|
|
1433
|
+
project_id: typing.Optional[str] = OMIT,
|
|
1430
1434
|
workspace_id: typing.Optional[str] = OMIT,
|
|
1435
|
+
organization_id: typing.Optional[str] = OMIT,
|
|
1431
1436
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1432
1437
|
) -> AppVariantResponse:
|
|
1433
1438
|
"""
|
|
@@ -1451,10 +1456,12 @@ class AsyncAppsClient:
|
|
|
1451
1456
|
|
|
1452
1457
|
env_vars : typing.Dict[str, str]
|
|
1453
1458
|
|
|
1454
|
-
|
|
1459
|
+
project_id : typing.Optional[str]
|
|
1455
1460
|
|
|
1456
1461
|
workspace_id : typing.Optional[str]
|
|
1457
1462
|
|
|
1463
|
+
organization_id : typing.Optional[str]
|
|
1464
|
+
|
|
1458
1465
|
request_options : typing.Optional[RequestOptions]
|
|
1459
1466
|
Request-specific configuration.
|
|
1460
1467
|
|
|
@@ -1491,9 +1498,10 @@ class AsyncAppsClient:
|
|
|
1491
1498
|
json={
|
|
1492
1499
|
"app_name": app_name,
|
|
1493
1500
|
"template_id": template_id,
|
|
1501
|
+
"project_id": project_id,
|
|
1502
|
+
"workspace_id": workspace_id,
|
|
1494
1503
|
"env_vars": env_vars,
|
|
1495
1504
|
"organization_id": organization_id,
|
|
1496
|
-
"workspace_id": workspace_id,
|
|
1497
1505
|
},
|
|
1498
1506
|
request_options=request_options,
|
|
1499
1507
|
omit=OMIT,
|
agenta/client/backend/client.py
CHANGED
|
@@ -24,6 +24,7 @@ from .core.jsonable_encoder import jsonable_encoder
|
|
|
24
24
|
from .types.organization import Organization
|
|
25
25
|
from .types.organization_output import OrganizationOutput
|
|
26
26
|
from .types.invite_request import InviteRequest
|
|
27
|
+
from .core.serialization import convert_and_respect_annotation_metadata
|
|
27
28
|
from .types.workspace_response import WorkspaceResponse
|
|
28
29
|
import datetime as dt
|
|
29
30
|
from .types.workspace_role_response import WorkspaceRoleResponse
|
|
@@ -732,7 +733,11 @@ class AgentaApi:
|
|
|
732
733
|
_response = self._client_wrapper.httpx_client.request(
|
|
733
734
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
734
735
|
method="POST",
|
|
735
|
-
json=
|
|
736
|
+
json=convert_and_respect_annotation_metadata(
|
|
737
|
+
object_=request,
|
|
738
|
+
annotation=typing.Sequence[InviteRequest],
|
|
739
|
+
direction="write",
|
|
740
|
+
),
|
|
736
741
|
request_options=request_options,
|
|
737
742
|
omit=OMIT,
|
|
738
743
|
)
|
|
@@ -847,6 +852,7 @@ class AgentaApi:
|
|
|
847
852
|
org_id: str,
|
|
848
853
|
workspace_id: str,
|
|
849
854
|
*,
|
|
855
|
+
project_id: str,
|
|
850
856
|
token: str,
|
|
851
857
|
request_options: typing.Optional[RequestOptions] = None,
|
|
852
858
|
) -> typing.Optional[typing.Any]:
|
|
@@ -867,6 +873,8 @@ class AgentaApi:
|
|
|
867
873
|
|
|
868
874
|
workspace_id : str
|
|
869
875
|
|
|
876
|
+
project_id : str
|
|
877
|
+
|
|
870
878
|
token : str
|
|
871
879
|
|
|
872
880
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -888,12 +896,16 @@ class AgentaApi:
|
|
|
888
896
|
client.accept_invitation(
|
|
889
897
|
org_id="org_id",
|
|
890
898
|
workspace_id="workspace_id",
|
|
899
|
+
project_id="project_id",
|
|
891
900
|
token="token",
|
|
892
901
|
)
|
|
893
902
|
"""
|
|
894
903
|
_response = self._client_wrapper.httpx_client.request(
|
|
895
904
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
896
905
|
method="POST",
|
|
906
|
+
params={
|
|
907
|
+
"project_id": project_id,
|
|
908
|
+
},
|
|
897
909
|
json={
|
|
898
910
|
"token": token,
|
|
899
911
|
},
|
|
@@ -2333,7 +2345,11 @@ class AsyncAgentaApi:
|
|
|
2333
2345
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2334
2346
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
2335
2347
|
method="POST",
|
|
2336
|
-
json=
|
|
2348
|
+
json=convert_and_respect_annotation_metadata(
|
|
2349
|
+
object_=request,
|
|
2350
|
+
annotation=typing.Sequence[InviteRequest],
|
|
2351
|
+
direction="write",
|
|
2352
|
+
),
|
|
2337
2353
|
request_options=request_options,
|
|
2338
2354
|
omit=OMIT,
|
|
2339
2355
|
)
|
|
@@ -2456,6 +2472,7 @@ class AsyncAgentaApi:
|
|
|
2456
2472
|
org_id: str,
|
|
2457
2473
|
workspace_id: str,
|
|
2458
2474
|
*,
|
|
2475
|
+
project_id: str,
|
|
2459
2476
|
token: str,
|
|
2460
2477
|
request_options: typing.Optional[RequestOptions] = None,
|
|
2461
2478
|
) -> typing.Optional[typing.Any]:
|
|
@@ -2476,6 +2493,8 @@ class AsyncAgentaApi:
|
|
|
2476
2493
|
|
|
2477
2494
|
workspace_id : str
|
|
2478
2495
|
|
|
2496
|
+
project_id : str
|
|
2497
|
+
|
|
2479
2498
|
token : str
|
|
2480
2499
|
|
|
2481
2500
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -2502,6 +2521,7 @@ class AsyncAgentaApi:
|
|
|
2502
2521
|
await client.accept_invitation(
|
|
2503
2522
|
org_id="org_id",
|
|
2504
2523
|
workspace_id="workspace_id",
|
|
2524
|
+
project_id="project_id",
|
|
2505
2525
|
token="token",
|
|
2506
2526
|
)
|
|
2507
2527
|
|
|
@@ -2511,6 +2531,9 @@ class AsyncAgentaApi:
|
|
|
2511
2531
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2512
2532
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
2513
2533
|
method="POST",
|
|
2534
|
+
params={
|
|
2535
|
+
"project_id": project_id,
|
|
2536
|
+
},
|
|
2514
2537
|
json={
|
|
2515
2538
|
"token": token,
|
|
2516
2539
|
},
|
|
@@ -387,7 +387,11 @@ class AsyncContainersClient:
|
|
|
387
387
|
files={
|
|
388
388
|
"tar_file": tar_file,
|
|
389
389
|
},
|
|
390
|
-
request_options=
|
|
390
|
+
request_options=(
|
|
391
|
+
{**request_options, "timeout_in_seconds": 600}
|
|
392
|
+
if request_options
|
|
393
|
+
else {"timeout_in_seconds": 600}
|
|
394
|
+
),
|
|
391
395
|
omit=OMIT,
|
|
392
396
|
)
|
|
393
397
|
try:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from .api_error import ApiError
|
|
4
4
|
from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
|
|
5
5
|
from .datetime_utils import serialize_datetime
|
|
6
|
-
from .file import File, convert_file_dict_to_httpx_tuples
|
|
6
|
+
from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
|
|
7
7
|
from .http_client import AsyncHttpClient, HttpClient
|
|
8
8
|
from .jsonable_encoder import jsonable_encoder
|
|
9
9
|
from .pydantic_utilities import (
|
|
@@ -43,4 +43,5 @@ __all__ = [
|
|
|
43
43
|
"universal_field_validator",
|
|
44
44
|
"universal_root_validator",
|
|
45
45
|
"update_forward_refs",
|
|
46
|
+
"with_content_type",
|
|
46
47
|
]
|
|
@@ -40,9 +40,9 @@ class SyncClientWrapper(BaseClientWrapper):
|
|
|
40
40
|
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
|
|
41
41
|
self.httpx_client = HttpClient(
|
|
42
42
|
httpx_client=httpx_client,
|
|
43
|
-
base_headers=self.get_headers
|
|
44
|
-
base_timeout=self.get_timeout
|
|
45
|
-
base_url=self.get_base_url
|
|
43
|
+
base_headers=self.get_headers,
|
|
44
|
+
base_timeout=self.get_timeout,
|
|
45
|
+
base_url=self.get_base_url,
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
|
|
@@ -58,7 +58,7 @@ class AsyncClientWrapper(BaseClientWrapper):
|
|
|
58
58
|
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
|
|
59
59
|
self.httpx_client = AsyncHttpClient(
|
|
60
60
|
httpx_client=httpx_client,
|
|
61
|
-
base_headers=self.get_headers
|
|
62
|
-
base_timeout=self.get_timeout
|
|
63
|
-
base_url=self.get_base_url
|
|
61
|
+
base_headers=self.get_headers,
|
|
62
|
+
base_timeout=self.get_timeout,
|
|
63
|
+
base_url=self.get_base_url,
|
|
64
64
|
)
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
from typing import IO, Dict, List, Mapping, Optional, Tuple, Union, cast
|
|
4
4
|
|
|
5
5
|
# File typing inspired by the flexibility of types within the httpx library
|
|
6
6
|
# https://github.com/encode/httpx/blob/master/httpx/_types.py
|
|
7
|
-
FileContent =
|
|
8
|
-
File =
|
|
7
|
+
FileContent = Union[IO[bytes], bytes, str]
|
|
8
|
+
File = Union[
|
|
9
9
|
# file (or bytes)
|
|
10
10
|
FileContent,
|
|
11
11
|
# (filename, file (or bytes))
|
|
12
|
-
|
|
12
|
+
Tuple[Optional[str], FileContent],
|
|
13
13
|
# (filename, file (or bytes), content_type)
|
|
14
|
-
|
|
14
|
+
Tuple[Optional[str], FileContent, Optional[str]],
|
|
15
15
|
# (filename, file (or bytes), content_type, headers)
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Tuple[
|
|
17
|
+
Optional[str],
|
|
18
18
|
FileContent,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Optional[str],
|
|
20
|
+
Mapping[str, str],
|
|
21
21
|
],
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def convert_file_dict_to_httpx_tuples(
|
|
26
|
-
d:
|
|
27
|
-
) ->
|
|
26
|
+
d: Dict[str, Union[File, List[File]]],
|
|
27
|
+
) -> List[Tuple[str, File]]:
|
|
28
28
|
"""
|
|
29
29
|
The format we use is a list of tuples, where the first element is the
|
|
30
30
|
name of the file and the second is the file object. Typically HTTPX wants
|
|
@@ -41,3 +41,25 @@ def convert_file_dict_to_httpx_tuples(
|
|
|
41
41
|
else:
|
|
42
42
|
httpx_tuples.append((key, file_like))
|
|
43
43
|
return httpx_tuples
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def with_content_type(*, file: File, content_type: str) -> File:
|
|
47
|
+
""" """
|
|
48
|
+
if isinstance(file, tuple):
|
|
49
|
+
if len(file) == 2:
|
|
50
|
+
filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore
|
|
51
|
+
return (filename, content, content_type)
|
|
52
|
+
elif len(file) == 3:
|
|
53
|
+
filename, content, _ = cast(
|
|
54
|
+
Tuple[Optional[str], FileContent, Optional[str]], file
|
|
55
|
+
) # type: ignore
|
|
56
|
+
return (filename, content, content_type)
|
|
57
|
+
elif len(file) == 4:
|
|
58
|
+
filename, content, _, headers = cast( # type: ignore
|
|
59
|
+
Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
|
|
60
|
+
file,
|
|
61
|
+
)
|
|
62
|
+
return (filename, content, content_type, headers)
|
|
63
|
+
else:
|
|
64
|
+
raise ValueError(f"Unexpected tuple length: {len(file)}")
|
|
65
|
+
return (None, file, content_type)
|
|
@@ -158,9 +158,9 @@ class HttpClient:
|
|
|
158
158
|
self,
|
|
159
159
|
*,
|
|
160
160
|
httpx_client: httpx.Client,
|
|
161
|
-
base_timeout: typing.Optional[float],
|
|
162
|
-
base_headers: typing.Dict[str, str],
|
|
163
|
-
base_url: typing.Optional[str] = None,
|
|
161
|
+
base_timeout: typing.Callable[[], typing.Optional[float]],
|
|
162
|
+
base_headers: typing.Callable[[], typing.Dict[str, str]],
|
|
163
|
+
base_url: typing.Optional[typing.Callable[[], str]] = None,
|
|
164
164
|
):
|
|
165
165
|
self.base_url = base_url
|
|
166
166
|
self.base_timeout = base_timeout
|
|
@@ -168,7 +168,10 @@ class HttpClient:
|
|
|
168
168
|
self.httpx_client = httpx_client
|
|
169
169
|
|
|
170
170
|
def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str:
|
|
171
|
-
base_url =
|
|
171
|
+
base_url = maybe_base_url
|
|
172
|
+
if self.base_url is not None and base_url is None:
|
|
173
|
+
base_url = self.base_url()
|
|
174
|
+
|
|
172
175
|
if base_url is None:
|
|
173
176
|
raise ValueError(
|
|
174
177
|
"A base_url is required to make this request, please provide one and try again."
|
|
@@ -200,7 +203,7 @@ class HttpClient:
|
|
|
200
203
|
request_options.get("timeout_in_seconds")
|
|
201
204
|
if request_options is not None
|
|
202
205
|
and request_options.get("timeout_in_seconds") is not None
|
|
203
|
-
else self.base_timeout
|
|
206
|
+
else self.base_timeout()
|
|
204
207
|
)
|
|
205
208
|
|
|
206
209
|
json_body, data_body = get_request_body(
|
|
@@ -213,7 +216,7 @@ class HttpClient:
|
|
|
213
216
|
headers=jsonable_encoder(
|
|
214
217
|
remove_none_from_dict(
|
|
215
218
|
{
|
|
216
|
-
**self.base_headers,
|
|
219
|
+
**self.base_headers(),
|
|
217
220
|
**(headers if headers is not None else {}),
|
|
218
221
|
**(
|
|
219
222
|
request_options.get("additional_headers", {}) or {}
|
|
@@ -248,7 +251,7 @@ class HttpClient:
|
|
|
248
251
|
content=content,
|
|
249
252
|
files=(
|
|
250
253
|
convert_file_dict_to_httpx_tuples(remove_none_from_dict(files))
|
|
251
|
-
if files is not None
|
|
254
|
+
if (files is not None and files is not omit)
|
|
252
255
|
else None
|
|
253
256
|
),
|
|
254
257
|
timeout=timeout,
|
|
@@ -302,7 +305,7 @@ class HttpClient:
|
|
|
302
305
|
request_options.get("timeout_in_seconds")
|
|
303
306
|
if request_options is not None
|
|
304
307
|
and request_options.get("timeout_in_seconds") is not None
|
|
305
|
-
else self.base_timeout
|
|
308
|
+
else self.base_timeout()
|
|
306
309
|
)
|
|
307
310
|
|
|
308
311
|
json_body, data_body = get_request_body(
|
|
@@ -315,7 +318,7 @@ class HttpClient:
|
|
|
315
318
|
headers=jsonable_encoder(
|
|
316
319
|
remove_none_from_dict(
|
|
317
320
|
{
|
|
318
|
-
**self.base_headers,
|
|
321
|
+
**self.base_headers(),
|
|
319
322
|
**(headers if headers is not None else {}),
|
|
320
323
|
**(
|
|
321
324
|
request_options.get("additional_headers", {})
|
|
@@ -349,7 +352,7 @@ class HttpClient:
|
|
|
349
352
|
content=content,
|
|
350
353
|
files=(
|
|
351
354
|
convert_file_dict_to_httpx_tuples(remove_none_from_dict(files))
|
|
352
|
-
if files is not None
|
|
355
|
+
if (files is not None and files is not omit)
|
|
353
356
|
else None
|
|
354
357
|
),
|
|
355
358
|
timeout=timeout,
|
|
@@ -362,9 +365,9 @@ class AsyncHttpClient:
|
|
|
362
365
|
self,
|
|
363
366
|
*,
|
|
364
367
|
httpx_client: httpx.AsyncClient,
|
|
365
|
-
base_timeout: typing.Optional[float],
|
|
366
|
-
base_headers: typing.Dict[str, str],
|
|
367
|
-
base_url: typing.Optional[str] = None,
|
|
368
|
+
base_timeout: typing.Callable[[], typing.Optional[float]],
|
|
369
|
+
base_headers: typing.Callable[[], typing.Dict[str, str]],
|
|
370
|
+
base_url: typing.Optional[typing.Callable[[], str]] = None,
|
|
368
371
|
):
|
|
369
372
|
self.base_url = base_url
|
|
370
373
|
self.base_timeout = base_timeout
|
|
@@ -372,7 +375,10 @@ class AsyncHttpClient:
|
|
|
372
375
|
self.httpx_client = httpx_client
|
|
373
376
|
|
|
374
377
|
def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str:
|
|
375
|
-
base_url =
|
|
378
|
+
base_url = maybe_base_url
|
|
379
|
+
if self.base_url is not None and base_url is None:
|
|
380
|
+
base_url = self.base_url()
|
|
381
|
+
|
|
376
382
|
if base_url is None:
|
|
377
383
|
raise ValueError(
|
|
378
384
|
"A base_url is required to make this request, please provide one and try again."
|
|
@@ -404,7 +410,7 @@ class AsyncHttpClient:
|
|
|
404
410
|
request_options.get("timeout_in_seconds")
|
|
405
411
|
if request_options is not None
|
|
406
412
|
and request_options.get("timeout_in_seconds") is not None
|
|
407
|
-
else self.base_timeout
|
|
413
|
+
else self.base_timeout()
|
|
408
414
|
)
|
|
409
415
|
|
|
410
416
|
json_body, data_body = get_request_body(
|
|
@@ -418,7 +424,7 @@ class AsyncHttpClient:
|
|
|
418
424
|
headers=jsonable_encoder(
|
|
419
425
|
remove_none_from_dict(
|
|
420
426
|
{
|
|
421
|
-
**self.base_headers,
|
|
427
|
+
**self.base_headers(),
|
|
422
428
|
**(headers if headers is not None else {}),
|
|
423
429
|
**(
|
|
424
430
|
request_options.get("additional_headers", {}) or {}
|
|
@@ -506,7 +512,7 @@ class AsyncHttpClient:
|
|
|
506
512
|
request_options.get("timeout_in_seconds")
|
|
507
513
|
if request_options is not None
|
|
508
514
|
and request_options.get("timeout_in_seconds") is not None
|
|
509
|
-
else self.base_timeout
|
|
515
|
+
else self.base_timeout()
|
|
510
516
|
)
|
|
511
517
|
|
|
512
518
|
json_body, data_body = get_request_body(
|
|
@@ -519,7 +525,7 @@ class AsyncHttpClient:
|
|
|
519
525
|
headers=jsonable_encoder(
|
|
520
526
|
remove_none_from_dict(
|
|
521
527
|
{
|
|
522
|
-
**self.base_headers,
|
|
528
|
+
**self.base_headers(),
|
|
523
529
|
**(headers if headers is not None else {}),
|
|
524
530
|
**(
|
|
525
531
|
request_options.get("additional_headers", {})
|