agenta 0.20.0a9__py3-none-any.whl → 0.20.0a10__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/sdk/decorators/llm_entrypoint.py +6 -6
- agenta/sdk/tracing/callbacks.py +34 -14
- agenta/sdk/tracing/llm_tracing.py +5 -2
- {agenta-0.20.0a9.dist-info → agenta-0.20.0a10.dist-info}/METADATA +1 -1
- {agenta-0.20.0a9.dist-info → agenta-0.20.0a10.dist-info}/RECORD +7 -7
- {agenta-0.20.0a9.dist-info → agenta-0.20.0a10.dist-info}/WHEEL +0 -0
- {agenta-0.20.0a9.dist-info → agenta-0.20.0a10.dist-info}/entry_points.txt +0 -0
|
@@ -120,7 +120,7 @@ class entrypoint(BaseDecorator):
|
|
|
120
120
|
routes = list()
|
|
121
121
|
|
|
122
122
|
def __init__(self, func: Callable[..., Any], route_path=""):
|
|
123
|
-
|
|
123
|
+
logging.info(f"Using Agenta Python SDK version {version('agenta')}")
|
|
124
124
|
|
|
125
125
|
DEFAULT_PATH = "generate"
|
|
126
126
|
PLAYGROUND_PATH = "/playground"
|
|
@@ -293,11 +293,11 @@ class entrypoint(BaseDecorator):
|
|
|
293
293
|
For synchronous functions, it calls them directly, while for asynchronous functions,
|
|
294
294
|
it awaits their execution.
|
|
295
295
|
"""
|
|
296
|
-
|
|
296
|
+
logging.info(f"Using Agenta Python SDK version {version('agenta')}")
|
|
297
297
|
|
|
298
298
|
WAIT_FOR_SPANS = True
|
|
299
|
-
TIMEOUT =
|
|
300
|
-
TIMESTEP = 0.
|
|
299
|
+
TIMEOUT = 1
|
|
300
|
+
TIMESTEP = 0.1
|
|
301
301
|
NOFSTEPS = TIMEOUT / TIMESTEP
|
|
302
302
|
|
|
303
303
|
data = None
|
|
@@ -319,7 +319,7 @@ class entrypoint(BaseDecorator):
|
|
|
319
319
|
remaining_steps = NOFSTEPS
|
|
320
320
|
|
|
321
321
|
while not ag.tracing.is_trace_ready() and remaining_steps > 0:
|
|
322
|
-
await asyncio.sleep(
|
|
322
|
+
await asyncio.sleep(TIMESTEP)
|
|
323
323
|
remaining_steps -= 1
|
|
324
324
|
|
|
325
325
|
trace = ag.tracing.dump_trace()
|
|
@@ -355,7 +355,7 @@ class entrypoint(BaseDecorator):
|
|
|
355
355
|
|
|
356
356
|
response = BaseResponse(data=data, trace=trace)
|
|
357
357
|
|
|
358
|
-
logging.debug(response)
|
|
358
|
+
# logging.debug(response)
|
|
359
359
|
|
|
360
360
|
return response
|
|
361
361
|
|
agenta/sdk/tracing/callbacks.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import agenta as ag
|
|
2
2
|
|
|
3
3
|
from agenta.sdk.tracing.tracing_context import tracing_context, TracingContext
|
|
4
|
+
from agenta.sdk.tracing.logger import llm_logger as logging
|
|
4
5
|
|
|
5
6
|
from agenta.sdk.utils.debug import debug
|
|
6
7
|
|
|
@@ -47,6 +48,7 @@ def litellm_handler():
|
|
|
47
48
|
spankind=span_kind,
|
|
48
49
|
active=False,
|
|
49
50
|
)
|
|
51
|
+
logging.info(f"log_pre_api_call({self.span.id})")
|
|
50
52
|
ag.tracing.set_attributes(
|
|
51
53
|
{
|
|
52
54
|
"model_config": {
|
|
@@ -59,10 +61,13 @@ def litellm_handler():
|
|
|
59
61
|
)
|
|
60
62
|
|
|
61
63
|
@debug()
|
|
62
|
-
def log_stream_event(self, kwargs,
|
|
64
|
+
def log_stream_event(self, kwargs, response_obj, start_time, end_time):
|
|
65
|
+
logging.info(f"log_stream_event({self.span.id})")
|
|
63
66
|
ag.tracing.set_status(status="OK", span_id=self.span.id)
|
|
64
67
|
ag.tracing.store_cost(kwargs.get("response_cost"))
|
|
65
|
-
ag.tracing.store_usage(
|
|
68
|
+
ag.tracing.store_usage(
|
|
69
|
+
response_obj.usage.dict() if hasattr(response_obj, "usage") else None
|
|
70
|
+
)
|
|
66
71
|
ag.tracing.store_outputs(
|
|
67
72
|
# the complete streamed response (only set if `completion(..stream=True)`
|
|
68
73
|
outputs={"message": kwargs.get("complete_streaming_response")},
|
|
@@ -71,18 +76,22 @@ def litellm_handler():
|
|
|
71
76
|
ag.tracing.close_span(span_id=self.span.id)
|
|
72
77
|
|
|
73
78
|
@debug()
|
|
74
|
-
def log_success_event(self, kwargs,
|
|
79
|
+
def log_success_event(self, kwargs, response_obj, start_time, end_time):
|
|
80
|
+
logging.info(f"log_success_event({self.span.id})")
|
|
75
81
|
ag.tracing.set_status(status="OK", span_id=self.span.id)
|
|
76
82
|
ag.tracing.store_cost(kwargs.get("response_cost"))
|
|
77
|
-
ag.tracing.store_usage(
|
|
83
|
+
ag.tracing.store_usage(
|
|
84
|
+
response_obj.usage.dict() if hasattr(response_obj, "usage") else None
|
|
85
|
+
)
|
|
78
86
|
ag.tracing.store_outputs(
|
|
79
|
-
outputs={"message":
|
|
87
|
+
outputs={"message": response_obj.choices[0].message.content},
|
|
80
88
|
span_id=self.span.id,
|
|
81
89
|
)
|
|
82
90
|
ag.tracing.close_span(span_id=self.span.id)
|
|
83
91
|
|
|
84
92
|
@debug()
|
|
85
|
-
def log_failure_event(self, kwargs,
|
|
93
|
+
def log_failure_event(self, kwargs, response_obj, start_time, end_time):
|
|
94
|
+
logging.info("log_failure_event()", self.span)
|
|
86
95
|
ag.tracing.set_status(status="ERROR", span_id=self.span.id)
|
|
87
96
|
ag.tracing.set_attributes(
|
|
88
97
|
{
|
|
@@ -96,7 +105,9 @@ def litellm_handler():
|
|
|
96
105
|
span_id=self.span.id,
|
|
97
106
|
)
|
|
98
107
|
ag.tracing.store_cost(kwargs.get("response_cost"))
|
|
99
|
-
ag.tracing.store_usage(
|
|
108
|
+
ag.tracing.store_usage(
|
|
109
|
+
response_obj.usage.dict() if hasattr(response_obj, "usage") else None
|
|
110
|
+
)
|
|
100
111
|
ag.tracing.store_outputs(
|
|
101
112
|
# the Exception raised
|
|
102
113
|
outputs={"message": repr(kwargs["exception"])},
|
|
@@ -106,11 +117,14 @@ def litellm_handler():
|
|
|
106
117
|
|
|
107
118
|
@debug()
|
|
108
119
|
async def async_log_stream_event(
|
|
109
|
-
self, kwargs,
|
|
120
|
+
self, kwargs, response_obj, start_time, end_time
|
|
110
121
|
):
|
|
122
|
+
logging.info(f"async_log_stream_event({self.span.id})")
|
|
111
123
|
ag.tracing.set_status(status="OK", span_id=self.span.id)
|
|
112
124
|
ag.tracing.store_cost(kwargs.get("response_cost"))
|
|
113
|
-
ag.tracing.store_usage(
|
|
125
|
+
ag.tracing.store_usage(
|
|
126
|
+
response_obj.usage.dict() if hasattr(response_obj, "usage") else None
|
|
127
|
+
)
|
|
114
128
|
ag.tracing.store_outputs(
|
|
115
129
|
# the complete streamed response (only set if `completion(..stream=True)`)
|
|
116
130
|
outputs={"message": kwargs.get("complete_streaming_response")},
|
|
@@ -120,21 +134,25 @@ def litellm_handler():
|
|
|
120
134
|
|
|
121
135
|
@debug()
|
|
122
136
|
async def async_log_success_event(
|
|
123
|
-
self, kwargs,
|
|
137
|
+
self, kwargs, response_obj, start_time, end_time
|
|
124
138
|
):
|
|
139
|
+
logging.info(f"async_log_success_event({self.span.id})")
|
|
125
140
|
ag.tracing.set_status(status="OK", span_id=self.span.id)
|
|
126
141
|
ag.tracing.store_cost(kwargs.get("response_cost"))
|
|
127
|
-
ag.tracing.store_usage(
|
|
142
|
+
ag.tracing.store_usage(
|
|
143
|
+
response_obj.usage.dict() if hasattr(response_obj, "usage") else None
|
|
144
|
+
)
|
|
128
145
|
ag.tracing.store_outputs(
|
|
129
|
-
outputs={"message":
|
|
146
|
+
outputs={"message": response_obj.choices[0].message.content},
|
|
130
147
|
span_id=self.span.id,
|
|
131
148
|
)
|
|
132
149
|
ag.tracing.close_span(span_id=self.span.id)
|
|
133
150
|
|
|
134
151
|
@debug()
|
|
135
152
|
async def async_log_failure_event(
|
|
136
|
-
self, kwargs,
|
|
153
|
+
self, kwargs, response_obj, start_time, end_time
|
|
137
154
|
):
|
|
155
|
+
logging.info(f"async_log_failure_event({self.span.id})")
|
|
138
156
|
ag.tracing.set_status(status="ERROR", span_id=self.span.id)
|
|
139
157
|
ag.tracing.set_attributes(
|
|
140
158
|
{
|
|
@@ -148,7 +166,9 @@ def litellm_handler():
|
|
|
148
166
|
span_id=self.span.id,
|
|
149
167
|
)
|
|
150
168
|
ag.tracing.store_cost(kwargs.get("response_cost"))
|
|
151
|
-
ag.tracing.store_usage(
|
|
169
|
+
ag.tracing.store_usage(
|
|
170
|
+
response_obj.usage.dict() if hasattr(response_obj, "usage") else None
|
|
171
|
+
)
|
|
152
172
|
ag.tracing.store_outputs(
|
|
153
173
|
# the Exception raised
|
|
154
174
|
outputs={"message": repr(kwargs["exception"])},
|
|
@@ -267,7 +267,7 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
267
267
|
outputs=None,
|
|
268
268
|
tags=None,
|
|
269
269
|
user=None,
|
|
270
|
-
end_time=
|
|
270
|
+
end_time=None,
|
|
271
271
|
tokens=None,
|
|
272
272
|
cost=None,
|
|
273
273
|
token_consumption=None,
|
|
@@ -372,7 +372,7 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
372
372
|
tracing.active_span = parent_span
|
|
373
373
|
### --- TO BE CLEANED --- <<<
|
|
374
374
|
|
|
375
|
-
logging.info(f"Closed span {
|
|
375
|
+
logging.info(f"Closed span {span.id} {spankind}")
|
|
376
376
|
|
|
377
377
|
@debug()
|
|
378
378
|
def store_internals(
|
|
@@ -457,6 +457,9 @@ class Tracing(metaclass=SingletonMeta):
|
|
|
457
457
|
trace["trace_id"] = tracing.trace_id
|
|
458
458
|
|
|
459
459
|
for span in tracing.spans.values():
|
|
460
|
+
if span.end_time is None:
|
|
461
|
+
span.end_time = span.start_time
|
|
462
|
+
|
|
460
463
|
if span.parent_span_id is None:
|
|
461
464
|
trace["cost"] = span.cost
|
|
462
465
|
trace["usage"] = (
|
|
@@ -131,13 +131,13 @@ agenta/sdk/agenta_init.py,sha256=8MfDuypxohd0qRTdtGjX7L17KW-1UGmzNVdiqF15_ak,979
|
|
|
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=
|
|
134
|
+
agenta/sdk/decorators/llm_entrypoint.py,sha256=9GFT6dpVWY2_1Ckh1Y_N0xSXwosoSjtNtqMEM7u55uY,28224
|
|
135
135
|
agenta/sdk/decorators/tracing.py,sha256=TwzhG3ZoyvmS1hCy3Z4S_6ZJGu1J_WHHgZm8Lc9Vkes,4371
|
|
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=jX4nEmmQ9VX5NLQz6b0Crwv_MWzNjCweqW2DmmG7Nks,7250
|
|
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=FfZQcID-8E4G0R34H29SA05yFUNDMEPccb4MqVcNDLM,18064
|
|
141
141
|
agenta/sdk/tracing/logger.py,sha256=GfH7V-jBHcn7h5dbdrnkDMe_ml3wkXFBeoQiqR4KVRc,474
|
|
142
142
|
agenta/sdk/tracing/tasks_manager.py,sha256=FBSFOWIKBycyA4ShB2ZVMzrzYQ8pWGWWBClFX8nlZFA,3726
|
|
143
143
|
agenta/sdk/tracing/tracing_context.py,sha256=nt3ewa-TK9BRJviGIZYazsAQUiG4daWxjtsbjeaDprs,789
|
|
@@ -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.20.
|
|
165
|
-
agenta-0.20.
|
|
166
|
-
agenta-0.20.
|
|
167
|
-
agenta-0.20.
|
|
164
|
+
agenta-0.20.0a10.dist-info/METADATA,sha256=xKQS1zITOgYRQWrUuQjqur7I5G6pGVA1FdM_5vWA2_U,26463
|
|
165
|
+
agenta-0.20.0a10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
166
|
+
agenta-0.20.0a10.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
|
|
167
|
+
agenta-0.20.0a10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|