agenta 0.27.7a2__py3-none-any.whl → 0.28.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.
- agenta/cli/main.py +4 -51
- agenta/client/backend/apps/client.py +12 -58
- agenta/client/backend/evaluations/client.py +0 -11
- agenta/client/backend/testsets/client.py +8 -40
- agenta/sdk/agenta_init.py +4 -9
- agenta/sdk/decorators/routing.py +24 -42
- agenta/sdk/litellm/litellm.py +30 -75
- agenta/sdk/middleware/auth.py +9 -6
- agenta/sdk/tracing/context.py +6 -6
- agenta/sdk/tracing/inline.py +19 -11
- agenta/sdk/tracing/processors.py +1 -3
- agenta/sdk/tracing/tracing.py +1 -5
- agenta/sdk/utils/exceptions.py +15 -9
- agenta/sdk/utils/logging.py +5 -1
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/METADATA +1 -1
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/RECORD +18 -19
- agenta/sdk/utils/debug.py +0 -68
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/WHEEL +0 -0
- {agenta-0.27.7a2.dist-info → agenta-0.28.0.dist-info}/entry_points.txt +0 -0
agenta/sdk/decorators/routing.py
CHANGED
|
@@ -143,9 +143,7 @@ class entrypoint:
|
|
|
143
143
|
_MIDDLEWARES = False
|
|
144
144
|
|
|
145
145
|
except: # pylint: disable=bare-except
|
|
146
|
-
log.
|
|
147
|
-
log.error("Agenta SDK - failed to secure route: %s", route_path)
|
|
148
|
-
log.error("------------------------------------")
|
|
146
|
+
log.warning("Agenta SDK - failed to secure route: %s", route_path)
|
|
149
147
|
### --- Update Middleware --- #
|
|
150
148
|
|
|
151
149
|
DEFAULT_PATH = "generate"
|
|
@@ -357,9 +355,7 @@ class entrypoint:
|
|
|
357
355
|
*args,
|
|
358
356
|
**func_params,
|
|
359
357
|
):
|
|
360
|
-
log.info("
|
|
361
|
-
log.info(f"Agenta SDK - running route: {repr(self.route_path or '/')}")
|
|
362
|
-
log.info("---------------------------")
|
|
358
|
+
log.info("Agenta SDK - handling route: %s", repr(self.route_path or "/"))
|
|
363
359
|
|
|
364
360
|
tracing_context.set(routing_context.get())
|
|
365
361
|
|
|
@@ -377,36 +373,32 @@ class entrypoint:
|
|
|
377
373
|
|
|
378
374
|
async def handle_success(self, result: Any, inline_trace: bool):
|
|
379
375
|
data = None
|
|
380
|
-
|
|
376
|
+
tree = None
|
|
381
377
|
|
|
382
378
|
with suppress():
|
|
383
379
|
data = self.patch_result(result)
|
|
384
380
|
|
|
385
381
|
if inline_trace:
|
|
386
|
-
|
|
382
|
+
tree = await self.fetch_inline_trace(inline_trace)
|
|
387
383
|
|
|
388
384
|
log.info(f"----------------------------------")
|
|
389
385
|
log.info(f"Agenta SDK - exiting with success: 200")
|
|
390
386
|
log.info(f"----------------------------------")
|
|
391
387
|
|
|
392
|
-
return BaseResponse(data=data, tree=
|
|
388
|
+
return BaseResponse(data=data, tree=tree)
|
|
393
389
|
|
|
394
390
|
def handle_failure(self, error: Exception):
|
|
395
|
-
log.
|
|
396
|
-
log.
|
|
397
|
-
log.
|
|
398
|
-
log.
|
|
399
|
-
log.
|
|
391
|
+
log.warning("--------------------------------------------------")
|
|
392
|
+
log.warning("Agenta SDK - handling application exception below:")
|
|
393
|
+
log.warning("--------------------------------------------------")
|
|
394
|
+
log.warning(format_exc().strip("\n"))
|
|
395
|
+
log.warning("--------------------------------------------------")
|
|
400
396
|
|
|
401
397
|
status_code = error.status_code if hasattr(error, "status_code") else 500
|
|
402
398
|
message = str(error)
|
|
403
399
|
stacktrace = format_exception(error, value=error, tb=error.__traceback__) # type: ignore
|
|
404
400
|
detail = {"message": message, "stacktrace": stacktrace}
|
|
405
401
|
|
|
406
|
-
log.error(f"----------------------------------")
|
|
407
|
-
log.error(f"Agenta SDK - exiting with failure: {status_code}")
|
|
408
|
-
log.error(f"----------------------------------")
|
|
409
|
-
|
|
410
402
|
raise HTTPException(status_code=status_code, detail=detail)
|
|
411
403
|
|
|
412
404
|
def patch_result(self, result: Any):
|
|
@@ -683,10 +675,7 @@ class entrypoint:
|
|
|
683
675
|
|
|
684
676
|
loop = get_event_loop()
|
|
685
677
|
|
|
686
|
-
with routing_context_manager(
|
|
687
|
-
config=args_config_params,
|
|
688
|
-
environment="terminal",
|
|
689
|
-
):
|
|
678
|
+
with routing_context_manager(config=args_config_params):
|
|
690
679
|
result = loop.run_until_complete(
|
|
691
680
|
self.execute_function(
|
|
692
681
|
func,
|
|
@@ -695,30 +684,23 @@ class entrypoint:
|
|
|
695
684
|
)
|
|
696
685
|
)
|
|
697
686
|
|
|
698
|
-
SHOW_DETAILS = True
|
|
699
|
-
SHOW_DATA = False
|
|
700
|
-
SHOW_TRACE = False
|
|
701
|
-
|
|
702
687
|
if result.trace:
|
|
703
688
|
log.info("\n========= Result =========\n")
|
|
704
689
|
|
|
705
690
|
log.info(f"trace_id: {result.trace['trace_id']}")
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
log.info(f"----------------")
|
|
720
|
-
log.info(dumps(result.trace.get("spans", []), indent=2))
|
|
721
|
-
log.info(f"----------------")
|
|
691
|
+
log.info(f"latency: {result.trace.get('latency')}")
|
|
692
|
+
log.info(f"cost: {result.trace.get('cost')}")
|
|
693
|
+
log.info(f"usage: {list(result.trace.get('usage', {}).values())}")
|
|
694
|
+
|
|
695
|
+
log.info(" ")
|
|
696
|
+
log.info("data:")
|
|
697
|
+
log.info(dumps(result.data, indent=2))
|
|
698
|
+
|
|
699
|
+
log.info(" ")
|
|
700
|
+
log.info("trace:")
|
|
701
|
+
log.info("----------------")
|
|
702
|
+
log.info(dumps(result.trace.get("spans", []), indent=2))
|
|
703
|
+
log.info("----------------")
|
|
722
704
|
|
|
723
705
|
log.info("\n==========================\n")
|
|
724
706
|
|
agenta/sdk/litellm/litellm.py
CHANGED
|
@@ -60,7 +60,11 @@ def litellm_handler():
|
|
|
60
60
|
)
|
|
61
61
|
|
|
62
62
|
if not self.span:
|
|
63
|
-
log.
|
|
63
|
+
log.warning("Agenta SDK - litellm tracing failed")
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
if not self.span.is_recording():
|
|
67
|
+
log.error("Agenta SDK - litellm span not recording.")
|
|
64
68
|
return
|
|
65
69
|
|
|
66
70
|
self.span.set_attributes(
|
|
@@ -86,43 +90,11 @@ def litellm_handler():
|
|
|
86
90
|
end_time,
|
|
87
91
|
):
|
|
88
92
|
if not self.span:
|
|
89
|
-
log.
|
|
93
|
+
log.warning("Agenta SDK - litellm tracing failed")
|
|
90
94
|
return
|
|
91
95
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
for choice in response_obj.choices:
|
|
95
|
-
message = choice.message.__dict__
|
|
96
|
-
result.append(message)
|
|
97
|
-
|
|
98
|
-
outputs = {"completion": result}
|
|
99
|
-
self.span.set_attributes(
|
|
100
|
-
attributes={"outputs": outputs},
|
|
101
|
-
namespace="data",
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
except Exception as e:
|
|
105
|
-
pass
|
|
106
|
-
|
|
107
|
-
self.span.set_attributes(
|
|
108
|
-
attributes={"total": kwargs.get("response_cost")},
|
|
109
|
-
namespace="metrics.unit.costs",
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
self.span.set_attributes(
|
|
113
|
-
attributes=(
|
|
114
|
-
{
|
|
115
|
-
"prompt": response_obj.usage.prompt_tokens,
|
|
116
|
-
"completion": response_obj.usage.completion_tokens,
|
|
117
|
-
"total": response_obj.usage.total_tokens,
|
|
118
|
-
}
|
|
119
|
-
),
|
|
120
|
-
namespace="metrics.unit.tokens",
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
self.span.set_status(status="OK")
|
|
124
|
-
|
|
125
|
-
self.span.end()
|
|
96
|
+
if not self.span.is_recording():
|
|
97
|
+
return
|
|
126
98
|
|
|
127
99
|
def log_success_event(
|
|
128
100
|
self,
|
|
@@ -131,8 +103,14 @@ def litellm_handler():
|
|
|
131
103
|
start_time,
|
|
132
104
|
end_time,
|
|
133
105
|
):
|
|
106
|
+
if kwargs.get("stream"):
|
|
107
|
+
return
|
|
108
|
+
|
|
134
109
|
if not self.span:
|
|
135
|
-
log.
|
|
110
|
+
log.warning("Agenta SDK - litellm tracing failed")
|
|
111
|
+
return
|
|
112
|
+
|
|
113
|
+
if not self.span.is_recording():
|
|
136
114
|
return
|
|
137
115
|
|
|
138
116
|
try:
|
|
@@ -178,7 +156,10 @@ def litellm_handler():
|
|
|
178
156
|
end_time,
|
|
179
157
|
):
|
|
180
158
|
if not self.span:
|
|
181
|
-
log.
|
|
159
|
+
log.warning("Agenta SDK - litellm tracing failed")
|
|
160
|
+
return
|
|
161
|
+
|
|
162
|
+
if not self.span.is_recording():
|
|
182
163
|
return
|
|
183
164
|
|
|
184
165
|
self.span.record_exception(kwargs["exception"])
|
|
@@ -195,43 +176,11 @@ def litellm_handler():
|
|
|
195
176
|
end_time,
|
|
196
177
|
):
|
|
197
178
|
if not self.span:
|
|
198
|
-
log.
|
|
179
|
+
log.warning("Agenta SDK - litellm tracing failed")
|
|
199
180
|
return
|
|
200
181
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
for choice in response_obj.choices:
|
|
204
|
-
message = choice.message.__dict__
|
|
205
|
-
result.append(message)
|
|
206
|
-
|
|
207
|
-
outputs = {"completion": result}
|
|
208
|
-
self.span.set_attributes(
|
|
209
|
-
attributes={"outputs": outputs},
|
|
210
|
-
namespace="data",
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
except Exception as e:
|
|
214
|
-
pass
|
|
215
|
-
|
|
216
|
-
self.span.set_attributes(
|
|
217
|
-
attributes={"total": kwargs.get("response_cost")},
|
|
218
|
-
namespace="metrics.unit.costs",
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
self.span.set_attributes(
|
|
222
|
-
attributes=(
|
|
223
|
-
{
|
|
224
|
-
"prompt": response_obj.usage.prompt_tokens,
|
|
225
|
-
"completion": response_obj.usage.completion_tokens,
|
|
226
|
-
"total": response_obj.usage.total_tokens,
|
|
227
|
-
}
|
|
228
|
-
),
|
|
229
|
-
namespace="metrics.unit.tokens",
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
self.span.set_status(status="OK")
|
|
233
|
-
|
|
234
|
-
self.span.end()
|
|
182
|
+
if not self.span.is_recording():
|
|
183
|
+
return
|
|
235
184
|
|
|
236
185
|
async def async_log_success_event(
|
|
237
186
|
self,
|
|
@@ -241,7 +190,10 @@ def litellm_handler():
|
|
|
241
190
|
end_time,
|
|
242
191
|
):
|
|
243
192
|
if not self.span:
|
|
244
|
-
log.
|
|
193
|
+
log.warning("Agenta SDK - litellm tracing failed")
|
|
194
|
+
return
|
|
195
|
+
|
|
196
|
+
if not self.span.is_recording():
|
|
245
197
|
return
|
|
246
198
|
|
|
247
199
|
try:
|
|
@@ -287,7 +239,10 @@ def litellm_handler():
|
|
|
287
239
|
end_time,
|
|
288
240
|
):
|
|
289
241
|
if not self.span:
|
|
290
|
-
log.
|
|
242
|
+
log.warning("Agenta SDK - litellm tracing failed")
|
|
243
|
+
return
|
|
244
|
+
|
|
245
|
+
if not self.span.is_recording():
|
|
291
246
|
return
|
|
292
247
|
|
|
293
248
|
self.span.record_exception(kwargs["exception"])
|
agenta/sdk/middleware/auth.py
CHANGED
|
@@ -27,6 +27,8 @@ AGENTA_SDK_AUTH_CACHE = str(environ.get("AGENTA_SDK_AUTH_CACHE", True)).lower()
|
|
|
27
27
|
"t",
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
+
AGENTA_SDK_AUTH_CACHE = False
|
|
31
|
+
|
|
30
32
|
AGENTA_UNAUTHORIZED_EXECUTION_ALLOWED = str(
|
|
31
33
|
environ.get("AGENTA_UNAUTHORIZED_EXECUTION_ALLOWED", False)
|
|
32
34
|
).lower() in ("true", "1", "t")
|
|
@@ -61,7 +63,6 @@ class AuthorizationMiddleware(BaseHTTPMiddleware):
|
|
|
61
63
|
self,
|
|
62
64
|
request: Request,
|
|
63
65
|
call_next: Callable,
|
|
64
|
-
project_id: Optional[UUID] = None,
|
|
65
66
|
):
|
|
66
67
|
if AGENTA_UNAUTHORIZED_EXECUTION_ALLOWED:
|
|
67
68
|
return await call_next(request)
|
|
@@ -83,6 +84,8 @@ class AuthorizationMiddleware(BaseHTTPMiddleware):
|
|
|
83
84
|
"resource_id": self.resource_id,
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
project_id = request.query_params.get("project_id")
|
|
88
|
+
|
|
86
89
|
if project_id:
|
|
87
90
|
params["project_id"] = project_id
|
|
88
91
|
|
|
@@ -133,10 +136,10 @@ class AuthorizationMiddleware(BaseHTTPMiddleware):
|
|
|
133
136
|
return await call_next(request)
|
|
134
137
|
|
|
135
138
|
except: # pylint: disable=bare-except
|
|
136
|
-
log.
|
|
137
|
-
log.
|
|
138
|
-
log.
|
|
139
|
-
log.
|
|
140
|
-
log.
|
|
139
|
+
log.warning("------------------------------------------------------")
|
|
140
|
+
log.warning("Agenta SDK - handling auth middleware exception below:")
|
|
141
|
+
log.warning("------------------------------------------------------")
|
|
142
|
+
log.warning(format_exc().strip("\n"))
|
|
143
|
+
log.warning("------------------------------------------------------")
|
|
141
144
|
|
|
142
145
|
return Deny()
|
agenta/sdk/tracing/context.py
CHANGED
|
@@ -14,11 +14,11 @@ def tracing_context_manager():
|
|
|
14
14
|
token = tracing_context.set(_tracing_context)
|
|
15
15
|
try:
|
|
16
16
|
yield
|
|
17
|
-
except
|
|
18
|
-
log.
|
|
19
|
-
log.
|
|
20
|
-
log.
|
|
21
|
-
log.
|
|
22
|
-
log.
|
|
17
|
+
except: # pylint: disable=bare-except
|
|
18
|
+
log.warning("----------------------------------------------")
|
|
19
|
+
log.warning("Agenta SDK - handling tracing exception below:")
|
|
20
|
+
log.warning("----------------------------------------------")
|
|
21
|
+
log.warning(format_exc().strip("\n"))
|
|
22
|
+
log.warning("----------------------------------------------")
|
|
23
23
|
finally:
|
|
24
24
|
tracing_context.reset(token)
|
agenta/sdk/tracing/inline.py
CHANGED
|
@@ -41,7 +41,6 @@ from uuid import UUID
|
|
|
41
41
|
class TimeDTO(BaseModel):
|
|
42
42
|
start: datetime
|
|
43
43
|
end: datetime
|
|
44
|
-
span: int
|
|
45
44
|
|
|
46
45
|
|
|
47
46
|
class StatusCode(Enum):
|
|
@@ -846,12 +845,9 @@ def parse_from_otel_span_dto(
|
|
|
846
845
|
else None
|
|
847
846
|
)
|
|
848
847
|
|
|
849
|
-
duration = (otel_span_dto.end_time - otel_span_dto.start_time).total_seconds()
|
|
850
|
-
|
|
851
848
|
time = TimeDTO(
|
|
852
849
|
start=otel_span_dto.start_time,
|
|
853
850
|
end=otel_span_dto.end_time,
|
|
854
|
-
span=round(duration * 1_000_000), # microseconds
|
|
855
851
|
)
|
|
856
852
|
|
|
857
853
|
status = StatusDTO(
|
|
@@ -863,6 +859,13 @@ def parse_from_otel_span_dto(
|
|
|
863
859
|
|
|
864
860
|
data, metrics, meta, tags, refs = _parse_from_attributes(otel_span_dto)
|
|
865
861
|
|
|
862
|
+
duration = (otel_span_dto.end_time - otel_span_dto.start_time).total_seconds()
|
|
863
|
+
|
|
864
|
+
if metrics is None:
|
|
865
|
+
metrics = dict()
|
|
866
|
+
|
|
867
|
+
metrics["acc.duration.total"] = round(duration * 1_000, 3) # milliseconds
|
|
868
|
+
|
|
866
869
|
root_id = str(tree_id)
|
|
867
870
|
if refs is not None:
|
|
868
871
|
root_id = refs.get("scenario.id", root_id)
|
|
@@ -1118,13 +1121,15 @@ def calculate_costs(span_idx: Dict[str, SpanDTO]):
|
|
|
1118
1121
|
and span.meta
|
|
1119
1122
|
and span.metrics
|
|
1120
1123
|
):
|
|
1124
|
+
model = span.meta.get("response.model")
|
|
1125
|
+
prompt_tokens = span.metrics.get("unit.tokens.prompt", 0.0)
|
|
1126
|
+
completion_tokens = span.metrics.get("unit.tokens.completion", 0.0)
|
|
1127
|
+
|
|
1121
1128
|
try:
|
|
1122
1129
|
costs = cost_calculator.cost_per_token(
|
|
1123
|
-
model=
|
|
1124
|
-
prompt_tokens=
|
|
1125
|
-
completion_tokens=
|
|
1126
|
-
call_type=span.node.type.name.lower(),
|
|
1127
|
-
response_time_ms=span.time.span // 1_000,
|
|
1130
|
+
model=model,
|
|
1131
|
+
prompt_tokens=prompt_tokens,
|
|
1132
|
+
completion_tokens=completion_tokens,
|
|
1128
1133
|
)
|
|
1129
1134
|
|
|
1130
1135
|
if not costs:
|
|
@@ -1137,5 +1142,8 @@ def calculate_costs(span_idx: Dict[str, SpanDTO]):
|
|
|
1137
1142
|
span.metrics["unit.costs.completion"] = completion_cost
|
|
1138
1143
|
span.metrics["unit.costs.total"] = total_cost
|
|
1139
1144
|
|
|
1140
|
-
except:
|
|
1141
|
-
|
|
1145
|
+
except: # pylint: disable=bare-except
|
|
1146
|
+
print("Failed to calculate costs:")
|
|
1147
|
+
print(
|
|
1148
|
+
f"model={model}, prompt_tokens={prompt_tokens}, completion_tokens={completion_tokens}"
|
|
1149
|
+
)
|
agenta/sdk/tracing/processors.py
CHANGED
|
@@ -91,9 +91,7 @@ class TraceProcessor(BatchSpanProcessor):
|
|
|
91
91
|
ret = super().force_flush(timeout_millis)
|
|
92
92
|
|
|
93
93
|
if not ret:
|
|
94
|
-
log.
|
|
95
|
-
log.error("Agenta SDK - skipping export due to timeout.")
|
|
96
|
-
log.error("--------------------------------------------")
|
|
94
|
+
log.warning("Agenta SDK - skipping export due to timeout.")
|
|
97
95
|
|
|
98
96
|
def is_ready(
|
|
99
97
|
self,
|
agenta/sdk/tracing/tracing.py
CHANGED
|
@@ -90,7 +90,6 @@ class Tracing(metaclass=Singleton):
|
|
|
90
90
|
self.otlp_url,
|
|
91
91
|
)
|
|
92
92
|
log.info("--------------------------------------------")
|
|
93
|
-
|
|
94
93
|
check(
|
|
95
94
|
self.otlp_url,
|
|
96
95
|
headers=self.headers,
|
|
@@ -106,13 +105,10 @@ class Tracing(metaclass=Singleton):
|
|
|
106
105
|
)
|
|
107
106
|
|
|
108
107
|
self.tracer_provider.add_span_processor(_otlp)
|
|
109
|
-
|
|
110
108
|
log.info("Success: traces will be exported.")
|
|
111
109
|
log.info("--------------------------------------------")
|
|
112
|
-
|
|
113
110
|
except: # pylint: disable=bare-except
|
|
114
|
-
log.warning("
|
|
115
|
-
log.warning("--------------------------------------------")
|
|
111
|
+
log.warning("Agenta SDK - traces will not be exported.")
|
|
116
112
|
|
|
117
113
|
# GLOBAL TRACER PROVIDER -- INSTRUMENTATION LIBRARIES
|
|
118
114
|
set_tracer_provider(self.tracer_provider)
|
agenta/sdk/utils/exceptions.py
CHANGED
|
@@ -17,11 +17,11 @@ class suppress(AbstractContextManager): # pylint: disable=invalid-name
|
|
|
17
17
|
if exc_type is None:
|
|
18
18
|
return True
|
|
19
19
|
else:
|
|
20
|
-
log.
|
|
21
|
-
log.
|
|
22
|
-
log.
|
|
23
|
-
log.
|
|
24
|
-
log.
|
|
20
|
+
log.warning("-------------------------------------------------")
|
|
21
|
+
log.warning("Agenta SDK - suppressing tracing exception below:")
|
|
22
|
+
log.warning("-------------------------------------------------")
|
|
23
|
+
log.warning(format_exc().strip("\n"))
|
|
24
|
+
log.warning("-------------------------------------------------")
|
|
25
25
|
return True
|
|
26
26
|
|
|
27
27
|
|
|
@@ -34,8 +34,11 @@ def handle_exceptions():
|
|
|
34
34
|
try:
|
|
35
35
|
return await func(*args, **kwargs)
|
|
36
36
|
except Exception as e:
|
|
37
|
-
log.
|
|
38
|
-
log.
|
|
37
|
+
log.warning("------------------------------------------")
|
|
38
|
+
log.warning("Agenta SDK - intercepting exception below:")
|
|
39
|
+
log.warning("------------------------------------------")
|
|
40
|
+
log.warning(format_exc().strip("\n"))
|
|
41
|
+
log.warning("------------------------------------------")
|
|
39
42
|
raise e
|
|
40
43
|
|
|
41
44
|
@wraps(func)
|
|
@@ -43,8 +46,11 @@ def handle_exceptions():
|
|
|
43
46
|
try:
|
|
44
47
|
return func(*args, **kwargs)
|
|
45
48
|
except Exception as e:
|
|
46
|
-
log.
|
|
47
|
-
log.
|
|
49
|
+
log.warning("------------------------------------------")
|
|
50
|
+
log.warning("Agenta SDK - intercepting exception below:")
|
|
51
|
+
log.warning("------------------------------------------")
|
|
52
|
+
log.warning(format_exc().strip("\n"))
|
|
53
|
+
log.warning("------------------------------------------")
|
|
48
54
|
raise e
|
|
49
55
|
|
|
50
56
|
return async_wrapper if is_coroutine_function else sync_wrapper
|
agenta/sdk/utils/logging.py
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
from os import getenv
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class Logger:
|
|
5
|
-
def __init__(self, name="agenta.logger", level=logging.
|
|
6
|
+
def __init__(self, name="agenta.logger", level=logging.WARNING):
|
|
7
|
+
if getenv("AGENTA_DEBUG"):
|
|
8
|
+
level = logging.DEBUG
|
|
9
|
+
|
|
6
10
|
self.logger = logging.getLogger(name)
|
|
7
11
|
self.logger.setLevel(level)
|
|
8
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
agenta/__init__.py,sha256=XXPgAjzPw5CXQpuQbDNpKRuoBL5X_YoobKeebjYHiSY,2101
|
|
2
2
|
agenta/cli/evaluation_commands.py,sha256=fs6492tprPId9p8eGO02Xy-NCBm2RZNJLZWcUxugwd8,474
|
|
3
3
|
agenta/cli/helper.py,sha256=P97HbNb_qzOyl5CM_MjAqWEBCdgebU6M81G_4UCmF1A,6288
|
|
4
|
-
agenta/cli/main.py,sha256=
|
|
4
|
+
agenta/cli/main.py,sha256=drRCn7x9-rP3zcLXEIgAqVWS68g_vXnRyo4N7DGFBW8,7946
|
|
5
5
|
agenta/cli/telemetry.py,sha256=GaFFRsE_NtrcSSJ10r2jhgFs5Sk8gf2C09Ox3gOr3eU,1317
|
|
6
6
|
agenta/cli/variant_commands.py,sha256=HfKRZsajKOXwZD2OyzjSfNtSx1yI01wI1cfqpvoHETI,17400
|
|
7
7
|
agenta/cli/variant_configs.py,sha256=PLiuMKadVzs6Gi2uYaT0pZzyULNHDXaTMDWboqpwWdU,1293
|
|
@@ -11,7 +11,7 @@ agenta/client/api.py,sha256=r5pwYD8DWppDrV4xaNYwUmwMLjWVNfVzxK_clIboEWg,2434
|
|
|
11
11
|
agenta/client/api_models.py,sha256=zebfE2-0-SW1SvzyarzmSJMXqyiCLKrX2sHpzoX-RnU,623
|
|
12
12
|
agenta/client/backend/__init__.py,sha256=Q7KdR_MAfYvg7LlGVXvOUZi4L_7k6pbSVc8vIaNy-Bg,5637
|
|
13
13
|
agenta/client/backend/apps/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
14
|
-
agenta/client/backend/apps/client.py,sha256=
|
|
14
|
+
agenta/client/backend/apps/client.py,sha256=QucGNzuxfkOH2OU4dQMd7BdOjRTw4ac31On5FED3vVI,52590
|
|
15
15
|
agenta/client/backend/bases/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
16
16
|
agenta/client/backend/bases/client.py,sha256=BZsz5eXaa2voZdJXqgd5J5hPUuYvWwIcPCWyl49w-oY,6028
|
|
17
17
|
agenta/client/backend/client.py,sha256=YkeIJbq_8_TKsF-L3x6fNoRazRaM0BzhYckaeUAB4vI,103549
|
|
@@ -38,7 +38,7 @@ agenta/client/backend/environments/client.py,sha256=JG980MafNEcMX60gCtLdPQb8Ja6R
|
|
|
38
38
|
agenta/client/backend/errors/__init__.py,sha256=pbbVUFtB9LCocA1RMWMMF_RKjsy5YkOKX5BAuE49w6g,170
|
|
39
39
|
agenta/client/backend/errors/unprocessable_entity_error.py,sha256=FvR7XPlV3Xx5nu8HNlmLhBRdk4so_gCHjYT5PyZe6sM,313
|
|
40
40
|
agenta/client/backend/evaluations/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
41
|
-
agenta/client/backend/evaluations/client.py,sha256=
|
|
41
|
+
agenta/client/backend/evaluations/client.py,sha256=GgBq5iXFR89VMt6SSbSpk6zDseR79brzVtpfJM1XxxA,46339
|
|
42
42
|
agenta/client/backend/evaluators/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
43
43
|
agenta/client/backend/evaluators/client.py,sha256=fdfb0ZFLP-kI5jXr6F3O-wKWvWBGUXhqRXIoetyN-zQ,40405
|
|
44
44
|
agenta/client/backend/observability/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
@@ -49,7 +49,7 @@ agenta/client/backend/observability_v_1/types/__init__.py,sha256=vHpFg4KBBFowe8E
|
|
|
49
49
|
agenta/client/backend/observability_v_1/types/format.py,sha256=U-b6HwkOirqvyU7WWDfXyDkYlxBV90lRe1YKds4qg_Q,157
|
|
50
50
|
agenta/client/backend/observability_v_1/types/query_traces_response.py,sha256=0-4nNfKLnciOR7E1859HupWqcwunJe53OLgXRlxxeb8,452
|
|
51
51
|
agenta/client/backend/testsets/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
52
|
-
agenta/client/backend/testsets/client.py,sha256=
|
|
52
|
+
agenta/client/backend/testsets/client.py,sha256=nmH7xcA4ByXTNHr8m24HbYGKmCdHrFOzlXRGV2QO7L0,34343
|
|
53
53
|
agenta/client/backend/types/__init__.py,sha256=fjXpRS1ZZAJPTRYybJcuAMJ9JnkmmvDbghY3GGLYm34,7521
|
|
54
54
|
agenta/client/backend/types/agenta_node_dto.py,sha256=DLZltD_ueVOfdiSZ1u2i3mu1C3kshxhcggQFFfybBdY,1747
|
|
55
55
|
agenta/client/backend/types/agenta_node_dto_nodes_value.py,sha256=ifG7dBYLphFoCgQ70ivvDXkTSlxX8w5x_9S-Glh8FlI,180
|
|
@@ -174,42 +174,41 @@ agenta/docker/docker-assets/lambda_function.py,sha256=h4UZSSfqwpfsCgERv6frqwm_4J
|
|
|
174
174
|
agenta/docker/docker-assets/main.py,sha256=7MI-21n81U7N7A0GxebNi0cmGWtJKcR2sPB6FcH2QfA,251
|
|
175
175
|
agenta/docker/docker_utils.py,sha256=kO1q2_IR0fEAo4M-2Pt_v-zC7GxxnkLogjKFhU869Ps,3555
|
|
176
176
|
agenta/sdk/__init__.py,sha256=Rz5ZqSbz5wIl-v4Jf4kkaTy6ofCYg5CcybyfgeAgaP8,1948
|
|
177
|
-
agenta/sdk/agenta_init.py,sha256=
|
|
177
|
+
agenta/sdk/agenta_init.py,sha256=vH7FOY7XshKqHfAV7P54Owb-7E0cuxuMMCRobd1PT1U,10870
|
|
178
178
|
agenta/sdk/assets.py,sha256=Zv4i8MVUSB3jMODQon1mzJtYxuntmrCNjLGk8f-2fls,2856
|
|
179
179
|
agenta/sdk/client.py,sha256=trKyBOYFZRk0v5Eptxvh87yPf50Y9CqY6Qgv4Fy-VH4,2142
|
|
180
180
|
agenta/sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
181
181
|
agenta/sdk/context/routing.py,sha256=ycUgmJZyWhL4bHjKtUSAsTlt_0Fujr_6OpoaEH1lAN0,683
|
|
182
182
|
agenta/sdk/context/tracing.py,sha256=UmmW15UFFsvxS0myS6aD9wBk5iNepNlQi4tEQ_ejfYM,96
|
|
183
183
|
agenta/sdk/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
184
|
-
agenta/sdk/decorators/routing.py,sha256=
|
|
184
|
+
agenta/sdk/decorators/routing.py,sha256=eU_Sq4OmRLpGBhbHj4j4PfEIN_HM1uLsy89OkK0_6O0,36576
|
|
185
185
|
agenta/sdk/decorators/tracing.py,sha256=vL5e6TVX6TQwO0t9raZwnzXHV3vElVT0pHS1vD-vzEo,8523
|
|
186
186
|
agenta/sdk/litellm/__init__.py,sha256=Bpz1gfHQc0MN1yolWcjifLWznv6GjHggvRGQSpxpihM,37
|
|
187
|
-
agenta/sdk/litellm/litellm.py,sha256=
|
|
187
|
+
agenta/sdk/litellm/litellm.py,sha256=97eDU9MUTW6Wv2e7QYhCWLrRYwhaRqG6LVcedp3qNrk,7186
|
|
188
188
|
agenta/sdk/managers/__init__.py,sha256=SN-LRwG0pRRDV3u2Q4JiiSTigN3-mYpzGNM35RzT4mc,238
|
|
189
189
|
agenta/sdk/managers/config.py,sha256=AuFfHYOkmilDdcAJt2nlw_WlA3ho4Htjf29FKTZGElM,11716
|
|
190
190
|
agenta/sdk/managers/deployment.py,sha256=SEokjZeh6n7HRKZ92Y0WncdG49hIFx-Z3B3HAl2kmUg,1174
|
|
191
191
|
agenta/sdk/managers/shared.py,sha256=e53jckQq5PIMpjdxADOonUj7o8aGfzmSvdeH5f43rGs,21497
|
|
192
192
|
agenta/sdk/managers/variant.py,sha256=A5ga3mq3b0weUTXa9HO72MGaspthGcu1uK9K5OnP738,4172
|
|
193
193
|
agenta/sdk/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
194
|
-
agenta/sdk/middleware/auth.py,sha256=
|
|
194
|
+
agenta/sdk/middleware/auth.py,sha256=E7Uw0C3P7aZ9K_GYs8YComMjrKrNyE_SNJ4DXpQcf3Y,4156
|
|
195
195
|
agenta/sdk/middleware/cache.py,sha256=C_LEzFbulbCBIKtcut2T4qJzh90q4369WCsApDg3Vm0,902
|
|
196
196
|
agenta/sdk/router.py,sha256=mOguvtOwl2wmyAgOuWTsf98pQwpNiUILKIo67W_hR3A,119
|
|
197
197
|
agenta/sdk/tracing/__init__.py,sha256=rQNe5-zT5Kt7_CDhq-lnUIi1EYTBVzVf_MbfcIxVD98,41
|
|
198
198
|
agenta/sdk/tracing/attributes.py,sha256=zh8JQZSeYCLBeIRSopKJx6QQ-WEgw08Cr64DS_WOcT8,3833
|
|
199
|
-
agenta/sdk/tracing/context.py,sha256=
|
|
199
|
+
agenta/sdk/tracing/context.py,sha256=IpNENDGRrXWjs-vti5XheqwybQs0QdD-ii4aK0enNrM,803
|
|
200
200
|
agenta/sdk/tracing/conventions.py,sha256=JBtznBXZ3aRkGKkLl7cPwdMNh3w1G-H2Ta2YrAxbr38,950
|
|
201
201
|
agenta/sdk/tracing/exporters.py,sha256=YvTke0RaxeOLqWOuhC5EFzYwFY39kcoBtDLfcyla3j4,1604
|
|
202
|
-
agenta/sdk/tracing/inline.py,sha256=
|
|
203
|
-
agenta/sdk/tracing/processors.py,sha256=
|
|
202
|
+
agenta/sdk/tracing/inline.py,sha256=sYocvSWjuQaun_XaBYNDQyNw4ETS2hFMbFg6g3RCdeg,31463
|
|
203
|
+
agenta/sdk/tracing/processors.py,sha256=tPf3Hx1TmnWSljvX28kYFOFrp4ImIXhlwAaR39sf5qU,2979
|
|
204
204
|
agenta/sdk/tracing/spans.py,sha256=nqUOjjirBxB8Eacv8Qj4Ra_6rknGi3lbJdNyKmk5ODQ,3707
|
|
205
|
-
agenta/sdk/tracing/tracing.py,sha256=
|
|
205
|
+
agenta/sdk/tracing/tracing.py,sha256=RUSnQIWwfOFwhWbiyJfgC0wYtvcV1PusXTwNslV5WZo,6912
|
|
206
206
|
agenta/sdk/types.py,sha256=_lGsGSEaZJrUT4cVcT3zSpgEqex2jFaPtfpFeUEetbc,7247
|
|
207
207
|
agenta/sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
208
208
|
agenta/sdk/utils/costs.py,sha256=i8C7ud__pThLS55XkN4YW8czXtGeXr2mx7jjcOFeiXg,5955
|
|
209
|
-
agenta/sdk/utils/
|
|
210
|
-
agenta/sdk/utils/exceptions.py,sha256=AU0csJtuzswjkr8O8K-PmuOEr0vRNymKPZVRnRR_0Ts,1646
|
|
209
|
+
agenta/sdk/utils/exceptions.py,sha256=UPO5aqNkpxevE7I_gW6O2B0FbtqqwgQobp5b6RQy_Ik,2132
|
|
211
210
|
agenta/sdk/utils/globals.py,sha256=2HhyzWn55BbYNCZ3rT8dAxk1GGXuGQPbtq_THjaHbBw,372
|
|
212
|
-
agenta/sdk/utils/logging.py,sha256=
|
|
211
|
+
agenta/sdk/utils/logging.py,sha256=eFzEFuYpggfIhEKv09JZRqcDzkmZ482a_E2G-X0FK7Y,473
|
|
213
212
|
agenta/sdk/utils/preinit.py,sha256=YlJL7RLfel0R7DFp-jK7OV-z4ZIQJM0oupYlk7g8b5o,1278
|
|
214
213
|
agenta/sdk/utils/singleton.py,sha256=17Ph7LGnnV8HkPjImruKita2ni03Ari5jr0jqm__4sc,312
|
|
215
214
|
agenta/templates/compose_email/README.md,sha256=ss7vZPpI1Hg0VmYtFliwq_r5LnqbCy_S5OQDXg8UoIA,308
|
|
@@ -227,7 +226,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
|
|
|
227
226
|
agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
|
|
228
227
|
agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
|
|
229
228
|
agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
|
|
230
|
-
agenta-0.
|
|
231
|
-
agenta-0.
|
|
232
|
-
agenta-0.
|
|
233
|
-
agenta-0.
|
|
229
|
+
agenta-0.28.0.dist-info/METADATA,sha256=ls-DP_rlKu2AxB9H3hbou42HAnCZTNBPP9h1kq8ndWc,31617
|
|
230
|
+
agenta-0.28.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
231
|
+
agenta-0.28.0.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
|
|
232
|
+
agenta-0.28.0.dist-info/RECORD,,
|