ragaai-catalyst 2.1.5b17__py3-none-any.whl → 2.1.5b19__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 +21 -10
- ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +48 -33
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b19.dist-info}/METADATA +2 -2
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b19.dist-info}/RECORD +7 -7
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b19.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b19.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b19.dist-info}/top_level.txt +0 -0
@@ -188,21 +188,32 @@ class BaseTracer:
|
|
188
188
|
self.trace.metadata.resources.cpu.values = self.cpu_usage_list
|
189
189
|
|
190
190
|
#track network and disk usage
|
191
|
-
|
191
|
+
network_uploads, network_downloads = 0, 0
|
192
192
|
disk_read, disk_write = 0, 0
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
193
|
+
|
194
|
+
# Handle cases where lists might have different lengths
|
195
|
+
min_len = min(len(self.network_usage_list), len(self.disk_usage_list))
|
196
|
+
for i in range(min_len):
|
197
|
+
network_usage = self.network_usage_list[i]
|
198
|
+
disk_usage = self.disk_usage_list[i]
|
199
|
+
|
200
|
+
# Safely get network usage values with defaults of 0
|
201
|
+
network_uploads += network_usage.get('uploads', 0) or 0
|
202
|
+
network_downloads += network_usage.get('downloads', 0) or 0
|
203
|
+
|
204
|
+
# Safely get disk usage values with defaults of 0
|
205
|
+
disk_read += disk_usage.get('disk_read', 0) or 0
|
206
|
+
disk_write += disk_usage.get('disk_write', 0) or 0
|
198
207
|
|
199
208
|
#track disk usage
|
200
|
-
|
201
|
-
self.trace.metadata.resources.disk.
|
209
|
+
disk_list_len = len(self.disk_usage_list)
|
210
|
+
self.trace.metadata.resources.disk.read = [disk_read / disk_list_len if disk_list_len > 0 else 0]
|
211
|
+
self.trace.metadata.resources.disk.write = [disk_write / disk_list_len if disk_list_len > 0 else 0]
|
202
212
|
|
203
213
|
#track network usage
|
204
|
-
|
205
|
-
self.trace.metadata.resources.network.
|
214
|
+
network_list_len = len(self.network_usage_list)
|
215
|
+
self.trace.metadata.resources.network.uploads = [network_uploads / network_list_len if network_list_len > 0 else 0]
|
216
|
+
self.trace.metadata.resources.network.downloads = [network_downloads / network_list_len if network_list_len > 0 else 0]
|
206
217
|
|
207
218
|
# update interval time
|
208
219
|
self.trace.metadata.resources.cpu.interval = float(self.interval_time)
|
@@ -10,6 +10,8 @@ from datetime import datetime
|
|
10
10
|
import uuid
|
11
11
|
import contextvars
|
12
12
|
import traceback
|
13
|
+
import importlib
|
14
|
+
import sys
|
13
15
|
|
14
16
|
from ..utils.llm_utils import (
|
15
17
|
extract_model_name,
|
@@ -63,19 +65,26 @@ class LLMTracerMixin:
|
|
63
65
|
self.auto_instrument_file_io = False
|
64
66
|
self.auto_instrument_network = False
|
65
67
|
|
68
|
+
def check_package_available(self, package_name):
|
69
|
+
"""Check if a package is available in the environment"""
|
70
|
+
try:
|
71
|
+
importlib.import_module(package_name)
|
72
|
+
return True
|
73
|
+
except ImportError:
|
74
|
+
return False
|
75
|
+
|
76
|
+
def validate_openai_key(self):
|
77
|
+
"""Validate if OpenAI API key is available"""
|
78
|
+
return bool(os.getenv("OPENAI_API_KEY"))
|
79
|
+
|
66
80
|
def instrument_llm_calls(self):
|
67
81
|
"""Enable LLM instrumentation"""
|
68
82
|
self.auto_instrument_llm = True
|
69
83
|
|
70
|
-
#
|
71
|
-
import sys
|
72
|
-
|
84
|
+
# Check currently loaded modules
|
73
85
|
if "vertexai" in sys.modules:
|
74
86
|
self.patch_vertex_ai_methods(sys.modules["vertexai"])
|
75
|
-
if "
|
76
|
-
self.patch_vertex_ai_methods(sys.modules["vertexai.generative_models"])
|
77
|
-
|
78
|
-
if "openai" in sys.modules:
|
87
|
+
if "openai" in sys.modules and self.validate_openai_key():
|
79
88
|
self.patch_openai_methods(sys.modules["openai"])
|
80
89
|
self.patch_openai_beta_methods(sys.modules["openai"])
|
81
90
|
if "litellm" in sys.modules:
|
@@ -85,32 +94,42 @@ class LLMTracerMixin:
|
|
85
94
|
if "google.generativeai" in sys.modules:
|
86
95
|
self.patch_google_genai_methods(sys.modules["google.generativeai"])
|
87
96
|
if "langchain_google_vertexai" in sys.modules:
|
88
|
-
self.patch_langchain_google_methods(
|
89
|
-
sys.modules["langchain_google_vertexai"]
|
90
|
-
)
|
97
|
+
self.patch_langchain_google_methods(sys.modules["langchain_google_vertexai"])
|
91
98
|
if "langchain_google_genai" in sys.modules:
|
92
99
|
self.patch_langchain_google_methods(sys.modules["langchain_google_genai"])
|
93
100
|
|
94
|
-
# Register hooks for future imports
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
)
|
101
|
+
# Register hooks for future imports with availability checks
|
102
|
+
if self.check_package_available("vertexai"):
|
103
|
+
wrapt.register_post_import_hook(self.patch_vertex_ai_methods, "vertexai")
|
104
|
+
wrapt.register_post_import_hook(
|
105
|
+
self.patch_vertex_ai_methods, "vertexai.generative_models"
|
106
|
+
)
|
107
|
+
|
108
|
+
if self.check_package_available("openai") and self.validate_openai_key():
|
109
|
+
wrapt.register_post_import_hook(self.patch_openai_methods, "openai")
|
110
|
+
wrapt.register_post_import_hook(self.patch_openai_beta_methods, "openai")
|
111
|
+
|
112
|
+
if self.check_package_available("litellm"):
|
113
|
+
wrapt.register_post_import_hook(self.patch_litellm_methods, "litellm")
|
114
|
+
|
115
|
+
if self.check_package_available("anthropic"):
|
116
|
+
wrapt.register_post_import_hook(self.patch_anthropic_methods, "anthropic")
|
117
|
+
|
118
|
+
if self.check_package_available("google.generativeai"):
|
119
|
+
wrapt.register_post_import_hook(
|
120
|
+
self.patch_google_genai_methods, "google.generativeai"
|
121
|
+
)
|
106
122
|
|
107
|
-
# Add hooks for LangChain integrations
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
)
|
123
|
+
# Add hooks for LangChain integrations with availability checks
|
124
|
+
if self.check_package_available("langchain_google_vertexai"):
|
125
|
+
wrapt.register_post_import_hook(
|
126
|
+
self.patch_langchain_google_methods, "langchain_google_vertexai"
|
127
|
+
)
|
128
|
+
|
129
|
+
if self.check_package_available("langchain_google_genai"):
|
130
|
+
wrapt.register_post_import_hook(
|
131
|
+
self.patch_langchain_google_methods, "langchain_google_genai"
|
132
|
+
)
|
114
133
|
|
115
134
|
def instrument_user_interaction_calls(self):
|
116
135
|
"""Enable user interaction instrumentation for LLM calls"""
|
@@ -256,10 +275,6 @@ class LLMTracerMixin:
|
|
256
275
|
self.wrap_method(chat_class, "acomplete")
|
257
276
|
|
258
277
|
def wrap_openai_client_methods(self, client_class):
|
259
|
-
# Skip if OpenAI is not being used (no API key set)
|
260
|
-
if not os.getenv("OPENAI_API_KEY"):
|
261
|
-
return
|
262
|
-
|
263
278
|
original_init = client_class.__init__
|
264
279
|
|
265
280
|
@functools.wraps(original_init)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b19
|
4
4
|
Summary: RAGA AI CATALYST
|
5
|
-
Author-email: Kiran Scaria <kiran.scaria@raga.ai>,
|
5
|
+
Author-email: Kiran Scaria <kiran.scaria@raga.ai>, Siddhartha Kosti <siddhartha.kosti@raga.ai>, Vijay Chaurasia <vijay.chaurasia@raga.ai>, Tanaya Pakhale <tanaya.pakhale@raga.ai>, Ritika Goel <ritika.goel@raga.ai>, Kedar Gaikwad <kedar.gaikwad@raga.ai>, Dushyant Mahajan <dushyant.mahajan@raga.ai>
|
6
6
|
Requires-Python: <3.13,>=3.9
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
License-File: LICENSE
|
@@ -29,10 +29,10 @@ ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py,sha256=S4rCcKzU
|
|
29
29
|
ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py,sha256=Xk1cLzs-2A3dgyBwRRnCWs7Eubki40FVonwd433hPN8,4805
|
30
30
|
ragaai_catalyst/tracers/agentic_tracing/tracers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
31
|
ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=8d6YovuWiyRZ_h3GQwV6G5WdHzr14ukXtxE_TK1WIUY,26365
|
32
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=
|
32
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=xzJKOpL0Wm5hAIJp80QidDsPaHRV3pkyTMAEQSJgbNQ,37987
|
33
33
|
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=OHet_Cphyrsq2CP4WiooTsWSgg3Rc1n8QsOl1s2vqdY,13480
|
34
34
|
ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=
|
35
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=OSRGwftAYpylvziXD50HGjEfEMe8k11-3SRSZKw2tHI,35255
|
36
36
|
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=JEwvFV6KdYcg8zt2qUTKmmPvrkEft0YNAyUYK6FWF7c,18335
|
37
37
|
ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=m8CxYkl7iMiFya_lNwN1ykBc3Pmo-2pR_2HmpptwHWQ,10352
|
38
38
|
ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=nmgkE3jRlTpq_uk6FYw0hTv2VgT8ejxvvBRL7gso39I,21037
|
@@ -66,8 +66,8 @@ ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpa
|
|
66
66
|
ragaai_catalyst/tracers/utils/convert_langchain_callbacks_output.py,sha256=ofrNrxf2b1hpjDh_zeaxiYq86azn1MF3kW8-ViYPEg0,1641
|
67
67
|
ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py,sha256=qK67fdUBz5Xr99ajqXbYf1ueKS1V3a3_XR0zCcN4iGI,3061
|
68
68
|
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
69
|
-
ragaai_catalyst-2.1.
|
70
|
-
ragaai_catalyst-2.1.
|
71
|
-
ragaai_catalyst-2.1.
|
72
|
-
ragaai_catalyst-2.1.
|
73
|
-
ragaai_catalyst-2.1.
|
69
|
+
ragaai_catalyst-2.1.5b19.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
70
|
+
ragaai_catalyst-2.1.5b19.dist-info/METADATA,sha256=GrXo-ai5bjeLWnyq2OVaWWMBYDkFWe3XXewhCbKX4_0,12837
|
71
|
+
ragaai_catalyst-2.1.5b19.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
72
|
+
ragaai_catalyst-2.1.5b19.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
73
|
+
ragaai_catalyst-2.1.5b19.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|