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