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