agenta 0.26.0__py3-none-any.whl → 0.27.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/__init__.py +29 -10
- agenta/cli/helper.py +5 -1
- agenta/client/backend/__init__.py +14 -0
- agenta/client/backend/apps/client.py +28 -20
- agenta/client/backend/client.py +47 -16
- 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 +45 -31
- 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/docker/docker-assets/Dockerfile.cloud.template +1 -1
- agenta/sdk/__init__.py +44 -7
- agenta/sdk/agenta_init.py +85 -33
- agenta/sdk/context/__init__.py +0 -0
- agenta/sdk/context/routing.py +26 -0
- agenta/sdk/context/tracing.py +3 -0
- agenta/sdk/decorators/__init__.py +0 -0
- agenta/sdk/decorators/{llm_entrypoint.py → routing.py} +216 -191
- agenta/sdk/decorators/tracing.py +218 -99
- agenta/sdk/litellm/__init__.py +1 -0
- agenta/sdk/litellm/litellm.py +288 -0
- 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/router.py +0 -7
- agenta/sdk/tracing/__init__.py +1 -0
- agenta/sdk/tracing/attributes.py +141 -0
- agenta/sdk/tracing/context.py +24 -0
- agenta/sdk/tracing/conventions.py +49 -0
- agenta/sdk/tracing/exporters.py +65 -0
- agenta/sdk/tracing/inline.py +1252 -0
- agenta/sdk/tracing/processors.py +117 -0
- agenta/sdk/tracing/spans.py +136 -0
- agenta/sdk/tracing/tracing.py +233 -0
- agenta/sdk/types.py +49 -2
- agenta/sdk/utils/{helper/openai_cost.py → costs.py} +3 -0
- agenta/sdk/utils/debug.py +5 -5
- agenta/sdk/utils/exceptions.py +52 -0
- agenta/sdk/utils/globals.py +3 -5
- agenta/sdk/{tracing/logger.py → utils/logging.py} +3 -5
- agenta/sdk/utils/singleton.py +13 -0
- {agenta-0.26.0.dist-info → agenta-0.27.0.dist-info}/METADATA +5 -1
- {agenta-0.26.0.dist-info → agenta-0.27.0.dist-info}/RECORD +78 -57
- agenta/sdk/config_manager.py +0 -205
- agenta/sdk/context.py +0 -41
- agenta/sdk/decorators/base.py +0 -10
- agenta/sdk/tracing/callbacks.py +0 -187
- agenta/sdk/tracing/llm_tracing.py +0 -617
- agenta/sdk/tracing/tasks_manager.py +0 -129
- agenta/sdk/tracing/tracing_context.py +0 -27
- {agenta-0.26.0.dist-info → agenta-0.27.0.dist-info}/WHEEL +0 -0
- {agenta-0.26.0.dist-info → agenta-0.27.0.dist-info}/entry_points.txt +0 -0
agenta/__init__.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from .sdk.utils.preinit import PreInitObject
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import agenta.client.backend.types as client_types # pylint: disable=wrong-import-order
|
|
4
|
+
|
|
3
5
|
from .sdk.types import (
|
|
4
|
-
Context,
|
|
5
6
|
DictInput,
|
|
6
7
|
MultipleChoice,
|
|
7
8
|
FloatParam,
|
|
@@ -13,19 +14,37 @@ from .sdk.types import (
|
|
|
13
14
|
TextParam,
|
|
14
15
|
FileInputURL,
|
|
15
16
|
BinaryParam,
|
|
17
|
+
Prompt,
|
|
16
18
|
)
|
|
17
19
|
|
|
18
|
-
from .sdk.
|
|
19
|
-
from .sdk.tracing
|
|
20
|
+
from .sdk.utils.logging import log as logging
|
|
21
|
+
from .sdk.tracing import Tracing
|
|
20
22
|
from .sdk.decorators.tracing import instrument
|
|
21
|
-
from .sdk.
|
|
22
|
-
from .sdk.
|
|
23
|
-
from .sdk.
|
|
23
|
+
from .sdk.tracing.conventions import Reference
|
|
24
|
+
from .sdk.decorators.routing import entrypoint, app, route
|
|
25
|
+
from .sdk.agenta_init import Config, AgentaSingleton, init as _init
|
|
26
|
+
from .sdk.utils.costs import calculate_token_usage
|
|
24
27
|
from .sdk.client import Agenta
|
|
25
|
-
from .sdk.
|
|
26
|
-
from .sdk.
|
|
28
|
+
from .sdk.litellm import litellm as callbacks
|
|
29
|
+
from .sdk.managers.config import ConfigManager
|
|
30
|
+
from .sdk.managers.variant import VariantManager
|
|
31
|
+
from .sdk.managers.deployment import DeploymentManager
|
|
27
32
|
from .sdk import assets as assets
|
|
33
|
+
from .sdk import tracer
|
|
28
34
|
|
|
29
35
|
config = PreInitObject("agenta.config", Config)
|
|
30
36
|
DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
|
|
31
|
-
|
|
37
|
+
|
|
38
|
+
types = client_types
|
|
39
|
+
tracing = None
|
|
40
|
+
api = None
|
|
41
|
+
async_api = None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def init(*args, **kwargs):
|
|
45
|
+
global api, async_api, tracing, config
|
|
46
|
+
_init(*args, **kwargs)
|
|
47
|
+
|
|
48
|
+
tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
|
|
49
|
+
api = DEFAULT_AGENTA_SINGLETON_INSTANCE.api # type: ignore
|
|
50
|
+
async_api = DEFAULT_AGENTA_SINGLETON_INSTANCE.async_api # type: ignore
|
agenta/cli/helper.py
CHANGED
|
@@ -15,6 +15,9 @@ import toml
|
|
|
15
15
|
from agenta.client.backend.client import AgentaApi
|
|
16
16
|
|
|
17
17
|
BACKEND_URL_SUFFIX = os.environ.get("BACKEND_URL_SUFFIX", "api")
|
|
18
|
+
POSTHOG_KEY = os.environ.get(
|
|
19
|
+
"POSTHOG_KEY", "phc_hmVSxIjTW1REBHXgj2aw4HW9X6CXb6FzerBgP9XenC7"
|
|
20
|
+
)
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
def get_global_config(var_name: str) -> Optional[Any]:
|
|
@@ -111,7 +114,8 @@ def init_telemetry_config() -> None:
|
|
|
111
114
|
):
|
|
112
115
|
set_global_config("telemetry_tracking_enabled", True)
|
|
113
116
|
set_global_config(
|
|
114
|
-
"telemetry_api_key",
|
|
117
|
+
"telemetry_api_key",
|
|
118
|
+
POSTHOG_KEY,
|
|
115
119
|
)
|
|
116
120
|
|
|
117
121
|
|
|
@@ -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
|
|
@@ -88,13 +89,17 @@ class AgentaApi:
|
|
|
88
89
|
self._client_wrapper = SyncClientWrapper(
|
|
89
90
|
base_url=base_url,
|
|
90
91
|
api_key=api_key,
|
|
91
|
-
httpx_client=
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
httpx_client=(
|
|
93
|
+
httpx_client
|
|
94
|
+
if httpx_client is not None
|
|
95
|
+
else (
|
|
96
|
+
httpx.Client(
|
|
97
|
+
timeout=_defaulted_timeout, follow_redirects=follow_redirects
|
|
98
|
+
)
|
|
99
|
+
if follow_redirects is not None
|
|
100
|
+
else httpx.Client(timeout=_defaulted_timeout)
|
|
101
|
+
)
|
|
102
|
+
),
|
|
98
103
|
timeout=_defaulted_timeout,
|
|
99
104
|
)
|
|
100
105
|
self.observability = ObservabilityClient(client_wrapper=self._client_wrapper)
|
|
@@ -728,7 +733,11 @@ class AgentaApi:
|
|
|
728
733
|
_response = self._client_wrapper.httpx_client.request(
|
|
729
734
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
730
735
|
method="POST",
|
|
731
|
-
json=
|
|
736
|
+
json=convert_and_respect_annotation_metadata(
|
|
737
|
+
object_=request,
|
|
738
|
+
annotation=typing.Sequence[InviteRequest],
|
|
739
|
+
direction="write",
|
|
740
|
+
),
|
|
732
741
|
request_options=request_options,
|
|
733
742
|
omit=OMIT,
|
|
734
743
|
)
|
|
@@ -843,6 +852,7 @@ class AgentaApi:
|
|
|
843
852
|
org_id: str,
|
|
844
853
|
workspace_id: str,
|
|
845
854
|
*,
|
|
855
|
+
project_id: str,
|
|
846
856
|
token: str,
|
|
847
857
|
request_options: typing.Optional[RequestOptions] = None,
|
|
848
858
|
) -> typing.Optional[typing.Any]:
|
|
@@ -863,6 +873,8 @@ class AgentaApi:
|
|
|
863
873
|
|
|
864
874
|
workspace_id : str
|
|
865
875
|
|
|
876
|
+
project_id : str
|
|
877
|
+
|
|
866
878
|
token : str
|
|
867
879
|
|
|
868
880
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -884,12 +896,16 @@ class AgentaApi:
|
|
|
884
896
|
client.accept_invitation(
|
|
885
897
|
org_id="org_id",
|
|
886
898
|
workspace_id="workspace_id",
|
|
899
|
+
project_id="project_id",
|
|
887
900
|
token="token",
|
|
888
901
|
)
|
|
889
902
|
"""
|
|
890
903
|
_response = self._client_wrapper.httpx_client.request(
|
|
891
904
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
892
905
|
method="POST",
|
|
906
|
+
params={
|
|
907
|
+
"project_id": project_id,
|
|
908
|
+
},
|
|
893
909
|
json={
|
|
894
910
|
"token": token,
|
|
895
911
|
},
|
|
@@ -1603,13 +1619,17 @@ class AsyncAgentaApi:
|
|
|
1603
1619
|
self._client_wrapper = AsyncClientWrapper(
|
|
1604
1620
|
base_url=base_url,
|
|
1605
1621
|
api_key=api_key,
|
|
1606
|
-
httpx_client=
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1622
|
+
httpx_client=(
|
|
1623
|
+
httpx_client
|
|
1624
|
+
if httpx_client is not None
|
|
1625
|
+
else (
|
|
1626
|
+
httpx.AsyncClient(
|
|
1627
|
+
timeout=_defaulted_timeout, follow_redirects=follow_redirects
|
|
1628
|
+
)
|
|
1629
|
+
if follow_redirects is not None
|
|
1630
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout)
|
|
1631
|
+
)
|
|
1632
|
+
),
|
|
1613
1633
|
timeout=_defaulted_timeout,
|
|
1614
1634
|
)
|
|
1615
1635
|
self.observability = AsyncObservabilityClient(
|
|
@@ -2325,7 +2345,11 @@ class AsyncAgentaApi:
|
|
|
2325
2345
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2326
2346
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
2327
2347
|
method="POST",
|
|
2328
|
-
json=
|
|
2348
|
+
json=convert_and_respect_annotation_metadata(
|
|
2349
|
+
object_=request,
|
|
2350
|
+
annotation=typing.Sequence[InviteRequest],
|
|
2351
|
+
direction="write",
|
|
2352
|
+
),
|
|
2329
2353
|
request_options=request_options,
|
|
2330
2354
|
omit=OMIT,
|
|
2331
2355
|
)
|
|
@@ -2448,6 +2472,7 @@ class AsyncAgentaApi:
|
|
|
2448
2472
|
org_id: str,
|
|
2449
2473
|
workspace_id: str,
|
|
2450
2474
|
*,
|
|
2475
|
+
project_id: str,
|
|
2451
2476
|
token: str,
|
|
2452
2477
|
request_options: typing.Optional[RequestOptions] = None,
|
|
2453
2478
|
) -> typing.Optional[typing.Any]:
|
|
@@ -2468,6 +2493,8 @@ class AsyncAgentaApi:
|
|
|
2468
2493
|
|
|
2469
2494
|
workspace_id : str
|
|
2470
2495
|
|
|
2496
|
+
project_id : str
|
|
2497
|
+
|
|
2471
2498
|
token : str
|
|
2472
2499
|
|
|
2473
2500
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -2494,6 +2521,7 @@ class AsyncAgentaApi:
|
|
|
2494
2521
|
await client.accept_invitation(
|
|
2495
2522
|
org_id="org_id",
|
|
2496
2523
|
workspace_id="workspace_id",
|
|
2524
|
+
project_id="project_id",
|
|
2497
2525
|
token="token",
|
|
2498
2526
|
)
|
|
2499
2527
|
|
|
@@ -2503,6 +2531,9 @@ class AsyncAgentaApi:
|
|
|
2503
2531
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2504
2532
|
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
2505
2533
|
method="POST",
|
|
2534
|
+
params={
|
|
2535
|
+
"project_id": project_id,
|
|
2536
|
+
},
|
|
2506
2537
|
json={
|
|
2507
2538
|
"token": token,
|
|
2508
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)
|