ragaai-catalyst 2.1b5__py3-none-any.whl → 2.1.1b0__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.
@@ -20,16 +20,23 @@ class AgentTracerMixin:
20
20
  self.agent_children = contextvars.ContextVar("agent_children", default=[])
21
21
  self.component_network_calls = contextvars.ContextVar("component_network_calls", default={})
22
22
  self.component_user_interaction = contextvars.ContextVar("component_user_interaction", default={})
23
+ self.version = contextvars.ContextVar("version", default="1.0.0")
24
+ self.agent_type = contextvars.ContextVar("agent_type", default="generic")
25
+ self.capabilities = contextvars.ContextVar("capabilities", default=[])
26
+ self.start_time = contextvars.ContextVar("start_time", default=None)
27
+ self.input_data = contextvars.ContextVar("input_data", default=None)
23
28
  self.gt = None
24
29
 
25
30
 
26
- def trace_agent(self, name: str, agent_type: str = "generic", version: str = "1.0.0", capabilities: List[str] = None):
31
+ def trace_agent(self, name: str, agent_type: str = None, version: str = None, capabilities: List[str] = None):
27
32
  def decorator(target):
28
33
  # Check if target is a class
29
34
  is_class = isinstance(target, type)
30
35
  tracer = self # Store reference to tracer instance
31
36
  top_level_hash_id = generate_unique_hash_simple(target) # Generate hash based on the decorated target code
32
-
37
+ self.version.set(version)
38
+ self.agent_type.set(agent_type)
39
+ self.capabilities.set(capabilities)
33
40
 
34
41
  if is_class:
35
42
  # Store original __init__
@@ -160,6 +167,8 @@ class AgentTracerMixin:
160
167
  return func(*args, **kwargs)
161
168
 
162
169
  start_time = datetime.now()
170
+ self.start_time = start_time
171
+ self.input_data = self._sanitize_input(args, kwargs)
163
172
  start_memory = psutil.Process().memory_info().rss
164
173
  component_id = str(uuid.uuid4())
165
174
 
@@ -206,12 +215,11 @@ class AgentTracerMixin:
206
215
  start_time=start_time,
207
216
  end_time=end_time,
208
217
  memory_used=memory_used,
209
- input_data=self._sanitize_input(args, kwargs),
218
+ input_data=self.input_data,
210
219
  output_data=self._sanitize_output(result),
211
220
  children=children,
212
221
  parent_id=parent_agent_id
213
222
  )
214
-
215
223
  # Add ground truth to component data if present
216
224
  if ground_truth is not None:
217
225
  agent_component["data"]["gt"] = ground_truth
@@ -253,13 +261,12 @@ class AgentTracerMixin:
253
261
  start_time=start_time,
254
262
  end_time=datetime.now(),
255
263
  memory_used=0,
256
- input_data=self._sanitize_input(args, kwargs),
264
+ input_data=self.input_data,
257
265
  output_data=None,
258
266
  error=error_component,
259
267
  children=children,
260
268
  parent_id=parent_agent_id # Add parent ID if exists
261
269
  )
262
-
263
270
  # If this is a nested agent, add it to parent's children
264
271
  if parent_agent_id:
265
272
  parent_component = self._agent_components.get(parent_agent_id)
@@ -164,12 +164,11 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
164
164
  self.trace.metadata.total_cost = total_cost
165
165
  self.trace.metadata.total_tokens = total_tokens
166
166
 
167
- def add_component(self, component_data: dict):
167
+ def add_component(self, component_data: dict, is_error: bool = False):
168
168
  """Add a component to the trace data"""
169
169
  # Convert dict to appropriate Component type
170
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
-
173
172
  if component_data["type"] == "llm":
174
173
  component = LLMComponent(**filtered_data)
175
174
  elif component_data["type"] == "agent":
@@ -179,8 +178,6 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
179
178
  else:
180
179
  component = Component(**component_data)
181
180
 
182
- # import pdb; pdb.set_trace()
183
-
184
181
  # Check if there's an active agent context
185
182
  current_agent_id = self.current_agent_id.get()
186
183
  if current_agent_id and component_data["type"] in ["llm", "tool"]:
@@ -191,6 +188,43 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
191
188
  else:
192
189
  # Add component to the main trace
193
190
  super().add_component(component)
191
+
192
+ # Handle error case
193
+ if is_error:
194
+ # Get the parent component if it exists
195
+ parent_id = component_data.get("parent_id")
196
+ children = self.agent_children.get()
197
+
198
+ # Set parent_id for all children
199
+ for child in children:
200
+ child["parent_id"] = parent_id
201
+
202
+ agent_tracer_mixin = AgentTracerMixin()
203
+ agent_tracer_mixin.component_network_calls = self.component_network_calls
204
+ agent_tracer_mixin.component_user_interaction = self.component_user_interaction
205
+
206
+ # Create parent component with error info
207
+ parent_component = agent_tracer_mixin.create_agent_component(
208
+ component_id=parent_id,
209
+ hash_id=str(uuid.uuid4()),
210
+ name=self.current_agent_name.get(),
211
+ agent_type=self.agent_type.get(),
212
+ version=self.version.get(),
213
+ capabilities=self.capabilities.get(),
214
+ start_time=self.start_time,
215
+ end_time=datetime.now(),
216
+ memory_used=0,
217
+ input_data=self.input_data,
218
+ output_data=None,
219
+ children=children,
220
+ parent_id=None # Add parent ID if exists
221
+ )
222
+
223
+ filtered_data = {k: v for k, v in parent_component.items() if k in ["id", "hash_id", "type", "name", "start_time", "end_time", "parent_id", "info", "data", "network_calls", "interactions", "error"]}
224
+ parent_agent_component = AgentComponent(**filtered_data)
225
+ # Add the parent component to trace and stop tracing
226
+ super().add_component(parent_agent_component)
227
+ self.stop()
194
228
 
195
229
  def __enter__(self):
196
230
  """Context manager entry"""
@@ -617,10 +617,11 @@ class LLMTracerMixin:
617
617
  error=error_component
618
618
  )
619
619
 
620
- self.add_component(llm_component)
620
+ self.add_component(llm_component, is_error=True)
621
621
  raise
622
622
 
623
623
  def trace_llm(self, name: str = None):
624
+ self.current_llm_call_name.set(name)
624
625
  def decorator(func):
625
626
  @self.file_tracker.trace_decorator
626
627
  @functools.wraps(func)
@@ -634,7 +635,6 @@ class LLMTracerMixin:
634
635
  parent_agent_id = self.current_agent_id.get()
635
636
  self.start_component(component_id)
636
637
 
637
- start_time = datetime.now()
638
638
  error_info = None
639
639
  result = None
640
640
 
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ragaai_catalyst
3
- Version: 2.1b5
3
+ Version: 2.1.1b0
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.13,>=3.9
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,7 +27,7 @@ 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
30
+ Requires-Dist: llama-index~=0.10
31
31
  Requires-Dist: pyopenssl>=24.2.1
32
32
  Requires-Dist: psutil~=6.0.0
33
33
  Requires-Dist: py-cpuinfo~=9.0.0
@@ -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=M5RBNzcuSCEKv-rYwmzBMN-BxvthM3y6d_279UYERZQ,20832
20
- ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py,sha256=WsddEXn2afdPx8PfignQoLIwZfn9350XsqtkqtZdMxw,8502
19
+ ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py,sha256=oLe5QtrndaO-sBAHvxUPfj9GB_EwQbi0T3JwjcqmvtY,21388
20
+ ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py,sha256=yqWu_xnKfLE6nVYM0TqaAYLI_tzy5Z2wZwgA9-Gjppo,10218
21
21
  ragaai_catalyst/tracers/agentic_tracing/base.py,sha256=jRf_-5EIfCzGbaSQtkqgiDQAH4ymoKUrg9A8YqB08jk,14008
22
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=BpazvaHy9YBsnizQMIEZoRlan7DiM7pCUO9u-RSYiXo,32721
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.1b5.dist-info/METADATA,sha256=Aqk9psd4uVTwFEtlydBvf79poBz1uPttrh_qLw-p5Bc,1795
54
- ragaai_catalyst-2.1b5.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
55
- ragaai_catalyst-2.1b5.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
56
- ragaai_catalyst-2.1b5.dist-info/RECORD,,
53
+ ragaai_catalyst-2.1.1b0.dist-info/METADATA,sha256=qAtdLG3fZX-NLrkgejCFS-aIna4O_suzsle3OKByqew,1801
54
+ ragaai_catalyst-2.1.1b0.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
55
+ ragaai_catalyst-2.1.1b0.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
56
+ ragaai_catalyst-2.1.1b0.dist-info/RECORD,,