ragaai-catalyst 2.1b3__py3-none-any.whl → 2.1b4__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.
@@ -225,6 +225,52 @@ class AgentTracerMixin:
225
225
  self.add_component(agent_component)
226
226
 
227
227
  return result
228
+ except Exception as e:
229
+ error_component = {
230
+ "code": 500,
231
+ "type": type(e).__name__,
232
+ "message": str(e),
233
+ "details": {}
234
+ }
235
+
236
+ # Get children even in case of error
237
+ children = self.agent_children.get()
238
+
239
+ # Set parent_id for all children
240
+ for child in children:
241
+ child["parent_id"] = component_id
242
+
243
+ # End tracking network calls for this component
244
+ self.end_component(component_id)
245
+
246
+ agent_component = self.create_agent_component(
247
+ component_id=component_id,
248
+ hash_id=hash_id,
249
+ name=name,
250
+ agent_type=agent_type,
251
+ version=version,
252
+ capabilities=capabilities or [],
253
+ start_time=start_time,
254
+ end_time=datetime.now(),
255
+ memory_used=0,
256
+ input_data=self._sanitize_input(args, kwargs),
257
+ output_data=None,
258
+ error=error_component,
259
+ children=children,
260
+ parent_id=parent_agent_id # Add parent ID if exists
261
+ )
262
+
263
+ # If this is a nested agent, add it to parent's children
264
+ if parent_agent_id:
265
+ parent_component = self._agent_components.get(parent_agent_id)
266
+ if parent_component:
267
+ if 'children' not in parent_component['data']:
268
+ parent_component['data']['children'] = []
269
+ parent_component['data']['children'].append(agent_component)
270
+ else:
271
+ # Only add to root components if no parent
272
+ self.add_component(agent_component)
273
+ raise
228
274
  finally:
229
275
  self.current_agent_id.reset(agent_token)
230
276
  self.current_agent_name.reset(agent_name_token)
@@ -167,16 +167,19 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
167
167
  def add_component(self, component_data: dict):
168
168
  """Add a component to the trace data"""
169
169
  # Convert dict to appropriate Component type
170
- filtered_data = {k: v for k, v in component_data.items() if k in ["id", "hash_id", "type", "name", "start_time", "end_time", "parent_id", "info", "data", "network_calls", "interactions"]}
170
+ filtered_data = {k: v for k, v in component_data.items() if k in ["id", "hash_id", "type", "name", "start_time", "end_time", "parent_id", "info", "data", "network_calls", "interactions", "error"]}
171
+
171
172
 
172
173
  if component_data["type"] == "llm":
173
174
  component = LLMComponent(**filtered_data)
174
- elif component_data["type"] == "agent":
175
+ elif component_data["type"] == "agent":
175
176
  component = AgentComponent(**filtered_data)
176
177
  elif component_data["type"] == "tool":
177
178
  component = ToolComponent(**filtered_data)
178
179
  else:
179
180
  component = Component(**component_data)
181
+
182
+ # import pdb; pdb.set_trace()
180
183
 
181
184
  # Check if there's an active agent context
182
185
  current_agent_id = self.current_agent_id.get()
@@ -160,9 +160,8 @@ class ToolInfo:
160
160
  memory_used: int
161
161
 
162
162
  class Component:
163
- def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Error] = None):
163
+ def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
164
164
  self.id = id
165
- self.error = error
166
165
  self.hash_id = hash_id
167
166
  self.type = type
168
167
  self.name = name
@@ -171,8 +170,10 @@ class Component:
171
170
  self.parent_id = parent_id
172
171
  self.info = info
173
172
  self.data = data
173
+ self.error = error
174
174
  self.network_calls = network_calls or []
175
175
  self.interactions = []
176
+ self.error = error
176
177
  if interactions:
177
178
  for interaction in interactions:
178
179
  if isinstance(interaction, dict):
@@ -197,22 +198,24 @@ class Component:
197
198
  "end_time": self.end_time,
198
199
  "parent_id": self.parent_id,
199
200
  "info": self.info,
201
+ "error": self.error,
200
202
  "data": self.data,
203
+ "error": self.error,
201
204
  "network_calls": [call.to_dict() if hasattr(call, 'to_dict') else call for call in self.network_calls],
202
205
  "interactions": self.interactions
203
206
  }
204
207
 
205
208
  class LLMComponent(Component):
206
- def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None):
207
- super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions)
209
+ def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
210
+ super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)
208
211
 
209
212
  class AgentComponent(Component):
210
- def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None):
211
- super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions)
213
+ def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
214
+ super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)
212
215
 
213
216
  class ToolComponent(Component):
214
- def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None):
215
- super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions)
217
+ def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
218
+ super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)
216
219
 
217
220
  @dataclass
218
221
  class ComponentInfo:
@@ -501,6 +501,12 @@ class LLMTracerMixin:
501
501
  name = self.current_llm_call_name.get()
502
502
  if name is None:
503
503
  name = original_func.__name__
504
+
505
+ end_memory = psutil.Process().memory_info().rss
506
+ memory_used = max(0, end_memory - start_memory)
507
+
508
+ # Get parent agent ID if exists
509
+ parent_agent_id = self.current_agent_id.get() if hasattr(self, 'current_agent_id') else None
504
510
 
505
511
  llm_component = self.create_llm_component(
506
512
  component_id=component_id,
@@ -508,15 +514,24 @@ class LLMTracerMixin:
508
514
  name=name,
509
515
  llm_type="unknown",
510
516
  version="1.0.0",
511
- memory_used=0,
517
+ memory_used=memory_used,
512
518
  start_time=start_time,
513
519
  end_time=end_time,
514
520
  input_data=self._extract_input_data(args, kwargs, None),
515
521
  output_data=None,
516
- error=error_component
522
+ error=error_component,
523
+ parent_id=parent_agent_id
517
524
  )
518
525
 
519
- self.add_component(llm_component)
526
+ # If this is part of an agent trace, add it to agent's children
527
+ if parent_agent_id and hasattr(self, 'agent_children'):
528
+ parent_children = self.agent_children.get()
529
+ parent_children.append(llm_component)
530
+ self.agent_children.set(parent_children)
531
+ else:
532
+ # Only add to root components if no parent
533
+ self.add_component(llm_component)
534
+
520
535
  raise
521
536
 
522
537
  def trace_llm_call_sync(self, original_func, *args, **kwargs):
@@ -603,6 +618,9 @@ class LLMTracerMixin:
603
618
  end_memory = psutil.Process().memory_info().rss
604
619
  memory_used = max(0, end_memory - start_memory)
605
620
 
621
+ # Get parent agent ID if exists
622
+ parent_agent_id = self.current_agent_id.get() if hasattr(self, 'current_agent_id') else None
623
+
606
624
  llm_component = self.create_llm_component(
607
625
  component_id=component_id,
608
626
  hash_id=hash_id,
@@ -614,10 +632,19 @@ class LLMTracerMixin:
614
632
  end_time=end_time,
615
633
  input_data=self._extract_input_data(args, kwargs, None),
616
634
  output_data=None,
617
- error=error_component
635
+ error=error_component,
636
+ parent_id=parent_agent_id
618
637
  )
619
638
 
620
- self.add_component(llm_component)
639
+ # If this is part of an agent trace, add it to agent's children
640
+ if parent_agent_id and hasattr(self, 'agent_children'):
641
+ parent_children = self.agent_children.get()
642
+ parent_children.append(llm_component)
643
+ self.agent_children.set(parent_children)
644
+ else:
645
+ # Only add to root components if no parent
646
+ self.add_component(llm_component)
647
+
621
648
  raise
622
649
 
623
650
  def trace_llm(self, name: str = None):
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ragaai_catalyst
3
- Version: 2.1b3
3
+ Version: 2.1b4
4
4
  Summary: RAGA AI CATALYST
5
5
  Author-email: Kiran Scaria <kiran.scaria@raga.ai>, Kedar Gaikwad <kedar.gaikwad@raga.ai>, Dushyant Mahajan <dushyant.mahajan@raga.ai>, Siddhartha Kosti <siddhartha.kosti@raga.ai>, Ritika Goel <ritika.goel@raga.ai>, Vijay Chaurasia <vijay.chaurasia@raga.ai>
6
- Requires-Python: >=3.9
6
+ Requires-Python: >=3.11
7
7
  Description-Content-Type: text/markdown
8
8
  Requires-Dist: aiohttp>=3.10.2
9
9
  Requires-Dist: opentelemetry-api==1.25.0
@@ -27,13 +27,13 @@ Requires-Dist: Markdown>=3.7
27
27
  Requires-Dist: litellm==1.51.1
28
28
  Requires-Dist: tenacity==8.3.0
29
29
  Requires-Dist: tqdm>=4.66.5
30
- Requires-Dist: llama-index==0.10.0
31
- Requires-Dist: pyopenssl==24.2.1
30
+ Requires-Dist: llama-index>=0.10.0
31
+ Requires-Dist: pyopenssl>=24.2.1
32
32
  Requires-Dist: psutil~=6.0.0
33
33
  Requires-Dist: py-cpuinfo~=9.0.0
34
34
  Requires-Dist: requests~=2.32.3
35
35
  Requires-Dist: GPUtil~=1.4.0
36
- Requires-Dist: astor==0.8.1
36
+ Requires-Dist: astor>=0.8.1
37
37
  Provides-Extra: dev
38
38
  Requires-Dist: pytest; extra == "dev"
39
39
  Requires-Dist: pytest-cov; extra == "dev"
@@ -16,12 +16,12 @@ ragaai_catalyst/tracers/llamaindex_callback.py,sha256=vPE7MieKjfwLrLUnnPs20Df0xN
16
16
  ragaai_catalyst/tracers/tracer.py,sha256=dGYQfo0RXms6w-sAJf04gqTo1zOXTqreGXaJlnvK48A,12463
17
17
  ragaai_catalyst/tracers/upload_traces.py,sha256=hs0PEmit3n3_uUqrdbwcBdyK5Nbkik3JQVwJMEwYTd4,4796
18
18
  ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=6QyQI8P7aNFHTantNJOP1ZdSNrDKBLhlg_gGNj7tm1c,73
19
- ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py,sha256=Ff9KbTjKkuZkGAECyvKRe8LjjAjwQ-seTwsX2ycGnIg,18995
20
- ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py,sha256=NVLw1n3FZUhZR-znaV_kSpWh1fQq2ElHYTklxPFg_Vc,8452
19
+ ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py,sha256=M5RBNzcuSCEKv-rYwmzBMN-BxvthM3y6d_279UYERZQ,20832
20
+ ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py,sha256=WsddEXn2afdPx8PfignQoLIwZfn9350XsqtkqtZdMxw,8502
21
21
  ragaai_catalyst/tracers/agentic_tracing/base.py,sha256=jRf_-5EIfCzGbaSQtkqgiDQAH4ymoKUrg9A8YqB08jk,14008
22
- ragaai_catalyst/tracers/agentic_tracing/data_structure.py,sha256=qyfCI1oGQ461WbS6BYBiAEUmgpw9xFsccpjsi_mVX3c,7152
22
+ ragaai_catalyst/tracers/agentic_tracing/data_structure.py,sha256=wkZctMTUQUViqKrHhdZiMERSBVfwURAJ-lFlQUou638,7395
23
23
  ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py,sha256=515NNDQJTyy3O-2rdlUYUoWL9qSwLIfvV3sMB9BtHp8,1366
24
- ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py,sha256=dI2Pg4cNGTf5k7g7ViVRUu6Pck8In4aqQYGLn_xwNxY,32705
24
+ ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py,sha256=oxziex6mT4RcZY1zWTVgsPXVewiTWt16CQAfWi9_YD0,34072
25
25
  ragaai_catalyst/tracers/agentic_tracing/network_tracer.py,sha256=6FTA15xMnum9omM_0Jd9cMIuWdKu1gR5Tc8fOXAkP8E,10068
26
26
  ragaai_catalyst/tracers/agentic_tracing/sample.py,sha256=S4rCcKzU_5SB62BYEbNn_1VbbTdG4396N8rdZ3ZNGcE,5654
27
27
  ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py,sha256=Yc4x82rk0hCANwXUt4M66Qv_4OdpsXsjlq6OIOef1io,8763
@@ -50,7 +50,7 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
50
50
  ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
51
51
  ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
52
52
  ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
53
- ragaai_catalyst-2.1b3.dist-info/METADATA,sha256=nXXIldP0lixlE4HcRaOoMgTUAWnbOZCTWz4I40T6nAg,1795
54
- ragaai_catalyst-2.1b3.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
55
- ragaai_catalyst-2.1b3.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
56
- ragaai_catalyst-2.1b3.dist-info/RECORD,,
53
+ ragaai_catalyst-2.1b4.dist-info/METADATA,sha256=A9MMHw5G0oZq-8lh5mwo57hNwgYsOhM80wOXe418FDQ,1796
54
+ ragaai_catalyst-2.1b4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
55
+ ragaai_catalyst-2.1b4.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
56
+ ragaai_catalyst-2.1b4.dist-info/RECORD,,