ragaai-catalyst 2.1.5b25__py3-none-any.whl → 2.1.5b27__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.
- ragaai_catalyst/evaluation.py +3 -0
- ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py +137 -101
- ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +1 -0
- ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py +4 -6
- ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +193 -155
- ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py +7 -60
- ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py +4 -6
- ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py +5 -1
- ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py +33 -13
- ragaai_catalyst/tracers/distributed.py +10 -27
- ragaai_catalyst/tracers/langchain_callback.py +59 -6
- ragaai_catalyst/tracers/llamaindex_instrumentation.py +424 -0
- ragaai_catalyst/tracers/tracer.py +37 -20
- ragaai_catalyst/tracers/upload_traces.py +4 -1
- ragaai_catalyst/tracers/utils/convert_llama_instru_callback.py +69 -0
- ragaai_catalyst/tracers/utils/extraction_logic_llama_index.py +74 -0
- {ragaai_catalyst-2.1.5b25.dist-info → ragaai_catalyst-2.1.5b27.dist-info}/METADATA +11 -4
- {ragaai_catalyst-2.1.5b25.dist-info → ragaai_catalyst-2.1.5b27.dist-info}/RECORD +21 -18
- {ragaai_catalyst-2.1.5b25.dist-info → ragaai_catalyst-2.1.5b27.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b25.dist-info → ragaai_catalyst-2.1.5b27.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b25.dist-info → ragaai_catalyst-2.1.5b27.dist-info}/top_level.txt +0 -0
ragaai_catalyst/evaluation.py
CHANGED
@@ -510,8 +510,11 @@ class Evaluation:
|
|
510
510
|
df = pd.read_csv(io.StringIO(response_text))
|
511
511
|
|
512
512
|
column_list = df.columns.to_list()
|
513
|
+
# Remove unwanted columns
|
513
514
|
column_list = [col for col in column_list if not col.startswith('_')]
|
514
515
|
column_list = [col for col in column_list if '.' not in col]
|
516
|
+
# Remove _claims_ columns
|
517
|
+
column_list = [col for col in column_list if '_claims_' not in col]
|
515
518
|
return df[column_list]
|
516
519
|
else:
|
517
520
|
return pd.DataFrame()
|
@@ -106,48 +106,42 @@ class AgentTracerMixin:
|
|
106
106
|
if gt is not None:
|
107
107
|
span = self.span(name)
|
108
108
|
span.add_gt(gt)
|
109
|
-
# Set agent context before initializing
|
110
|
-
component_id = str(uuid.uuid4())
|
111
|
-
hash_id = top_level_hash_id
|
112
|
-
|
113
|
-
# Store the component ID in the instance
|
114
|
-
self._agent_component_id = component_id
|
115
|
-
|
116
|
-
# Get parent agent ID if exists
|
117
|
-
parent_agent_id = tracer.current_agent_id.get()
|
118
|
-
|
119
|
-
# Create agent component
|
120
|
-
agent_component = tracer.create_agent_component(
|
121
|
-
component_id=component_id,
|
122
|
-
hash_id=hash_id,
|
123
|
-
name=name,
|
124
|
-
agent_type=agent_type,
|
125
|
-
version=version,
|
126
|
-
capabilities=capabilities or [],
|
127
|
-
start_time=datetime.now().astimezone().isoformat(),
|
128
|
-
memory_used=0,
|
129
|
-
input_data=tracer._sanitize_input(args, kwargs),
|
130
|
-
output_data=None,
|
131
|
-
children=[],
|
132
|
-
parent_id=parent_agent_id,
|
133
|
-
)
|
134
|
-
|
135
|
-
# Store component for later updates
|
136
|
-
if not hasattr(tracer, "_agent_components"):
|
137
|
-
tracer._agent_components = {}
|
138
|
-
tracer._agent_components[component_id] = agent_component
|
139
109
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
tracer.
|
148
|
-
|
149
|
-
|
150
|
-
|
110
|
+
if not hasattr(self, '_agent_component_id'):
|
111
|
+
component_id = str(uuid.uuid4())
|
112
|
+
self._agent_component_id = component_id
|
113
|
+
|
114
|
+
# Get parent agent ID if exists
|
115
|
+
parent_agent_id = tracer.current_agent_id.get()
|
116
|
+
|
117
|
+
agent_component = tracer.create_agent_component(
|
118
|
+
component_id=component_id,
|
119
|
+
hash_id=top_level_hash_id,
|
120
|
+
name=name,
|
121
|
+
agent_type=agent_type,
|
122
|
+
version=version,
|
123
|
+
capabilities=capabilities or [],
|
124
|
+
start_time=datetime.now().astimezone().isoformat(),
|
125
|
+
memory_used=0,
|
126
|
+
input_data=tracer._sanitize_input(args, kwargs),
|
127
|
+
output_data=None,
|
128
|
+
children=[],
|
129
|
+
parent_id=parent_agent_id,
|
130
|
+
)
|
131
|
+
|
132
|
+
if not hasattr(tracer, "_agent_components"):
|
133
|
+
tracer._agent_components = {}
|
134
|
+
tracer._agent_components[component_id] = agent_component
|
135
|
+
|
136
|
+
# For class agents, only add to parent's children if parent exists
|
137
|
+
if parent_agent_id and parent_agent_id in tracer._agent_components:
|
138
|
+
parent_component = tracer._agent_components[parent_agent_id]
|
139
|
+
if not hasattr(parent_component, "children"):
|
140
|
+
parent_component["children"] = []
|
141
|
+
if component_id not in parent_component["children"]:
|
142
|
+
parent_component["children"].append(component_id)
|
143
|
+
|
144
|
+
token = tracer.current_agent_id.set(self._agent_component_id)
|
151
145
|
try:
|
152
146
|
original_init(self, *args, **kwargs)
|
153
147
|
finally:
|
@@ -160,7 +154,6 @@ class AgentTracerMixin:
|
|
160
154
|
if callable(attr_value):
|
161
155
|
|
162
156
|
def wrap_method(method):
|
163
|
-
@self.file_tracker.trace_decorator
|
164
157
|
@functools.wraps(method)
|
165
158
|
def wrapped_method(self, *args, **kwargs):
|
166
159
|
gt = kwargs.get("gt") if kwargs else None
|
@@ -225,15 +218,60 @@ class AgentTracerMixin:
|
|
225
218
|
setattr(target, attr_name, wrap_method(attr_value))
|
226
219
|
|
227
220
|
# Replace __init__ with wrapped version
|
221
|
+
|
228
222
|
target.__init__ = wrapped_init
|
223
|
+
|
224
|
+
# Wrap all methods to maintain parent-child relationship
|
225
|
+
for attr_name, attr_value in target.__dict__.items():
|
226
|
+
if callable(attr_value) and not attr_name.startswith('__'):
|
227
|
+
original_method = attr_value
|
228
|
+
|
229
|
+
def create_wrapper(method):
|
230
|
+
@self.file_tracker.trace_decorator
|
231
|
+
@functools.wraps(method)
|
232
|
+
def method_wrapper(self, *args, **kwargs):
|
233
|
+
gt = kwargs.get("gt") if kwargs else None
|
234
|
+
if gt is not None:
|
235
|
+
span = tracer.span(name)
|
236
|
+
span.add_gt(gt)
|
237
|
+
# Use the class instance's agent ID as parent
|
238
|
+
parent_id = getattr(self, '_agent_component_id', None)
|
239
|
+
if parent_id:
|
240
|
+
if asyncio.iscoroutinefunction(method):
|
241
|
+
return tracer._trace_agent_execution(
|
242
|
+
method.__get__(self, type(self)),
|
243
|
+
name,
|
244
|
+
agent_type,
|
245
|
+
version,
|
246
|
+
capabilities,
|
247
|
+
top_level_hash_id,
|
248
|
+
*args,
|
249
|
+
**kwargs,
|
250
|
+
)
|
251
|
+
else:
|
252
|
+
return tracer._trace_sync_agent_execution(
|
253
|
+
method.__get__(self, type(self)),
|
254
|
+
name,
|
255
|
+
agent_type,
|
256
|
+
version,
|
257
|
+
capabilities,
|
258
|
+
top_level_hash_id,
|
259
|
+
*args,
|
260
|
+
**kwargs,
|
261
|
+
)
|
262
|
+
else:
|
263
|
+
return method(self, *args, **kwargs)
|
264
|
+
return method_wrapper
|
265
|
+
|
266
|
+
setattr(target, attr_name, create_wrapper(original_method))
|
267
|
+
|
229
268
|
return target
|
230
269
|
else:
|
231
|
-
# For
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
return await self._trace_agent_execution(
|
270
|
+
# For non-class targets (e.g., functions), use existing function wrapping logic
|
271
|
+
@functools.wraps(target)
|
272
|
+
def wrapper(*args, **kwargs):
|
273
|
+
if asyncio.iscoroutinefunction(target):
|
274
|
+
return tracer._trace_agent_execution(
|
237
275
|
target,
|
238
276
|
name,
|
239
277
|
agent_type,
|
@@ -243,12 +281,8 @@ class AgentTracerMixin:
|
|
243
281
|
*args,
|
244
282
|
**kwargs,
|
245
283
|
)
|
246
|
-
|
247
|
-
|
248
|
-
else:
|
249
|
-
|
250
|
-
def wrapper(*args, **kwargs):
|
251
|
-
return self._trace_sync_agent_execution(
|
284
|
+
else:
|
285
|
+
return tracer._trace_sync_agent_execution(
|
252
286
|
target,
|
253
287
|
name,
|
254
288
|
agent_type,
|
@@ -258,16 +292,13 @@ class AgentTracerMixin:
|
|
258
292
|
*args,
|
259
293
|
**kwargs,
|
260
294
|
)
|
261
|
-
|
262
|
-
return wrapper
|
295
|
+
return wrapper
|
263
296
|
|
264
297
|
return decorator
|
265
298
|
|
266
299
|
def _trace_sync_agent_execution(
|
267
|
-
|
300
|
+
self, func, name, agent_type, version, capabilities, top_level_hash_id, *args, **kwargs
|
268
301
|
):
|
269
|
-
hash_id = top_level_hash_id
|
270
|
-
|
271
302
|
"""Synchronous version of agent tracing"""
|
272
303
|
if not self.is_active:
|
273
304
|
return func(*args, **kwargs)
|
@@ -303,7 +334,7 @@ class AgentTracerMixin:
|
|
303
334
|
|
304
335
|
try:
|
305
336
|
# Execute the agent
|
306
|
-
result =
|
337
|
+
result = func(*args, **kwargs)
|
307
338
|
|
308
339
|
# Calculate resource usage
|
309
340
|
end_memory = psutil.Process().memory_info().rss
|
@@ -318,7 +349,7 @@ class AgentTracerMixin:
|
|
318
349
|
# Create agent component with children and parent if exists
|
319
350
|
agent_component = self.create_agent_component(
|
320
351
|
component_id=component_id,
|
321
|
-
hash_id=
|
352
|
+
hash_id=top_level_hash_id,
|
322
353
|
name=name,
|
323
354
|
agent_type=agent_type,
|
324
355
|
version=version,
|
@@ -331,12 +362,17 @@ class AgentTracerMixin:
|
|
331
362
|
parent_id=parent_agent_id,
|
332
363
|
)
|
333
364
|
|
334
|
-
#
|
335
|
-
|
336
|
-
|
365
|
+
# Store component for updates
|
366
|
+
if not hasattr(self, "_agent_components"):
|
367
|
+
self._agent_components = {}
|
368
|
+
self._agent_components[component_id] = agent_component
|
337
369
|
|
338
|
-
# Only add to root
|
339
|
-
if
|
370
|
+
# Only add to hierarchy if this is a root component (no parent)
|
371
|
+
# or if the parent explicitly added it as a child
|
372
|
+
if parent_agent_id:
|
373
|
+
parent_children.append(agent_component)
|
374
|
+
self.agent_children.set(parent_children)
|
375
|
+
else:
|
340
376
|
self.add_component(agent_component)
|
341
377
|
|
342
378
|
return result
|
@@ -351,16 +387,10 @@ class AgentTracerMixin:
|
|
351
387
|
# Get children even in case of error
|
352
388
|
children = self.agent_children.get()
|
353
389
|
|
354
|
-
#
|
355
|
-
for child in children:
|
356
|
-
child["parent_id"] = component_id
|
357
|
-
|
358
|
-
# End tracking network calls for this component
|
359
|
-
self.end_component(component_id)
|
360
|
-
|
390
|
+
# Create error component
|
361
391
|
agent_component = self.create_agent_component(
|
362
392
|
component_id=component_id,
|
363
|
-
hash_id=
|
393
|
+
hash_id=top_level_hash_id,
|
364
394
|
name=name,
|
365
395
|
agent_type=agent_type,
|
366
396
|
version=version,
|
@@ -373,16 +403,20 @@ class AgentTracerMixin:
|
|
373
403
|
children=children,
|
374
404
|
parent_id=parent_agent_id, # Add parent ID if exists
|
375
405
|
)
|
376
|
-
|
406
|
+
|
407
|
+
# Store component for updates
|
408
|
+
if not hasattr(self, "_agent_components"):
|
409
|
+
self._agent_components = {}
|
410
|
+
self._agent_components[component_id] = agent_component
|
411
|
+
|
412
|
+
# Only add to hierarchy if this is a root component (no parent)
|
413
|
+
# or if the parent explicitly added it as a child
|
377
414
|
if parent_agent_id:
|
378
|
-
|
379
|
-
|
380
|
-
if "children" not in parent_component["data"]:
|
381
|
-
parent_component["data"]["children"] = []
|
382
|
-
parent_component["data"]["children"].append(agent_component)
|
415
|
+
parent_children.append(agent_component)
|
416
|
+
self.agent_children.set(parent_children)
|
383
417
|
else:
|
384
418
|
# Only add to root components if no parent
|
385
|
-
self.add_component(agent_component)
|
419
|
+
self.add_component(agent_component, is_error=True)
|
386
420
|
|
387
421
|
raise
|
388
422
|
finally:
|
@@ -424,7 +458,7 @@ class AgentTracerMixin:
|
|
424
458
|
|
425
459
|
try:
|
426
460
|
# Execute the agent
|
427
|
-
result = await
|
461
|
+
result = await func(*args, **kwargs)
|
428
462
|
|
429
463
|
# Calculate resource usage
|
430
464
|
end_memory = psutil.Process().memory_info().rss
|
@@ -451,12 +485,17 @@ class AgentTracerMixin:
|
|
451
485
|
parent_id=parent_agent_id,
|
452
486
|
)
|
453
487
|
|
454
|
-
#
|
455
|
-
|
456
|
-
|
488
|
+
# Store component for updates
|
489
|
+
if not hasattr(self, "_agent_components"):
|
490
|
+
self._agent_components = {}
|
491
|
+
self._agent_components[component_id] = agent_component
|
457
492
|
|
458
|
-
# Only add to root
|
459
|
-
if
|
493
|
+
# Only add to hierarchy if this is a root component (no parent)
|
494
|
+
# or if the parent explicitly added it as a child
|
495
|
+
if parent_agent_id:
|
496
|
+
parent_children.append(agent_component)
|
497
|
+
self.agent_children.set(parent_children)
|
498
|
+
else:
|
460
499
|
self.add_component(agent_component)
|
461
500
|
|
462
501
|
return result
|
@@ -471,13 +510,7 @@ class AgentTracerMixin:
|
|
471
510
|
# Get children even in case of error
|
472
511
|
children = self.agent_children.get()
|
473
512
|
|
474
|
-
#
|
475
|
-
for child in children:
|
476
|
-
child["parent_id"] = component_id
|
477
|
-
|
478
|
-
# End tracking network calls for this component
|
479
|
-
self.end_component(component_id)
|
480
|
-
|
513
|
+
# Create error component
|
481
514
|
agent_component = self.create_agent_component(
|
482
515
|
component_id=component_id,
|
483
516
|
hash_id=hash_id,
|
@@ -494,16 +527,19 @@ class AgentTracerMixin:
|
|
494
527
|
parent_id=parent_agent_id, # Add parent ID if exists
|
495
528
|
)
|
496
529
|
|
497
|
-
#
|
530
|
+
# Store component for updates
|
531
|
+
if not hasattr(self, "_agent_components"):
|
532
|
+
self._agent_components = {}
|
533
|
+
self._agent_components[component_id] = agent_component
|
534
|
+
|
535
|
+
# Only add to hierarchy if this is a root component (no parent)
|
536
|
+
# or if the parent explicitly added it as a child
|
498
537
|
if parent_agent_id:
|
499
|
-
|
500
|
-
|
501
|
-
if "children" not in parent_component["data"]:
|
502
|
-
parent_component["data"]["children"] = []
|
503
|
-
parent_component["data"]["children"].append(agent_component)
|
538
|
+
parent_children.append(agent_component)
|
539
|
+
self.agent_children.set(parent_children)
|
504
540
|
else:
|
505
541
|
# Only add to root components if no parent
|
506
|
-
self.add_component(agent_component)
|
542
|
+
self.add_component(agent_component, is_error=True)
|
507
543
|
|
508
544
|
raise
|
509
545
|
finally:
|
@@ -137,6 +137,7 @@ class BaseTracer:
|
|
137
137
|
"""Initialize a new trace"""
|
138
138
|
self.tracking = True
|
139
139
|
self.trace_id = str(uuid.uuid4())
|
140
|
+
self.file_tracker.trace_main_file()
|
140
141
|
self.system_monitor = SystemMonitor(self.trace_id)
|
141
142
|
threading.Thread(target=self._track_memory_usage).start()
|
142
143
|
threading.Thread(target=self._track_cpu_usage).start()
|
@@ -41,7 +41,6 @@ class CustomTracerMixin:
|
|
41
41
|
# Check if the function is async
|
42
42
|
is_async = asyncio.iscoroutinefunction(func)
|
43
43
|
|
44
|
-
@self.file_tracker.trace_decorator
|
45
44
|
@functools.wraps(func)
|
46
45
|
async def async_wrapper(*args, **kwargs):
|
47
46
|
async_wrapper.metadata = metadata
|
@@ -53,7 +52,6 @@ class CustomTracerMixin:
|
|
53
52
|
func, name or func.__name__, custom_type, version, trace_variables, *args, **kwargs
|
54
53
|
)
|
55
54
|
|
56
|
-
@self.file_tracker.trace_decorator
|
57
55
|
@functools.wraps(func)
|
58
56
|
def sync_wrapper(*args, **kwargs):
|
59
57
|
sync_wrapper.metadata = metadata
|
@@ -104,7 +102,7 @@ class CustomTracerMixin:
|
|
104
102
|
|
105
103
|
try:
|
106
104
|
# Execute the function
|
107
|
-
result =
|
105
|
+
result = func(*args, **kwargs)
|
108
106
|
|
109
107
|
# Calculate resource usage
|
110
108
|
end_time = datetime.now().astimezone().isoformat()
|
@@ -160,7 +158,7 @@ class CustomTracerMixin:
|
|
160
158
|
error=error_component
|
161
159
|
)
|
162
160
|
|
163
|
-
self.add_component(custom_component)
|
161
|
+
self.add_component(custom_component, is_error=True)
|
164
162
|
raise
|
165
163
|
|
166
164
|
async def _trace_custom_execution(self, func, name, custom_type, version, trace_variables, *args, **kwargs):
|
@@ -192,7 +190,7 @@ class CustomTracerMixin:
|
|
192
190
|
|
193
191
|
try:
|
194
192
|
# Execute the function
|
195
|
-
result = await
|
193
|
+
result = await func(*args, **kwargs)
|
196
194
|
|
197
195
|
# Calculate resource usage
|
198
196
|
end_time = datetime.now().astimezone().isoformat()
|
@@ -240,7 +238,7 @@ class CustomTracerMixin:
|
|
240
238
|
output_data=None,
|
241
239
|
error=error_component
|
242
240
|
)
|
243
|
-
self.add_component(custom_component)
|
241
|
+
self.add_component(custom_component, is_error=True)
|
244
242
|
raise
|
245
243
|
|
246
244
|
def create_custom_component(self, **kwargs):
|