agenta 0.12.2__py3-none-any.whl → 0.32.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 (244) hide show
  1. agenta/__init__.py +64 -7
  2. agenta/cli/helper.py +7 -3
  3. agenta/cli/main.py +15 -50
  4. agenta/cli/variant_commands.py +50 -29
  5. agenta/client/Readme.md +72 -64
  6. agenta/client/api.py +2 -2
  7. agenta/client/backend/__init__.py +193 -22
  8. agenta/client/backend/access_control/__init__.py +1 -0
  9. agenta/client/backend/access_control/client.py +167 -0
  10. agenta/client/backend/apps/__init__.py +1 -0
  11. agenta/client/backend/apps/client.py +1691 -0
  12. agenta/client/backend/bases/__init__.py +1 -0
  13. agenta/client/backend/bases/client.py +190 -0
  14. agenta/client/backend/client.py +2508 -5712
  15. agenta/client/backend/configs/__init__.py +1 -0
  16. agenta/client/backend/configs/client.py +604 -0
  17. agenta/client/backend/containers/__init__.py +5 -0
  18. agenta/client/backend/containers/client.py +648 -0
  19. agenta/client/backend/containers/types/__init__.py +5 -0
  20. agenta/client/backend/{types → containers/types}/container_templates_response.py +1 -2
  21. agenta/client/backend/core/__init__.py +30 -0
  22. agenta/client/backend/core/client_wrapper.py +42 -9
  23. agenta/client/backend/core/file.py +70 -0
  24. agenta/client/backend/core/http_client.py +575 -0
  25. agenta/client/backend/core/jsonable_encoder.py +33 -39
  26. agenta/client/backend/core/pydantic_utilities.py +325 -0
  27. agenta/client/backend/core/query_encoder.py +60 -0
  28. agenta/client/backend/core/remove_none_from_dict.py +2 -2
  29. agenta/client/backend/core/request_options.py +35 -0
  30. agenta/client/backend/core/serialization.py +276 -0
  31. agenta/client/backend/environments/__init__.py +1 -0
  32. agenta/client/backend/environments/client.py +196 -0
  33. agenta/client/backend/evaluations/__init__.py +1 -0
  34. agenta/client/backend/evaluations/client.py +1469 -0
  35. agenta/client/backend/evaluators/__init__.py +1 -0
  36. agenta/client/backend/evaluators/client.py +1283 -0
  37. agenta/client/backend/observability/__init__.py +1 -0
  38. agenta/client/backend/observability/client.py +1286 -0
  39. agenta/client/backend/observability_v_1/__init__.py +5 -0
  40. agenta/client/backend/observability_v_1/client.py +763 -0
  41. agenta/client/backend/observability_v_1/types/__init__.py +7 -0
  42. agenta/client/backend/observability_v_1/types/format.py +5 -0
  43. agenta/client/backend/observability_v_1/types/query_analytics_response.py +7 -0
  44. agenta/client/backend/observability_v_1/types/query_traces_response.py +11 -0
  45. agenta/client/backend/scopes/__init__.py +1 -0
  46. agenta/client/backend/scopes/client.py +114 -0
  47. agenta/client/backend/testsets/__init__.py +1 -0
  48. agenta/client/backend/testsets/client.py +1284 -0
  49. agenta/client/backend/types/__init__.py +154 -26
  50. agenta/client/backend/types/agenta_node_dto.py +48 -0
  51. agenta/client/backend/types/agenta_node_dto_nodes_value.py +6 -0
  52. agenta/client/backend/types/agenta_nodes_response.py +30 -0
  53. agenta/client/backend/types/agenta_root_dto.py +30 -0
  54. agenta/client/backend/types/agenta_roots_response.py +30 -0
  55. agenta/client/backend/types/agenta_tree_dto.py +30 -0
  56. agenta/client/backend/types/agenta_trees_response.py +30 -0
  57. agenta/client/backend/types/aggregated_result.py +16 -31
  58. agenta/client/backend/types/aggregated_result_evaluator_config.py +8 -0
  59. agenta/client/backend/types/analytics_response.py +24 -0
  60. agenta/client/backend/types/app.py +17 -30
  61. agenta/client/backend/types/app_variant_response.py +36 -0
  62. agenta/client/backend/types/app_variant_revision.py +17 -32
  63. agenta/client/backend/types/base_output.py +13 -28
  64. agenta/client/backend/types/body_import_testset.py +15 -31
  65. agenta/client/backend/types/bucket_dto.py +26 -0
  66. agenta/client/backend/types/collect_status_response.py +22 -0
  67. agenta/client/backend/types/config_db.py +16 -31
  68. agenta/client/backend/types/config_dto.py +32 -0
  69. agenta/client/backend/types/config_response_model.py +32 -0
  70. agenta/client/backend/types/correct_answer.py +22 -0
  71. agenta/client/backend/types/create_app_output.py +13 -28
  72. agenta/client/backend/types/create_span.py +45 -0
  73. agenta/client/backend/types/create_trace_response.py +22 -0
  74. agenta/client/backend/types/docker_env_vars.py +13 -28
  75. agenta/client/backend/types/environment_output.py +22 -34
  76. agenta/client/backend/types/environment_output_extended.py +31 -0
  77. agenta/client/backend/types/environment_revision.py +26 -0
  78. agenta/client/backend/types/error.py +22 -0
  79. agenta/client/backend/types/evaluation.py +22 -33
  80. agenta/client/backend/types/evaluation_scenario.py +18 -33
  81. agenta/client/backend/types/evaluation_scenario_input.py +16 -31
  82. agenta/client/backend/types/evaluation_scenario_output.py +17 -30
  83. agenta/client/backend/types/evaluation_scenario_result.py +14 -29
  84. agenta/client/backend/types/evaluation_scenario_score_update.py +21 -0
  85. agenta/client/backend/types/evaluation_status_enum.py +11 -29
  86. agenta/client/backend/types/evaluation_type.py +3 -21
  87. agenta/client/backend/types/evaluator.py +20 -31
  88. agenta/client/backend/types/evaluator_config.py +21 -33
  89. agenta/client/backend/types/evaluator_mapping_output_interface.py +21 -0
  90. agenta/client/backend/types/evaluator_output_interface.py +21 -0
  91. agenta/client/backend/types/exception_dto.py +26 -0
  92. agenta/client/backend/types/get_config_response.py +23 -0
  93. agenta/client/backend/types/header_dto.py +22 -0
  94. agenta/client/backend/types/http_validation_error.py +14 -29
  95. agenta/client/backend/types/human_evaluation.py +18 -34
  96. agenta/client/backend/types/human_evaluation_scenario.py +22 -38
  97. agenta/client/backend/types/human_evaluation_scenario_input.py +13 -28
  98. agenta/client/backend/types/human_evaluation_scenario_output.py +13 -28
  99. agenta/client/backend/types/human_evaluation_scenario_update.py +30 -0
  100. agenta/client/backend/types/human_evaluation_update.py +22 -0
  101. agenta/client/backend/types/image.py +18 -32
  102. agenta/client/backend/types/invite_request.py +16 -30
  103. agenta/client/backend/types/legacy_analytics_response.py +29 -0
  104. agenta/client/backend/types/legacy_data_point.py +27 -0
  105. agenta/client/backend/types/lifecycle_dto.py +24 -0
  106. agenta/client/backend/types/link_dto.py +24 -0
  107. agenta/client/backend/types/list_api_keys_response.py +24 -0
  108. agenta/client/backend/types/llm_run_rate_limit.py +13 -28
  109. agenta/client/backend/types/llm_tokens.py +23 -0
  110. agenta/client/backend/types/metrics_dto.py +24 -0
  111. agenta/client/backend/types/new_human_evaluation.py +27 -0
  112. agenta/client/backend/types/new_testset.py +16 -31
  113. agenta/client/backend/types/node_dto.py +24 -0
  114. agenta/client/backend/types/node_type.py +19 -0
  115. agenta/client/backend/types/o_tel_context_dto.py +22 -0
  116. agenta/client/backend/types/o_tel_event_dto.py +23 -0
  117. agenta/client/backend/types/o_tel_extra_dto.py +26 -0
  118. agenta/client/backend/types/o_tel_link_dto.py +23 -0
  119. agenta/client/backend/types/o_tel_span_dto.py +37 -0
  120. agenta/client/backend/types/o_tel_span_kind.py +15 -0
  121. agenta/client/backend/types/o_tel_spans_response.py +24 -0
  122. agenta/client/backend/types/o_tel_status_code.py +8 -0
  123. agenta/client/backend/types/organization.py +22 -35
  124. agenta/client/backend/types/organization_output.py +13 -28
  125. agenta/client/backend/types/outputs.py +5 -0
  126. agenta/client/backend/types/parent_dto.py +21 -0
  127. agenta/client/backend/types/permission.py +41 -0
  128. agenta/client/backend/types/projects_response.py +28 -0
  129. agenta/client/backend/types/provider_key_dto.py +23 -0
  130. agenta/client/backend/types/provider_kind.py +21 -0
  131. agenta/client/backend/types/reference_dto.py +23 -0
  132. agenta/client/backend/types/reference_request_model.py +23 -0
  133. agenta/client/backend/types/result.py +18 -31
  134. agenta/client/backend/types/root_dto.py +21 -0
  135. agenta/client/backend/types/{human_evaluation_scenario_score.py → score.py} +1 -1
  136. agenta/client/backend/types/secret_dto.py +24 -0
  137. agenta/client/backend/types/{human_evaluation_scenario_update_score.py → secret_kind.py} +1 -1
  138. agenta/client/backend/types/secret_response_dto.py +27 -0
  139. agenta/client/backend/types/simple_evaluation_output.py +13 -28
  140. agenta/client/backend/types/span.py +39 -49
  141. agenta/client/backend/types/span_detail.py +44 -0
  142. agenta/client/backend/types/span_dto.py +54 -0
  143. agenta/client/backend/types/span_dto_nodes_value.py +9 -0
  144. agenta/client/backend/types/span_status_code.py +5 -0
  145. agenta/client/backend/types/span_variant.py +23 -0
  146. agenta/client/backend/types/status_code.py +5 -0
  147. agenta/client/backend/types/status_dto.py +23 -0
  148. agenta/client/backend/types/template.py +14 -29
  149. agenta/client/backend/types/template_image_info.py +21 -35
  150. agenta/client/backend/types/test_set_output_response.py +20 -33
  151. agenta/client/backend/types/test_set_simple_response.py +13 -28
  152. agenta/client/backend/types/time_dto.py +23 -0
  153. agenta/client/backend/types/trace_detail.py +44 -0
  154. agenta/client/backend/types/tree_dto.py +23 -0
  155. agenta/client/backend/types/tree_type.py +5 -0
  156. agenta/client/backend/types/update_app_output.py +22 -0
  157. agenta/client/backend/types/uri.py +13 -28
  158. agenta/client/backend/types/validation_error.py +13 -28
  159. agenta/client/backend/types/variant_action.py +14 -29
  160. agenta/client/backend/types/variant_action_enum.py +1 -19
  161. agenta/client/backend/types/with_pagination.py +26 -0
  162. agenta/client/backend/types/workspace_member_response.py +23 -0
  163. agenta/client/backend/types/workspace_permission.py +25 -0
  164. agenta/client/backend/types/workspace_response.py +29 -0
  165. agenta/client/backend/types/workspace_role.py +15 -0
  166. agenta/client/backend/types/workspace_role_response.py +23 -0
  167. agenta/client/backend/variants/__init__.py +5 -0
  168. agenta/client/backend/variants/client.py +2814 -0
  169. agenta/client/backend/variants/types/__init__.py +7 -0
  170. agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +8 -0
  171. agenta/client/backend/vault/__init__.py +1 -0
  172. agenta/client/backend/vault/client.py +685 -0
  173. agenta/client/client.py +1 -1
  174. agenta/config.py +0 -2
  175. agenta/config.toml +0 -1
  176. agenta/docker/docker-assets/Dockerfile.cloud.template +2 -1
  177. agenta/docker/docker-assets/Dockerfile.template +2 -1
  178. agenta/docker/docker_utils.py +11 -12
  179. agenta/sdk/__init__.py +58 -7
  180. agenta/sdk/agenta_init.py +182 -164
  181. agenta/sdk/assets.py +95 -0
  182. agenta/sdk/client.py +56 -0
  183. agenta/sdk/context/__init__.py +0 -0
  184. agenta/sdk/context/exporting.py +25 -0
  185. agenta/sdk/context/routing.py +27 -0
  186. agenta/sdk/context/tracing.py +28 -0
  187. agenta/sdk/decorators/__init__.py +0 -0
  188. agenta/sdk/decorators/routing.py +576 -0
  189. agenta/sdk/decorators/tracing.py +296 -0
  190. agenta/sdk/litellm/__init__.py +1 -0
  191. agenta/sdk/litellm/litellm.py +314 -0
  192. agenta/sdk/litellm/mockllm.py +27 -0
  193. agenta/sdk/litellm/mocks/__init__.py +26 -0
  194. agenta/sdk/managers/__init__.py +6 -0
  195. agenta/sdk/managers/config.py +208 -0
  196. agenta/sdk/managers/deployment.py +45 -0
  197. agenta/sdk/managers/secrets.py +38 -0
  198. agenta/sdk/managers/shared.py +639 -0
  199. agenta/sdk/managers/variant.py +182 -0
  200. agenta/sdk/managers/vault.py +16 -0
  201. agenta/sdk/middleware/__init__.py +0 -0
  202. agenta/sdk/middleware/auth.py +180 -0
  203. agenta/sdk/middleware/cache.py +47 -0
  204. agenta/sdk/middleware/config.py +255 -0
  205. agenta/sdk/middleware/cors.py +29 -0
  206. agenta/sdk/middleware/inline.py +38 -0
  207. agenta/sdk/middleware/mock.py +33 -0
  208. agenta/sdk/middleware/otel.py +40 -0
  209. agenta/sdk/middleware/vault.py +145 -0
  210. agenta/sdk/router.py +0 -7
  211. agenta/sdk/tracing/__init__.py +1 -0
  212. agenta/sdk/tracing/attributes.py +141 -0
  213. agenta/sdk/tracing/conventions.py +49 -0
  214. agenta/sdk/tracing/exporters.py +103 -0
  215. agenta/sdk/tracing/inline.py +1146 -0
  216. agenta/sdk/tracing/processors.py +121 -0
  217. agenta/sdk/tracing/spans.py +136 -0
  218. agenta/sdk/tracing/tracing.py +237 -0
  219. agenta/sdk/types.py +478 -74
  220. agenta/sdk/utils/__init__.py +0 -0
  221. agenta/sdk/utils/constants.py +1 -0
  222. agenta/sdk/utils/{helper/openai_cost.py → costs.py} +3 -0
  223. agenta/sdk/utils/exceptions.py +59 -0
  224. agenta/sdk/utils/globals.py +6 -10
  225. agenta/sdk/utils/helpers.py +8 -0
  226. agenta/sdk/utils/logging.py +21 -0
  227. agenta/sdk/utils/singleton.py +13 -0
  228. agenta/sdk/utils/timing.py +58 -0
  229. {agenta-0.12.2.dist-info → agenta-0.32.0a1.dist-info}/METADATA +98 -151
  230. agenta-0.32.0a1.dist-info/RECORD +263 -0
  231. {agenta-0.12.2.dist-info → agenta-0.32.0a1.dist-info}/WHEEL +1 -1
  232. agenta/client/backend/types/add_variant_from_base_and_config_response.py +0 -7
  233. agenta/client/backend/types/app_variant_output.py +0 -47
  234. agenta/client/backend/types/app_variant_output_extended.py +0 -50
  235. agenta/client/backend/types/delete_evaluation.py +0 -36
  236. agenta/client/backend/types/evaluation_webhook.py +0 -36
  237. agenta/client/backend/types/feedback.py +0 -40
  238. agenta/client/backend/types/get_config_reponse.py +0 -39
  239. agenta/client/backend/types/list_api_keys_output.py +0 -39
  240. agenta/client/backend/types/trace.py +0 -48
  241. agenta/sdk/agenta_decorator.py +0 -443
  242. agenta/sdk/context.py +0 -41
  243. agenta-0.12.2.dist-info/RECORD +0 -114
  244. {agenta-0.12.2.dist-info → agenta-0.32.0a1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,1286 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from ..core.request_options import RequestOptions
6
+ from ..core.pydantic_utilities import parse_obj_as
7
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
8
+ from ..types.http_validation_error import HttpValidationError
9
+ from json.decoder import JSONDecodeError
10
+ from ..core.api_error import ApiError
11
+ from ..types.create_span import CreateSpan
12
+ from ..types.create_trace_response import CreateTraceResponse
13
+ from ..core.serialization import convert_and_respect_annotation_metadata
14
+ from ..types.with_pagination import WithPagination
15
+ from ..types.trace_detail import TraceDetail
16
+ from ..core.jsonable_encoder import jsonable_encoder
17
+ from ..types.span_detail import SpanDetail
18
+ from ..core.client_wrapper import AsyncClientWrapper
19
+
20
+ # this is used as the default value for optional parameters
21
+ OMIT = typing.cast(typing.Any, ...)
22
+
23
+
24
+ class ObservabilityClient:
25
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
26
+ self._client_wrapper = client_wrapper
27
+
28
+ def dashboard(
29
+ self,
30
+ *,
31
+ app_id: str,
32
+ time_range: typing.Optional[str] = None,
33
+ environment: typing.Optional[str] = None,
34
+ variant: typing.Optional[str] = None,
35
+ request_options: typing.Optional[RequestOptions] = None,
36
+ ) -> typing.Optional[typing.Any]:
37
+ """
38
+ Parameters
39
+ ----------
40
+ app_id : str
41
+
42
+ time_range : typing.Optional[str]
43
+
44
+ environment : typing.Optional[str]
45
+
46
+ variant : typing.Optional[str]
47
+
48
+ request_options : typing.Optional[RequestOptions]
49
+ Request-specific configuration.
50
+
51
+ Returns
52
+ -------
53
+ typing.Optional[typing.Any]
54
+ Successful Response
55
+
56
+ Examples
57
+ --------
58
+ from agenta import AgentaApi
59
+
60
+ client = AgentaApi(
61
+ api_key="YOUR_API_KEY",
62
+ base_url="https://yourhost.com/path/to/api",
63
+ )
64
+ client.observability.dashboard(
65
+ app_id="app_id",
66
+ )
67
+ """
68
+ _response = self._client_wrapper.httpx_client.request(
69
+ "observability/dashboard",
70
+ method="GET",
71
+ params={
72
+ "app_id": app_id,
73
+ "timeRange": time_range,
74
+ "environment": environment,
75
+ "variant": variant,
76
+ },
77
+ request_options=request_options,
78
+ )
79
+ try:
80
+ if 200 <= _response.status_code < 300:
81
+ return typing.cast(
82
+ typing.Optional[typing.Any],
83
+ parse_obj_as(
84
+ type_=typing.Optional[typing.Any], # type: ignore
85
+ object_=_response.json(),
86
+ ),
87
+ )
88
+ if _response.status_code == 422:
89
+ raise UnprocessableEntityError(
90
+ typing.cast(
91
+ HttpValidationError,
92
+ parse_obj_as(
93
+ type_=HttpValidationError, # type: ignore
94
+ object_=_response.json(),
95
+ ),
96
+ )
97
+ )
98
+ _response_json = _response.json()
99
+ except JSONDecodeError:
100
+ raise ApiError(status_code=_response.status_code, body=_response.text)
101
+ raise ApiError(status_code=_response.status_code, body=_response_json)
102
+
103
+ def create_traces(
104
+ self,
105
+ *,
106
+ trace: str,
107
+ spans: typing.Sequence[CreateSpan],
108
+ request_options: typing.Optional[RequestOptions] = None,
109
+ ) -> CreateTraceResponse:
110
+ """
111
+ Parameters
112
+ ----------
113
+ trace : str
114
+
115
+ spans : typing.Sequence[CreateSpan]
116
+
117
+ request_options : typing.Optional[RequestOptions]
118
+ Request-specific configuration.
119
+
120
+ Returns
121
+ -------
122
+ CreateTraceResponse
123
+ Successful Response
124
+
125
+ Examples
126
+ --------
127
+ import datetime
128
+
129
+ from agenta import AgentaApi, CreateSpan
130
+
131
+ client = AgentaApi(
132
+ api_key="YOUR_API_KEY",
133
+ base_url="https://yourhost.com/path/to/api",
134
+ )
135
+ client.observability.create_traces(
136
+ trace="trace",
137
+ spans=[
138
+ CreateSpan(
139
+ id="id",
140
+ app_id="app_id",
141
+ name="name",
142
+ spankind="spankind",
143
+ status="status",
144
+ start_time=datetime.datetime.fromisoformat(
145
+ "2024-01-15 09:30:00+00:00",
146
+ ),
147
+ end_time=datetime.datetime.fromisoformat(
148
+ "2024-01-15 09:30:00+00:00",
149
+ ),
150
+ )
151
+ ],
152
+ )
153
+ """
154
+ _response = self._client_wrapper.httpx_client.request(
155
+ "observability/trace",
156
+ method="POST",
157
+ json={
158
+ "trace": trace,
159
+ "spans": convert_and_respect_annotation_metadata(
160
+ object_=spans,
161
+ annotation=typing.Sequence[CreateSpan],
162
+ direction="write",
163
+ ),
164
+ },
165
+ headers={
166
+ "content-type": "application/json",
167
+ },
168
+ request_options=request_options,
169
+ omit=OMIT,
170
+ )
171
+ try:
172
+ if 200 <= _response.status_code < 300:
173
+ return typing.cast(
174
+ CreateTraceResponse,
175
+ parse_obj_as(
176
+ type_=CreateTraceResponse, # type: ignore
177
+ object_=_response.json(),
178
+ ),
179
+ )
180
+ if _response.status_code == 422:
181
+ raise UnprocessableEntityError(
182
+ typing.cast(
183
+ HttpValidationError,
184
+ parse_obj_as(
185
+ type_=HttpValidationError, # type: ignore
186
+ object_=_response.json(),
187
+ ),
188
+ )
189
+ )
190
+ _response_json = _response.json()
191
+ except JSONDecodeError:
192
+ raise ApiError(status_code=_response.status_code, body=_response.text)
193
+ raise ApiError(status_code=_response.status_code, body=_response_json)
194
+
195
+ def get_traces(
196
+ self,
197
+ *,
198
+ app_id: str,
199
+ page: typing.Optional[int] = None,
200
+ page_size: typing.Optional[int] = None,
201
+ type: typing.Optional[str] = None,
202
+ trace_id: typing.Optional[str] = None,
203
+ environment: typing.Optional[str] = None,
204
+ variant: typing.Optional[str] = None,
205
+ created_at: typing.Optional[str] = None,
206
+ request_options: typing.Optional[RequestOptions] = None,
207
+ ) -> WithPagination:
208
+ """
209
+ Parameters
210
+ ----------
211
+ app_id : str
212
+
213
+ page : typing.Optional[int]
214
+
215
+ page_size : typing.Optional[int]
216
+
217
+ type : typing.Optional[str]
218
+
219
+ trace_id : typing.Optional[str]
220
+
221
+ environment : typing.Optional[str]
222
+
223
+ variant : typing.Optional[str]
224
+
225
+ created_at : typing.Optional[str]
226
+
227
+ request_options : typing.Optional[RequestOptions]
228
+ Request-specific configuration.
229
+
230
+ Returns
231
+ -------
232
+ WithPagination
233
+ Successful Response
234
+
235
+ Examples
236
+ --------
237
+ from agenta import AgentaApi
238
+
239
+ client = AgentaApi(
240
+ api_key="YOUR_API_KEY",
241
+ base_url="https://yourhost.com/path/to/api",
242
+ )
243
+ client.observability.get_traces(
244
+ app_id="app_id",
245
+ )
246
+ """
247
+ _response = self._client_wrapper.httpx_client.request(
248
+ "observability/traces",
249
+ method="GET",
250
+ params={
251
+ "app_id": app_id,
252
+ "page": page,
253
+ "pageSize": page_size,
254
+ "type": type,
255
+ "trace_id": trace_id,
256
+ "environment": environment,
257
+ "variant": variant,
258
+ "created_at": created_at,
259
+ },
260
+ request_options=request_options,
261
+ )
262
+ try:
263
+ if 200 <= _response.status_code < 300:
264
+ return typing.cast(
265
+ WithPagination,
266
+ parse_obj_as(
267
+ type_=WithPagination, # type: ignore
268
+ object_=_response.json(),
269
+ ),
270
+ )
271
+ if _response.status_code == 422:
272
+ raise UnprocessableEntityError(
273
+ typing.cast(
274
+ HttpValidationError,
275
+ parse_obj_as(
276
+ type_=HttpValidationError, # type: ignore
277
+ object_=_response.json(),
278
+ ),
279
+ )
280
+ )
281
+ _response_json = _response.json()
282
+ except JSONDecodeError:
283
+ raise ApiError(status_code=_response.status_code, body=_response.text)
284
+ raise ApiError(status_code=_response.status_code, body=_response_json)
285
+
286
+ def delete_traces_legacy(
287
+ self,
288
+ *,
289
+ request: typing.Sequence[str],
290
+ request_options: typing.Optional[RequestOptions] = None,
291
+ ) -> bool:
292
+ """
293
+ Parameters
294
+ ----------
295
+ request : typing.Sequence[str]
296
+
297
+ request_options : typing.Optional[RequestOptions]
298
+ Request-specific configuration.
299
+
300
+ Returns
301
+ -------
302
+ bool
303
+ Successful Response
304
+
305
+ Examples
306
+ --------
307
+ from agenta import AgentaApi
308
+
309
+ client = AgentaApi(
310
+ api_key="YOUR_API_KEY",
311
+ base_url="https://yourhost.com/path/to/api",
312
+ )
313
+ client.observability.delete_traces_legacy(
314
+ request=["string"],
315
+ )
316
+ """
317
+ _response = self._client_wrapper.httpx_client.request(
318
+ "observability/traces",
319
+ method="DELETE",
320
+ json=request,
321
+ request_options=request_options,
322
+ omit=OMIT,
323
+ )
324
+ try:
325
+ if 200 <= _response.status_code < 300:
326
+ return typing.cast(
327
+ bool,
328
+ parse_obj_as(
329
+ type_=bool, # type: ignore
330
+ object_=_response.json(),
331
+ ),
332
+ )
333
+ if _response.status_code == 422:
334
+ raise UnprocessableEntityError(
335
+ typing.cast(
336
+ HttpValidationError,
337
+ parse_obj_as(
338
+ type_=HttpValidationError, # type: ignore
339
+ object_=_response.json(),
340
+ ),
341
+ )
342
+ )
343
+ _response_json = _response.json()
344
+ except JSONDecodeError:
345
+ raise ApiError(status_code=_response.status_code, body=_response.text)
346
+ raise ApiError(status_code=_response.status_code, body=_response_json)
347
+
348
+ def get_trace_detail(
349
+ self, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
350
+ ) -> TraceDetail:
351
+ """
352
+ Parameters
353
+ ----------
354
+ trace_id : str
355
+
356
+ request_options : typing.Optional[RequestOptions]
357
+ Request-specific configuration.
358
+
359
+ Returns
360
+ -------
361
+ TraceDetail
362
+ Successful Response
363
+
364
+ Examples
365
+ --------
366
+ from agenta import AgentaApi
367
+
368
+ client = AgentaApi(
369
+ api_key="YOUR_API_KEY",
370
+ base_url="https://yourhost.com/path/to/api",
371
+ )
372
+ client.observability.get_trace_detail(
373
+ trace_id="trace_id",
374
+ )
375
+ """
376
+ _response = self._client_wrapper.httpx_client.request(
377
+ f"observability/traces/{jsonable_encoder(trace_id)}",
378
+ method="GET",
379
+ request_options=request_options,
380
+ )
381
+ try:
382
+ if 200 <= _response.status_code < 300:
383
+ return typing.cast(
384
+ TraceDetail,
385
+ parse_obj_as(
386
+ type_=TraceDetail, # type: ignore
387
+ object_=_response.json(),
388
+ ),
389
+ )
390
+ if _response.status_code == 422:
391
+ raise UnprocessableEntityError(
392
+ typing.cast(
393
+ HttpValidationError,
394
+ parse_obj_as(
395
+ type_=HttpValidationError, # type: ignore
396
+ object_=_response.json(),
397
+ ),
398
+ )
399
+ )
400
+ _response_json = _response.json()
401
+ except JSONDecodeError:
402
+ raise ApiError(status_code=_response.status_code, body=_response.text)
403
+ raise ApiError(status_code=_response.status_code, body=_response_json)
404
+
405
+ def get_spans_of_generation(
406
+ self,
407
+ *,
408
+ app_id: str,
409
+ page: typing.Optional[int] = None,
410
+ page_size: typing.Optional[int] = None,
411
+ type: typing.Optional[str] = None,
412
+ trace_id: typing.Optional[str] = None,
413
+ environment: typing.Optional[str] = None,
414
+ variant: typing.Optional[str] = None,
415
+ created_at: typing.Optional[str] = None,
416
+ request_options: typing.Optional[RequestOptions] = None,
417
+ ) -> typing.Optional[typing.Any]:
418
+ """
419
+ Parameters
420
+ ----------
421
+ app_id : str
422
+
423
+ page : typing.Optional[int]
424
+
425
+ page_size : typing.Optional[int]
426
+
427
+ type : typing.Optional[str]
428
+
429
+ trace_id : typing.Optional[str]
430
+
431
+ environment : typing.Optional[str]
432
+
433
+ variant : typing.Optional[str]
434
+
435
+ created_at : typing.Optional[str]
436
+
437
+ request_options : typing.Optional[RequestOptions]
438
+ Request-specific configuration.
439
+
440
+ Returns
441
+ -------
442
+ typing.Optional[typing.Any]
443
+ Successful Response
444
+
445
+ Examples
446
+ --------
447
+ from agenta import AgentaApi
448
+
449
+ client = AgentaApi(
450
+ api_key="YOUR_API_KEY",
451
+ base_url="https://yourhost.com/path/to/api",
452
+ )
453
+ client.observability.get_spans_of_generation(
454
+ app_id="app_id",
455
+ )
456
+ """
457
+ _response = self._client_wrapper.httpx_client.request(
458
+ "observability/spans",
459
+ method="GET",
460
+ params={
461
+ "app_id": app_id,
462
+ "page": page,
463
+ "pageSize": page_size,
464
+ "type": type,
465
+ "trace_id": trace_id,
466
+ "environment": environment,
467
+ "variant": variant,
468
+ "created_at": created_at,
469
+ },
470
+ request_options=request_options,
471
+ )
472
+ try:
473
+ if 200 <= _response.status_code < 300:
474
+ return typing.cast(
475
+ typing.Optional[typing.Any],
476
+ parse_obj_as(
477
+ type_=typing.Optional[typing.Any], # type: ignore
478
+ object_=_response.json(),
479
+ ),
480
+ )
481
+ if _response.status_code == 422:
482
+ raise UnprocessableEntityError(
483
+ typing.cast(
484
+ HttpValidationError,
485
+ parse_obj_as(
486
+ type_=HttpValidationError, # type: ignore
487
+ object_=_response.json(),
488
+ ),
489
+ )
490
+ )
491
+ _response_json = _response.json()
492
+ except JSONDecodeError:
493
+ raise ApiError(status_code=_response.status_code, body=_response.text)
494
+ raise ApiError(status_code=_response.status_code, body=_response_json)
495
+
496
+ def delete_spans_of_trace(
497
+ self,
498
+ *,
499
+ request: typing.Sequence[str],
500
+ request_options: typing.Optional[RequestOptions] = None,
501
+ ) -> bool:
502
+ """
503
+ Parameters
504
+ ----------
505
+ request : typing.Sequence[str]
506
+
507
+ request_options : typing.Optional[RequestOptions]
508
+ Request-specific configuration.
509
+
510
+ Returns
511
+ -------
512
+ bool
513
+ Successful Response
514
+
515
+ Examples
516
+ --------
517
+ from agenta import AgentaApi
518
+
519
+ client = AgentaApi(
520
+ api_key="YOUR_API_KEY",
521
+ base_url="https://yourhost.com/path/to/api",
522
+ )
523
+ client.observability.delete_spans_of_trace(
524
+ request=["string"],
525
+ )
526
+ """
527
+ _response = self._client_wrapper.httpx_client.request(
528
+ "observability/spans",
529
+ method="DELETE",
530
+ json=request,
531
+ request_options=request_options,
532
+ omit=OMIT,
533
+ )
534
+ try:
535
+ if 200 <= _response.status_code < 300:
536
+ return typing.cast(
537
+ bool,
538
+ parse_obj_as(
539
+ type_=bool, # type: ignore
540
+ object_=_response.json(),
541
+ ),
542
+ )
543
+ if _response.status_code == 422:
544
+ raise UnprocessableEntityError(
545
+ typing.cast(
546
+ HttpValidationError,
547
+ parse_obj_as(
548
+ type_=HttpValidationError, # type: ignore
549
+ object_=_response.json(),
550
+ ),
551
+ )
552
+ )
553
+ _response_json = _response.json()
554
+ except JSONDecodeError:
555
+ raise ApiError(status_code=_response.status_code, body=_response.text)
556
+ raise ApiError(status_code=_response.status_code, body=_response_json)
557
+
558
+ def get_span_of_generation(
559
+ self,
560
+ span_id: str,
561
+ *,
562
+ type: typing.Optional[str] = None,
563
+ request_options: typing.Optional[RequestOptions] = None,
564
+ ) -> SpanDetail:
565
+ """
566
+ Parameters
567
+ ----------
568
+ span_id : str
569
+
570
+ type : typing.Optional[str]
571
+
572
+ request_options : typing.Optional[RequestOptions]
573
+ Request-specific configuration.
574
+
575
+ Returns
576
+ -------
577
+ SpanDetail
578
+ Successful Response
579
+
580
+ Examples
581
+ --------
582
+ from agenta import AgentaApi
583
+
584
+ client = AgentaApi(
585
+ api_key="YOUR_API_KEY",
586
+ base_url="https://yourhost.com/path/to/api",
587
+ )
588
+ client.observability.get_span_of_generation(
589
+ span_id="span_id",
590
+ )
591
+ """
592
+ _response = self._client_wrapper.httpx_client.request(
593
+ f"observability/spans/{jsonable_encoder(span_id)}",
594
+ method="GET",
595
+ params={
596
+ "type": type,
597
+ },
598
+ request_options=request_options,
599
+ )
600
+ try:
601
+ if 200 <= _response.status_code < 300:
602
+ return typing.cast(
603
+ SpanDetail,
604
+ parse_obj_as(
605
+ type_=SpanDetail, # type: ignore
606
+ object_=_response.json(),
607
+ ),
608
+ )
609
+ if _response.status_code == 422:
610
+ raise UnprocessableEntityError(
611
+ typing.cast(
612
+ HttpValidationError,
613
+ parse_obj_as(
614
+ type_=HttpValidationError, # type: ignore
615
+ object_=_response.json(),
616
+ ),
617
+ )
618
+ )
619
+ _response_json = _response.json()
620
+ except JSONDecodeError:
621
+ raise ApiError(status_code=_response.status_code, body=_response.text)
622
+ raise ApiError(status_code=_response.status_code, body=_response_json)
623
+
624
+
625
+ class AsyncObservabilityClient:
626
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
627
+ self._client_wrapper = client_wrapper
628
+
629
+ async def dashboard(
630
+ self,
631
+ *,
632
+ app_id: str,
633
+ time_range: typing.Optional[str] = None,
634
+ environment: typing.Optional[str] = None,
635
+ variant: typing.Optional[str] = None,
636
+ request_options: typing.Optional[RequestOptions] = None,
637
+ ) -> typing.Optional[typing.Any]:
638
+ """
639
+ Parameters
640
+ ----------
641
+ app_id : str
642
+
643
+ time_range : typing.Optional[str]
644
+
645
+ environment : typing.Optional[str]
646
+
647
+ variant : typing.Optional[str]
648
+
649
+ request_options : typing.Optional[RequestOptions]
650
+ Request-specific configuration.
651
+
652
+ Returns
653
+ -------
654
+ typing.Optional[typing.Any]
655
+ Successful Response
656
+
657
+ Examples
658
+ --------
659
+ import asyncio
660
+
661
+ from agenta import AsyncAgentaApi
662
+
663
+ client = AsyncAgentaApi(
664
+ api_key="YOUR_API_KEY",
665
+ base_url="https://yourhost.com/path/to/api",
666
+ )
667
+
668
+
669
+ async def main() -> None:
670
+ await client.observability.dashboard(
671
+ app_id="app_id",
672
+ )
673
+
674
+
675
+ asyncio.run(main())
676
+ """
677
+ _response = await self._client_wrapper.httpx_client.request(
678
+ "observability/dashboard",
679
+ method="GET",
680
+ params={
681
+ "app_id": app_id,
682
+ "timeRange": time_range,
683
+ "environment": environment,
684
+ "variant": variant,
685
+ },
686
+ request_options=request_options,
687
+ )
688
+ try:
689
+ if 200 <= _response.status_code < 300:
690
+ return typing.cast(
691
+ typing.Optional[typing.Any],
692
+ parse_obj_as(
693
+ type_=typing.Optional[typing.Any], # type: ignore
694
+ object_=_response.json(),
695
+ ),
696
+ )
697
+ if _response.status_code == 422:
698
+ raise UnprocessableEntityError(
699
+ typing.cast(
700
+ HttpValidationError,
701
+ parse_obj_as(
702
+ type_=HttpValidationError, # type: ignore
703
+ object_=_response.json(),
704
+ ),
705
+ )
706
+ )
707
+ _response_json = _response.json()
708
+ except JSONDecodeError:
709
+ raise ApiError(status_code=_response.status_code, body=_response.text)
710
+ raise ApiError(status_code=_response.status_code, body=_response_json)
711
+
712
+ async def create_traces(
713
+ self,
714
+ *,
715
+ trace: str,
716
+ spans: typing.Sequence[CreateSpan],
717
+ request_options: typing.Optional[RequestOptions] = None,
718
+ ) -> CreateTraceResponse:
719
+ """
720
+ Parameters
721
+ ----------
722
+ trace : str
723
+
724
+ spans : typing.Sequence[CreateSpan]
725
+
726
+ request_options : typing.Optional[RequestOptions]
727
+ Request-specific configuration.
728
+
729
+ Returns
730
+ -------
731
+ CreateTraceResponse
732
+ Successful Response
733
+
734
+ Examples
735
+ --------
736
+ import asyncio
737
+ import datetime
738
+
739
+ from agenta import AsyncAgentaApi, CreateSpan
740
+
741
+ client = AsyncAgentaApi(
742
+ api_key="YOUR_API_KEY",
743
+ base_url="https://yourhost.com/path/to/api",
744
+ )
745
+
746
+
747
+ async def main() -> None:
748
+ await client.observability.create_traces(
749
+ trace="trace",
750
+ spans=[
751
+ CreateSpan(
752
+ id="id",
753
+ app_id="app_id",
754
+ name="name",
755
+ spankind="spankind",
756
+ status="status",
757
+ start_time=datetime.datetime.fromisoformat(
758
+ "2024-01-15 09:30:00+00:00",
759
+ ),
760
+ end_time=datetime.datetime.fromisoformat(
761
+ "2024-01-15 09:30:00+00:00",
762
+ ),
763
+ )
764
+ ],
765
+ )
766
+
767
+
768
+ asyncio.run(main())
769
+ """
770
+ _response = await self._client_wrapper.httpx_client.request(
771
+ "observability/trace",
772
+ method="POST",
773
+ json={
774
+ "trace": trace,
775
+ "spans": convert_and_respect_annotation_metadata(
776
+ object_=spans,
777
+ annotation=typing.Sequence[CreateSpan],
778
+ direction="write",
779
+ ),
780
+ },
781
+ headers={
782
+ "content-type": "application/json",
783
+ },
784
+ request_options=request_options,
785
+ omit=OMIT,
786
+ )
787
+ try:
788
+ if 200 <= _response.status_code < 300:
789
+ return typing.cast(
790
+ CreateTraceResponse,
791
+ parse_obj_as(
792
+ type_=CreateTraceResponse, # type: ignore
793
+ object_=_response.json(),
794
+ ),
795
+ )
796
+ if _response.status_code == 422:
797
+ raise UnprocessableEntityError(
798
+ typing.cast(
799
+ HttpValidationError,
800
+ parse_obj_as(
801
+ type_=HttpValidationError, # type: ignore
802
+ object_=_response.json(),
803
+ ),
804
+ )
805
+ )
806
+ _response_json = _response.json()
807
+ except JSONDecodeError:
808
+ raise ApiError(status_code=_response.status_code, body=_response.text)
809
+ raise ApiError(status_code=_response.status_code, body=_response_json)
810
+
811
+ async def get_traces(
812
+ self,
813
+ *,
814
+ app_id: str,
815
+ page: typing.Optional[int] = None,
816
+ page_size: typing.Optional[int] = None,
817
+ type: typing.Optional[str] = None,
818
+ trace_id: typing.Optional[str] = None,
819
+ environment: typing.Optional[str] = None,
820
+ variant: typing.Optional[str] = None,
821
+ created_at: typing.Optional[str] = None,
822
+ request_options: typing.Optional[RequestOptions] = None,
823
+ ) -> WithPagination:
824
+ """
825
+ Parameters
826
+ ----------
827
+ app_id : str
828
+
829
+ page : typing.Optional[int]
830
+
831
+ page_size : typing.Optional[int]
832
+
833
+ type : typing.Optional[str]
834
+
835
+ trace_id : typing.Optional[str]
836
+
837
+ environment : typing.Optional[str]
838
+
839
+ variant : typing.Optional[str]
840
+
841
+ created_at : typing.Optional[str]
842
+
843
+ request_options : typing.Optional[RequestOptions]
844
+ Request-specific configuration.
845
+
846
+ Returns
847
+ -------
848
+ WithPagination
849
+ Successful Response
850
+
851
+ Examples
852
+ --------
853
+ import asyncio
854
+
855
+ from agenta import AsyncAgentaApi
856
+
857
+ client = AsyncAgentaApi(
858
+ api_key="YOUR_API_KEY",
859
+ base_url="https://yourhost.com/path/to/api",
860
+ )
861
+
862
+
863
+ async def main() -> None:
864
+ await client.observability.get_traces(
865
+ app_id="app_id",
866
+ )
867
+
868
+
869
+ asyncio.run(main())
870
+ """
871
+ _response = await self._client_wrapper.httpx_client.request(
872
+ "observability/traces",
873
+ method="GET",
874
+ params={
875
+ "app_id": app_id,
876
+ "page": page,
877
+ "pageSize": page_size,
878
+ "type": type,
879
+ "trace_id": trace_id,
880
+ "environment": environment,
881
+ "variant": variant,
882
+ "created_at": created_at,
883
+ },
884
+ request_options=request_options,
885
+ )
886
+ try:
887
+ if 200 <= _response.status_code < 300:
888
+ return typing.cast(
889
+ WithPagination,
890
+ parse_obj_as(
891
+ type_=WithPagination, # type: ignore
892
+ object_=_response.json(),
893
+ ),
894
+ )
895
+ if _response.status_code == 422:
896
+ raise UnprocessableEntityError(
897
+ typing.cast(
898
+ HttpValidationError,
899
+ parse_obj_as(
900
+ type_=HttpValidationError, # type: ignore
901
+ object_=_response.json(),
902
+ ),
903
+ )
904
+ )
905
+ _response_json = _response.json()
906
+ except JSONDecodeError:
907
+ raise ApiError(status_code=_response.status_code, body=_response.text)
908
+ raise ApiError(status_code=_response.status_code, body=_response_json)
909
+
910
+ async def delete_traces_legacy(
911
+ self,
912
+ *,
913
+ request: typing.Sequence[str],
914
+ request_options: typing.Optional[RequestOptions] = None,
915
+ ) -> bool:
916
+ """
917
+ Parameters
918
+ ----------
919
+ request : typing.Sequence[str]
920
+
921
+ request_options : typing.Optional[RequestOptions]
922
+ Request-specific configuration.
923
+
924
+ Returns
925
+ -------
926
+ bool
927
+ Successful Response
928
+
929
+ Examples
930
+ --------
931
+ import asyncio
932
+
933
+ from agenta import AsyncAgentaApi
934
+
935
+ client = AsyncAgentaApi(
936
+ api_key="YOUR_API_KEY",
937
+ base_url="https://yourhost.com/path/to/api",
938
+ )
939
+
940
+
941
+ async def main() -> None:
942
+ await client.observability.delete_traces_legacy(
943
+ request=["string"],
944
+ )
945
+
946
+
947
+ asyncio.run(main())
948
+ """
949
+ _response = await self._client_wrapper.httpx_client.request(
950
+ "observability/traces",
951
+ method="DELETE",
952
+ json=request,
953
+ request_options=request_options,
954
+ omit=OMIT,
955
+ )
956
+ try:
957
+ if 200 <= _response.status_code < 300:
958
+ return typing.cast(
959
+ bool,
960
+ parse_obj_as(
961
+ type_=bool, # type: ignore
962
+ object_=_response.json(),
963
+ ),
964
+ )
965
+ if _response.status_code == 422:
966
+ raise UnprocessableEntityError(
967
+ typing.cast(
968
+ HttpValidationError,
969
+ parse_obj_as(
970
+ type_=HttpValidationError, # type: ignore
971
+ object_=_response.json(),
972
+ ),
973
+ )
974
+ )
975
+ _response_json = _response.json()
976
+ except JSONDecodeError:
977
+ raise ApiError(status_code=_response.status_code, body=_response.text)
978
+ raise ApiError(status_code=_response.status_code, body=_response_json)
979
+
980
+ async def get_trace_detail(
981
+ self, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None
982
+ ) -> TraceDetail:
983
+ """
984
+ Parameters
985
+ ----------
986
+ trace_id : str
987
+
988
+ request_options : typing.Optional[RequestOptions]
989
+ Request-specific configuration.
990
+
991
+ Returns
992
+ -------
993
+ TraceDetail
994
+ Successful Response
995
+
996
+ Examples
997
+ --------
998
+ import asyncio
999
+
1000
+ from agenta import AsyncAgentaApi
1001
+
1002
+ client = AsyncAgentaApi(
1003
+ api_key="YOUR_API_KEY",
1004
+ base_url="https://yourhost.com/path/to/api",
1005
+ )
1006
+
1007
+
1008
+ async def main() -> None:
1009
+ await client.observability.get_trace_detail(
1010
+ trace_id="trace_id",
1011
+ )
1012
+
1013
+
1014
+ asyncio.run(main())
1015
+ """
1016
+ _response = await self._client_wrapper.httpx_client.request(
1017
+ f"observability/traces/{jsonable_encoder(trace_id)}",
1018
+ method="GET",
1019
+ request_options=request_options,
1020
+ )
1021
+ try:
1022
+ if 200 <= _response.status_code < 300:
1023
+ return typing.cast(
1024
+ TraceDetail,
1025
+ parse_obj_as(
1026
+ type_=TraceDetail, # type: ignore
1027
+ object_=_response.json(),
1028
+ ),
1029
+ )
1030
+ if _response.status_code == 422:
1031
+ raise UnprocessableEntityError(
1032
+ typing.cast(
1033
+ HttpValidationError,
1034
+ parse_obj_as(
1035
+ type_=HttpValidationError, # type: ignore
1036
+ object_=_response.json(),
1037
+ ),
1038
+ )
1039
+ )
1040
+ _response_json = _response.json()
1041
+ except JSONDecodeError:
1042
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1043
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1044
+
1045
+ async def get_spans_of_generation(
1046
+ self,
1047
+ *,
1048
+ app_id: str,
1049
+ page: typing.Optional[int] = None,
1050
+ page_size: typing.Optional[int] = None,
1051
+ type: typing.Optional[str] = None,
1052
+ trace_id: typing.Optional[str] = None,
1053
+ environment: typing.Optional[str] = None,
1054
+ variant: typing.Optional[str] = None,
1055
+ created_at: typing.Optional[str] = None,
1056
+ request_options: typing.Optional[RequestOptions] = None,
1057
+ ) -> typing.Optional[typing.Any]:
1058
+ """
1059
+ Parameters
1060
+ ----------
1061
+ app_id : str
1062
+
1063
+ page : typing.Optional[int]
1064
+
1065
+ page_size : typing.Optional[int]
1066
+
1067
+ type : typing.Optional[str]
1068
+
1069
+ trace_id : typing.Optional[str]
1070
+
1071
+ environment : typing.Optional[str]
1072
+
1073
+ variant : typing.Optional[str]
1074
+
1075
+ created_at : typing.Optional[str]
1076
+
1077
+ request_options : typing.Optional[RequestOptions]
1078
+ Request-specific configuration.
1079
+
1080
+ Returns
1081
+ -------
1082
+ typing.Optional[typing.Any]
1083
+ Successful Response
1084
+
1085
+ Examples
1086
+ --------
1087
+ import asyncio
1088
+
1089
+ from agenta import AsyncAgentaApi
1090
+
1091
+ client = AsyncAgentaApi(
1092
+ api_key="YOUR_API_KEY",
1093
+ base_url="https://yourhost.com/path/to/api",
1094
+ )
1095
+
1096
+
1097
+ async def main() -> None:
1098
+ await client.observability.get_spans_of_generation(
1099
+ app_id="app_id",
1100
+ )
1101
+
1102
+
1103
+ asyncio.run(main())
1104
+ """
1105
+ _response = await self._client_wrapper.httpx_client.request(
1106
+ "observability/spans",
1107
+ method="GET",
1108
+ params={
1109
+ "app_id": app_id,
1110
+ "page": page,
1111
+ "pageSize": page_size,
1112
+ "type": type,
1113
+ "trace_id": trace_id,
1114
+ "environment": environment,
1115
+ "variant": variant,
1116
+ "created_at": created_at,
1117
+ },
1118
+ request_options=request_options,
1119
+ )
1120
+ try:
1121
+ if 200 <= _response.status_code < 300:
1122
+ return typing.cast(
1123
+ typing.Optional[typing.Any],
1124
+ parse_obj_as(
1125
+ type_=typing.Optional[typing.Any], # type: ignore
1126
+ object_=_response.json(),
1127
+ ),
1128
+ )
1129
+ if _response.status_code == 422:
1130
+ raise UnprocessableEntityError(
1131
+ typing.cast(
1132
+ HttpValidationError,
1133
+ parse_obj_as(
1134
+ type_=HttpValidationError, # type: ignore
1135
+ object_=_response.json(),
1136
+ ),
1137
+ )
1138
+ )
1139
+ _response_json = _response.json()
1140
+ except JSONDecodeError:
1141
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1142
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1143
+
1144
+ async def delete_spans_of_trace(
1145
+ self,
1146
+ *,
1147
+ request: typing.Sequence[str],
1148
+ request_options: typing.Optional[RequestOptions] = None,
1149
+ ) -> bool:
1150
+ """
1151
+ Parameters
1152
+ ----------
1153
+ request : typing.Sequence[str]
1154
+
1155
+ request_options : typing.Optional[RequestOptions]
1156
+ Request-specific configuration.
1157
+
1158
+ Returns
1159
+ -------
1160
+ bool
1161
+ Successful Response
1162
+
1163
+ Examples
1164
+ --------
1165
+ import asyncio
1166
+
1167
+ from agenta import AsyncAgentaApi
1168
+
1169
+ client = AsyncAgentaApi(
1170
+ api_key="YOUR_API_KEY",
1171
+ base_url="https://yourhost.com/path/to/api",
1172
+ )
1173
+
1174
+
1175
+ async def main() -> None:
1176
+ await client.observability.delete_spans_of_trace(
1177
+ request=["string"],
1178
+ )
1179
+
1180
+
1181
+ asyncio.run(main())
1182
+ """
1183
+ _response = await self._client_wrapper.httpx_client.request(
1184
+ "observability/spans",
1185
+ method="DELETE",
1186
+ json=request,
1187
+ request_options=request_options,
1188
+ omit=OMIT,
1189
+ )
1190
+ try:
1191
+ if 200 <= _response.status_code < 300:
1192
+ return typing.cast(
1193
+ bool,
1194
+ parse_obj_as(
1195
+ type_=bool, # type: ignore
1196
+ object_=_response.json(),
1197
+ ),
1198
+ )
1199
+ if _response.status_code == 422:
1200
+ raise UnprocessableEntityError(
1201
+ typing.cast(
1202
+ HttpValidationError,
1203
+ parse_obj_as(
1204
+ type_=HttpValidationError, # type: ignore
1205
+ object_=_response.json(),
1206
+ ),
1207
+ )
1208
+ )
1209
+ _response_json = _response.json()
1210
+ except JSONDecodeError:
1211
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1212
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1213
+
1214
+ async def get_span_of_generation(
1215
+ self,
1216
+ span_id: str,
1217
+ *,
1218
+ type: typing.Optional[str] = None,
1219
+ request_options: typing.Optional[RequestOptions] = None,
1220
+ ) -> SpanDetail:
1221
+ """
1222
+ Parameters
1223
+ ----------
1224
+ span_id : str
1225
+
1226
+ type : typing.Optional[str]
1227
+
1228
+ request_options : typing.Optional[RequestOptions]
1229
+ Request-specific configuration.
1230
+
1231
+ Returns
1232
+ -------
1233
+ SpanDetail
1234
+ Successful Response
1235
+
1236
+ Examples
1237
+ --------
1238
+ import asyncio
1239
+
1240
+ from agenta import AsyncAgentaApi
1241
+
1242
+ client = AsyncAgentaApi(
1243
+ api_key="YOUR_API_KEY",
1244
+ base_url="https://yourhost.com/path/to/api",
1245
+ )
1246
+
1247
+
1248
+ async def main() -> None:
1249
+ await client.observability.get_span_of_generation(
1250
+ span_id="span_id",
1251
+ )
1252
+
1253
+
1254
+ asyncio.run(main())
1255
+ """
1256
+ _response = await self._client_wrapper.httpx_client.request(
1257
+ f"observability/spans/{jsonable_encoder(span_id)}",
1258
+ method="GET",
1259
+ params={
1260
+ "type": type,
1261
+ },
1262
+ request_options=request_options,
1263
+ )
1264
+ try:
1265
+ if 200 <= _response.status_code < 300:
1266
+ return typing.cast(
1267
+ SpanDetail,
1268
+ parse_obj_as(
1269
+ type_=SpanDetail, # type: ignore
1270
+ object_=_response.json(),
1271
+ ),
1272
+ )
1273
+ if _response.status_code == 422:
1274
+ raise UnprocessableEntityError(
1275
+ typing.cast(
1276
+ HttpValidationError,
1277
+ parse_obj_as(
1278
+ type_=HttpValidationError, # type: ignore
1279
+ object_=_response.json(),
1280
+ ),
1281
+ )
1282
+ )
1283
+ _response_json = _response.json()
1284
+ except JSONDecodeError:
1285
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1286
+ raise ApiError(status_code=_response.status_code, body=_response_json)