ragaai-catalyst 2.1.5b1__py3-none-any.whl → 2.1.5b2__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/dataset.py +10 -10
- ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +50 -129
- ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +36 -0
- ragaai_catalyst/tracers/agentic_tracing/utils/system_monitor.py +215 -0
- {ragaai_catalyst-2.1.5b1.dist-info → ragaai_catalyst-2.1.5b2.dist-info}/METADATA +1 -1
- {ragaai_catalyst-2.1.5b1.dist-info → ragaai_catalyst-2.1.5b2.dist-info}/RECORD +9 -8
- {ragaai_catalyst-2.1.5b1.dist-info → ragaai_catalyst-2.1.5b2.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b1.dist-info → ragaai_catalyst-2.1.5b2.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b1.dist-info → ragaai_catalyst-2.1.5b2.dist-info}/top_level.txt +0 -0
ragaai_catalyst/dataset.py
CHANGED
@@ -434,17 +434,16 @@ class Dataset:
|
|
434
434
|
|
435
435
|
# Check response
|
436
436
|
response_data = response.json()
|
437
|
-
if
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
return response_data
|
437
|
+
if response_data.get('success', False):
|
438
|
+
print(f"{response_data['message']}")
|
439
|
+
else:
|
440
|
+
raise ValueError(response_data.get('message', 'Failed to add rows'))
|
442
441
|
|
443
442
|
except Exception as e:
|
444
443
|
logger.error(f"Error in add_rows_to_dataset: {e}")
|
445
444
|
raise
|
446
445
|
|
447
|
-
def add_columns(self,text_fields,dataset_name, column_name, provider, model,variables={}):
|
446
|
+
def add_columns(self, text_fields, dataset_name, column_name, provider, model, variables={}):
|
448
447
|
"""
|
449
448
|
Add a column to a dataset with dynamically fetched model parameters
|
450
449
|
|
@@ -571,7 +570,7 @@ class Dataset:
|
|
571
570
|
variable_specs.append({
|
572
571
|
"name": key,
|
573
572
|
"type": "string",
|
574
|
-
"schema":
|
573
|
+
"schema": "query"
|
575
574
|
})
|
576
575
|
add_column_payload["promptTemplate"]["variableSpecs"] = variable_specs
|
577
576
|
|
@@ -593,9 +592,10 @@ class Dataset:
|
|
593
592
|
response.raise_for_status()
|
594
593
|
response_data = response.json()
|
595
594
|
|
596
|
-
|
597
|
-
|
598
|
-
|
595
|
+
if response_data.get('success', False):
|
596
|
+
print(f"Column '{column_name}' added successfully to dataset '{dataset_name}'")
|
597
|
+
else:
|
598
|
+
raise ValueError(response_data.get('message', 'Failed to add column'))
|
599
599
|
|
600
600
|
except requests.exceptions.RequestException as e:
|
601
601
|
print(f"Error adding column: {e}")
|
@@ -1,8 +1,5 @@
|
|
1
1
|
import json
|
2
2
|
import os
|
3
|
-
import platform
|
4
|
-
import psutil
|
5
|
-
import pkg_resources
|
6
3
|
from datetime import datetime
|
7
4
|
from pathlib import Path
|
8
5
|
from typing import List, Any, Dict
|
@@ -16,20 +13,9 @@ from ..data.data_structure import (
|
|
16
13
|
Trace,
|
17
14
|
Metadata,
|
18
15
|
SystemInfo,
|
19
|
-
OSInfo,
|
20
|
-
EnvironmentInfo,
|
21
16
|
Resources,
|
22
|
-
CPUResource,
|
23
|
-
MemoryResource,
|
24
|
-
DiskResource,
|
25
|
-
NetworkResource,
|
26
|
-
ResourceInfo,
|
27
|
-
MemoryInfo,
|
28
|
-
DiskInfo,
|
29
|
-
NetworkInfo,
|
30
17
|
Component,
|
31
18
|
)
|
32
|
-
|
33
19
|
from ..upload.upload_agentic_traces import UploadAgenticTraces
|
34
20
|
from ..upload.upload_code import upload_code
|
35
21
|
from ..upload.upload_trace_metric import upload_trace_metric
|
@@ -37,9 +23,8 @@ from ..utils.file_name_tracker import TrackName
|
|
37
23
|
from ..utils.zip_list_of_unique_files import zip_list_of_unique_files
|
38
24
|
from ..utils.span_attributes import SpanAttributes
|
39
25
|
from ..utils.create_dataset_schema import create_dataset_schema_with_trace
|
26
|
+
from ..utils.system_monitor import SystemMonitor
|
40
27
|
|
41
|
-
|
42
|
-
# Configure logging to show debug messages (which includes info messages as well)
|
43
28
|
import logging
|
44
29
|
|
45
30
|
logger = logging.getLogger(__name__)
|
@@ -76,12 +61,12 @@ class TracerJSONEncoder(json.JSONEncoder):
|
|
76
61
|
class BaseTracer:
|
77
62
|
def __init__(self, user_details):
|
78
63
|
self.user_details = user_details
|
79
|
-
self.project_name = self.user_details["project_name"]
|
80
|
-
self.dataset_name = self.user_details["dataset_name"]
|
81
|
-
self.project_id = self.user_details["project_id"]
|
82
|
-
self.trace_name = self.user_details["trace_name"]
|
64
|
+
self.project_name = self.user_details["project_name"]
|
65
|
+
self.dataset_name = self.user_details["dataset_name"]
|
66
|
+
self.project_id = self.user_details["project_id"]
|
67
|
+
self.trace_name = self.user_details["trace_name"]
|
83
68
|
self.visited_metrics = []
|
84
|
-
self.trace_metrics = []
|
69
|
+
self.trace_metrics = []
|
85
70
|
|
86
71
|
# Initialize trace data
|
87
72
|
self.trace_id = None
|
@@ -97,117 +82,60 @@ class BaseTracer:
|
|
97
82
|
self.network_usage_list = []
|
98
83
|
self.tracking_thread = None
|
99
84
|
self.tracking = False
|
85
|
+
self.system_monitor = None
|
100
86
|
|
101
87
|
def _get_system_info(self) -> SystemInfo:
|
102
|
-
|
103
|
-
os_info = OSInfo(
|
104
|
-
name=platform.system(),
|
105
|
-
version=platform.version(),
|
106
|
-
platform=platform.machine(),
|
107
|
-
kernel_version=platform.release(),
|
108
|
-
)
|
109
|
-
|
110
|
-
# Get Python environment info
|
111
|
-
installed_packages = [
|
112
|
-
f"{pkg.key}=={pkg.version}" for pkg in pkg_resources.working_set
|
113
|
-
]
|
114
|
-
env_info = EnvironmentInfo(
|
115
|
-
name="Python",
|
116
|
-
version=platform.python_version(),
|
117
|
-
packages=installed_packages,
|
118
|
-
env_path=sys.prefix,
|
119
|
-
command_to_run=f"python {sys.argv[0]}",
|
120
|
-
)
|
121
|
-
|
122
|
-
return SystemInfo(
|
123
|
-
id=f"sys_{self.trace_id}",
|
124
|
-
os=os_info,
|
125
|
-
environment=env_info,
|
126
|
-
source_code="Path to the source code .zip file in format hashid.zip", # TODO: Implement source code archiving
|
127
|
-
)
|
88
|
+
return self.system_monitor.get_system_info()
|
128
89
|
|
129
90
|
def _get_resources(self) -> Resources:
|
130
|
-
|
131
|
-
cpu_info = ResourceInfo(
|
132
|
-
name=platform.processor(),
|
133
|
-
cores=psutil.cpu_count(logical=False),
|
134
|
-
threads=psutil.cpu_count(logical=True),
|
135
|
-
)
|
136
|
-
cpu = CPUResource(info=cpu_info, interval="5s", values=[psutil.cpu_percent()])
|
137
|
-
|
138
|
-
# Memory info
|
139
|
-
memory = psutil.virtual_memory()
|
140
|
-
mem_info = MemoryInfo(
|
141
|
-
total=memory.total / (1024**3), # Convert to GB
|
142
|
-
free=memory.available / (1024**3),
|
143
|
-
)
|
144
|
-
mem = MemoryResource(info=mem_info, interval="5s", values=[memory.percent])
|
145
|
-
|
146
|
-
# Disk info
|
147
|
-
disk = psutil.disk_usage("/")
|
148
|
-
disk_info = DiskInfo(total=disk.total / (1024**3), free=disk.free / (1024**3))
|
149
|
-
disk_io = psutil.disk_io_counters()
|
150
|
-
disk_resource = DiskResource(
|
151
|
-
info=disk_info,
|
152
|
-
interval="5s",
|
153
|
-
read=[disk_io.read_bytes / (1024**2)], # MB
|
154
|
-
write=[disk_io.write_bytes / (1024**2)],
|
155
|
-
)
|
156
|
-
|
157
|
-
# Network info
|
158
|
-
net_io = psutil.net_io_counters()
|
159
|
-
net_info = NetworkInfo(
|
160
|
-
upload_speed=net_io.bytes_sent / (1024**2), # MB
|
161
|
-
download_speed=net_io.bytes_recv / (1024**2),
|
162
|
-
)
|
163
|
-
net = NetworkResource(
|
164
|
-
info=net_info,
|
165
|
-
interval="5s",
|
166
|
-
uploads=[net_io.bytes_sent / (1024**2)],
|
167
|
-
downloads=[net_io.bytes_recv / (1024**2)],
|
168
|
-
)
|
169
|
-
|
170
|
-
return Resources(cpu=cpu, memory=mem, disk=disk_resource, network=net)
|
91
|
+
return self.system_monitor.get_resources()
|
171
92
|
|
172
93
|
def _track_memory_usage(self):
|
173
94
|
self.memory_usage_list = []
|
174
95
|
while self.tracking:
|
175
|
-
|
176
|
-
self.memory_usage_list.append(
|
177
|
-
|
96
|
+
usage = self.system_monitor.track_memory_usage()
|
97
|
+
self.memory_usage_list.append(usage)
|
98
|
+
try:
|
99
|
+
time.sleep(self.interval_time)
|
100
|
+
except Exception as e:
|
101
|
+
logger.warning(f"Sleep interrupted in memory tracking: {str(e)}")
|
178
102
|
|
179
103
|
def _track_cpu_usage(self):
|
180
104
|
self.cpu_usage_list = []
|
181
105
|
while self.tracking:
|
182
|
-
|
183
|
-
self.cpu_usage_list.append(
|
184
|
-
|
106
|
+
usage = self.system_monitor.track_cpu_usage(self.interval_time)
|
107
|
+
self.cpu_usage_list.append(usage)
|
108
|
+
try:
|
109
|
+
time.sleep(self.interval_time)
|
110
|
+
except Exception as e:
|
111
|
+
logger.warning(f"Sleep interrupted in CPU tracking: {str(e)}")
|
185
112
|
|
186
113
|
def _track_disk_usage(self):
|
187
114
|
self.disk_usage_list = []
|
188
115
|
while self.tracking:
|
189
|
-
|
190
|
-
self.disk_usage_list.append(
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
116
|
+
usage = self.system_monitor.track_disk_usage()
|
117
|
+
self.disk_usage_list.append(usage)
|
118
|
+
try:
|
119
|
+
time.sleep(self.interval_time)
|
120
|
+
except Exception as e:
|
121
|
+
logger.warning(f"Sleep interrupted in disk tracking: {str(e)}")
|
195
122
|
|
196
123
|
def _track_network_usage(self):
|
197
124
|
self.network_usage_list = []
|
198
125
|
while self.tracking:
|
199
|
-
|
200
|
-
self.network_usage_list.append(
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
126
|
+
usage = self.system_monitor.track_network_usage()
|
127
|
+
self.network_usage_list.append(usage)
|
128
|
+
try:
|
129
|
+
time.sleep(self.interval_time)
|
130
|
+
except Exception as e:
|
131
|
+
logger.warning(f"Sleep interrupted in network tracking: {str(e)}")
|
205
132
|
|
206
133
|
def start(self):
|
207
134
|
"""Initialize a new trace"""
|
208
135
|
self.tracking = True
|
209
|
-
self.
|
210
|
-
self.
|
136
|
+
self.trace_id = str(uuid.uuid4())
|
137
|
+
self.system_monitor = SystemMonitor(self.trace_id)
|
138
|
+
threading.Thread(target=self._track_memory_usage).start()
|
211
139
|
threading.Thread(target=self._track_cpu_usage).start()
|
212
140
|
threading.Thread(target=self._track_disk_usage).start()
|
213
141
|
threading.Thread(target=self._track_network_usage).start()
|
@@ -223,9 +151,6 @@ class BaseTracer:
|
|
223
151
|
resources=self._get_resources(),
|
224
152
|
)
|
225
153
|
|
226
|
-
# Generate a unique trace ID, when trace starts
|
227
|
-
self.trace_id = str(uuid.uuid4())
|
228
|
-
|
229
154
|
# Get the start time
|
230
155
|
self.start_time = datetime.now().astimezone().isoformat()
|
231
156
|
|
@@ -257,8 +182,6 @@ class BaseTracer:
|
|
257
182
|
|
258
183
|
#track memory usage
|
259
184
|
self.tracking = False
|
260
|
-
if self.tracking_thread is not None:
|
261
|
-
self.tracking_thread.join()
|
262
185
|
self.trace.metadata.resources.memory.values = self.memory_usage_list
|
263
186
|
|
264
187
|
#track cpu usage
|
@@ -695,12 +618,11 @@ class BaseTracer:
|
|
695
618
|
# Process additional interactions and network calls
|
696
619
|
if "interactions" in child:
|
697
620
|
for interaction in child["interactions"]:
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
interaction_id += 1
|
621
|
+
interaction["id"] = str(interaction_id)
|
622
|
+
interaction["span_id"] = child.get("id")
|
623
|
+
interaction["error"] = None
|
624
|
+
interactions.append(interaction)
|
625
|
+
interaction_id += 1
|
704
626
|
|
705
627
|
if "network_calls" in child:
|
706
628
|
for child_network_call in child["network_calls"]:
|
@@ -877,16 +799,15 @@ class BaseTracer:
|
|
877
799
|
# Process interactions from span.data if they exist
|
878
800
|
if span.interactions:
|
879
801
|
for span_interaction in span.interactions:
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
interaction_id += 1
|
802
|
+
interaction = {}
|
803
|
+
interaction["id"] = str(interaction_id)
|
804
|
+
interaction["span_id"] = span.id
|
805
|
+
interaction["interaction_type"] = span_interaction.type
|
806
|
+
interaction["content"] = span_interaction.content
|
807
|
+
interaction["timestamp"] = span_interaction.timestamp
|
808
|
+
interaction["error"] = span.error
|
809
|
+
interactions.append(interaction)
|
810
|
+
interaction_id += 1
|
890
811
|
|
891
812
|
if span.network_calls:
|
892
813
|
for span_network_call in span.network_calls:
|
@@ -78,6 +78,7 @@ class LLMTracerMixin:
|
|
78
78
|
|
79
79
|
if "openai" in sys.modules:
|
80
80
|
self.patch_openai_methods(sys.modules["openai"])
|
81
|
+
self.patch_openai_beta_methods(sys.modules["openai"])
|
81
82
|
if "litellm" in sys.modules:
|
82
83
|
self.patch_litellm_methods(sys.modules["litellm"])
|
83
84
|
if "anthropic" in sys.modules:
|
@@ -97,6 +98,7 @@ class LLMTracerMixin:
|
|
97
98
|
self.patch_vertex_ai_methods, "vertexai.generative_models"
|
98
99
|
)
|
99
100
|
wrapt.register_post_import_hook(self.patch_openai_methods, "openai")
|
101
|
+
wrapt.register_post_import_hook(self.patch_openai_beta_methods, "openai")
|
100
102
|
wrapt.register_post_import_hook(self.patch_litellm_methods, "litellm")
|
101
103
|
wrapt.register_post_import_hook(self.patch_anthropic_methods, "anthropic")
|
102
104
|
wrapt.register_post_import_hook(
|
@@ -135,6 +137,40 @@ class LLMTracerMixin:
|
|
135
137
|
# Log the error but continue execution
|
136
138
|
print(f"Warning: Failed to patch OpenAI methods: {str(e)}")
|
137
139
|
|
140
|
+
def patch_openai_beta_methods(self, openai_module):
|
141
|
+
"""
|
142
|
+
Patch the new openai.beta endpoints (threads, runs, messages, etc.)
|
143
|
+
so that calls like openai.beta.threads.create(...) or
|
144
|
+
openai.beta.threads.runs.create(...) are automatically traced.
|
145
|
+
"""
|
146
|
+
# Make sure openai_module has a 'beta' attribute
|
147
|
+
if not hasattr(openai_module, "beta"):
|
148
|
+
return
|
149
|
+
|
150
|
+
beta_module = openai_module.beta
|
151
|
+
|
152
|
+
# Patch openai.beta.threads
|
153
|
+
if hasattr(beta_module, "threads"):
|
154
|
+
threads_obj = beta_module.threads
|
155
|
+
# Patch top-level methods on openai.beta.threads
|
156
|
+
for method_name in ["create", "list"]:
|
157
|
+
if hasattr(threads_obj, method_name):
|
158
|
+
self.wrap_method(threads_obj, method_name)
|
159
|
+
|
160
|
+
# Patch the nested objects: messages, runs
|
161
|
+
if hasattr(threads_obj, "messages"):
|
162
|
+
messages_obj = threads_obj.messages
|
163
|
+
for method_name in ["create", "list"]:
|
164
|
+
if hasattr(messages_obj, method_name):
|
165
|
+
self.wrap_method(messages_obj, method_name)
|
166
|
+
|
167
|
+
if hasattr(threads_obj, "runs"):
|
168
|
+
runs_obj = threads_obj.runs
|
169
|
+
for method_name in ["create", "retrieve", "list"]:
|
170
|
+
if hasattr(runs_obj, method_name):
|
171
|
+
self.wrap_method(runs_obj, method_name)
|
172
|
+
|
173
|
+
|
138
174
|
def patch_anthropic_methods(self, module):
|
139
175
|
if hasattr(module, "Anthropic"):
|
140
176
|
client_class = getattr(module, "Anthropic")
|
@@ -0,0 +1,215 @@
|
|
1
|
+
import platform
|
2
|
+
import psutil
|
3
|
+
import sys
|
4
|
+
import pkg_resources
|
5
|
+
import logging
|
6
|
+
from typing import Dict, List, Optional
|
7
|
+
from ..data.data_structure import (
|
8
|
+
SystemInfo,
|
9
|
+
OSInfo,
|
10
|
+
EnvironmentInfo,
|
11
|
+
Resources,
|
12
|
+
CPUResource,
|
13
|
+
MemoryResource,
|
14
|
+
DiskResource,
|
15
|
+
NetworkResource,
|
16
|
+
ResourceInfo,
|
17
|
+
MemoryInfo,
|
18
|
+
DiskInfo,
|
19
|
+
NetworkInfo,
|
20
|
+
)
|
21
|
+
|
22
|
+
logger = logging.getLogger(__name__)
|
23
|
+
|
24
|
+
class SystemMonitor:
|
25
|
+
def __init__(self, trace_id: str):
|
26
|
+
self.trace_id = trace_id
|
27
|
+
|
28
|
+
def get_system_info(self) -> SystemInfo:
|
29
|
+
# Initialize with None values
|
30
|
+
os_info = OSInfo(
|
31
|
+
name=None,
|
32
|
+
version=None,
|
33
|
+
platform=None,
|
34
|
+
kernel_version=None,
|
35
|
+
)
|
36
|
+
env_info = EnvironmentInfo(
|
37
|
+
name=None,
|
38
|
+
version=None,
|
39
|
+
packages=[],
|
40
|
+
env_path=None,
|
41
|
+
command_to_run=None,
|
42
|
+
)
|
43
|
+
|
44
|
+
try:
|
45
|
+
# Get OS info
|
46
|
+
os_info = OSInfo(
|
47
|
+
name=platform.system(),
|
48
|
+
version=platform.version(),
|
49
|
+
platform=platform.machine(),
|
50
|
+
kernel_version=platform.release(),
|
51
|
+
)
|
52
|
+
except Exception as e:
|
53
|
+
logger.warning(f"Failed to get OS info: {str(e)}")
|
54
|
+
|
55
|
+
try:
|
56
|
+
# Get Python environment info
|
57
|
+
installed_packages = [
|
58
|
+
f"{pkg.key}=={pkg.version}" for pkg in pkg_resources.working_set
|
59
|
+
]
|
60
|
+
env_info = EnvironmentInfo(
|
61
|
+
name="Python",
|
62
|
+
version=platform.python_version(),
|
63
|
+
packages=installed_packages,
|
64
|
+
env_path=sys.prefix,
|
65
|
+
command_to_run=f"python {sys.argv[0]}",
|
66
|
+
)
|
67
|
+
except Exception as e:
|
68
|
+
logger.warning(f"Failed to get environment info: {str(e)}")
|
69
|
+
|
70
|
+
|
71
|
+
# Always return a valid SystemInfo object
|
72
|
+
return SystemInfo(
|
73
|
+
id=f"sys_{self.trace_id}",
|
74
|
+
os=os_info,
|
75
|
+
environment=env_info,
|
76
|
+
source_code="",
|
77
|
+
)
|
78
|
+
|
79
|
+
def get_resources(self) -> Resources:
|
80
|
+
# Initialize with None values
|
81
|
+
cpu_info = ResourceInfo(
|
82
|
+
name=None,
|
83
|
+
cores=None,
|
84
|
+
threads=None,
|
85
|
+
)
|
86
|
+
cpu = CPUResource(info=cpu_info, interval="5s", values=[])
|
87
|
+
|
88
|
+
mem_info = MemoryInfo(
|
89
|
+
total=None,
|
90
|
+
free=None,
|
91
|
+
)
|
92
|
+
mem = MemoryResource(info=mem_info, interval="5s", values=[])
|
93
|
+
|
94
|
+
disk_info = DiskInfo(
|
95
|
+
total=None,
|
96
|
+
free=None,
|
97
|
+
)
|
98
|
+
disk_resource = DiskResource(
|
99
|
+
info=disk_info,
|
100
|
+
interval="5s",
|
101
|
+
read=[],
|
102
|
+
write=[],
|
103
|
+
)
|
104
|
+
|
105
|
+
net_info = NetworkInfo(
|
106
|
+
upload_speed=None,
|
107
|
+
download_speed=None,
|
108
|
+
)
|
109
|
+
net = NetworkResource(
|
110
|
+
info=net_info,
|
111
|
+
interval="5s",
|
112
|
+
uploads=[],
|
113
|
+
downloads=[],
|
114
|
+
)
|
115
|
+
|
116
|
+
try:
|
117
|
+
# CPU info
|
118
|
+
cpu_info = ResourceInfo(
|
119
|
+
name=platform.processor(),
|
120
|
+
cores=psutil.cpu_count(logical=False),
|
121
|
+
threads=psutil.cpu_count(logical=True),
|
122
|
+
)
|
123
|
+
cpu = CPUResource(info=cpu_info, interval="5s", values=[psutil.cpu_percent()])
|
124
|
+
except Exception as e:
|
125
|
+
logger.warning(f"Failed to get CPU info: {str(e)}")
|
126
|
+
|
127
|
+
|
128
|
+
try:
|
129
|
+
# Memory info
|
130
|
+
memory = psutil.virtual_memory()
|
131
|
+
mem_info = MemoryInfo(
|
132
|
+
total=memory.total / (1024**3), # Convert to GB
|
133
|
+
free=memory.available / (1024**3),
|
134
|
+
)
|
135
|
+
mem = MemoryResource(info=mem_info, interval="5s", values=[memory.percent])
|
136
|
+
except Exception as e:
|
137
|
+
logger.warning(f"Failed to get memory info: {str(e)}")
|
138
|
+
|
139
|
+
|
140
|
+
try:
|
141
|
+
# Disk info
|
142
|
+
disk = psutil.disk_usage("/")
|
143
|
+
disk_info = DiskInfo(total=disk.total / (1024**3), free=disk.free / (1024**3))
|
144
|
+
disk_io = psutil.disk_io_counters()
|
145
|
+
disk_resource = DiskResource(
|
146
|
+
info=disk_info,
|
147
|
+
interval="5s",
|
148
|
+
read=[disk_io.read_bytes / (1024**2)], # MB
|
149
|
+
write=[disk_io.write_bytes / (1024**2)],
|
150
|
+
)
|
151
|
+
except Exception as e:
|
152
|
+
logger.warning(f"Failed to get disk info: {str(e)}")
|
153
|
+
|
154
|
+
try:
|
155
|
+
# Network info
|
156
|
+
net_io = psutil.net_io_counters()
|
157
|
+
net_info = NetworkInfo(
|
158
|
+
upload_speed=net_io.bytes_sent / (1024**2), # MB
|
159
|
+
download_speed=net_io.bytes_recv / (1024**2),
|
160
|
+
)
|
161
|
+
net = NetworkResource(
|
162
|
+
info=net_info,
|
163
|
+
interval="5s",
|
164
|
+
uploads=[net_io.bytes_sent / (1024**2)],
|
165
|
+
downloads=[net_io.bytes_recv / (1024**2)],
|
166
|
+
)
|
167
|
+
except Exception as e:
|
168
|
+
logger.warning(f"Failed to get network info: {str(e)}")
|
169
|
+
|
170
|
+
|
171
|
+
# Always return a valid Resources object
|
172
|
+
return Resources(cpu=cpu, memory=mem, disk=disk_resource, network=net)
|
173
|
+
|
174
|
+
def track_memory_usage(self) -> Optional[float]:
|
175
|
+
"""Track memory usage in MB"""
|
176
|
+
try:
|
177
|
+
memory_usage = psutil.Process().memory_info().rss
|
178
|
+
return memory_usage / (1024 * 1024) # Convert to MB
|
179
|
+
except Exception as e:
|
180
|
+
logger.warning(f"Failed to track memory usage: {str(e)}")
|
181
|
+
return None
|
182
|
+
|
183
|
+
def track_cpu_usage(self, interval: float) -> Optional[float]:
|
184
|
+
"""Track CPU usage percentage"""
|
185
|
+
try:
|
186
|
+
return psutil.cpu_percent(interval=interval)
|
187
|
+
except Exception as e:
|
188
|
+
logger.warning(f"Failed to track CPU usage: {str(e)}")
|
189
|
+
return None
|
190
|
+
|
191
|
+
def track_disk_usage(self) -> Dict[str, Optional[float]]:
|
192
|
+
"""Track disk I/O in MB"""
|
193
|
+
default_response = {'disk_read': None, 'disk_write': None}
|
194
|
+
try:
|
195
|
+
disk_io = psutil.disk_io_counters()
|
196
|
+
return {
|
197
|
+
'disk_read': disk_io.read_bytes / (1024 * 1024), # Convert to MB
|
198
|
+
'disk_write': disk_io.write_bytes / (1024 * 1024) # Convert to MB
|
199
|
+
}
|
200
|
+
except Exception as e:
|
201
|
+
logger.warning(f"Failed to track disk usage: {str(e)}")
|
202
|
+
return default_response
|
203
|
+
|
204
|
+
def track_network_usage(self) -> Dict[str, Optional[float]]:
|
205
|
+
"""Track network I/O in MB"""
|
206
|
+
default_response = {'uploads': None, 'downloads': None}
|
207
|
+
try:
|
208
|
+
net_io = psutil.net_io_counters()
|
209
|
+
return {
|
210
|
+
'uploads': net_io.bytes_sent / (1024 * 1024), # Convert to MB
|
211
|
+
'downloads': net_io.bytes_recv / (1024 * 1024) # Convert to MB
|
212
|
+
}
|
213
|
+
except Exception as e:
|
214
|
+
logger.warning(f"Failed to track network usage: {str(e)}")
|
215
|
+
return default_response
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b2
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
ragaai_catalyst/__init__.py,sha256=tvESV8UuVtth14E89wQxgf0WvQZSApWfDeLiIdmMhkE,791
|
2
2
|
ragaai_catalyst/_version.py,sha256=JKt9KaVNOMVeGs8ojO6LvIZr7ZkMzNN-gCcvryy4x8E,460
|
3
|
-
ragaai_catalyst/dataset.py,sha256=
|
3
|
+
ragaai_catalyst/dataset.py,sha256=8EbZEpcV4Fb8oO0vhYIK_WIwGyYvJ4VzwGeIZDtu2E8,23475
|
4
4
|
ragaai_catalyst/evaluation.py,sha256=34H2bYZNSrcu0jMQgDZw1OLVbQU80PaVLo2avju8POM,20311
|
5
5
|
ragaai_catalyst/experiment.py,sha256=8yQo1phCHlpnJ-4CqCaIbLXg_1ZlAuLGI9kqGBl-OTE,18859
|
6
6
|
ragaai_catalyst/guard_executor.py,sha256=llPbE3DyVtrybojXknzBZj8-dtUrGBQwi9-ZiPJxGRo,3762
|
@@ -28,10 +28,10 @@ ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py,sha256=S4rCcKzU
|
|
28
28
|
ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py,sha256=Xk1cLzs-2A3dgyBwRRnCWs7Eubki40FVonwd433hPN8,4805
|
29
29
|
ragaai_catalyst/tracers/agentic_tracing/tracers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
30
|
ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=--wvhOJ-J2433WPatIS3wx6VFeCUIcgRT5_ZjGQDv2c,26364
|
31
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=
|
31
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=88rX7OkOGEyVNECUrc4bYqODyulXve_-99d9ku5hBeQ,37373
|
32
32
|
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=l3x3uFO5ov93I7UUrUX1M06WVGy2ug2jEZ1G7o315z4,13075
|
33
33
|
ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=
|
34
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=91aWXJGb3GDfyDfJyA7Irnk3XSyfkQaQppW_NMORGJQ,31725
|
35
35
|
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=6hsg-Yw11v4qeELI1CWrdX8BXf-wJrTF5smBI5prgoo,15873
|
36
36
|
ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=m8CxYkl7iMiFya_lNwN1ykBc3Pmo-2pR_2HmpptwHWQ,10352
|
37
37
|
ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=4rWL7fIJE5wN0nwh6fMWyh3OrrenZHJkNzyQXikyzQI,13771
|
@@ -49,6 +49,7 @@ ragaai_catalyst/tracers/agentic_tracing/utils/get_user_trace_metrics.py,sha256=v
|
|
49
49
|
ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=wlXCuaRe81s-7FWdJ_MquXFGRZZfNrZxLIIxl-Ohbqk,15541
|
50
50
|
ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=GXV1s349reRMpYF_EkK-b6peSb4SY-17WnlkvpuQ4sM,294430
|
51
51
|
ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py,sha256=MqeRNGxzeuh9qTK0NbYMftl9V9Z0V7gMgBoHkrXP56k,1592
|
52
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/system_monitor.py,sha256=H8WNsk4v_5T6OUw4TFOzlDLjQhJwjh1nAMyMAoqMEi4,6946
|
52
53
|
ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py,sha256=RciiDdo2riibEoM8X0FKHaXi78y3bWwNkV8U0leqigk,3508
|
53
54
|
ragaai_catalyst/tracers/agentic_tracing/utils/unique_decorator.py,sha256=DQHjcEuqEKsNSWaNs7SoOaq50yK4Jsl966S7mBnV-zA,5723
|
54
55
|
ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py,sha256=8SAN4pjA3XKBWlUZiDGXGh26ve1qRH_fv0VwewsfCFc,18818
|
@@ -61,8 +62,8 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
|
|
61
62
|
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
62
63
|
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
63
64
|
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
64
|
-
ragaai_catalyst-2.1.
|
65
|
-
ragaai_catalyst-2.1.
|
66
|
-
ragaai_catalyst-2.1.
|
67
|
-
ragaai_catalyst-2.1.
|
68
|
-
ragaai_catalyst-2.1.
|
65
|
+
ragaai_catalyst-2.1.5b2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
66
|
+
ragaai_catalyst-2.1.5b2.dist-info/METADATA,sha256=OtU5W4jpT4K2GVF82w9jYeaVglZOWOIwpPfXJNN_SmM,12764
|
67
|
+
ragaai_catalyst-2.1.5b2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
68
|
+
ragaai_catalyst-2.1.5b2.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
69
|
+
ragaai_catalyst-2.1.5b2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|