agenta 0.19.9__py3-none-any.whl → 0.20.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of agenta might be problematic. Click here for more details.
- agenta/__init__.py +1 -1
- agenta/client/backend/types/create_span.py +4 -1
- agenta/client/backend/types/llm_tokens.py +3 -3
- agenta/sdk/__init__.py +1 -1
- agenta/sdk/decorators/llm_entrypoint.py +210 -78
- agenta/sdk/decorators/tracing.py +16 -111
- agenta/sdk/tracing/callbacks.py +43 -14
- agenta/sdk/tracing/llm_tracing.py +221 -89
- agenta/sdk/tracing/tasks_manager.py +3 -2
- agenta/sdk/tracing/tracing_context.py +5 -6
- agenta/sdk/types.py +5 -6
- {agenta-0.19.9.dist-info → agenta-0.20.0a1.dist-info}/METADATA +1 -1
- {agenta-0.19.9.dist-info → agenta-0.20.0a1.dist-info}/RECORD +15 -15
- {agenta-0.19.9.dist-info → agenta-0.20.0a1.dist-info}/WHEEL +0 -0
- {agenta-0.19.9.dist-info → agenta-0.20.0a1.dist-info}/entry_points.txt +0 -0
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import copy
|
|
3
|
+
import json
|
|
2
4
|
from uuid import uuid4
|
|
3
5
|
|
|
6
|
+
import traceback
|
|
4
7
|
from threading import Lock
|
|
5
8
|
from datetime import datetime, timezone
|
|
6
9
|
from typing import Optional, Dict, Any, List
|
|
7
10
|
|
|
8
|
-
from
|
|
11
|
+
from contextlib import contextmanager
|
|
12
|
+
|
|
13
|
+
from agenta.sdk.tracing.tracing_context import tracing_context, TracingContext
|
|
9
14
|
from agenta.sdk.tracing.logger import llm_logger as logging
|
|
10
15
|
from agenta.sdk.tracing.tasks_manager import TaskQueue
|
|
11
16
|
from agenta.client.backend.client import AsyncAgentaApi
|
|
@@ -20,7 +25,7 @@ from bson.objectid import ObjectId
|
|
|
20
25
|
|
|
21
26
|
VARIANT_TRACKING_FEATURE_FLAG = False
|
|
22
27
|
|
|
23
|
-
from agenta.sdk.utils.debug import debug
|
|
28
|
+
from agenta.sdk.utils.debug import debug
|
|
24
29
|
|
|
25
30
|
|
|
26
31
|
logging.setLevel("DEBUG")
|
|
@@ -91,6 +96,46 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
91
96
|
base_url=self.host, api_key=self.api_key, timeout=120 # type: ignore
|
|
92
97
|
).observability
|
|
93
98
|
|
|
99
|
+
### --- Context Manager --- ###
|
|
100
|
+
|
|
101
|
+
@contextmanager
|
|
102
|
+
def Context(self, **kwargs):
|
|
103
|
+
# This will evolve as be work towards OTel compliance
|
|
104
|
+
|
|
105
|
+
token = None
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
if tracing_context.get() is None:
|
|
109
|
+
token = tracing_context.set(TracingContext())
|
|
110
|
+
|
|
111
|
+
self.open_span(**kwargs)
|
|
112
|
+
|
|
113
|
+
yield
|
|
114
|
+
|
|
115
|
+
self.set_status(status="OK")
|
|
116
|
+
|
|
117
|
+
except Exception as e:
|
|
118
|
+
logging.error(e)
|
|
119
|
+
|
|
120
|
+
result = {
|
|
121
|
+
"message": str(e),
|
|
122
|
+
"stacktrace": traceback.format_exc(),
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
self.set_status(status="ERROR")
|
|
126
|
+
self.set_attributes({"traceback_exception": traceback.format_exc()})
|
|
127
|
+
self.store_outputs(result)
|
|
128
|
+
|
|
129
|
+
raise
|
|
130
|
+
|
|
131
|
+
finally:
|
|
132
|
+
self.close_span()
|
|
133
|
+
|
|
134
|
+
if token is not None:
|
|
135
|
+
self.flush_spans()
|
|
136
|
+
|
|
137
|
+
tracing_context.reset(token)
|
|
138
|
+
|
|
94
139
|
### --- API --- ###
|
|
95
140
|
|
|
96
141
|
@debug()
|
|
@@ -150,6 +195,14 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
150
195
|
|
|
151
196
|
tracing.trace_tags.extend(tags)
|
|
152
197
|
|
|
198
|
+
@debug()
|
|
199
|
+
def is_trace_ready(self):
|
|
200
|
+
tracing = tracing_context.get()
|
|
201
|
+
|
|
202
|
+
are_spans_ready = [span.end_time is not None for span in tracing.spans.values()]
|
|
203
|
+
|
|
204
|
+
return all(are_spans_ready)
|
|
205
|
+
|
|
153
206
|
@debug()
|
|
154
207
|
def close_trace(self) -> None:
|
|
155
208
|
"""
|
|
@@ -177,11 +230,7 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
177
230
|
if not self.api_key:
|
|
178
231
|
logging.error("No API key")
|
|
179
232
|
else:
|
|
180
|
-
self.
|
|
181
|
-
|
|
182
|
-
self._clear_closed_spans()
|
|
183
|
-
self._clear_tracked_spans()
|
|
184
|
-
self._clear_active_span()
|
|
233
|
+
self._process_spans()
|
|
185
234
|
|
|
186
235
|
self._clear_trace_tags()
|
|
187
236
|
|
|
@@ -193,6 +242,7 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
193
242
|
name: str,
|
|
194
243
|
spankind: str,
|
|
195
244
|
input: Dict[str, Any],
|
|
245
|
+
active: bool = True,
|
|
196
246
|
config: Optional[Dict[str, Any]] = None,
|
|
197
247
|
**kwargs,
|
|
198
248
|
) -> CreateSpan:
|
|
@@ -213,6 +263,7 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
213
263
|
attributes={},
|
|
214
264
|
status=SpanStatusCode.UNSET.value,
|
|
215
265
|
start_time=datetime.now(timezone.utc),
|
|
266
|
+
internals=None,
|
|
216
267
|
outputs=None,
|
|
217
268
|
tags=None,
|
|
218
269
|
user=None,
|
|
@@ -224,12 +275,18 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
224
275
|
)
|
|
225
276
|
|
|
226
277
|
if tracing.trace_id is None:
|
|
227
|
-
self.
|
|
278
|
+
self.open_trace(span, config)
|
|
228
279
|
else:
|
|
229
280
|
span.parent_span_id = tracing.active_span.id # type: ignore
|
|
230
281
|
|
|
231
|
-
tracing.
|
|
232
|
-
|
|
282
|
+
tracing.spans[span.id] = span
|
|
283
|
+
|
|
284
|
+
if active:
|
|
285
|
+
tracing.active_span = span
|
|
286
|
+
else:
|
|
287
|
+
# DETACHED SPAN
|
|
288
|
+
pass
|
|
289
|
+
|
|
233
290
|
### --- TO BE CLEANED --- <<<
|
|
234
291
|
|
|
235
292
|
logging.info(f"Opened span {span_id} {spankind.upper()}")
|
|
@@ -238,8 +295,7 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
238
295
|
|
|
239
296
|
@debug(req=True)
|
|
240
297
|
def set_attributes(
|
|
241
|
-
self,
|
|
242
|
-
attributes: Dict[str, Any] = {},
|
|
298
|
+
self, attributes: Dict[str, Any] = {}, span_id: Optional[str] = None
|
|
243
299
|
) -> None:
|
|
244
300
|
"""
|
|
245
301
|
Set attributes for the active span.
|
|
@@ -248,41 +304,31 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
248
304
|
attributes (Dict[str, Any], optional): A dictionary of attributes to set. Defaults to {}.
|
|
249
305
|
"""
|
|
250
306
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if tracing.active_span is None:
|
|
254
|
-
logging.error(f"Cannot set attributes ({set(attributes)}), no active span")
|
|
255
|
-
return
|
|
307
|
+
span = self._get_target_span(span_id)
|
|
256
308
|
|
|
257
309
|
logging.info(
|
|
258
|
-
f"Setting span {
|
|
310
|
+
f"Setting span {span.id} {span.spankind.upper()} attributes={attributes}"
|
|
259
311
|
)
|
|
260
312
|
|
|
261
313
|
for key, value in attributes.items():
|
|
262
|
-
|
|
314
|
+
span.attributes[key] = value # type: ignore
|
|
263
315
|
|
|
264
316
|
@debug()
|
|
265
|
-
def set_status(self, status: str) -> None:
|
|
317
|
+
def set_status(self, status: str, span_id: Optional[str] = None) -> None:
|
|
266
318
|
"""
|
|
267
319
|
Set status for the active span.
|
|
268
320
|
|
|
269
321
|
Args:
|
|
270
322
|
status: Enum ( UNSET, OK, ERROR )
|
|
271
323
|
"""
|
|
272
|
-
|
|
324
|
+
span = self._get_target_span(span_id)
|
|
273
325
|
|
|
274
|
-
|
|
275
|
-
logging.error(f"Cannot set status ({status}), no active span")
|
|
276
|
-
return
|
|
277
|
-
|
|
278
|
-
logging.info(
|
|
279
|
-
f"Setting span {tracing.active_span.id} {tracing.active_span.spankind.upper()} status={status}"
|
|
280
|
-
)
|
|
326
|
+
logging.info(f"Setting span {span.id} {span.spankind.upper()} status={status}")
|
|
281
327
|
|
|
282
|
-
|
|
328
|
+
span.status = status
|
|
283
329
|
|
|
284
330
|
@debug()
|
|
285
|
-
def close_span(self,
|
|
331
|
+
def close_span(self, span_id: Optional[str] = None) -> None:
|
|
286
332
|
"""
|
|
287
333
|
Ends the active span, if it is a parent span, ends the trace too.
|
|
288
334
|
|
|
@@ -299,45 +345,122 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
299
345
|
Returns:
|
|
300
346
|
None
|
|
301
347
|
"""
|
|
348
|
+
span = self._get_target_span(span_id)
|
|
302
349
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if tracing.active_span is None:
|
|
306
|
-
logging.error("Cannot close span, no active span")
|
|
350
|
+
spankind = span.spankind
|
|
307
351
|
|
|
308
|
-
|
|
309
|
-
spankind = tracing.active_span.spankind
|
|
310
|
-
|
|
311
|
-
logging.info(f"Closing span {span_id} {spankind}")
|
|
352
|
+
logging.info(f"Closing span {span.id} {spankind}")
|
|
312
353
|
|
|
313
354
|
### --- TO BE CLEANED --- >>>
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
tracing.active_span.outputs = [outputs.get("message", "")]
|
|
355
|
+
span.end_time = datetime.now(timezone.utc)
|
|
317
356
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
"
|
|
321
|
-
|
|
322
|
-
self._update_span_cost(tracing.active_span, outputs.get("cost", None))
|
|
323
|
-
self._update_span_tokens(tracing.active_span, outputs.get("usage", None))
|
|
357
|
+
# TODO: Remove this whole part. Setting the cost should be done through set_span_attribute
|
|
358
|
+
if isinstance(span.outputs, dict):
|
|
359
|
+
self._update_span_cost(span, span.outputs.get("cost", None))
|
|
360
|
+
self._update_span_tokens(span, span.outputs.get("usage", None))
|
|
324
361
|
|
|
325
|
-
|
|
362
|
+
span_parent_id = span.parent_span_id
|
|
326
363
|
|
|
327
|
-
|
|
364
|
+
if span_parent_id is not None:
|
|
365
|
+
tracing = tracing_context.get()
|
|
328
366
|
|
|
329
|
-
|
|
330
|
-
self.
|
|
367
|
+
parent_span = tracing.spans[span_parent_id]
|
|
368
|
+
self._update_span_cost(parent_span, span.cost)
|
|
369
|
+
self._update_span_tokens(parent_span, span.tokens)
|
|
331
370
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
self._update_span_cost(parent_span, tracing.active_span.cost)
|
|
335
|
-
self._update_span_tokens(parent_span, tracing.active_span.tokens)
|
|
336
|
-
tracing.active_span = parent_span
|
|
371
|
+
if span_id is None:
|
|
372
|
+
tracing.active_span = parent_span
|
|
337
373
|
### --- TO BE CLEANED --- <<<
|
|
338
374
|
|
|
339
375
|
logging.info(f"Closed span {span_id} {spankind}")
|
|
340
376
|
|
|
377
|
+
@debug()
|
|
378
|
+
def store_internals(
|
|
379
|
+
self, internals: Dict[str, Any] = {}, span_id: Optional[str] = None
|
|
380
|
+
) -> None:
|
|
381
|
+
"""
|
|
382
|
+
Set internals for the active span.
|
|
383
|
+
|
|
384
|
+
Args:
|
|
385
|
+
internals (Dict[str, Any], optional): A dictionary of local variables to set. Defaults to {}.
|
|
386
|
+
"""
|
|
387
|
+
span = self._get_target_span(span_id)
|
|
388
|
+
|
|
389
|
+
logging.info(
|
|
390
|
+
f"Setting span {span.id} {span.spankind.upper()} internals={internals}"
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
if span.internals is None:
|
|
394
|
+
span.internals = dict()
|
|
395
|
+
|
|
396
|
+
for key, value in internals.items():
|
|
397
|
+
span.internals[key] = value # type: ignore
|
|
398
|
+
|
|
399
|
+
@debug()
|
|
400
|
+
def store_outputs(
|
|
401
|
+
self, outputs: Dict[str, Any] = {}, span_id: Optional[str] = None
|
|
402
|
+
) -> None:
|
|
403
|
+
"""
|
|
404
|
+
Set outputs for the active span.
|
|
405
|
+
|
|
406
|
+
Args:
|
|
407
|
+
outputs (Dict[str, Any], optional): A dictionary of output variables to set. Defaults to {}.
|
|
408
|
+
"""
|
|
409
|
+
span = self._get_target_span(span_id)
|
|
410
|
+
|
|
411
|
+
logging.info(
|
|
412
|
+
f"Setting span {span.id} {span.spankind.upper()} outputs={outputs}"
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
span.outputs = outputs
|
|
416
|
+
|
|
417
|
+
@debug()
|
|
418
|
+
def dump_trace(self):
|
|
419
|
+
"""
|
|
420
|
+
Collects and organizes tracing information into a dictionary.
|
|
421
|
+
This function retrieves the current tracing context and extracts relevant data such as `trace_id`, `cost`, `tokens`, and `latency` for the whole trace.
|
|
422
|
+
It also dumps detailed span information using the `dump_spans` method and includes it in the trace dictionary.
|
|
423
|
+
If an error occurs during the process, it logs the error message and stack trace.
|
|
424
|
+
|
|
425
|
+
Returns:
|
|
426
|
+
dict: A dictionary containing the trace information.
|
|
427
|
+
"""
|
|
428
|
+
try:
|
|
429
|
+
trace = dict()
|
|
430
|
+
|
|
431
|
+
tracing = tracing_context.get()
|
|
432
|
+
|
|
433
|
+
trace["trace_id"] = tracing.trace_id
|
|
434
|
+
|
|
435
|
+
for span in tracing.spans.values():
|
|
436
|
+
if span.parent_span_id is None:
|
|
437
|
+
trace["cost"] = span.cost
|
|
438
|
+
trace["usage"] = (
|
|
439
|
+
None if span.tokens is None else json.loads(span.tokens.json())
|
|
440
|
+
)
|
|
441
|
+
trace["latency"] = (
|
|
442
|
+
(span.end_time if span.end_time else span.start_time)
|
|
443
|
+
- span.start_time
|
|
444
|
+
).total_seconds()
|
|
445
|
+
|
|
446
|
+
spans = (
|
|
447
|
+
[]
|
|
448
|
+
if len(tracing.spans) == 0
|
|
449
|
+
else [json.loads(span.json()) for span in tracing.spans.values()]
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
if spans is not None:
|
|
453
|
+
trace["spans"] = spans
|
|
454
|
+
|
|
455
|
+
except Exception as e:
|
|
456
|
+
logging.error(e)
|
|
457
|
+
logging.error(traceback.format_exc())
|
|
458
|
+
|
|
459
|
+
return trace
|
|
460
|
+
|
|
461
|
+
def flush_spans(self) -> None:
|
|
462
|
+
self.close_trace()
|
|
463
|
+
|
|
341
464
|
### --- Legacy API --- ###
|
|
342
465
|
|
|
343
466
|
def start_trace(
|
|
@@ -348,7 +471,7 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
348
471
|
) -> None: # Legacy
|
|
349
472
|
self.open_trace(span, config, **kwargs)
|
|
350
473
|
|
|
351
|
-
def end_trace(self,
|
|
474
|
+
def end_trace(self, _: CreateSpan) -> None: # Legacy
|
|
352
475
|
self.close_trace()
|
|
353
476
|
|
|
354
477
|
def start_span(
|
|
@@ -371,7 +494,8 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
371
494
|
self.set_attributes(attributes)
|
|
372
495
|
|
|
373
496
|
def end_span(self, outputs: Dict[str, Any]) -> None: # Legacy
|
|
374
|
-
self.
|
|
497
|
+
self.store_outputs(outputs)
|
|
498
|
+
self.close_span()
|
|
375
499
|
|
|
376
500
|
### --- Helper Functions --- ###
|
|
377
501
|
|
|
@@ -400,46 +524,44 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
400
524
|
# return uuid4().hex[:16]
|
|
401
525
|
return str(ObjectId())
|
|
402
526
|
|
|
403
|
-
def
|
|
527
|
+
def _get_target_span(self, span_id) -> CreateSpan:
|
|
404
528
|
tracing = tracing_context.get()
|
|
405
529
|
|
|
406
|
-
|
|
530
|
+
span = None
|
|
407
531
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
532
|
+
if span_id is None:
|
|
533
|
+
if tracing.active_span is None:
|
|
534
|
+
logging.error(f"Cannot set attributes, no active span")
|
|
535
|
+
return
|
|
411
536
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
trace=tracing.trace_id,
|
|
418
|
-
spans=tracing.closed_spans, # type: ignore
|
|
419
|
-
),
|
|
420
|
-
self.client,
|
|
421
|
-
)
|
|
537
|
+
span = tracing.active_span
|
|
538
|
+
else:
|
|
539
|
+
if span_id not in tracing.spans.keys():
|
|
540
|
+
logging.error(f"Cannot set attributes, span ({span_id}) not found")
|
|
541
|
+
return
|
|
422
542
|
|
|
423
|
-
|
|
543
|
+
span = tracing.spans[span_id]
|
|
424
544
|
|
|
425
|
-
|
|
426
|
-
tracing = tracing_context.get()
|
|
427
|
-
|
|
428
|
-
tracing.closed_spans.clear()
|
|
545
|
+
return span
|
|
429
546
|
|
|
430
|
-
def
|
|
547
|
+
def _process_spans(self) -> None:
|
|
431
548
|
tracing = tracing_context.get()
|
|
432
549
|
|
|
433
|
-
tracing.
|
|
434
|
-
|
|
435
|
-
def _clear_active_span(self) -> None:
|
|
436
|
-
tracing = tracing_context.get()
|
|
550
|
+
spans = list(tracing.spans.values())
|
|
437
551
|
|
|
438
|
-
|
|
552
|
+
logging.info(f"Sending trace {tracing.trace_id} spans={len(spans)} ")
|
|
439
553
|
|
|
440
|
-
|
|
554
|
+
self.tasks_manager.add_task(
|
|
555
|
+
tracing.trace_id,
|
|
556
|
+
"send-trace",
|
|
557
|
+
# mock_create_traces(
|
|
558
|
+
self.client.create_traces(
|
|
559
|
+
trace=tracing.trace_id, spans=spans # type: ignore
|
|
560
|
+
),
|
|
561
|
+
self.client,
|
|
562
|
+
)
|
|
441
563
|
|
|
442
|
-
logging.
|
|
564
|
+
logging.info(f"Sent trace {tracing.trace_id}")
|
|
443
565
|
|
|
444
566
|
def _update_span_cost(self, span: CreateSpan, cost: Optional[float]) -> None:
|
|
445
567
|
if span is not None and cost is not None and isinstance(cost, float):
|
|
@@ -455,6 +577,16 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
455
577
|
if span.tokens is None:
|
|
456
578
|
span.tokens = LlmTokens(**tokens)
|
|
457
579
|
else:
|
|
458
|
-
span.tokens.prompt_tokens +=
|
|
459
|
-
|
|
460
|
-
|
|
580
|
+
span.tokens.prompt_tokens += (
|
|
581
|
+
tokens["prompt_tokens"]
|
|
582
|
+
if tokens["prompt_tokens"] is not None
|
|
583
|
+
else 0
|
|
584
|
+
)
|
|
585
|
+
span.tokens.completion_tokens += (
|
|
586
|
+
tokens["completion_tokens"]
|
|
587
|
+
if tokens["completion_tokens"] is not None
|
|
588
|
+
else 0
|
|
589
|
+
)
|
|
590
|
+
span.tokens.total_tokens += (
|
|
591
|
+
tokens["total_tokens"] if tokens["total_tokens"] is not None else 0
|
|
592
|
+
)
|
|
@@ -105,8 +105,9 @@ class TaskQueue(object):
|
|
|
105
105
|
future = self._thread_pool.submit(asyncio.run, task.run())
|
|
106
106
|
future.result()
|
|
107
107
|
except Exception as exc:
|
|
108
|
-
self._logger.error(
|
|
109
|
-
|
|
108
|
+
self._logger.error(
|
|
109
|
+
f"Task '{task.coroutine_type}' failed with error: {str(exc)}"
|
|
110
|
+
)
|
|
110
111
|
break
|
|
111
112
|
finally:
|
|
112
113
|
self.tasks.task_done()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
from contextvars import ContextVar
|
|
2
2
|
|
|
3
|
-
from typing import Optional, Dict,
|
|
3
|
+
from typing import Optional, Dict, List
|
|
4
4
|
|
|
5
5
|
from agenta.client.backend.types.create_span import CreateSpan
|
|
6
6
|
|
|
@@ -15,14 +15,13 @@ class TracingContext:
|
|
|
15
15
|
|
|
16
16
|
### --- SPANS --- ###
|
|
17
17
|
self.active_span: Optional[CreateSpan] = None
|
|
18
|
-
self.
|
|
19
|
-
self.closed_spans: List[CreateSpan] = []
|
|
18
|
+
self.spans: Dict[str, CreateSpan] = {}
|
|
20
19
|
|
|
21
20
|
def __repr__(self) -> str:
|
|
22
|
-
return f"TracingContext(
|
|
21
|
+
return f"TracingContext(trace='{self.trace_id}', spans={[f'{span.id} {span.spankind}' for span in self.spans.values()]})"
|
|
23
22
|
|
|
24
23
|
def __str__(self) -> str:
|
|
25
24
|
return self.__repr__()
|
|
26
25
|
|
|
27
26
|
|
|
28
|
-
tracing_context =
|
|
27
|
+
tracing_context = ContextVar(CURRENT_TRACING_CONTEXT_KEY, default=None)
|
agenta/sdk/types.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import Dict, List, Optional
|
|
2
|
+
from typing import Dict, List, Optional, Any
|
|
3
3
|
|
|
4
4
|
from pydantic import ConfigDict, BaseModel, HttpUrl
|
|
5
5
|
|
|
@@ -16,11 +16,10 @@ class LLMTokenUsage(BaseModel):
|
|
|
16
16
|
total_tokens: int
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
class
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
latency: float
|
|
19
|
+
class BaseResponse(BaseModel):
|
|
20
|
+
version: Optional[str] = "2.0"
|
|
21
|
+
data: Optional[Dict[str, Any]]
|
|
22
|
+
trace: Optional[Dict[str, Any]]
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
class DictInput(dict):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
agenta/__init__.py,sha256=
|
|
1
|
+
agenta/__init__.py,sha256=nL_Fogmx_64xS--WjhE4gE_0h5LIJDbDGKpjZoNJ9oI,894
|
|
2
2
|
agenta/cli/evaluation_commands.py,sha256=fs6492tprPId9p8eGO02Xy-NCBm2RZNJLZWcUxugwd8,474
|
|
3
3
|
agenta/cli/helper.py,sha256=vRxHyeNaltzNIGrfU2vO0H28_rXDzx9QqIZ_S-W6zL4,6212
|
|
4
4
|
agenta/cli/main.py,sha256=Wz0ODhoeKK3Qg_CFUhu6D909szk05tc8ZVBB6H1-w7k,9763
|
|
@@ -54,7 +54,7 @@ agenta/client/backend/types/base_output.py,sha256=ynXhDBQKrkR6Lnkx-yv6Q8xW4wXmzX
|
|
|
54
54
|
agenta/client/backend/types/body_import_testset.py,sha256=7dVF3mv3VO0Co8F0qxLAgu4jabqDPjebK4mYvcd_TuA,1061
|
|
55
55
|
agenta/client/backend/types/config_db.py,sha256=P0cSYvVOn0ZxpYMIdvhWpQVjRuBS5APe6qlc69AXaF4,1028
|
|
56
56
|
agenta/client/backend/types/create_app_output.py,sha256=pgnTnfZx35Q-8wZ1yTZBQ0ydYacGzFC9kyLug_UvymM,986
|
|
57
|
-
agenta/client/backend/types/create_span.py,sha256=
|
|
57
|
+
agenta/client/backend/types/create_span.py,sha256=CfTLCHRnDyicJS3-cioDM5ZWZQq8SEi6z3BEDfnQ9Hs,1913
|
|
58
58
|
agenta/client/backend/types/create_trace_response.py,sha256=FO-Ii9JEn2AQ1nmZYmjnKRbACsNxRvY_-xn7Ys7Yo8A,1012
|
|
59
59
|
agenta/client/backend/types/docker_env_vars.py,sha256=altCvA1k-zdAkKNYLwaCnmV48HZg9cwe2cHu_BGImac,986
|
|
60
60
|
agenta/client/backend/types/environment_output.py,sha256=dl0GKodeqB7kWK5mH6Y4iBppkpwRzSTmtkXH1II4L6w,1257
|
|
@@ -85,7 +85,7 @@ agenta/client/backend/types/image.py,sha256=p7Vmp7HlMV3YyXe8SFdXYJjCbPNIypW6NfVG
|
|
|
85
85
|
agenta/client/backend/types/invite_request.py,sha256=1nJTUHspzw2WYpUSd4UUtRnjDHM-dqDBvYewgw-hCQE,993
|
|
86
86
|
agenta/client/backend/types/list_api_keys_response.py,sha256=ZNh7jKwHEMKNp8OV5WJ5XxtKn39DwqK1f8vlFKl54x4,1097
|
|
87
87
|
agenta/client/backend/types/llm_run_rate_limit.py,sha256=mfT4lTczPxrJvd8ZCOAjPvw58QoM151p_uZT0PWNOJ4,1045
|
|
88
|
-
agenta/client/backend/types/llm_tokens.py,sha256=
|
|
88
|
+
agenta/client/backend/types/llm_tokens.py,sha256=nDaiJRZs1jvsXVDDoc-CXGNLUP8hRhioY37P1CGEav0,1082
|
|
89
89
|
agenta/client/backend/types/new_human_evaluation.py,sha256=lIgMjVccSp22RRfMGGLH4-yKjMtJeQvjhlwX9EtAxmY,1150
|
|
90
90
|
agenta/client/backend/types/new_testset.py,sha256=9NOC1-f_UZASy4ptzidLNcRU6Odq609ayvSQxEva-40,1009
|
|
91
91
|
agenta/client/backend/types/organization.py,sha256=vJf6Gbz8WCnqabPQmt_t_gfrWPpuvTXgTxKCJKJsrmc,1218
|
|
@@ -126,22 +126,22 @@ agenta/docker/docker-assets/entrypoint.sh,sha256=29XK8VQjQsx4hN2j-4JDy-6kQb5y4LC
|
|
|
126
126
|
agenta/docker/docker-assets/lambda_function.py,sha256=h4UZSSfqwpfsCgERv6frqwm_4JrYu9rLz3I-LxCfeEg,83
|
|
127
127
|
agenta/docker/docker-assets/main.py,sha256=7MI-21n81U7N7A0GxebNi0cmGWtJKcR2sPB6FcH2QfA,251
|
|
128
128
|
agenta/docker/docker_utils.py,sha256=5uHMCzXkCvIsDdEiwbnnn97KkzsFbBvyMwogCsv_Z5U,3509
|
|
129
|
-
agenta/sdk/__init__.py,sha256=
|
|
129
|
+
agenta/sdk/__init__.py,sha256=ewYNjm6AHlqkIrPfX2D_pXZMwShOdhEUcWXb7xGA2bk,769
|
|
130
130
|
agenta/sdk/agenta_init.py,sha256=8MfDuypxohd0qRTdtGjX7L17KW-1UGmzNVdiqF15_ak,9790
|
|
131
131
|
agenta/sdk/client.py,sha256=trKyBOYFZRk0v5Eptxvh87yPf50Y9CqY6Qgv4Fy-VH4,2142
|
|
132
132
|
agenta/sdk/context.py,sha256=q-PxL05-I84puunUAs9LGsffEXcYhDxhQxjuOz2vK90,901
|
|
133
133
|
agenta/sdk/decorators/base.py,sha256=9aNdX5h8a2mFweuhdO-BQPwXGKY9ONPIdLRhSGAGMfY,217
|
|
134
|
-
agenta/sdk/decorators/llm_entrypoint.py,sha256=
|
|
135
|
-
agenta/sdk/decorators/tracing.py,sha256=
|
|
134
|
+
agenta/sdk/decorators/llm_entrypoint.py,sha256=ukdw3jyKarkXHKNaQyQmzVnJsYCntzmgoAFccvCZQnA,27343
|
|
135
|
+
agenta/sdk/decorators/tracing.py,sha256=BzXa_2b2VvbO5ZNTh126OkL3LFq8dMK-QFug8BHUBKA,2687
|
|
136
136
|
agenta/sdk/router.py,sha256=0sbajvn5C7t18anH6yNo7-oYxldHnYfwcbmQnIXBePw,269
|
|
137
137
|
agenta/sdk/tracing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
138
|
-
agenta/sdk/tracing/callbacks.py,sha256=
|
|
138
|
+
agenta/sdk/tracing/callbacks.py,sha256=xWP3RRtmj3ogXeqYI6zdj6gF5QGu70UlQ17WNwdXIx8,8063
|
|
139
139
|
agenta/sdk/tracing/context_manager.py,sha256=HskDaiORoOhjeN375gm05wYnieQzh5UnoIsnSAHkAyc,252
|
|
140
|
-
agenta/sdk/tracing/llm_tracing.py,sha256=
|
|
140
|
+
agenta/sdk/tracing/llm_tracing.py,sha256=A7_-Xx3Rioh_nfT7OjZvDPbKUvxEqruKhYRfdGwyo4w,17312
|
|
141
141
|
agenta/sdk/tracing/logger.py,sha256=GfH7V-jBHcn7h5dbdrnkDMe_ml3wkXFBeoQiqR4KVRc,474
|
|
142
|
-
agenta/sdk/tracing/tasks_manager.py,sha256=
|
|
143
|
-
agenta/sdk/tracing/tracing_context.py,sha256=
|
|
144
|
-
agenta/sdk/types.py,sha256=
|
|
142
|
+
agenta/sdk/tracing/tasks_manager.py,sha256=FBSFOWIKBycyA4ShB2ZVMzrzYQ8pWGWWBClFX8nlZFA,3726
|
|
143
|
+
agenta/sdk/tracing/tracing_context.py,sha256=nt3ewa-TK9BRJviGIZYazsAQUiG4daWxjtsbjeaDprs,789
|
|
144
|
+
agenta/sdk/types.py,sha256=1rVy8ob-rTOrIFcSSseXrt0JQtqqhlJfVgVxCB2ErCk,5754
|
|
145
145
|
agenta/sdk/utils/debug.py,sha256=QyuPsSoN0425UD13x_msPxSF_VT6YwHiQunZUibI-jg,2149
|
|
146
146
|
agenta/sdk/utils/globals.py,sha256=JmhJcCOSbwvjQ6GDyUc2_SYR27DZk7YcrRH80ktHHOM,435
|
|
147
147
|
agenta/sdk/utils/helper/openai_cost.py,sha256=1VkgvucDnNZm1pTfcVLz9icWunntp1d7zwMmnviy3Uw,5877
|
|
@@ -161,7 +161,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
|
|
|
161
161
|
agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
|
|
162
162
|
agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
|
|
163
163
|
agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
|
|
164
|
-
agenta-0.
|
|
165
|
-
agenta-0.
|
|
166
|
-
agenta-0.
|
|
167
|
-
agenta-0.
|
|
164
|
+
agenta-0.20.0a1.dist-info/METADATA,sha256=s33kh03kzj-9YuQZipN4uhW57Tyhoj9O5g-g70w_aCY,26462
|
|
165
|
+
agenta-0.20.0a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
166
|
+
agenta-0.20.0a1.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
|
|
167
|
+
agenta-0.20.0a1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|