agenta 0.28.2a1__py3-none-any.whl → 0.28.2a2__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 CHANGED
@@ -47,9 +47,9 @@ def check_latest_version() -> Union[str, None]:
47
47
 
48
48
 
49
49
  def notify_update(available_version: str):
50
- import importlib.metadata
50
+ import pkg_resources
51
51
 
52
- installed_version = importlib.metadata.version("agenta")
52
+ installed_version = pkg_resources.get_distribution("agenta").version
53
53
  if available_version > installed_version:
54
54
  click.echo(
55
55
  click.style(
@@ -18,7 +18,6 @@ from agenta.sdk.middleware.auth import AuthorizationMiddleware
18
18
  from agenta.sdk.context.routing import routing_context_manager, routing_context
19
19
  from agenta.sdk.context.tracing import tracing_context
20
20
  from agenta.sdk.router import router
21
- from agenta.sdk.utils import helpers
22
21
  from agenta.sdk.utils.exceptions import suppress
23
22
  from agenta.sdk.utils.logging import log
24
23
  from agenta.sdk.types import (
@@ -288,9 +287,6 @@ class entrypoint:
288
287
  app.openapi_schema = None # Forces FastAPI to re-generate the schema
289
288
  openapi_schema = app.openapi()
290
289
 
291
- # Inject the current version of the SDK into the openapi_schema
292
- openapi_schema["agenta_sdk"] = {"version": helpers.get_current_version()}
293
-
294
290
  for route in entrypoint.routes:
295
291
  self.override_schema(
296
292
  openapi_schema=openapi_schema,
@@ -1,3 +1,4 @@
1
+ from typing import Dict
1
2
  from opentelemetry.trace import SpanKind
2
3
 
3
4
  import agenta as ag
@@ -34,7 +35,7 @@ def litellm_handler():
34
35
  def __init__(self):
35
36
  super().__init__()
36
37
 
37
- self.span = None
38
+ self.span: Dict[str, CustomSpan] = dict()
38
39
 
39
40
  def log_pre_api_call(
40
41
  self,
@@ -42,6 +43,12 @@ def litellm_handler():
42
43
  messages,
43
44
  kwargs,
44
45
  ):
46
+ litellm_call_id = kwargs.get("litellm_call_id")
47
+
48
+ if not litellm_call_id:
49
+ log.warning("Agenta SDK - litellm tracing failed")
50
+ return
51
+
45
52
  type = ( # pylint: disable=redefined-builtin
46
53
  "chat"
47
54
  if kwargs.get("call_type") in ["completion", "acompletion"]
@@ -50,29 +57,31 @@ def litellm_handler():
50
57
 
51
58
  kind = SpanKind.CLIENT
52
59
 
53
- self.span = CustomSpan(
60
+ self.span[litellm_call_id] = CustomSpan(
54
61
  ag.tracer.start_span(name=f"litellm_{kind.name.lower()}", kind=kind)
55
62
  )
56
63
 
57
- self.span.set_attributes(
58
- attributes={"node": type},
59
- namespace="type",
60
- )
64
+ span = self.span[litellm_call_id]
61
65
 
62
- if not self.span:
66
+ if not span:
63
67
  log.warning("Agenta SDK - litellm tracing failed")
64
68
  return
65
69
 
66
- if not self.span.is_recording():
70
+ if not span.is_recording():
67
71
  log.error("Agenta SDK - litellm span not recording.")
68
72
  return
69
73
 
70
- self.span.set_attributes(
74
+ span.set_attributes(
75
+ attributes={"node": type},
76
+ namespace="type",
77
+ )
78
+
79
+ span.set_attributes(
71
80
  attributes={"inputs": {"prompt": kwargs["messages"]}},
72
81
  namespace="data",
73
82
  )
74
83
 
75
- self.span.set_attributes(
84
+ span.set_attributes(
76
85
  attributes={
77
86
  "configuration": {
78
87
  "model": kwargs.get("model"),
@@ -89,11 +98,19 @@ def litellm_handler():
89
98
  start_time,
90
99
  end_time,
91
100
  ):
92
- if not self.span:
101
+ litellm_call_id = kwargs.get("litellm_call_id")
102
+
103
+ if not litellm_call_id:
104
+ log.warning("Agenta SDK - litellm tracing failed")
105
+ return
106
+
107
+ span = self.span[litellm_call_id]
108
+
109
+ if not span:
93
110
  log.warning("Agenta SDK - litellm tracing failed")
94
111
  return
95
112
 
96
- if not self.span.is_recording():
113
+ if not span.is_recording():
97
114
  return
98
115
 
99
116
  def log_success_event(
@@ -106,11 +123,19 @@ def litellm_handler():
106
123
  if kwargs.get("stream"):
107
124
  return
108
125
 
109
- if not self.span:
126
+ litellm_call_id = kwargs.get("litellm_call_id")
127
+
128
+ if not litellm_call_id:
110
129
  log.warning("Agenta SDK - litellm tracing failed")
111
130
  return
112
131
 
113
- if not self.span.is_recording():
132
+ span = self.span[litellm_call_id]
133
+
134
+ if not span:
135
+ log.warning("Agenta SDK - litellm tracing failed")
136
+ return
137
+
138
+ if not span.is_recording():
114
139
  return
115
140
 
116
141
  try:
@@ -120,7 +145,7 @@ def litellm_handler():
120
145
  result.append(message)
121
146
 
122
147
  outputs = {"completion": result}
123
- self.span.set_attributes(
148
+ span.set_attributes(
124
149
  attributes={"outputs": outputs},
125
150
  namespace="data",
126
151
  )
@@ -128,12 +153,12 @@ def litellm_handler():
128
153
  except Exception as e:
129
154
  pass
130
155
 
131
- self.span.set_attributes(
156
+ span.set_attributes(
132
157
  attributes={"total": kwargs.get("response_cost")},
133
158
  namespace="metrics.unit.costs",
134
159
  )
135
160
 
136
- self.span.set_attributes(
161
+ span.set_attributes(
137
162
  attributes=(
138
163
  {
139
164
  "prompt": response_obj.usage.prompt_tokens,
@@ -144,9 +169,9 @@ def litellm_handler():
144
169
  namespace="metrics.unit.tokens",
145
170
  )
146
171
 
147
- self.span.set_status(status="OK")
172
+ span.set_status(status="OK")
148
173
 
149
- self.span.end()
174
+ span.end()
150
175
 
151
176
  def log_failure_event(
152
177
  self,
@@ -155,18 +180,26 @@ def litellm_handler():
155
180
  start_time,
156
181
  end_time,
157
182
  ):
158
- if not self.span:
183
+ litellm_call_id = kwargs.get("litellm_call_id")
184
+
185
+ if not litellm_call_id:
159
186
  log.warning("Agenta SDK - litellm tracing failed")
160
187
  return
161
188
 
162
- if not self.span.is_recording():
189
+ span = self.span[litellm_call_id]
190
+
191
+ if not span:
192
+ log.warning("Agenta SDK - litellm tracing failed")
193
+ return
194
+
195
+ if not span.is_recording():
163
196
  return
164
197
 
165
- self.span.record_exception(kwargs["exception"])
198
+ span.record_exception(kwargs["exception"])
166
199
 
167
- self.span.set_status(status="ERROR")
200
+ span.set_status(status="ERROR")
168
201
 
169
- self.span.end()
202
+ span.end()
170
203
 
171
204
  async def async_log_stream_event(
172
205
  self,
@@ -175,11 +208,22 @@ def litellm_handler():
175
208
  start_time,
176
209
  end_time,
177
210
  ):
178
- if not self.span:
211
+ if kwargs.get("stream"):
212
+ return
213
+
214
+ litellm_call_id = kwargs.get("litellm_call_id")
215
+
216
+ if not litellm_call_id:
217
+ log.warning("Agenta SDK - litellm tracing failed")
218
+ return
219
+
220
+ span = self.span[litellm_call_id]
221
+
222
+ if not span:
179
223
  log.warning("Agenta SDK - litellm tracing failed")
180
224
  return
181
225
 
182
- if not self.span.is_recording():
226
+ if not span.is_recording():
183
227
  return
184
228
 
185
229
  async def async_log_success_event(
@@ -189,11 +233,19 @@ def litellm_handler():
189
233
  start_time,
190
234
  end_time,
191
235
  ):
192
- if not self.span:
236
+ litellm_call_id = kwargs.get("litellm_call_id")
237
+
238
+ if not litellm_call_id:
239
+ log.warning("Agenta SDK - litellm tracing failed")
240
+ return
241
+
242
+ span = self.span[litellm_call_id]
243
+
244
+ if not span:
193
245
  log.warning("Agenta SDK - litellm tracing failed")
194
246
  return
195
247
 
196
- if not self.span.is_recording():
248
+ if not span.is_recording():
197
249
  return
198
250
 
199
251
  try:
@@ -203,7 +255,7 @@ def litellm_handler():
203
255
  result.append(message)
204
256
 
205
257
  outputs = {"completion": result}
206
- self.span.set_attributes(
258
+ span.set_attributes(
207
259
  attributes={"outputs": outputs},
208
260
  namespace="data",
209
261
  )
@@ -211,12 +263,12 @@ def litellm_handler():
211
263
  except Exception as e:
212
264
  pass
213
265
 
214
- self.span.set_attributes(
266
+ span.set_attributes(
215
267
  attributes={"total": kwargs.get("response_cost")},
216
268
  namespace="metrics.unit.costs",
217
269
  )
218
270
 
219
- self.span.set_attributes(
271
+ span.set_attributes(
220
272
  attributes=(
221
273
  {
222
274
  "prompt": response_obj.usage.prompt_tokens,
@@ -227,9 +279,9 @@ def litellm_handler():
227
279
  namespace="metrics.unit.tokens",
228
280
  )
229
281
 
230
- self.span.set_status(status="OK")
282
+ span.set_status(status="OK")
231
283
 
232
- self.span.end()
284
+ span.end()
233
285
 
234
286
  async def async_log_failure_event(
235
287
  self,
@@ -238,17 +290,25 @@ def litellm_handler():
238
290
  start_time,
239
291
  end_time,
240
292
  ):
241
- if not self.span:
293
+ litellm_call_id = kwargs.get("litellm_call_id")
294
+
295
+ if not litellm_call_id:
296
+ log.warning("Agenta SDK - litellm tracing failed")
297
+ return
298
+
299
+ span = self.span[litellm_call_id]
300
+
301
+ if not span:
242
302
  log.warning("Agenta SDK - litellm tracing failed")
243
303
  return
244
304
 
245
- if not self.span.is_recording():
305
+ if not span.is_recording():
246
306
  return
247
307
 
248
- self.span.record_exception(kwargs["exception"])
308
+ span.record_exception(kwargs["exception"])
249
309
 
250
- self.span.set_status(status="ERROR")
310
+ span.set_status(status="ERROR")
251
311
 
252
- self.span.end()
312
+ span.end()
253
313
 
254
314
  return LitellmHandler()
@@ -1143,7 +1143,4 @@ def calculate_costs(span_idx: Dict[str, SpanDTO]):
1143
1143
  span.metrics["unit.costs.total"] = total_cost
1144
1144
 
1145
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
- )
1146
+ pass
@@ -43,8 +43,6 @@ class TraceProcessor(BatchSpanProcessor):
43
43
  span: Span,
44
44
  parent_context: Optional[Context] = None,
45
45
  ) -> None:
46
- # ADD LINKS FROM CONTEXT, HERE
47
-
48
46
  for key in self.references.keys():
49
47
  span.set_attribute(f"ag.refs.{key}", self.references[key])
50
48
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agenta
3
- Version: 0.28.2a1
3
+ Version: 0.28.2a2
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Home-page: https://agenta.ai
6
6
  Keywords: LLMOps,LLM,evaluation,prompt engineering
@@ -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=WJSp-kJ6j0bea64l5QJlnOPpLwTgNcN7Am4X2YZBP1A,7939
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
@@ -181,10 +181,10 @@ agenta/sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
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=LN9UJO30rJESnw3yokISKjYHbkiMmycbqa8jonEz5mM,36712
184
+ agenta/sdk/decorators/routing.py,sha256=vsR0fNRBvXnzHC-wjC8PkXlZ0XHw82tMbzhuFAWoqRA,36520
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=97eDU9MUTW6Wv2e7QYhCWLrRYwhaRqG6LVcedp3qNrk,7186
187
+ agenta/sdk/litellm/litellm.py,sha256=Ke0It-jA1z0KQ2770gIlWIEgramZGmt1k0GjmpEnFV4,8793
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
@@ -199,8 +199,8 @@ agenta/sdk/tracing/attributes.py,sha256=zh8JQZSeYCLBeIRSopKJx6QQ-WEgw08Cr64DS_WO
199
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=sYocvSWjuQaun_XaBYNDQyNw4ETS2hFMbFg6g3RCdeg,31463
203
- agenta/sdk/tracing/processors.py,sha256=tPf3Hx1TmnWSljvX28kYFOFrp4ImIXhlwAaR39sf5qU,2979
202
+ agenta/sdk/tracing/inline.py,sha256=IBdy7AKtHYQ5yDObtAbqEixNAcOkBsw1DmgDTuQXID0,31284
203
+ agenta/sdk/tracing/processors.py,sha256=R4TL8jDV1nx3HgINal82tjNu2rrSBziFfyis8aAL-cI,2939
204
204
  agenta/sdk/tracing/spans.py,sha256=nqUOjjirBxB8Eacv8Qj4Ra_6rknGi3lbJdNyKmk5ODQ,3707
205
205
  agenta/sdk/tracing/tracing.py,sha256=RUSnQIWwfOFwhWbiyJfgC0wYtvcV1PusXTwNslV5WZo,6912
206
206
  agenta/sdk/types.py,sha256=_lGsGSEaZJrUT4cVcT3zSpgEqex2jFaPtfpFeUEetbc,7247
@@ -208,7 +208,6 @@ agenta/sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
208
208
  agenta/sdk/utils/costs.py,sha256=i8C7ud__pThLS55XkN4YW8czXtGeXr2mx7jjcOFeiXg,5955
209
209
  agenta/sdk/utils/exceptions.py,sha256=UPO5aqNkpxevE7I_gW6O2B0FbtqqwgQobp5b6RQy_Ik,2132
210
210
  agenta/sdk/utils/globals.py,sha256=2HhyzWn55BbYNCZ3rT8dAxk1GGXuGQPbtq_THjaHbBw,372
211
- agenta/sdk/utils/helpers.py,sha256=utrxDoELpR6QgFgHCEAWrWW4TYWXA10q72Gs5R78Ens,181
212
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
@@ -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.28.2a1.dist-info/METADATA,sha256=V12g0Avxhkv0NXK0pUDis-62vBAsgAvHUm-7GS704OQ,29044
231
- agenta-0.28.2a1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
232
- agenta-0.28.2a1.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
233
- agenta-0.28.2a1.dist-info/RECORD,,
229
+ agenta-0.28.2a2.dist-info/METADATA,sha256=69xnz5RPYthrXTLw6r_fmO7sT7BnVGqjrP_GsRZH_L0,29044
230
+ agenta-0.28.2a2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
231
+ agenta-0.28.2a2.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
232
+ agenta-0.28.2a2.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- import importlib.metadata
2
-
3
-
4
- def get_current_version():
5
- """Returns the current version of Agenta's SDK."""
6
-
7
- version = importlib.metadata.version("agenta")
8
- return version