agenta 0.12.7__py3-none-any.whl → 0.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

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