ragaai-catalyst 2.1.4b2__py3-none-any.whl → 2.1.4b3__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/tracers/agentic_tracing/tracers/base.py +186 -214
- ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py +0 -3
- {ragaai_catalyst-2.1.4b2.dist-info → ragaai_catalyst-2.1.4b3.dist-info}/METADATA +1 -1
- {ragaai_catalyst-2.1.4b2.dist-info → ragaai_catalyst-2.1.4b3.dist-info}/RECORD +6 -6
- {ragaai_catalyst-2.1.4b2.dist-info → ragaai_catalyst-2.1.4b3.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.4b2.dist-info → ragaai_catalyst-2.1.4b3.dist-info}/top_level.txt +0 -0
@@ -284,17 +284,25 @@ class BaseTracer:
|
|
284
284
|
def __exit__(self, exc_type, exc_value, traceback):
|
285
285
|
self.stop()
|
286
286
|
|
287
|
+
def _process_children(self, children_list, parent_id, current_id):
|
288
|
+
"""Helper function to process children recursively."""
|
289
|
+
for child in children_list:
|
290
|
+
child["id"] = current_id
|
291
|
+
child["parent_id"] = parent_id
|
292
|
+
current_id += 1
|
293
|
+
# Recursively process nested children if they exist
|
294
|
+
if "children" in child["data"]:
|
295
|
+
current_id = self._process_children(child["data"]["children"], child["id"], current_id)
|
296
|
+
return current_id
|
297
|
+
|
287
298
|
def _change_span_ids_to_int(self, trace):
|
288
299
|
id, parent_id = 1, 0
|
289
300
|
for span in trace.data[0]["spans"]:
|
290
301
|
span.id = id
|
291
302
|
span.parent_id = parent_id
|
292
303
|
id += 1
|
293
|
-
if span.type == "agent":
|
294
|
-
|
295
|
-
children["id"] = id
|
296
|
-
children["parent_id"] = span.id
|
297
|
-
id += 1
|
304
|
+
if span.type == "agent" and "children" in span.data:
|
305
|
+
id = self._process_children(span.data["children"], span.id, id)
|
298
306
|
return trace
|
299
307
|
|
300
308
|
def _change_agent_input_output(self, trace):
|
@@ -445,63 +453,169 @@ class BaseTracer:
|
|
445
453
|
def add_tags(self, tags: List[str]):
|
446
454
|
raise NotImplementedError
|
447
455
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
456
|
+
def _process_child_interactions(self, child, interaction_id, interactions):
|
457
|
+
"""
|
458
|
+
Helper method to process child interactions recursively.
|
459
|
+
|
460
|
+
Args:
|
461
|
+
child (dict): The child span to process
|
462
|
+
interaction_id (int): Current interaction ID
|
463
|
+
interactions (list): List of interactions to append to
|
464
|
+
|
465
|
+
Returns:
|
466
|
+
int: Next interaction ID to use
|
467
|
+
"""
|
468
|
+
child_type = child.get("type")
|
469
|
+
|
470
|
+
if child_type == "tool":
|
471
|
+
# Tool call start
|
472
|
+
interactions.append(
|
473
|
+
{
|
474
|
+
"id": str(interaction_id),
|
475
|
+
"span_id": child.get("id"),
|
476
|
+
"interaction_type": "tool_call_start",
|
477
|
+
"name": child.get("name"),
|
478
|
+
"content": {
|
479
|
+
"parameters": [
|
480
|
+
child.get("data", {}).get("input", {}).get("args"),
|
481
|
+
child.get("data", {}).get("input", {}).get("kwargs"),
|
482
|
+
]
|
483
|
+
},
|
484
|
+
"timestamp": child.get("start_time"),
|
485
|
+
"error": child.get("error"),
|
486
|
+
}
|
487
|
+
)
|
488
|
+
interaction_id += 1
|
489
|
+
|
490
|
+
# Tool call end
|
491
|
+
interactions.append(
|
492
|
+
{
|
493
|
+
"id": str(interaction_id),
|
494
|
+
"span_id": child.get("id"),
|
495
|
+
"interaction_type": "tool_call_end",
|
496
|
+
"name": child.get("name"),
|
497
|
+
"content": {
|
498
|
+
"returns": child.get("data", {}).get("output"),
|
499
|
+
},
|
500
|
+
"timestamp": child.get("end_time"),
|
501
|
+
"error": child.get("error"),
|
502
|
+
}
|
503
|
+
)
|
504
|
+
interaction_id += 1
|
505
|
+
|
506
|
+
elif child_type == "llm":
|
507
|
+
interactions.append(
|
508
|
+
{
|
509
|
+
"id": str(interaction_id),
|
510
|
+
"span_id": child.get("id"),
|
511
|
+
"interaction_type": "llm_call_start",
|
512
|
+
"name": child.get("name"),
|
513
|
+
"content": {
|
514
|
+
"prompt": child.get("data", {}).get("input"),
|
515
|
+
},
|
516
|
+
"timestamp": child.get("start_time"),
|
517
|
+
"error": child.get("error"),
|
518
|
+
}
|
519
|
+
)
|
520
|
+
interaction_id += 1
|
521
|
+
|
522
|
+
interactions.append(
|
523
|
+
{
|
524
|
+
"id": str(interaction_id),
|
525
|
+
"span_id": child.get("id"),
|
526
|
+
"interaction_type": "llm_call_end",
|
527
|
+
"name": child.get("name"),
|
528
|
+
"content": {
|
529
|
+
"response": child.get("data", {}).get("output")
|
530
|
+
},
|
531
|
+
"timestamp": child.get("end_time"),
|
532
|
+
"error": child.get("error"),
|
533
|
+
}
|
534
|
+
)
|
535
|
+
interaction_id += 1
|
536
|
+
|
537
|
+
elif child_type == "agent":
|
538
|
+
interactions.append(
|
539
|
+
{
|
540
|
+
"id": str(interaction_id),
|
541
|
+
"span_id": child.get("id"),
|
542
|
+
"interaction_type": "agent_call_start",
|
543
|
+
"name": child.get("name"),
|
544
|
+
"content": None,
|
545
|
+
"timestamp": child.get("start_time"),
|
546
|
+
"error": child.get("error"),
|
547
|
+
}
|
548
|
+
)
|
549
|
+
interaction_id += 1
|
500
550
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
551
|
+
# Process nested children recursively
|
552
|
+
if "children" in child.get("data", {}):
|
553
|
+
for nested_child in child["data"]["children"]:
|
554
|
+
interaction_id = self._process_child_interactions(
|
555
|
+
nested_child, interaction_id, interactions
|
556
|
+
)
|
557
|
+
|
558
|
+
interactions.append(
|
559
|
+
{
|
560
|
+
"id": str(interaction_id),
|
561
|
+
"span_id": child.get("id"),
|
562
|
+
"interaction_type": "agent_call_end",
|
563
|
+
"name": child.get("name"),
|
564
|
+
"content": child.get("data", {}).get("output"),
|
565
|
+
"timestamp": child.get("end_time"),
|
566
|
+
"error": child.get("error"),
|
567
|
+
}
|
568
|
+
)
|
569
|
+
interaction_id += 1
|
570
|
+
|
571
|
+
else:
|
572
|
+
interactions.append(
|
573
|
+
{
|
574
|
+
"id": str(interaction_id),
|
575
|
+
"span_id": child.get("id"),
|
576
|
+
"interaction_type": child_type,
|
577
|
+
"name": child.get("name"),
|
578
|
+
"content": child.get("data", {}),
|
579
|
+
"timestamp": child.get("start_time"),
|
580
|
+
"error": child.get("error"),
|
581
|
+
}
|
582
|
+
)
|
583
|
+
interaction_id += 1
|
584
|
+
|
585
|
+
# Process additional interactions and network calls
|
586
|
+
if "interactions" in child:
|
587
|
+
for interaction in child["interactions"]:
|
588
|
+
interaction["id"] = str(interaction_id)
|
589
|
+
interaction["span_id"] = child.get("id")
|
590
|
+
interaction["error"] = None
|
591
|
+
interactions.append(interaction)
|
592
|
+
interaction_id += 1
|
593
|
+
|
594
|
+
if "network_calls" in child:
|
595
|
+
for child_network_call in child["network_calls"]:
|
596
|
+
network_call = {}
|
597
|
+
network_call["id"] = str(interaction_id)
|
598
|
+
network_call["span_id"] = child.get("id")
|
599
|
+
network_call["interaction_type"] = "network_call"
|
600
|
+
network_call["name"] = None
|
601
|
+
network_call["content"] = {
|
602
|
+
"request": {
|
603
|
+
"url": child_network_call.get("url"),
|
604
|
+
"method": child_network_call.get("method"),
|
605
|
+
"headers": child_network_call.get("headers"),
|
606
|
+
},
|
607
|
+
"response": {
|
608
|
+
"status_code": child_network_call.get("status_code"),
|
609
|
+
"headers": child_network_call.get("response_headers"),
|
610
|
+
"body": child_network_call.get("response_body"),
|
611
|
+
},
|
612
|
+
}
|
613
|
+
network_call["timestamp"] = child_network_call.get("start_time")
|
614
|
+
network_call["error"] = child_network_call.get("error")
|
615
|
+
interactions.append(network_call)
|
616
|
+
interaction_id += 1
|
617
|
+
|
618
|
+
return interaction_id
|
505
619
|
|
506
620
|
def format_interactions(self) -> dict:
|
507
621
|
"""
|
@@ -513,14 +627,14 @@ class BaseTracer:
|
|
513
627
|
tool_call_end, llm_call, file_read, file_write, network_call.
|
514
628
|
|
515
629
|
Returns:
|
516
|
-
dict: A dictionary with "
|
630
|
+
dict: A dictionary with "workflow" key containing a list of interactions
|
517
631
|
sorted by timestamp.
|
518
632
|
"""
|
519
633
|
interactions = []
|
520
634
|
interaction_id = 1
|
521
635
|
|
522
636
|
if not hasattr(self, "trace") or not self.trace.data:
|
523
|
-
return {"
|
637
|
+
return {"workflow": []}
|
524
638
|
|
525
639
|
for span in self.trace.data[0]["spans"]:
|
526
640
|
# Process agent spans
|
@@ -539,159 +653,12 @@ class BaseTracer:
|
|
539
653
|
)
|
540
654
|
interaction_id += 1
|
541
655
|
|
542
|
-
# Process children of agent
|
656
|
+
# Process children of agent recursively
|
543
657
|
if "children" in span.data:
|
544
658
|
for child in span.data["children"]:
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
interactions.append(
|
549
|
-
{
|
550
|
-
"id": str(interaction_id),
|
551
|
-
"span_id": child.get("id"),
|
552
|
-
"interaction_type": "tool_call_start",
|
553
|
-
"name": child.get("name"),
|
554
|
-
"content": {
|
555
|
-
"parameters": [
|
556
|
-
child.get("data", {})
|
557
|
-
.get("input")
|
558
|
-
.get("args"),
|
559
|
-
child.get("data", {})
|
560
|
-
.get("input")
|
561
|
-
.get("kwargs"),
|
562
|
-
]
|
563
|
-
},
|
564
|
-
"timestamp": child.get("start_time"),
|
565
|
-
"error": child.get("error"),
|
566
|
-
}
|
567
|
-
)
|
568
|
-
interaction_id += 1
|
569
|
-
|
570
|
-
# Tool call end
|
571
|
-
interactions.append(
|
572
|
-
{
|
573
|
-
"id": str(interaction_id),
|
574
|
-
"span_id": child.get("id"),
|
575
|
-
"interaction_type": "tool_call_end",
|
576
|
-
"name": child.get("name"),
|
577
|
-
"content": {
|
578
|
-
"returns": child.get("data", {}).get("output"),
|
579
|
-
},
|
580
|
-
"timestamp": child.get("end_time"),
|
581
|
-
"error": child.get("error"),
|
582
|
-
}
|
583
|
-
)
|
584
|
-
interaction_id += 1
|
585
|
-
|
586
|
-
elif child_type == "llm":
|
587
|
-
interactions.append(
|
588
|
-
{
|
589
|
-
"id": str(interaction_id),
|
590
|
-
"span_id": child.get("id"),
|
591
|
-
"interaction_type": "llm_call_start",
|
592
|
-
"name": child.get("name"),
|
593
|
-
"content": {
|
594
|
-
"prompt": child.get("data", {}).get("input"),
|
595
|
-
},
|
596
|
-
"timestamp": child.get("start_time"),
|
597
|
-
"error": child.get("error"),
|
598
|
-
}
|
599
|
-
)
|
600
|
-
interaction_id += 1
|
601
|
-
|
602
|
-
interactions.append(
|
603
|
-
{
|
604
|
-
"id": str(interaction_id),
|
605
|
-
"span_id": child.get("id"),
|
606
|
-
"interaction_type": "llm_call_end",
|
607
|
-
"name": child.get("name"),
|
608
|
-
"content": {
|
609
|
-
"response": child.get("data", {}).get("output")
|
610
|
-
},
|
611
|
-
"timestamp": child.get("end_time"),
|
612
|
-
"error": child.get("error"),
|
613
|
-
}
|
614
|
-
)
|
615
|
-
interaction_id += 1
|
616
|
-
|
617
|
-
elif child_type == "agent":
|
618
|
-
interactions.append(
|
619
|
-
{
|
620
|
-
"id": str(interaction_id),
|
621
|
-
"span_id": child.get("id"),
|
622
|
-
"interaction_type": "agent_call_start",
|
623
|
-
"name": child.get("name"),
|
624
|
-
"content": None,
|
625
|
-
"timestamp": child.get("start_time"),
|
626
|
-
"error": child.get("error"),
|
627
|
-
}
|
628
|
-
)
|
629
|
-
interaction_id += 1
|
630
|
-
|
631
|
-
interactions.append(
|
632
|
-
{
|
633
|
-
"id": str(interaction_id),
|
634
|
-
"span_id": child.get("id"),
|
635
|
-
"interaction_type": "agent_call_end",
|
636
|
-
"name": child.get("name"),
|
637
|
-
"content": child.get("data", {}).get("output"),
|
638
|
-
"timestamp": child.get("end_time"),
|
639
|
-
"error": child.get("error"),
|
640
|
-
}
|
641
|
-
)
|
642
|
-
interaction_id += 1
|
643
|
-
|
644
|
-
else:
|
645
|
-
interactions.append(
|
646
|
-
{
|
647
|
-
"id": str(interaction_id),
|
648
|
-
"span_id": child.get("id"),
|
649
|
-
"interaction_type": child_type,
|
650
|
-
"name": child.get("name"),
|
651
|
-
"content": child.get("data", {}),
|
652
|
-
"timestamp": child.get("start_time"),
|
653
|
-
"error": child.get("error"),
|
654
|
-
}
|
655
|
-
)
|
656
|
-
interaction_id += 1
|
657
|
-
|
658
|
-
if "interactions" in child:
|
659
|
-
for interaction in child["interactions"]:
|
660
|
-
interaction["id"] = str(interaction_id)
|
661
|
-
interaction["span_id"] = child.get("id")
|
662
|
-
interaction["error"] = None
|
663
|
-
interactions.append(interaction)
|
664
|
-
interaction_id += 1
|
665
|
-
|
666
|
-
if "network_calls" in child:
|
667
|
-
for child_network_call in child["network_calls"]:
|
668
|
-
network_call = {}
|
669
|
-
network_call["id"] = str(interaction_id)
|
670
|
-
network_call["span_id"] = child.get("id")
|
671
|
-
network_call["interaction_type"] = "network_call"
|
672
|
-
network_call["name"] = None
|
673
|
-
network_call["content"] = {
|
674
|
-
"request": {
|
675
|
-
"url": child_network_call.get("url"),
|
676
|
-
"method": child_network_call.get("method"),
|
677
|
-
"headers": child_network_call.get("headers"),
|
678
|
-
},
|
679
|
-
"response": {
|
680
|
-
"status_code": child_network_call.get(
|
681
|
-
"status_code"
|
682
|
-
),
|
683
|
-
"headers": child_network_call.get(
|
684
|
-
"response_headers"
|
685
|
-
),
|
686
|
-
"body": child_network_call.get("response_body"),
|
687
|
-
},
|
688
|
-
}
|
689
|
-
network_call["timestamp"] = child_network_call[
|
690
|
-
"start_time"
|
691
|
-
]
|
692
|
-
network_call["error"] = child_network_call.get("error")
|
693
|
-
interactions.append(network_call)
|
694
|
-
interaction_id += 1
|
659
|
+
interaction_id = self._process_child_interactions(
|
660
|
+
child, interaction_id, interactions
|
661
|
+
)
|
695
662
|
|
696
663
|
# Add agent_end interaction
|
697
664
|
interactions.append(
|
@@ -830,3 +797,8 @@ class BaseTracer:
|
|
830
797
|
interaction["id"] = str(idx)
|
831
798
|
|
832
799
|
return {"workflow": sorted_interactions}
|
800
|
+
|
801
|
+
def span(self, span_name):
|
802
|
+
if span_name not in self.span_attributes_dict:
|
803
|
+
self.span_attributes_dict[span_name] = SpanAttributes(span_name)
|
804
|
+
return self.span_attributes_dict[span_name]
|
@@ -91,7 +91,6 @@ class CustomTracerMixin:
|
|
91
91
|
pass
|
92
92
|
return trace_variables_func
|
93
93
|
|
94
|
-
sys.settrace(trace_variables_func)
|
95
94
|
|
96
95
|
# Start tracking network calls for this component
|
97
96
|
self.start_component(component_id)
|
@@ -187,8 +186,6 @@ class CustomTracerMixin:
|
|
187
186
|
pass
|
188
187
|
return trace_variables_func
|
189
188
|
|
190
|
-
sys.settrace(trace_variables_func)
|
191
|
-
|
192
189
|
try:
|
193
190
|
# Execute the function
|
194
191
|
result = await func(*args, **kwargs)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.4b3
|
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
6
|
Requires-Python: <3.13,>=3.9
|
@@ -27,8 +27,8 @@ ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py,sha256=S4rCcKzU
|
|
27
27
|
ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py,sha256=Xk1cLzs-2A3dgyBwRRnCWs7Eubki40FVonwd433hPN8,4805
|
28
28
|
ragaai_catalyst/tracers/agentic_tracing/tracers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
29
|
ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=unr4AVpXu2IJeNz_oL-fEtJ-tNmbCgdWJN5euCfdC8c,24951
|
30
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=
|
31
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=
|
30
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=Ly9UhNu5G8MWZhIM2Rj7L0uYV65w6mC6caokbjXcwQE,31201
|
31
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=JR_XhRWmw01XpzAc2P3VdUCkuXkmHtbFHSsJ7d3uL2w,12372
|
32
32
|
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=9EYrfkMYNYXYur9msb0wmxJlN_c58mzSj-GTDbLb154,28759
|
33
33
|
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=Tthd1lm_QKeY8E4HLYWW9djujnOO_5X-LIKnv1pNwJI,15092
|
34
34
|
ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=Tq9by4DV51UR4BCUc3fnAiNR4SZku-gOaOfjJryowAA,10218
|
@@ -59,7 +59,7 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
|
|
59
59
|
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
60
60
|
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
61
61
|
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
62
|
-
ragaai_catalyst-2.1.
|
63
|
-
ragaai_catalyst-2.1.
|
64
|
-
ragaai_catalyst-2.1.
|
65
|
-
ragaai_catalyst-2.1.
|
62
|
+
ragaai_catalyst-2.1.4b3.dist-info/METADATA,sha256=5Pc4_m7M2O8YxyhO4kJNYJwVmemLutem1Tmew_77ygY,12770
|
63
|
+
ragaai_catalyst-2.1.4b3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
64
|
+
ragaai_catalyst-2.1.4b3.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
65
|
+
ragaai_catalyst-2.1.4b3.dist-info/RECORD,,
|
File without changes
|
File without changes
|