ragaai-catalyst 2.1.5b16__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 -31
- {ragaai_catalyst-2.1.5b16.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/METADATA +1 -1
- {ragaai_catalyst-2.1.5b16.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/RECORD +6 -6
- {ragaai_catalyst-2.1.5b16.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b16.dist-info → ragaai_catalyst-2.1.5b18.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b16.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,
|
@@ -45,7 +47,6 @@ class LLMTracerMixin:
|
|
45
47
|
self.model_costs = load_model_costs()
|
46
48
|
except Exception as e:
|
47
49
|
self.model_costs = {
|
48
|
-
# TODO: Default cost handling needs to be improved
|
49
50
|
"default": {"input_cost_per_token": 0.0, "output_cost_per_token": 0.0}
|
50
51
|
}
|
51
52
|
self.MAX_PARAMETERS_TO_DISPLAY = 10
|
@@ -59,25 +60,31 @@ class LLMTracerMixin:
|
|
59
60
|
self.total_cost = 0.0
|
60
61
|
self.llm_data = {}
|
61
62
|
|
62
|
-
# Add auto_instrument options
|
63
63
|
self.auto_instrument_llm = False
|
64
64
|
self.auto_instrument_user_interaction = False
|
65
65
|
self.auto_instrument_file_io = False
|
66
66
|
self.auto_instrument_network = False
|
67
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
|
+
|
68
80
|
def instrument_llm_calls(self):
|
69
81
|
"""Enable LLM instrumentation"""
|
70
82
|
self.auto_instrument_llm = True
|
71
83
|
|
72
|
-
#
|
73
|
-
import sys
|
74
|
-
|
84
|
+
# Check currently loaded modules
|
75
85
|
if "vertexai" in sys.modules:
|
76
86
|
self.patch_vertex_ai_methods(sys.modules["vertexai"])
|
77
|
-
if "
|
78
|
-
self.patch_vertex_ai_methods(sys.modules["vertexai.generative_models"])
|
79
|
-
|
80
|
-
if "openai" in sys.modules:
|
87
|
+
if "openai" in sys.modules and self.validate_openai_key():
|
81
88
|
self.patch_openai_methods(sys.modules["openai"])
|
82
89
|
self.patch_openai_beta_methods(sys.modules["openai"])
|
83
90
|
if "litellm" in sys.modules:
|
@@ -87,32 +94,42 @@ class LLMTracerMixin:
|
|
87
94
|
if "google.generativeai" in sys.modules:
|
88
95
|
self.patch_google_genai_methods(sys.modules["google.generativeai"])
|
89
96
|
if "langchain_google_vertexai" in sys.modules:
|
90
|
-
self.patch_langchain_google_methods(
|
91
|
-
sys.modules["langchain_google_vertexai"]
|
92
|
-
)
|
97
|
+
self.patch_langchain_google_methods(sys.modules["langchain_google_vertexai"])
|
93
98
|
if "langchain_google_genai" in sys.modules:
|
94
99
|
self.patch_langchain_google_methods(sys.modules["langchain_google_genai"])
|
95
100
|
|
96
|
-
# Register hooks for future imports
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
)
|
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
|
+
)
|
108
122
|
|
109
|
-
# Add hooks for LangChain integrations
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
)
|
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
|
+
)
|
116
133
|
|
117
134
|
def instrument_user_interaction_calls(self):
|
118
135
|
"""Enable user interaction instrumentation for LLM calls"""
|
@@ -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
|