agenta 0.14.1a0__py3-none-any.whl → 0.14.1a1__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.

@@ -19,7 +19,7 @@ class SingletonMeta(type):
19
19
  Thread-safe implementation of Singleton.
20
20
  """
21
21
 
22
- _instances = {}
22
+ _instances = {} # type: ignore
23
23
 
24
24
  # We need the lock mechanism to synchronize threads \
25
25
  # during the initial access to the Singleton object.
@@ -73,6 +73,7 @@ class Tracing(metaclass=SingletonMeta):
73
73
  self.app_id = app_id
74
74
  self.variant_id = variant_id
75
75
  self.variant_name = variant_name
76
+ self.tracing_enabled = True
76
77
  self.tasks_manager = TaskQueue(
77
78
  max_workers if max_workers else 4, logger=llm_logger
78
79
  )
@@ -95,12 +96,24 @@ class Tracing(metaclass=SingletonMeta):
95
96
  base_url=self.base_url, api_key=self.api_key, timeout=120 # type: ignore
96
97
  ).observability
97
98
 
99
+ @property
100
+ def _is_tracing_enabled(self) -> bool:
101
+ """Checks if tracing is enabled.
102
+
103
+ Returns:
104
+ bool: If tracing is enabled
105
+ """
106
+
107
+ return self.tracing_enabled
108
+
98
109
  def set_span_attribute(
99
110
  self, parent_key: Optional[str] = None, attributes: Dict[str, Any] = {}
100
111
  ):
101
- span = self.span_dict[self.active_span.id] # type: ignore
102
- for key, value in attributes.items():
103
- self.set_attribute(span.attributes, key, value, parent_key) # type: ignore
112
+ if self._is_tracing_enabled:
113
+ span = self.span_dict[self.active_span.id] # type: ignore
114
+ for key, value in attributes.items():
115
+ self.set_attribute(span.attributes, key, value, parent_key) # type: ignore
116
+ return
104
117
 
105
118
  def set_attribute(
106
119
  self,
@@ -123,28 +136,30 @@ class Tracing(metaclass=SingletonMeta):
123
136
  def start_parent_span(
124
137
  self, name: str, inputs: Dict[str, Any], config: Dict[str, Any], **kwargs
125
138
  ):
126
- trace_id = self._create_trace_id()
127
- span_id = self._create_span_id()
128
- self.llm_logger.info("Recording parent span...")
129
- span = CreateSpan(
130
- id=span_id,
131
- app_id=self.app_id,
132
- variant_id=self.variant_id,
133
- variant_name=self.variant_name,
134
- inputs=inputs,
135
- name=name,
136
- config=config,
137
- environment=kwargs.get("environment"),
138
- spankind=SpanKind.WORKFLOW.value,
139
- status=SpanStatusCode.UNSET.value,
140
- start_time=datetime.now(timezone.utc),
141
- )
142
- self.active_trace = span
143
- self.recording_trace_id = trace_id
144
- self.parent_span_id = span.id
145
- self.llm_logger.info(
146
- f"Recorded active_trace and setting parent_span_id: {span.id}"
147
- )
139
+ if self._is_tracing_enabled:
140
+ trace_id = self._create_trace_id()
141
+ span_id = self._create_span_id()
142
+ self.llm_logger.info("Recording parent span...")
143
+ span = CreateSpan(
144
+ id=span_id,
145
+ app_id=self.app_id,
146
+ variant_id=self.variant_id,
147
+ variant_name=self.variant_name,
148
+ inputs=inputs,
149
+ name=name,
150
+ config=config,
151
+ environment=kwargs.get("environment"),
152
+ spankind=SpanKind.WORKFLOW.value,
153
+ status=SpanStatusCode.UNSET.value,
154
+ start_time=datetime.now(timezone.utc),
155
+ )
156
+ self.active_trace = span
157
+ self.recording_trace_id = trace_id
158
+ self.parent_span_id = span.id
159
+ self.llm_logger.info(
160
+ f"Recorded active_trace and setting parent_span_id: {span.id}"
161
+ )
162
+ return
148
163
 
149
164
  def start_span(
150
165
  self,
@@ -152,71 +167,79 @@ class Tracing(metaclass=SingletonMeta):
152
167
  spankind: str,
153
168
  input: Dict[str, Any],
154
169
  config: Dict[str, Any] = {},
155
- ) -> CreateSpan:
156
- span_id = self._create_span_id()
157
- self.llm_logger.info(f"Recording {spankind} span...")
158
- span = CreateSpan(
159
- id=span_id,
160
- inputs=input,
161
- name=name,
162
- app_id=self.app_id,
163
- variant_id=self.variant_id,
164
- variant_name=self.variant_name,
165
- config=config,
166
- environment=self.active_trace.environment,
167
- parent_span_id=self.parent_span_id,
168
- spankind=spankind.upper(),
169
- attributes={},
170
- status=SpanStatusCode.UNSET.value,
171
- start_time=datetime.now(timezone.utc),
172
- )
173
-
174
- self.active_span = span
175
- self.span_dict[span.id] = span
176
- self.parent_span_id = span.id
177
- self.llm_logger.info(
178
- f"Recorded active_span and setting parent_span_id: {span.id}"
179
- )
180
- return span
170
+ ) -> Optional[CreateSpan]:
171
+ if self._is_tracing_enabled:
172
+ span_id = self._create_span_id()
173
+ self.llm_logger.info(f"Recording {spankind} span...")
174
+ span = CreateSpan(
175
+ id=span_id,
176
+ inputs=input,
177
+ name=name,
178
+ app_id=self.app_id,
179
+ variant_id=self.variant_id,
180
+ variant_name=self.variant_name,
181
+ config=config,
182
+ environment=self.active_trace.environment,
183
+ parent_span_id=self.parent_span_id,
184
+ spankind=spankind.upper(),
185
+ attributes={},
186
+ status=SpanStatusCode.UNSET.value,
187
+ start_time=datetime.now(timezone.utc),
188
+ )
189
+
190
+ self.active_span = span
191
+ self.span_dict[span.id] = span
192
+ self.parent_span_id = span.id
193
+ self.llm_logger.info(
194
+ f"Recorded active_span and setting parent_span_id: {span.id}"
195
+ )
196
+ return span
197
+ return
181
198
 
182
199
  def update_span_status(self, span: CreateSpan, value: str):
183
- updated_span = CreateSpan(**{**span.dict(), "status": value})
184
- self.active_span = updated_span
200
+ if self._is_tracing_enabled:
201
+ updated_span = CreateSpan(**{**span.dict(), "status": value})
202
+ self.active_span = updated_span
203
+ return
185
204
 
186
205
  def end_span(self, outputs: Dict[str, Any], span: CreateSpan, **kwargs):
187
- updated_span = CreateSpan(
188
- **span.dict(),
189
- end_time=datetime.now(timezone.utc),
190
- outputs=[outputs["message"]],
191
- cost=outputs.get("cost", None),
192
- tokens=outputs.get("usage"),
193
- )
194
-
195
- # Push span to list of recorded spans
196
- self.recorded_spans.append(updated_span)
197
- self.llm_logger.info(
198
- f"Pushed {updated_span.spankind} span {updated_span.id} to recorded spans."
199
- )
206
+ if self._is_tracing_enabled:
207
+ updated_span = CreateSpan(
208
+ **span.dict(),
209
+ end_time=datetime.now(timezone.utc),
210
+ outputs=[outputs["message"]],
211
+ cost=outputs.get("cost", None),
212
+ tokens=outputs.get("usage"),
213
+ )
214
+
215
+ # Push span to list of recorded spans
216
+ self.recorded_spans.append(updated_span)
217
+ self.llm_logger.info(
218
+ f"Pushed {updated_span.spankind} span {updated_span.id} to recorded spans."
219
+ )
220
+ return
200
221
 
201
222
  def end_recording(self, outputs: Dict[str, Any], span: CreateSpan, **kwargs):
202
223
  self.end_span(outputs=outputs, span=span, **kwargs)
203
224
  if self.api_key == "":
204
225
  return
205
226
 
206
- self.llm_logger.info(f"Preparing to send recorded spans for processing.")
207
- self.llm_logger.info(f"Recorded spans => {len(self.recorded_spans)}")
208
- self.tasks_manager.add_task(
209
- self.active_trace.id,
210
- "trace",
211
- self.client.create_traces(
212
- trace=self.recording_trace_id, spans=self.recorded_spans # type: ignore
213
- ),
214
- self.client,
215
- )
216
- self.llm_logger.info(
217
- f"Tracing for {span.id} recorded successfully and sent for processing."
218
- )
219
- self._clear_recorded_spans()
227
+ if self._is_tracing_enabled:
228
+ self.llm_logger.info(f"Preparing to send recorded spans for processing.")
229
+ self.llm_logger.info(f"Recorded spans => {len(self.recorded_spans)}")
230
+ self.tasks_manager.add_task(
231
+ self.active_trace.id,
232
+ "trace",
233
+ self.client.create_traces(
234
+ trace=self.recording_trace_id, spans=self.recorded_spans # type: ignore
235
+ ),
236
+ self.client,
237
+ )
238
+ self.llm_logger.info(
239
+ f"Tracing for {span.id} recorded successfully and sent for processing."
240
+ )
241
+ self._clear_recorded_spans()
242
+ return
220
243
 
221
244
  def _create_trace_id(self) -> str:
222
245
  """Creates a unique mongo id for the trace object.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agenta
3
- Version: 0.14.1a0
3
+ Version: 0.14.1a1
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
@@ -22,7 +22,6 @@ Requires-Dist: fastapi (>=0.96.1)
22
22
  Requires-Dist: httpx (>=0.27.0,<0.28.0)
23
23
  Requires-Dist: importlib-metadata (>=6.7.0,<7.0.0)
24
24
  Requires-Dist: ipdb (>=0.13)
25
- Requires-Dist: litellm (>=1.35.33,<2.0.0)
26
25
  Requires-Dist: posthog (>=3.1.0,<4.0.0)
27
26
  Requires-Dist: pydantic (==1.10.13)
28
27
  Requires-Dist: pymongo (>=4.6.3,<5.0.0)
@@ -1,4 +1,4 @@
1
- agenta/__init__.py,sha256=ZJZlhn56j2rjl-QKTuNU6HHlJLVlmd_NcU67VIBvGGI,668
1
+ agenta/__init__.py,sha256=Hffk2VlICZOmfWwUh6f6cemQxEB7aD9obCOdnXQZy1s,614
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=GgYu6UsrnHbqPV7zPlO14b61IyaDiTIjGMYQS9DlqC4,9551
@@ -126,16 +126,16 @@ 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=3At8FvbuYFoP5IIYs4FZWYQK8l4XlVD1zv4E6QsgQv0,702
130
- agenta/sdk/agenta_decorator.py,sha256=ucoGffoIefsYaxniMfMgsepKDo8jrlVMA7gGoTYyQUc,17805
131
- agenta/sdk/agenta_init.py,sha256=wDfStpe8_3ZXRLtikarwDKI_VpA1YW4eIz_3fXq39is,9044
129
+ agenta/sdk/__init__.py,sha256=MNYk8dgbieeL2rTLHTX7lDgKn_CzOCqsPD5cSfTTX6Q,584
130
+ agenta/sdk/agenta_init.py,sha256=APcEklQrRkFw0tssX1IXf3D-aCay5k4utekYLf-wSbk,9005
132
131
  agenta/sdk/client.py,sha256=trKyBOYFZRk0v5Eptxvh87yPf50Y9CqY6Qgv4Fy-VH4,2142
133
132
  agenta/sdk/context.py,sha256=q-PxL05-I84puunUAs9LGsffEXcYhDxhQxjuOz2vK90,901
133
+ agenta/sdk/decorators/base.py,sha256=9aNdX5h8a2mFweuhdO-BQPwXGKY9ONPIdLRhSGAGMfY,217
134
+ agenta/sdk/decorators/llm_entrypoint.py,sha256=cmfdte6NgDR0aej07Yi9NrYAqyvQg5SyQxyKR1YrlSw,20305
135
+ agenta/sdk/decorators/tracing.py,sha256=7nXt_6oyB2FdUcXITFnaeMI25nn64qmisoGFqbHF6Iw,1636
134
136
  agenta/sdk/router.py,sha256=0sbajvn5C7t18anH6yNo7-oYxldHnYfwcbmQnIXBePw,269
135
- agenta/sdk/tracing/callbacks.py,sha256=hwOHgu1pGp5C7KTs0Tm07y7Uv_0gCo2YoyckKfnjmqw,4342
136
137
  agenta/sdk/tracing/context_manager.py,sha256=HskDaiORoOhjeN375gm05wYnieQzh5UnoIsnSAHkAyc,252
137
- agenta/sdk/tracing/decorators.py,sha256=ujtU8gf3GDoHYuLTfEYK_2eIYZ-1oX5dpv02Mf4l_II,1191
138
- agenta/sdk/tracing/llm_tracing.py,sha256=f69FtUIA187gNob8N6IZ-eiF6QQyBVl2JUMJ4Nnnp7M,8671
138
+ agenta/sdk/tracing/llm_tracing.py,sha256=mgOGy_ux_bWxVrcnA8col31nBtPWtljfHP-QYDtZZ0I,9559
139
139
  agenta/sdk/tracing/logger.py,sha256=4zG9c51p8xPdKA5SL8MOgBfkpCnBSuV6JfWiXO0A7oc,473
140
140
  agenta/sdk/tracing/tasks_manager.py,sha256=XVGBEOwmHa6KcCC0PApk0_bZ0Ilk2ESuduNObB1rw2s,3792
141
141
  agenta/sdk/types.py,sha256=Mn0yBlHh_Yr_5oQXUfsYI3V7sJAVWkJgkxEOBDOOMS0,5852
@@ -157,7 +157,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
157
157
  agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
158
158
  agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
159
159
  agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
160
- agenta-0.14.1a0.dist-info/METADATA,sha256=Z4cOQ0WJuec014xZcsQcU5CtcaKIKsAOMlLVux4rnJ4,26518
161
- agenta-0.14.1a0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
162
- agenta-0.14.1a0.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
163
- agenta-0.14.1a0.dist-info/RECORD,,
160
+ agenta-0.14.1a1.dist-info/METADATA,sha256=bSWVu4XuadyQvb99k6sw7hcMGV6hxEkaXrLXC2K7n_s,26476
161
+ agenta-0.14.1a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
162
+ agenta-0.14.1a1.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
163
+ agenta-0.14.1a1.dist-info/RECORD,,