agenta 0.19.1__py3-none-any.whl → 0.19.1a0__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/agenta_init.py CHANGED
@@ -26,6 +26,16 @@ class AgentaSingleton:
26
26
  cls._instance = super(AgentaSingleton, cls).__new__(cls)
27
27
  return cls._instance
28
28
 
29
+ @property
30
+ def client(self):
31
+ """API Backend client.
32
+
33
+ Returns:
34
+ AgentaAPI: instance of agenta api backend
35
+ """
36
+
37
+ return AgentaApi(base_url=self.host + "/api", api_key=self.api_key)
38
+
29
39
  def init(
30
40
  self,
31
41
  app_id: Optional[str] = None,
@@ -85,7 +95,7 @@ class AgentaSingleton:
85
95
 
86
96
 
87
97
  class Config:
88
- def __init__(self, base_id: str, host: str, api_key: Optional[str] = ""):
98
+ def __init__(self, base_id: str, host: str, api_key: str = ""):
89
99
  self.base_id = base_id
90
100
  self.host = host
91
101
 
@@ -93,9 +103,7 @@ class Config:
93
103
  self.persist = False
94
104
  else:
95
105
  self.persist = True
96
- self.client = AgentaApi(
97
- base_url=self.host + "/api", api_key=api_key if api_key else ""
98
- )
106
+ self.client = AgentaApi(base_url=self.host + "/api", api_key=api_key)
99
107
 
100
108
  def register_default(self, overwrite=False, **kwargs):
101
109
  """alias for default"""
@@ -178,7 +178,7 @@ class Tracing(metaclass=SingletonMeta):
178
178
  span.status = value
179
179
 
180
180
  def _update_span_cost(self, span: CreateSpan, cost: Optional[float]):
181
- if cost is not None and isinstance(cost, float):
181
+ if span is not None and cost is not None and isinstance(cost, float):
182
182
  if span.cost is None:
183
183
  span.cost = cost
184
184
  else:
@@ -187,7 +187,7 @@ class Tracing(metaclass=SingletonMeta):
187
187
  def _update_span_tokens(self, span: CreateSpan, tokens: Optional[dict]):
188
188
  if isinstance(tokens, LlmTokens):
189
189
  tokens = tokens.dict()
190
- if tokens is not None and isinstance(tokens, dict):
190
+ if span is not None and tokens is not None and isinstance(tokens, dict):
191
191
  if span.tokens is None:
192
192
  span.tokens = LlmTokens(**tokens)
193
193
  else:
@@ -218,6 +218,7 @@ class Tracing(metaclass=SingletonMeta):
218
218
 
219
219
  self.active_span.end_time = datetime.now(timezone.utc)
220
220
  self.active_span.outputs = [outputs.get("message", "")]
221
+
221
222
  if self.active_span.spankind in [
222
223
  "LLM",
223
224
  "RETRIEVER",
@@ -229,45 +230,15 @@ class Tracing(metaclass=SingletonMeta):
229
230
  self.pending_spans.append(self.active_span)
230
231
 
231
232
  active_span_parent_id = self.active_span.parent_span_id
232
- if (
233
- self.active_span.status == SpanStatusCode.ERROR.value
234
- and active_span_parent_id is not None
235
- ):
236
- self.record_exception_and_end_trace(span_parent_id=active_span_parent_id)
237
233
 
238
234
  if active_span_parent_id is None:
239
235
  self.end_trace(parent_span=self.active_span)
240
-
241
236
  else:
242
237
  parent_span = self.span_dict[active_span_parent_id]
243
238
  self._update_span_cost(parent_span, self.active_span.cost)
244
239
  self._update_span_tokens(parent_span, self.active_span.tokens)
245
240
  self.active_span = parent_span
246
241
 
247
- def record_exception_and_end_trace(self, span_parent_id: str):
248
- """
249
- Record an exception and end the trace.
250
-
251
- Args:
252
- span_parent_id (str): The ID of the parent span.
253
-
254
- Returns:
255
- None
256
- """
257
-
258
- parent_span = self.span_dict.get(span_parent_id)
259
- if parent_span is not None:
260
- # Update parent span of active span
261
- parent_span.outputs = self.active_span.outputs # type: ignore
262
- parent_span.status = "ERROR"
263
- parent_span.end_time = datetime.now(timezone.utc)
264
-
265
- # Push parent span to list of recorded spans and end trace
266
- self.pending_spans.append(parent_span)
267
- self.end_trace(parent_span=parent_span)
268
-
269
- # TODO: improve exception logic here.
270
-
271
242
  def end_trace(self, parent_span: CreateSpan):
272
243
  """
273
244
  Ends the active trace and sends the recorded spans for processing.
@@ -285,7 +256,7 @@ class Tracing(metaclass=SingletonMeta):
285
256
  if self.api_key == "":
286
257
  return
287
258
 
288
- if not self.active_trace_id:
259
+ if self.active_trace_id is None:
289
260
  raise RuntimeError("No active trace to end.")
290
261
 
291
262
  self.llm_logger.info("Preparing to send recorded spans for processing.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agenta
3
- Version: 0.19.1
3
+ Version: 0.19.1a0
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
@@ -127,7 +127,7 @@ agenta/docker/docker-assets/lambda_function.py,sha256=h4UZSSfqwpfsCgERv6frqwm_4J
127
127
  agenta/docker/docker-assets/main.py,sha256=7MI-21n81U7N7A0GxebNi0cmGWtJKcR2sPB6FcH2QfA,251
128
128
  agenta/docker/docker_utils.py,sha256=5uHMCzXkCvIsDdEiwbnnn97KkzsFbBvyMwogCsv_Z5U,3509
129
129
  agenta/sdk/__init__.py,sha256=cF0de6DiH-NZWEm0XvPN8_TeC1whPBnDf1WYYE1qK2g,762
130
- agenta/sdk/agenta_init.py,sha256=zhMYCH6QMDzQADrOmFBaqZRvAYrA6CC35XsePY7IMxg,9789
130
+ agenta/sdk/agenta_init.py,sha256=aKCJRoZ6nsY3dHWwvgxdxyJhYL3n5xEcD6ZJiqshchQ,9959
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
@@ -137,7 +137,7 @@ agenta/sdk/router.py,sha256=0sbajvn5C7t18anH6yNo7-oYxldHnYfwcbmQnIXBePw,269
137
137
  agenta/sdk/tracing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
138
138
  agenta/sdk/tracing/callbacks.py,sha256=8XYcGC4EZQ0lBn2IWmtPH_yC5Hu6Yu-NkdZRuY7CoTw,6816
139
139
  agenta/sdk/tracing/context_manager.py,sha256=HskDaiORoOhjeN375gm05wYnieQzh5UnoIsnSAHkAyc,252
140
- agenta/sdk/tracing/llm_tracing.py,sha256=fHtc1tKgdR2CDnFMrfDIxSvyjwFW3Qk2RE8P-y_tCM0,11361
140
+ agenta/sdk/tracing/llm_tracing.py,sha256=3zbyL0Spv6UFvze6deAb0VYcHWFllC5itwkt_wTkMBo,10389
141
141
  agenta/sdk/tracing/logger.py,sha256=GfH7V-jBHcn7h5dbdrnkDMe_ml3wkXFBeoQiqR4KVRc,474
142
142
  agenta/sdk/tracing/tasks_manager.py,sha256=ROrWIaqS2J2HHiJtRWiHKlLY8CCsqToP5VeXu7mamck,3748
143
143
  agenta/sdk/types.py,sha256=KMnQUOdjaHSWctDLIiMHnk0o3c-C47Vm4Mn2kIZ88YI,5740
@@ -159,7 +159,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
159
159
  agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
160
160
  agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
161
161
  agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
162
- agenta-0.19.1.dist-info/METADATA,sha256=5pVwD7MuunohvTraDMTtW3zlo7_y2UKnRJMHm1Wmrow,26458
163
- agenta-0.19.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
164
- agenta-0.19.1.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
165
- agenta-0.19.1.dist-info/RECORD,,
162
+ agenta-0.19.1a0.dist-info/METADATA,sha256=C6yd9GdZsaTuuJ-gxd0tD3N5QONjKuPJiNcTeslgApg,26460
163
+ agenta-0.19.1a0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
164
+ agenta-0.19.1a0.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
165
+ agenta-0.19.1a0.dist-info/RECORD,,