agenta 0.27.0__py3-none-any.whl → 0.27.0a1__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.

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