ragaai-catalyst 2.1.5b17__py3-none-any.whl → 2.1.5b18__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/llm_tracer.py +48 -33
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/METADATA +1 -1
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/RECORD +6 -6
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b17.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/top_level.txt +0 -0
@@ -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,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b18
|
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
|
@@ -32,7 +32,7 @@ ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=8d6YovuWi
|
|
32
32
|
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=88rX7OkOGEyVNECUrc4bYqODyulXve_-99d9ku5hBeQ,37373
|
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.5b18.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
70
|
+
ragaai_catalyst-2.1.5b18.dist-info/METADATA,sha256=U0TwkW7NhS1k21IvYfh-g5WtmMcFbeGJYQwl4L18xyc,12796
|
71
|
+
ragaai_catalyst-2.1.5b18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
72
|
+
ragaai_catalyst-2.1.5b18.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
73
|
+
ragaai_catalyst-2.1.5b18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|