ragaai-catalyst 2.1.5b39__py3-none-any.whl → 2.1.5b41__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/main_tracer.py +1 -1
- ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +26 -7
- ragaai_catalyst/tracers/exporters/dynamic_trace_exporter.py +27 -12
- ragaai_catalyst/tracers/exporters/ragaai_trace_exporter.py +10 -2
- ragaai_catalyst/tracers/utils/trace_json_converter.py +10 -7
- {ragaai_catalyst-2.1.5b39.dist-info → ragaai_catalyst-2.1.5b41.dist-info}/METADATA +2 -2
- {ragaai_catalyst-2.1.5b39.dist-info → ragaai_catalyst-2.1.5b41.dist-info}/RECORD +10 -10
- {ragaai_catalyst-2.1.5b39.dist-info → ragaai_catalyst-2.1.5b41.dist-info}/WHEEL +1 -1
- {ragaai_catalyst-2.1.5b39.dist-info → ragaai_catalyst-2.1.5b41.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b39.dist-info → ragaai_catalyst-2.1.5b41.dist-info}/top_level.txt +0 -0
@@ -74,6 +74,10 @@ def extract_model_name(args, kwargs, result):
|
|
74
74
|
return "gemini-1.5-pro"
|
75
75
|
if "gemini-pro" in model:
|
76
76
|
return "gemini-pro"
|
77
|
+
|
78
|
+
if 'response_metadata' in dir(result):
|
79
|
+
if 'model_name' in result.response_metadata:
|
80
|
+
model = result.response_metadata['model_name']
|
77
81
|
|
78
82
|
return model or "default"
|
79
83
|
|
@@ -116,8 +120,8 @@ def extract_token_usage(result):
|
|
116
120
|
# Run the coroutine in the current event loop
|
117
121
|
result = loop.run_until_complete(result)
|
118
122
|
|
119
|
-
# Handle text attribute responses (JSON string
|
120
|
-
if hasattr(result, "text"):
|
123
|
+
# Handle text attribute responses (JSON string for Vertex AI)
|
124
|
+
if hasattr(result, "text") and isinstance(result.text, (str, bytes, bytearray)):
|
121
125
|
# First try parsing as JSON for OpenAI responses
|
122
126
|
try:
|
123
127
|
import json
|
@@ -162,11 +166,26 @@ def extract_token_usage(result):
|
|
162
166
|
# Handle Google GenerativeAI format with usage_metadata
|
163
167
|
if hasattr(result, "usage_metadata"):
|
164
168
|
metadata = result.usage_metadata
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
169
|
+
if hasattr(metadata, "prompt_token_count"):
|
170
|
+
return {
|
171
|
+
"prompt_tokens": getattr(metadata, "prompt_token_count", 0),
|
172
|
+
"completion_tokens": getattr(metadata, "candidates_token_count", 0),
|
173
|
+
"total_tokens": getattr(metadata, "total_token_count", 0)
|
174
|
+
}
|
175
|
+
elif hasattr(metadata, "input_tokens"):
|
176
|
+
return {
|
177
|
+
"prompt_tokens": getattr(metadata, "input_tokens", 0),
|
178
|
+
"completion_tokens": getattr(metadata, "output_tokens", 0),
|
179
|
+
"total_tokens": getattr(metadata, "total_tokens", 0)
|
180
|
+
}
|
181
|
+
elif "input_tokens" in metadata:
|
182
|
+
return {
|
183
|
+
"prompt_tokens": metadata["input_tokens"],
|
184
|
+
"completion_tokens": metadata["output_tokens"],
|
185
|
+
"total_tokens": metadata["total_tokens"]
|
186
|
+
}
|
187
|
+
|
188
|
+
|
170
189
|
|
171
190
|
# Handle ChatResponse format with raw usuage
|
172
191
|
if hasattr(result, "raw") and hasattr(result.raw, "usage"):
|
@@ -42,7 +42,7 @@ class DynamicTraceExporter(SpanExporter):
|
|
42
42
|
self._project_id = project_id
|
43
43
|
self._dataset_name = dataset_name
|
44
44
|
self._user_details = user_details
|
45
|
-
self._base_url = base_url
|
45
|
+
self._base_url = base_url
|
46
46
|
self._custom_model_cost = custom_model_cost
|
47
47
|
|
48
48
|
|
@@ -57,22 +57,37 @@ class DynamicTraceExporter(SpanExporter):
|
|
57
57
|
Returns:
|
58
58
|
SpanExportResult: Result of the export operation
|
59
59
|
"""
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
try:
|
61
|
+
# Update the exporter's properties
|
62
|
+
self._update_exporter_properties()
|
63
|
+
except Exception as e:
|
64
|
+
raise Exception(f"Error updating exporter properties: {e}")
|
65
|
+
|
66
|
+
try:
|
67
|
+
# Forward the call to the underlying exporter
|
68
|
+
result = self._exporter.export(spans)
|
69
|
+
return result
|
70
|
+
except Exception as e:
|
71
|
+
raise Exception(f"Error exporting trace: {e}")
|
72
|
+
|
73
|
+
|
74
|
+
|
66
75
|
def shutdown(self):
|
67
76
|
"""
|
68
77
|
Shutdown the exporter by forwarding to the underlying exporter.
|
69
78
|
Before shutting down, update the exporter's properties with the current values.
|
70
79
|
"""
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
80
|
+
try:
|
81
|
+
# Update the exporter's properties
|
82
|
+
self._update_exporter_properties()
|
83
|
+
except Exception as e:
|
84
|
+
raise Exception(f"Error updating exporter properties: {e}")
|
85
|
+
|
86
|
+
try:
|
87
|
+
# Forward the call to the underlying exporter
|
88
|
+
return self._exporter.shutdown()
|
89
|
+
except Exception as e:
|
90
|
+
raise Exception(f"Error shutting down exporter: {e}")
|
76
91
|
|
77
92
|
def _update_exporter_properties(self):
|
78
93
|
"""
|
@@ -35,6 +35,8 @@ class RAGATraceExporter(SpanExporter):
|
|
35
35
|
for span in spans:
|
36
36
|
span_json = json.loads(span.to_json())
|
37
37
|
trace_id = span_json.get("context").get("trace_id")
|
38
|
+
if trace_id is None:
|
39
|
+
raise Exception("Trace ID is None")
|
38
40
|
|
39
41
|
if trace_id not in self.trace_spans:
|
40
42
|
self.trace_spans[trace_id] = list()
|
@@ -43,8 +45,14 @@ class RAGATraceExporter(SpanExporter):
|
|
43
45
|
|
44
46
|
if span_json["parent_id"] is None:
|
45
47
|
trace = self.trace_spans[trace_id]
|
46
|
-
|
47
|
-
|
48
|
+
try:
|
49
|
+
self.process_complete_trace(trace, trace_id)
|
50
|
+
except Exception as e:
|
51
|
+
raise Exception(f"Error processing complete trace: {e}")
|
52
|
+
try:
|
53
|
+
del self.trace_spans[trace_id]
|
54
|
+
except Exception as e:
|
55
|
+
raise Exception(f"Error deleting trace: {e}")
|
48
56
|
|
49
57
|
return SpanExportResult.SUCCESS
|
50
58
|
|
@@ -223,7 +223,10 @@ def convert_json_format(input_trace, custom_model_cost):
|
|
223
223
|
}
|
224
224
|
final_trace["replays"]={"source":None}
|
225
225
|
final_trace["data"]=[{}]
|
226
|
-
|
226
|
+
try:
|
227
|
+
final_trace["data"][0]["spans"] = get_spans(input_trace, custom_model_cost)
|
228
|
+
except Exception as e:
|
229
|
+
raise Exception(f"Error in get_spans function: {e}")
|
227
230
|
final_trace["network_calls"] =[]
|
228
231
|
final_trace["interactions"] = []
|
229
232
|
|
@@ -231,15 +234,15 @@ def convert_json_format(input_trace, custom_model_cost):
|
|
231
234
|
if itr["type"]=="llm":
|
232
235
|
if "tokens" in itr["info"]:
|
233
236
|
if "prompt_tokens" in itr["info"]["tokens"]:
|
234
|
-
final_trace["metadata"]["tokens"]["prompt_tokens"] += itr["info"]["tokens"]
|
235
|
-
final_trace["metadata"]["cost"]["input_cost"] += itr["info"]["cost"]
|
237
|
+
final_trace["metadata"]["tokens"]["prompt_tokens"] += itr["info"]["tokens"].get('prompt_tokens', 0.0)
|
238
|
+
final_trace["metadata"]["cost"]["input_cost"] += itr["info"]["cost"].get('input_cost', 0.0)
|
236
239
|
if "completion_tokens" in itr["info"]["tokens"]:
|
237
|
-
final_trace["metadata"]["tokens"]["completion_tokens"] += itr["info"]["tokens"]
|
238
|
-
final_trace["metadata"]["cost"]["output_cost"] += itr["info"]["cost"]
|
240
|
+
final_trace["metadata"]["tokens"]["completion_tokens"] += itr["info"]["tokens"].get('completion_tokens', 0.0)
|
241
|
+
final_trace["metadata"]["cost"]["output_cost"] += itr["info"]["cost"].get('output_cost', 0.0)
|
239
242
|
if "tokens" in itr["info"]:
|
240
243
|
if "total_tokens" in itr["info"]["tokens"]:
|
241
|
-
final_trace["metadata"]["tokens"]["total_tokens"] += itr["info"]["tokens"]
|
242
|
-
final_trace["metadata"]["cost"]["total_cost"] += itr["info"]["cost"]
|
244
|
+
final_trace["metadata"]["tokens"]["total_tokens"] += itr["info"]["tokens"].get('total_tokens', 0.0)
|
245
|
+
final_trace["metadata"]["cost"]["total_cost"] += itr["info"]["cost"].get('total_cost', 0.0)
|
243
246
|
|
244
247
|
# get the total tokens, cost
|
245
248
|
final_trace["metadata"]["total_cost"] = final_trace["metadata"]["cost"]["total_cost"]
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b41
|
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>, Tushar Kumar <tushar.kumar@raga.ai>
|
6
|
-
Requires-Python: <3.13,>=3.
|
6
|
+
Requires-Python: <3.13,>=3.9
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
License-File: LICENSE
|
9
9
|
Requires-Dist: aiohttp>=3.10.2
|
@@ -49,7 +49,7 @@ ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=Kmy1kgwy19e7MuMMq
|
|
49
49
|
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=OBJJjFSvwRjCGNJyqX3yIfC1W05ZN2QUXasCJ4gmCjQ,13930
|
50
50
|
ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
51
|
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=z-qzmCQCkhyW0aLDUR_rNq4pmxhAaVhNY-kZQsox-Ws,50221
|
52
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=
|
52
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=aiFobQb5ePPhyRADXJTZgI8_PrSGhjXnOu9W_o3ngEA,16148
|
53
53
|
ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=m8CxYkl7iMiFya_lNwN1ykBc3Pmo-2pR_2HmpptwHWQ,10352
|
54
54
|
ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=xxrliKPfdfbIZRZqMnUewsaTD8_Hv0dbuoBivNZGD4U,21674
|
55
55
|
ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py,sha256=bhSUhNQCuJXKjgJAXhjKEYjnHMpYN90FSZdR84fNIKU,4614
|
@@ -65,7 +65,7 @@ ragaai_catalyst/tracers/agentic_tracing/utils/create_dataset_schema.py,sha256=xH
|
|
65
65
|
ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py,sha256=YG601l1a29ov9VPu9Vl4RXxgL7l16k54_WWnoTNoG58,2064
|
66
66
|
ragaai_catalyst/tracers/agentic_tracing/utils/generic.py,sha256=WwXT01xmp8MSr7KinuDCSK9a1ifpLcT7ajFkvYviG_A,1190
|
67
67
|
ragaai_catalyst/tracers/agentic_tracing/utils/get_user_trace_metrics.py,sha256=vPZ4dn4EHFW0kqd1GyRpsYXbfrRrd0DXCmh-pzsDBNE,1109
|
68
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=
|
68
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=McKB7TQchmFcgg2h0zg-inuxxKaRjcwbqV_OnRzzYEw,22387
|
69
69
|
ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=2tzGw_cKCTPcfjEm7iGvFE6pTw7gMTPzeBov_MTaXNY,321336
|
70
70
|
ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py,sha256=qmODERcFZhc8MX24boFCXkkh6sJ-vZngRHPvxhyWFeE,4347
|
71
71
|
ragaai_catalyst/tracers/agentic_tracing/utils/supported_llm_provider.toml,sha256=LvFDivDIE96Zasp-fgDEqUJ5GEQZUawQucR3aOcSUTY,926
|
@@ -74,10 +74,10 @@ ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py,sha256=go7FVnofviAT
|
|
74
74
|
ragaai_catalyst/tracers/agentic_tracing/utils/unique_decorator.py,sha256=G027toV-Km20JjKrc-Y_PilQ8ABEKrBvvzgLTnqVg7I,5819
|
75
75
|
ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py,sha256=4TeCGsFF26249fV6dJHLTZDrRa93SG9oer4rudoF8Y4,19443
|
76
76
|
ragaai_catalyst/tracers/exporters/__init__.py,sha256=wQbaqyeIjVZxYprHCKZ9BeiqxeXYBKjzEgP79LWNxCU,293
|
77
|
-
ragaai_catalyst/tracers/exporters/dynamic_trace_exporter.py,sha256=
|
77
|
+
ragaai_catalyst/tracers/exporters/dynamic_trace_exporter.py,sha256=w9U8UTxvTbGTDUoMtsgy2BsdpYp-APTKFdGV4o5JPaM,5051
|
78
78
|
ragaai_catalyst/tracers/exporters/file_span_exporter.py,sha256=RgGteu-NVGprXKkynvyIO5yOjpbtA41R3W_NzCjnkwE,6445
|
79
79
|
ragaai_catalyst/tracers/exporters/raga_exporter.py,sha256=6xvjWXyh8XPkHKSLLmAZUQSvwuyY17ov8pv2VdfI0qA,17875
|
80
|
-
ragaai_catalyst/tracers/exporters/ragaai_trace_exporter.py,sha256=
|
80
|
+
ragaai_catalyst/tracers/exporters/ragaai_trace_exporter.py,sha256=s8zIUMrUKhtGrg-32XZnlJPKXWSyHo_WiJ1DoTcHVRg,5170
|
81
81
|
ragaai_catalyst/tracers/instrumentators/__init__.py,sha256=FgnMQupoRTzmVsG9YKsLQera2Pfs-AluZv8CxwavoyQ,253
|
82
82
|
ragaai_catalyst/tracers/instrumentators/langchain.py,sha256=yMN0qVF0pUVk6R5M1vJoUXezDo1ejs4klCFRlE8x4vE,574
|
83
83
|
ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hakE8rkrWHxMlmtmWD-AX6TeByc,416
|
@@ -88,10 +88,10 @@ ragaai_catalyst/tracers/utils/convert_llama_instru_callback.py,sha256=8qLo7x4Zsn
|
|
88
88
|
ragaai_catalyst/tracers/utils/extraction_logic_llama_index.py,sha256=ZhPs0YhVtB82-Pq9o1BvCinKE_WPvVxPTEcZjlJbFYM,2371
|
89
89
|
ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py,sha256=XS2_x2qneqEx9oAighLg-LRiueWcESLwIC2r7eJT-Ww,3117
|
90
90
|
ragaai_catalyst/tracers/utils/model_prices_and_context_window_backup.json,sha256=C3uwkibJ08C9sOX-54kulZYmJlIpZ-SQpfE6HNGrjbM,343502
|
91
|
-
ragaai_catalyst/tracers/utils/trace_json_converter.py,sha256=
|
91
|
+
ragaai_catalyst/tracers/utils/trace_json_converter.py,sha256=qXSYKr4JMUpGQsB3mnr9_2qH6FqzUhCynNqlDp1IWTs,12440
|
92
92
|
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
93
|
-
ragaai_catalyst-2.1.
|
94
|
-
ragaai_catalyst-2.1.
|
95
|
-
ragaai_catalyst-2.1.
|
96
|
-
ragaai_catalyst-2.1.
|
97
|
-
ragaai_catalyst-2.1.
|
93
|
+
ragaai_catalyst-2.1.5b41.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
94
|
+
ragaai_catalyst-2.1.5b41.dist-info/METADATA,sha256=CrlkR9TD7BsrlN3EbTlxlCqOKuk2GFWLMGJV3hqkHJQ,22060
|
95
|
+
ragaai_catalyst-2.1.5b41.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
96
|
+
ragaai_catalyst-2.1.5b41.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
97
|
+
ragaai_catalyst-2.1.5b41.dist-info/RECORD,,
|
File without changes
|
File without changes
|