ragaai-catalyst 2.1b1__py3-none-any.whl → 2.1b3__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.
@@ -112,6 +112,7 @@ class AgenticTracing(BaseTracer, LLMTracerMixin, ToolTracerMixin, AgentTracerMix
112
112
 
113
113
  # Cleanup
114
114
  self.unpatch_llm_calls()
115
+ self.user_interaction_tracer.interactions = [] # Clear interactions list
115
116
  self.is_active = False
116
117
 
117
118
 
@@ -1,27 +1,24 @@
1
1
  import json
2
2
  import os
3
3
  import platform
4
- import re
5
4
  import psutil
6
5
  import pkg_resources
7
6
  from datetime import datetime
8
7
  from pathlib import Path
9
- from typing import Optional, Dict, Any, List
8
+ from typing import List
10
9
  import uuid
11
10
  import sys
11
+ import tempfile
12
12
 
13
13
  from .data_structure import (
14
14
  Trace, Metadata, SystemInfo, OSInfo, EnvironmentInfo,
15
15
  Resources, CPUResource, MemoryResource, DiskResource, NetworkResource,
16
16
  ResourceInfo, MemoryInfo, DiskInfo, NetworkInfo,
17
- Component, LLMComponent, AgentComponent, ToolComponent,
18
- NetworkCall, Interaction, Error
17
+ Component,
19
18
  )
20
19
 
21
- from ..upload_traces import UploadTraces
22
20
  from .upload_agentic_traces import UploadAgenticTraces
23
21
  from .upload_code import upload_code
24
- from ...ragaai_catalyst import RagaAICatalyst
25
22
 
26
23
  from .file_name_tracker import TrackName
27
24
  from .zip_list_of_unique_files import zip_list_of_unique_files
@@ -182,14 +179,13 @@ class BaseTracer:
182
179
  self.trace = self._extract_cost_tokens(self.trace)
183
180
 
184
181
  # Create traces directory if it doesn't exist
185
- self.traces_dir = Path("traces")
186
- self.traces_dir.mkdir(exist_ok=True)
182
+ self.traces_dir = tempfile.gettempdir()
187
183
  filename = self.trace.id + ".json"
188
- filepath = self.traces_dir / filename
184
+ filepath = f"{self.traces_dir}/{filename}"
189
185
 
190
186
  #get unique files and zip it. Generate a unique hash ID for the contents of the files
191
187
  list_of_unique_files = self.file_tracker.get_unique_files()
192
- hash_id, zip_path = zip_list_of_unique_files(list_of_unique_files)
188
+ hash_id, zip_path = zip_list_of_unique_files(list_of_unique_files, output_dir=self.traces_dir)
193
189
 
194
190
  #replace source code with zip_path
195
191
  self.trace.metadata.system_info.source_code = hash_id
@@ -230,7 +226,7 @@ class BaseTracer:
230
226
 
231
227
  # Cleanup
232
228
  self.components = []
233
- self.file_tracker = TrackName()
229
+ self.file_tracker.reset()
234
230
 
235
231
  def add_component(self, component: Component):
236
232
  """Add a component to the trace"""
@@ -8,13 +8,9 @@ class TrackName:
8
8
  def trace_decorator(self, func):
9
9
  @wraps(func)
10
10
  def wrapper(*args, **kwargs):
11
- # frame = inspect.stack()[1]
12
- # file_name = frame.filename
13
11
  file_name = self._get_file_name()
14
- # print(f"Called from file: {frame.filename}")
15
- # print(f"Called from line: {frame.lineno}")
16
- # print(f"Called from function: {frame.function}")
17
12
  self.files.add(file_name)
13
+
18
14
  return func(*args, **kwargs)
19
15
  return wrapper
20
16
 
@@ -43,4 +39,8 @@ class TrackName:
43
39
 
44
40
 
45
41
  def get_unique_files(self):
46
- return list(self.files)
42
+ return list(self.files)
43
+
44
+ def reset(self):
45
+ """Reset the file tracker by clearing all tracked files."""
46
+ self.files.clear()
@@ -654,6 +654,10 @@ class LLMTracerMixin:
654
654
  finally:
655
655
 
656
656
  llm_component = self.llm_data
657
+ llm_component['name'] = name
658
+
659
+ if self.gt:
660
+ llm_component["data"]["gt"] = self.gt
657
661
 
658
662
  if error_info:
659
663
  llm_component["error"] = error_info["error"]
@@ -1,161 +1,3 @@
1
- # import os
2
- # import hashlib
3
- # import zipfile
4
- # import re
5
- # import ast
6
- # import importlib.util
7
- # import json
8
- # from pathlib import Path
9
-
10
- # class TraceDependencyTracker:
11
- # def __init__(self, output_dir=None):
12
- # self.tracked_files = set()
13
- # self.python_imports = set()
14
- # self.output_dir = output_dir or os.getcwd()
15
-
16
- # def track_file_access(self, filepath):
17
- # """Track a file that's been accessed."""
18
- # if os.path.exists(filepath):
19
- # self.tracked_files.add(os.path.abspath(filepath))
20
-
21
- # def find_config_files(self, content, base_path):
22
- # """Find configuration files referenced in the content."""
23
- # patterns = [
24
- # r'(?:open|read|load|with\s+open)\s*\([\'"]([^\'"]*\.(?:json|yaml|yml|txt|cfg|config|ini))[\'"]',
25
- # r'(?:config|cfg|conf|settings|file|path)(?:_file|_path)?\s*=\s*[\'"]([^\'"]*\.(?:json|yaml|yml|txt|cfg|config|ini))[\'"]',
26
- # r'[\'"]([^\'"]*\.txt)[\'"]',
27
- # r'[\'"]([^\'"]*\.(?:yaml|yml))[\'"]',
28
- # r'from\s+(\S+)\s+import',
29
- # r'import\s+(\S+)'
30
- # ]
31
-
32
- # for pattern in patterns:
33
- # matches = re.finditer(pattern, content)
34
- # for match in matches:
35
- # filepath = match.group(1)
36
- # if not os.path.isabs(filepath):
37
- # full_path = os.path.join(os.path.dirname(base_path), filepath)
38
- # else:
39
- # full_path = filepath
40
-
41
- # if os.path.exists(full_path):
42
- # self.track_file_access(full_path)
43
- # try:
44
- # with open(full_path, 'r', encoding='utf-8') as f:
45
- # self.find_config_files(f.read(), full_path)
46
- # except (UnicodeDecodeError, IOError):
47
- # pass
48
-
49
- # def analyze_python_imports(self, filepath):
50
- # """Analyze Python file for imports and track imported files."""
51
- # try:
52
- # with open(filepath, 'r', encoding='utf-8') as file:
53
- # tree = ast.parse(file.read(), filename=filepath)
54
-
55
- # for node in ast.walk(tree):
56
- # if isinstance(node, (ast.Import, ast.ImportFrom)):
57
- # if isinstance(node, ast.ImportFrom) and node.module:
58
- # module_name = node.module
59
- # else:
60
- # for name in node.names:
61
- # module_name = name.name.split('.')[0]
62
-
63
- # try:
64
- # spec = importlib.util.find_spec(module_name)
65
- # if spec and spec.origin and not spec.origin.startswith(os.path.dirname(importlib.__file__)):
66
- # self.python_imports.add(spec.origin)
67
- # except (ImportError, AttributeError):
68
- # pass
69
- # except Exception as e:
70
- # print(f"Warning: Could not analyze imports in {filepath}: {str(e)}")
71
-
72
- # def create_zip(self, filepaths):
73
- # """
74
- # Process files and create a single zip with all dependencies.
75
-
76
- # Args:
77
- # filepaths (list): List of file paths to process.
78
-
79
- # Returns:
80
- # tuple: A tuple containing the hash ID (str) and the path to the saved .zip file (str).
81
- # """
82
- # # Process all files and their dependencies
83
- # for filepath in filepaths:
84
- # abs_path = os.path.abspath(filepath)
85
- # self.track_file_access(abs_path)
86
-
87
- # try:
88
- # with open(abs_path, 'r', encoding='utf-8') as file:
89
- # content = file.read()
90
-
91
- # self.find_config_files(content, abs_path)
92
-
93
- # if filepath.endswith('.py'):
94
- # self.analyze_python_imports(abs_path)
95
- # except Exception as e:
96
- # print(f"Warning: Could not process {filepath}: {str(e)}")
97
-
98
- # # Add Python imports to tracked files
99
- # self.tracked_files.update(self.python_imports)
100
-
101
- # # Generate hash from all files
102
- # hash_contents = []
103
- # for filepath in sorted(self.tracked_files):
104
- # # Skip any file paths that contain 'env'
105
- # if 'env' in filepath:
106
- # continue # Skip env folder
107
- # try:
108
- # with open(filepath, 'rb') as file:
109
- # content = file.read()
110
- # hash_contents.append(content)
111
- # except Exception as e:
112
- # print(f"Warning: Could not read {filepath} for hash calculation: {str(e)}")
113
-
114
- # combined_content = b''.join(hash_contents)
115
- # hash_id = hashlib.sha256(combined_content).hexdigest()
116
-
117
- # # Create zip file
118
- # zip_filename = os.path.join(self.output_dir, f'{hash_id}.zip')
119
-
120
- # # Determine base path excluding 'env' folders
121
- # base_path = os.path.commonpath([os.path.abspath(p) for p in self.tracked_files if 'env' not in p])
122
-
123
- # with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
124
- # for filepath in sorted(self.tracked_files):
125
- # # Skip any file paths that contain 'env'
126
- # if 'env' in filepath:
127
- # continue # Skip env folder
128
- # try:
129
- # relative_path = os.path.relpath(filepath, base_path)
130
- # zipf.write(filepath, relative_path)
131
- # print(f"Added to zip: {relative_path}")
132
- # except Exception as e:
133
- # print(f"Warning: Could not add {filepath} to zip: {str(e)}")
134
-
135
- # return hash_id, zip_filename
136
-
137
- # def zip_list_of_unique_files(filepaths):
138
- # """
139
- # Enhanced version of the original function that tracks all dependencies.
140
-
141
- # Args:
142
- # filepaths (list): List of file paths to process.
143
-
144
- # Returns:
145
- # tuple: A tuple containing the hash ID (str) and the path to the saved .zip file (str).
146
- # """
147
- # tracker = TraceDependencyTracker()
148
- # return tracker.create_zip(filepaths)
149
-
150
- # if __name__ == "__main__":
151
- # filepaths = ["script1.py", "script2.py"]
152
- # hash_id, zip_path = zip_list_of_unique_files(filepaths)
153
- # print(f"Created zip file: {zip_path}")
154
- # print(f"Hash ID: {hash_id}")
155
-
156
-
157
-
158
-
159
1
  import os
160
2
  import hashlib
161
3
  import zipfile
@@ -165,6 +7,8 @@ import importlib.util
165
7
  import json
166
8
  import astor
167
9
  from pathlib import Path
10
+ import logging
11
+ logger = logging.getLogger(__name__)
168
12
 
169
13
  # Define the PackageUsageRemover class
170
14
  class PackageUsageRemover(ast.NodeTransformer):
@@ -323,15 +167,15 @@ class TraceDependencyTracker:
323
167
  try:
324
168
  relative_path = os.path.relpath(filepath, base_path)
325
169
  zipf.write(filepath, relative_path)
326
- print(f"Added to zip: {relative_path}")
170
+ # logger.info(f"Added to zip: {relative_path}")
327
171
  except Exception as e:
328
172
  print(f"Warning: Could not add {filepath} to zip: {str(e)}")
329
173
 
330
174
  return hash_id, zip_filename
331
175
 
332
176
  # Main function for creating a zip of unique files
333
- def zip_list_of_unique_files(filepaths):
334
- tracker = TraceDependencyTracker()
177
+ def zip_list_of_unique_files(filepaths, output_dir):
178
+ tracker = TraceDependencyTracker(output_dir)
335
179
  return tracker.create_zip(filepaths)
336
180
 
337
181
  # Example usage
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ragaai_catalyst
3
- Version: 2.1b1
3
+ Version: 2.1b3
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.9
@@ -17,11 +17,11 @@ ragaai_catalyst/tracers/tracer.py,sha256=dGYQfo0RXms6w-sAJf04gqTo1zOXTqreGXaJlnv
17
17
  ragaai_catalyst/tracers/upload_traces.py,sha256=hs0PEmit3n3_uUqrdbwcBdyK5Nbkik3JQVwJMEwYTd4,4796
18
18
  ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=6QyQI8P7aNFHTantNJOP1ZdSNrDKBLhlg_gGNj7tm1c,73
19
19
  ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py,sha256=Ff9KbTjKkuZkGAECyvKRe8LjjAjwQ-seTwsX2ycGnIg,18995
20
- ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py,sha256=vlh1nvIx9qAHI1m4YKe1R9HkjWiA6sKnP_6GRUed00g,8366
21
- ragaai_catalyst/tracers/agentic_tracing/base.py,sha256=FefIRrPw2BYNi1u707O8cNTmZIrVwi7OxMrfzdvC0U4,14205
20
+ ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py,sha256=NVLw1n3FZUhZR-znaV_kSpWh1fQq2ElHYTklxPFg_Vc,8452
21
+ ragaai_catalyst/tracers/agentic_tracing/base.py,sha256=jRf_-5EIfCzGbaSQtkqgiDQAH4ymoKUrg9A8YqB08jk,14008
22
22
  ragaai_catalyst/tracers/agentic_tracing/data_structure.py,sha256=qyfCI1oGQ461WbS6BYBiAEUmgpw9xFsccpjsi_mVX3c,7152
23
- ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py,sha256=1YibFmifGh-PF7Jl0vtCN2QYF-v6Xq9jTgozDkWvgO0,1501
24
- ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py,sha256=PTOnyj4AVEyUqyQK1fY-Beckt0v_-BvJfGwIEoIxca4,32561
23
+ ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py,sha256=515NNDQJTyy3O-2rdlUYUoWL9qSwLIfvV3sMB9BtHp8,1366
24
+ ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py,sha256=dI2Pg4cNGTf5k7g7ViVRUu6Pck8In4aqQYGLn_xwNxY,32705
25
25
  ragaai_catalyst/tracers/agentic_tracing/network_tracer.py,sha256=6FTA15xMnum9omM_0Jd9cMIuWdKu1gR5Tc8fOXAkP8E,10068
26
26
  ragaai_catalyst/tracers/agentic_tracing/sample.py,sha256=S4rCcKzU_5SB62BYEbNn_1VbbTdG4396N8rdZ3ZNGcE,5654
27
27
  ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py,sha256=Yc4x82rk0hCANwXUt4M66Qv_4OdpsXsjlq6OIOef1io,8763
@@ -30,7 +30,7 @@ ragaai_catalyst/tracers/agentic_tracing/unique_decorator_test.py,sha256=Xk1cLzs-
30
30
  ragaai_catalyst/tracers/agentic_tracing/upload_agentic_traces.py,sha256=ydaWAbrSS5B6ijabzTnUVxlW8m6eX5dsEJnzl06ZDFU,7539
31
31
  ragaai_catalyst/tracers/agentic_tracing/upload_code.py,sha256=u9bRWcM5oDezJupEQoHUXrKz7YvZJK9IZf10ejBWoa4,4254
32
32
  ragaai_catalyst/tracers/agentic_tracing/user_interaction_tracer.py,sha256=wsCwTK7tM_L3mdNrcg5Mq3D1k07XCHZkhOB26kz_rLY,1472
33
- ragaai_catalyst/tracers/agentic_tracing/zip_list_of_unique_files.py,sha256=mW2Cle4sAia2L5GBPWnIcyCms5T_89qOALlW2mxvLEw,13999
33
+ ragaai_catalyst/tracers/agentic_tracing/zip_list_of_unique_files.py,sha256=faFat_OAUnVJGnauMVo6yeHhTv-_njgyXGOtUwYJ8kE,7568
34
34
  ragaai_catalyst/tracers/agentic_tracing/examples/FinancialAnalysisSystem.ipynb,sha256=0qZxjWqYCTAVvdo3Tsp544D8Am48wfeMQ9RKpKgAL8g,34291
35
35
  ragaai_catalyst/tracers/agentic_tracing/examples/GameActivityEventPlanner.ipynb,sha256=QCMFJYbGX0fd9eMW4PqyQLZjyWuTXo7n1nqO_hMLf0s,4225
36
36
  ragaai_catalyst/tracers/agentic_tracing/examples/TravelPlanner.ipynb,sha256=fU3inXoemJbdTkGAQl_N1UwVEZ10LrKv4gCEpbQ4ISg,43481
@@ -50,7 +50,7 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
50
50
  ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
51
51
  ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
52
52
  ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
53
- ragaai_catalyst-2.1b1.dist-info/METADATA,sha256=cztOcfVRDK_Rz7DqQStsEX7vIXp7DxAg0Hhq_hmZiew,1795
54
- ragaai_catalyst-2.1b1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
55
- ragaai_catalyst-2.1b1.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
56
- ragaai_catalyst-2.1b1.dist-info/RECORD,,
53
+ ragaai_catalyst-2.1b3.dist-info/METADATA,sha256=nXXIldP0lixlE4HcRaOoMgTUAWnbOZCTWz4I40T6nAg,1795
54
+ ragaai_catalyst-2.1b3.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
55
+ ragaai_catalyst-2.1b3.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
56
+ ragaai_catalyst-2.1b3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5