ragaai-catalyst 2.1.4.1__py3-none-any.whl → 2.1.4.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.
- ragaai_catalyst/tracers/agentic_tracing/data/data_structure.py +2 -4
- ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +7 -97
- ragaai_catalyst/tracers/agentic_tracing/upload/upload_trace_metric.py +0 -7
- {ragaai_catalyst-2.1.4.1.dist-info → ragaai_catalyst-2.1.4.1b0.dist-info}/METADATA +1 -1
- {ragaai_catalyst-2.1.4.1.dist-info → ragaai_catalyst-2.1.4.1b0.dist-info}/RECORD +8 -8
- {ragaai_catalyst-2.1.4.1.dist-info → ragaai_catalyst-2.1.4.1b0.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.4.1.dist-info → ragaai_catalyst-2.1.4.1b0.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.4.1.dist-info → ragaai_catalyst-2.1.4.1b0.dist-info}/top_level.txt +0 -0
@@ -271,7 +271,7 @@ class ComponentInfo:
|
|
271
271
|
cost: Optional[Dict[str, float]] = None
|
272
272
|
|
273
273
|
class Trace:
|
274
|
-
def __init__(self, id: str, trace_name: str, project_name: str, start_time: str, end_time: str, metadata: Optional[Metadata] = None, data: Optional[List[Dict[str, Any]]] = None, replays: Optional[Dict[str, Any]] = None
|
274
|
+
def __init__(self, id: str, trace_name: str, project_name: str, start_time: str, end_time: str, metadata: Optional[Metadata] = None, data: Optional[List[Dict[str, Any]]] = None, replays: Optional[Dict[str, Any]] = None):
|
275
275
|
self.id = id
|
276
276
|
self.trace_name = trace_name
|
277
277
|
self.project_name = project_name
|
@@ -280,7 +280,6 @@ class Trace:
|
|
280
280
|
self.metadata = metadata or Metadata()
|
281
281
|
self.data = data or []
|
282
282
|
self.replays = replays
|
283
|
-
self.metrics = metrics or []
|
284
283
|
|
285
284
|
def to_dict(self):
|
286
285
|
return {
|
@@ -289,8 +288,7 @@ class Trace:
|
|
289
288
|
"project_name": self.project_name,
|
290
289
|
"start_time": self.start_time,
|
291
290
|
"end_time": self.end_time,
|
292
|
-
"metadata": self.metadata,
|
291
|
+
"metadata": self.metadata.to_dict() if self.metadata else None,
|
293
292
|
"data": self.data,
|
294
293
|
"replays": self.replays,
|
295
|
-
"metrics": self.metrics
|
296
294
|
}
|
@@ -5,7 +5,7 @@ import psutil
|
|
5
5
|
import pkg_resources
|
6
6
|
from datetime import datetime
|
7
7
|
from pathlib import Path
|
8
|
-
from typing import List, Any
|
8
|
+
from typing import List, Any
|
9
9
|
import uuid
|
10
10
|
import sys
|
11
11
|
import tempfile
|
@@ -81,7 +81,6 @@ class BaseTracer:
|
|
81
81
|
self.project_id = self.user_details["project_id"] # Access the project_id
|
82
82
|
self.trace_name = self.user_details["trace_name"] # Access the trace_name
|
83
83
|
self.visited_metrics = []
|
84
|
-
self.trace_metrics = [] # Store metrics here
|
85
84
|
|
86
85
|
# Initialize trace data
|
87
86
|
self.trace_id = None
|
@@ -212,10 +211,6 @@ class BaseTracer:
|
|
212
211
|
threading.Thread(target=self._track_disk_usage).start()
|
213
212
|
threading.Thread(target=self._track_network_usage).start()
|
214
213
|
|
215
|
-
# Reset metrics
|
216
|
-
self.visited_metrics = []
|
217
|
-
self.trace_metrics = []
|
218
|
-
|
219
214
|
metadata = Metadata(
|
220
215
|
cost={},
|
221
216
|
tokens={},
|
@@ -246,7 +241,6 @@ class BaseTracer:
|
|
246
241
|
metadata=metadata,
|
247
242
|
data=self.data_key,
|
248
243
|
replays={"source": None},
|
249
|
-
metrics=[] # Initialize empty metrics list
|
250
244
|
)
|
251
245
|
|
252
246
|
def stop(self):
|
@@ -306,12 +300,8 @@ class BaseTracer:
|
|
306
300
|
# replace source code with zip_path
|
307
301
|
self.trace.metadata.system_info.source_code = hash_id
|
308
302
|
|
309
|
-
# Add metrics to trace before saving
|
310
|
-
trace_data = self.trace.to_dict()
|
311
|
-
|
312
|
-
trace_data["metrics"] = self.trace_metrics
|
313
|
-
|
314
303
|
# Clean up trace_data before saving
|
304
|
+
trace_data = self.trace.__dict__
|
315
305
|
cleaned_trace_data = self._clean_trace(trace_data)
|
316
306
|
|
317
307
|
# Format interactions and add to trace
|
@@ -619,7 +609,9 @@ class BaseTracer:
|
|
619
609
|
"span_id": child.get("id"),
|
620
610
|
"interaction_type": "llm_call_end",
|
621
611
|
"name": child.get("name"),
|
622
|
-
"content": {
|
612
|
+
"content": {
|
613
|
+
"response": child.get("data", {}).get("output")
|
614
|
+
},
|
623
615
|
"timestamp": child.get("end_time"),
|
624
616
|
"error": child.get("error"),
|
625
617
|
}
|
@@ -890,90 +882,8 @@ class BaseTracer:
|
|
890
882
|
|
891
883
|
return {"workflow": sorted_interactions}
|
892
884
|
|
893
|
-
def add_metrics(
|
894
|
-
self,
|
895
|
-
name: str | List[Dict[str, Any]] | Dict[str, Any] = None,
|
896
|
-
score: float | int = None,
|
897
|
-
reasoning: str = "",
|
898
|
-
cost: float = None,
|
899
|
-
latency: float = None,
|
900
|
-
metadata: Dict[str, Any] = None,
|
901
|
-
config: Dict[str, Any] = None,
|
902
|
-
):
|
903
|
-
"""Add metrics at the trace level.
|
904
|
-
|
905
|
-
Can be called in two ways:
|
906
|
-
1. With individual parameters:
|
907
|
-
tracer.add_metrics(name="metric_name", score=0.9, reasoning="Good performance")
|
908
|
-
|
909
|
-
2. With a dictionary or list of dictionaries:
|
910
|
-
tracer.add_metrics({"name": "metric_name", "score": 0.9})
|
911
|
-
tracer.add_metrics([{"name": "metric1", "score": 0.9}, {"name": "metric2", "score": 0.8}])
|
912
|
-
|
913
|
-
Args:
|
914
|
-
name: Either the metric name (str) or a metric dictionary/list of dictionaries
|
915
|
-
score: Score value (float or int) when using individual parameters
|
916
|
-
reasoning: Optional explanation for the score
|
917
|
-
cost: Optional cost associated with the metric
|
918
|
-
latency: Optional latency measurement
|
919
|
-
metadata: Optional additional metadata as key-value pairs
|
920
|
-
config: Optional configuration parameters
|
921
|
-
"""
|
922
|
-
if not hasattr(self, 'trace'):
|
923
|
-
logger.warning("Cannot add metrics before trace is initialized. Call start() first.")
|
924
|
-
return
|
925
|
-
|
926
|
-
# Convert individual parameters to metric dict if needed
|
927
|
-
if isinstance(name, str):
|
928
|
-
metrics = [{
|
929
|
-
"name": name,
|
930
|
-
"score": score,
|
931
|
-
"reasoning": reasoning,
|
932
|
-
"cost": cost,
|
933
|
-
"latency": latency,
|
934
|
-
"metadata": metadata or {},
|
935
|
-
"config": config or {}
|
936
|
-
}]
|
937
|
-
else:
|
938
|
-
# Handle dict or list input
|
939
|
-
metrics = name if isinstance(name, list) else [name] if isinstance(name, dict) else []
|
940
|
-
|
941
|
-
try:
|
942
|
-
for metric in metrics:
|
943
|
-
if not isinstance(metric, dict):
|
944
|
-
raise ValueError(f"Expected dict, got {type(metric)}")
|
945
|
-
|
946
|
-
if "name" not in metric or "score" not in metric:
|
947
|
-
raise ValueError("Metric must contain 'name' and 'score' fields")
|
948
|
-
|
949
|
-
# Handle duplicate metric names
|
950
|
-
metric_name = metric["name"]
|
951
|
-
if metric_name in self.visited_metrics:
|
952
|
-
count = sum(1 for m in self.visited_metrics if m.startswith(metric_name))
|
953
|
-
metric_name = f"{metric_name}_{count + 1}"
|
954
|
-
self.visited_metrics.append(metric_name)
|
955
|
-
|
956
|
-
formatted_metric = {
|
957
|
-
"name": metric_name, # Use potentially modified name
|
958
|
-
"score": metric["score"],
|
959
|
-
"reason": metric.get("reasoning", ""),
|
960
|
-
"source": "user",
|
961
|
-
"cost": metric.get("cost"),
|
962
|
-
"latency": metric.get("latency"),
|
963
|
-
"metadata": metric.get("metadata", {}),
|
964
|
-
"mappings": [],
|
965
|
-
"config": metric.get("config", {})
|
966
|
-
}
|
967
|
-
|
968
|
-
self.trace_metrics.append(formatted_metric)
|
969
|
-
logger.debug(f"Added trace-level metric: {formatted_metric}")
|
970
|
-
|
971
|
-
except ValueError as e:
|
972
|
-
logger.error(f"Validation Error: {e}")
|
973
|
-
except Exception as e:
|
974
|
-
logger.error(f"Error adding metric: {e}")
|
975
|
-
|
976
885
|
def span(self, span_name):
|
977
886
|
if span_name not in self.span_attributes_dict:
|
978
887
|
self.span_attributes_dict[span_name] = SpanAttributes(span_name)
|
979
|
-
return self.span_attributes_dict[span_name]
|
888
|
+
return self.span_attributes_dict[span_name]
|
889
|
+
|
@@ -59,13 +59,6 @@ def _get_children_metrics_of_agent(children_traces):
|
|
59
59
|
|
60
60
|
def get_trace_metrics_from_trace(traces):
|
61
61
|
metrics = []
|
62
|
-
|
63
|
-
# get trace level metrics
|
64
|
-
if "metrics" in traces.keys():
|
65
|
-
if len(traces["metrics"]) > 0:
|
66
|
-
metrics.extend(traces["metrics"])
|
67
|
-
|
68
|
-
# get span level metrics
|
69
62
|
for span in traces["data"][0]["spans"]:
|
70
63
|
if span["type"] == "agent":
|
71
64
|
children_metric = _get_children_metrics_of_agent(span["data"]["children"])
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.4.
|
3
|
+
Version: 2.1.4.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
6
|
Requires-Python: <3.13,>=3.9
|
@@ -18,7 +18,7 @@ ragaai_catalyst/tracers/upload_traces.py,sha256=mT5rverNUL5Rcal9VR5_c75wHBAUrm2p
|
|
18
18
|
ragaai_catalyst/tracers/agentic_tracing/README.md,sha256=X4QwLb7-Jg7GQMIXj-SerZIgDETfw-7VgYlczOR8ZeQ,4508
|
19
19
|
ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=yf6SKvOPSpH-9LiKaoLKXwqj5sez8F_5wkOb91yp0oE,260
|
20
20
|
ragaai_catalyst/tracers/agentic_tracing/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
|
-
ragaai_catalyst/tracers/agentic_tracing/data/data_structure.py,sha256=
|
21
|
+
ragaai_catalyst/tracers/agentic_tracing/data/data_structure.py,sha256=nFnwqL1-Uznwndi2ugDnhziUbIASlcBYnM6Dyq7pPt8,9243
|
22
22
|
ragaai_catalyst/tracers/agentic_tracing/tests/FinancialAnalysisSystem.ipynb,sha256=0qZxjWqYCTAVvdo3Tsp544D8Am48wfeMQ9RKpKgAL8g,34291
|
23
23
|
ragaai_catalyst/tracers/agentic_tracing/tests/GameActivityEventPlanner.ipynb,sha256=QCMFJYbGX0fd9eMW4PqyQLZjyWuTXo7n1nqO_hMLf0s,4225
|
24
24
|
ragaai_catalyst/tracers/agentic_tracing/tests/TravelPlanner.ipynb,sha256=fU3inXoemJbdTkGAQl_N1UwVEZ10LrKv4gCEpbQ4ISg,43481
|
@@ -27,7 +27,7 @@ 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=aLiq5nPie5TT61QYtvAtvErsxjPFYiUxjayn5aCX1_k,25543
|
30
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=
|
30
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=u2DX_BsMGsuJkWqN6ucxboMO8GnvOcArKJe5L08y-YI,35014
|
31
31
|
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=uay8lU7T-CKsVu8KvWX31qfMqufK9S3Ive7XKo2Ksmk,12252
|
32
32
|
ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
33
|
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=fn5qxb365GmQkJy_yZAY5TiiWRMFKPNJdYk8KFr8uWA,29343
|
@@ -38,7 +38,7 @@ ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py,sha25
|
|
38
38
|
ragaai_catalyst/tracers/agentic_tracing/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
39
|
ragaai_catalyst/tracers/agentic_tracing/upload/upload_agentic_traces.py,sha256=1MDKXAAPzOEdxFKWWQrRgrmM3kz--DGXSywGXQmR3lQ,6041
|
40
40
|
ragaai_catalyst/tracers/agentic_tracing/upload/upload_code.py,sha256=HgpMgI-JTWZrizcM7GGUIaAgaZF4aRT3D0dJXVEkblY,4271
|
41
|
-
ragaai_catalyst/tracers/agentic_tracing/upload/upload_trace_metric.py,sha256=
|
41
|
+
ragaai_catalyst/tracers/agentic_tracing/upload/upload_trace_metric.py,sha256=iFagpPltlg6aKvdyAFvXsuxyjUUjcHAMmvXlevL-uYM,3312
|
42
42
|
ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py,sha256=XdB3X_ufe4RVvGorxSqAiB9dYv4UD7Hvvuw3bsDUppY,60
|
43
43
|
ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py,sha256=JyNCbfpW-w4O9CjtemTqmor2Rh1WGpQwhRaDSRmBxw8,689
|
44
44
|
ragaai_catalyst/tracers/agentic_tracing/utils/create_dataset_schema.py,sha256=lgvJL0cakJrX8WGsnU05YGvotequSj6HgSohyR4OJNE,804
|
@@ -60,8 +60,8 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
|
|
60
60
|
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
61
61
|
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
62
62
|
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
63
|
-
ragaai_catalyst-2.1.4.
|
64
|
-
ragaai_catalyst-2.1.4.
|
65
|
-
ragaai_catalyst-2.1.4.
|
66
|
-
ragaai_catalyst-2.1.4.
|
67
|
-
ragaai_catalyst-2.1.4.
|
63
|
+
ragaai_catalyst-2.1.4.1b0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
64
|
+
ragaai_catalyst-2.1.4.1b0.dist-info/METADATA,sha256=V5fmS2GcC5Ykd7yakB0_gDvqRPKHxzTtkp7TCt6T3O4,12794
|
65
|
+
ragaai_catalyst-2.1.4.1b0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
66
|
+
ragaai_catalyst-2.1.4.1b0.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
67
|
+
ragaai_catalyst-2.1.4.1b0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|