ragaai-catalyst 2.1b0__py3-none-any.whl → 2.1b2__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.
Files changed (45) hide show
  1. ragaai_catalyst/__init__.py +1 -0
  2. ragaai_catalyst/dataset.py +1 -4
  3. ragaai_catalyst/evaluation.py +4 -5
  4. ragaai_catalyst/guard_executor.py +97 -0
  5. ragaai_catalyst/guardrails_manager.py +41 -15
  6. ragaai_catalyst/internal_api_completion.py +1 -1
  7. ragaai_catalyst/prompt_manager.py +7 -2
  8. ragaai_catalyst/ragaai_catalyst.py +1 -1
  9. ragaai_catalyst/synthetic_data_generation.py +7 -0
  10. ragaai_catalyst/tracers/__init__.py +1 -1
  11. ragaai_catalyst/tracers/agentic_tracing/__init__.py +3 -0
  12. ragaai_catalyst/tracers/agentic_tracing/agent_tracer.py +422 -0
  13. ragaai_catalyst/tracers/agentic_tracing/agentic_tracing.py +198 -0
  14. ragaai_catalyst/tracers/agentic_tracing/base.py +376 -0
  15. ragaai_catalyst/tracers/agentic_tracing/data_structure.py +248 -0
  16. ragaai_catalyst/tracers/agentic_tracing/examples/FinancialAnalysisSystem.ipynb +536 -0
  17. ragaai_catalyst/tracers/agentic_tracing/examples/GameActivityEventPlanner.ipynb +134 -0
  18. ragaai_catalyst/tracers/agentic_tracing/examples/TravelPlanner.ipynb +563 -0
  19. ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py +46 -0
  20. ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py +808 -0
  21. ragaai_catalyst/tracers/agentic_tracing/network_tracer.py +286 -0
  22. ragaai_catalyst/tracers/agentic_tracing/sample.py +197 -0
  23. ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py +247 -0
  24. ragaai_catalyst/tracers/agentic_tracing/unique_decorator.py +165 -0
  25. ragaai_catalyst/tracers/agentic_tracing/unique_decorator_test.py +172 -0
  26. ragaai_catalyst/tracers/agentic_tracing/upload_agentic_traces.py +187 -0
  27. ragaai_catalyst/tracers/agentic_tracing/upload_code.py +115 -0
  28. ragaai_catalyst/tracers/agentic_tracing/user_interaction_tracer.py +43 -0
  29. ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py +3 -0
  30. ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py +18 -0
  31. ragaai_catalyst/tracers/agentic_tracing/utils/data_classes.py +61 -0
  32. ragaai_catalyst/tracers/agentic_tracing/utils/generic.py +32 -0
  33. ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +177 -0
  34. ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json +7823 -0
  35. ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py +74 -0
  36. ragaai_catalyst/tracers/agentic_tracing/zip_list_of_unique_files.py +184 -0
  37. ragaai_catalyst/tracers/exporters/raga_exporter.py +1 -7
  38. ragaai_catalyst/tracers/tracer.py +30 -4
  39. ragaai_catalyst/tracers/upload_traces.py +127 -0
  40. ragaai_catalyst-2.1b2.dist-info/METADATA +43 -0
  41. ragaai_catalyst-2.1b2.dist-info/RECORD +56 -0
  42. {ragaai_catalyst-2.1b0.dist-info → ragaai_catalyst-2.1b2.dist-info}/WHEEL +1 -1
  43. ragaai_catalyst-2.1b0.dist-info/METADATA +0 -295
  44. ragaai_catalyst-2.1b0.dist-info/RECORD +0 -28
  45. {ragaai_catalyst-2.1b0.dist-info → ragaai_catalyst-2.1b2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,74 @@
1
+ import json
2
+ import os
3
+ from importlib import resources
4
+ from dataclasses import asdict
5
+
6
+
7
+ def convert_usage_to_dict(usage):
8
+ # Initialize the token_usage dictionary with default values
9
+ token_usage = {
10
+ "input": 0,
11
+ "completion": 0,
12
+ "reasoning": 0, # Default reasoning tokens to 0 unless specified
13
+ }
14
+
15
+ if usage:
16
+ if isinstance(usage, dict):
17
+ # Access usage data as dictionary keys
18
+ token_usage["input"] = usage.get("prompt_tokens", 0)
19
+ token_usage["completion"] = usage.get("completion_tokens", 0)
20
+ # If reasoning tokens are provided, adjust accordingly
21
+ token_usage["reasoning"] = usage.get("reasoning_tokens", 0)
22
+ else:
23
+ # Handle the case where usage is not a dictionary
24
+ # This could be an object with attributes, or something else
25
+ try:
26
+ token_usage["input"] = getattr(usage, "prompt_tokens", 0)
27
+ token_usage["completion"] = getattr(usage, "completion_tokens", 0)
28
+ token_usage["reasoning"] = getattr(usage, "reasoning_tokens", 0)
29
+ except AttributeError:
30
+ # If attributes are not found, log or handle the error as needed
31
+ print(f"Warning: Unexpected usage type: {type(usage)}")
32
+
33
+ return token_usage
34
+
35
+
36
+ def calculate_cost(
37
+ token_usage,
38
+ input_cost_per_token=0.0,
39
+ output_cost_per_token=0.0,
40
+ reasoning_cost_per_token=0.0,
41
+ ):
42
+ input_tokens = token_usage.get("prompt_tokens", 0)
43
+ output_tokens = token_usage.get("completion_tokens", 0)
44
+ reasoning_tokens = token_usage.get("reasoning_tokens", 0)
45
+
46
+ input_cost = input_tokens * input_cost_per_token
47
+ output_cost = output_tokens * output_cost_per_token
48
+ reasoning_cost = reasoning_tokens * reasoning_cost_per_token
49
+
50
+ total_cost = input_cost + output_cost + reasoning_cost
51
+
52
+ return {
53
+ "input": input_cost,
54
+ "completion": output_cost,
55
+ "reasoning": reasoning_cost,
56
+ "total": total_cost,
57
+ }
58
+
59
+
60
+ def load_model_costs():
61
+ try:
62
+ current_dir = os.path.dirname(os.path.abspath(__file__))
63
+ model_costs_path = os.path.join(current_dir, "model_costs.json")
64
+ with open(model_costs_path, "r") as file:
65
+ return json.load(file)
66
+ except FileNotFoundError:
67
+ with resources.open_text("utils", "model_costs.json") as file:
68
+ return json.load(file)
69
+
70
+
71
+ def log_event(event_data, log_file_path):
72
+ event_data = asdict(event_data)
73
+ with open(log_file_path, "a") as f:
74
+ f.write(json.dumps(event_data) + "\n")
@@ -0,0 +1,184 @@
1
+ import os
2
+ import hashlib
3
+ import zipfile
4
+ import re
5
+ import ast
6
+ import importlib.util
7
+ import json
8
+ import astor
9
+ from pathlib import Path
10
+
11
+ # Define the PackageUsageRemover class
12
+ class PackageUsageRemover(ast.NodeTransformer):
13
+ def __init__(self, package_name):
14
+ self.package_name = package_name
15
+ self.imported_names = set()
16
+
17
+ def visit_Import(self, node):
18
+ filtered_names = []
19
+ for name in node.names:
20
+ if not name.name.startswith(self.package_name):
21
+ filtered_names.append(name)
22
+ else:
23
+ self.imported_names.add(name.asname or name.name)
24
+
25
+ if not filtered_names:
26
+ return None
27
+ node.names = filtered_names
28
+ return node
29
+
30
+ def visit_ImportFrom(self, node):
31
+ if node.module and node.module.startswith(self.package_name):
32
+ self.imported_names.update(n.asname or n.name for n in node.names)
33
+ return None
34
+ return node
35
+
36
+ def visit_Assign(self, node):
37
+ if self._uses_package(node.value):
38
+ return None
39
+ return node
40
+
41
+ def visit_Call(self, node):
42
+ if isinstance(node.func, ast.Name) and node.func.id in self.imported_names:
43
+ return None
44
+ if isinstance(node.func, ast.Attribute):
45
+ if isinstance(node.func.value, ast.Name) and node.func.value.id in self.imported_names:
46
+ return None
47
+ return node
48
+
49
+ def _uses_package(self, node):
50
+ if isinstance(node, ast.Name) and node.id in self.imported_names:
51
+ return True
52
+ if isinstance(node, ast.Call):
53
+ return self._uses_package(node.func)
54
+ if isinstance(node, ast.Attribute):
55
+ return self._uses_package(node.value)
56
+ return False
57
+
58
+ # Define the function to remove package code from a source code string
59
+ def remove_package_code(source_code: str, package_name: str) -> str:
60
+ try:
61
+ tree = ast.parse(source_code)
62
+ transformer = PackageUsageRemover(package_name)
63
+ modified_tree = transformer.visit(tree)
64
+ modified_code = astor.to_source(modified_tree)
65
+ return modified_code
66
+ except Exception as e:
67
+ raise Exception(f"Error processing source code: {str(e)}")
68
+
69
+ # TraceDependencyTracker class
70
+ class TraceDependencyTracker:
71
+ def __init__(self, output_dir=None):
72
+ self.tracked_files = set()
73
+ self.python_imports = set()
74
+ self.output_dir = output_dir or os.getcwd()
75
+
76
+ def track_file_access(self, filepath):
77
+ if os.path.exists(filepath):
78
+ self.tracked_files.add(os.path.abspath(filepath))
79
+
80
+ def find_config_files(self, content, base_path):
81
+ patterns = [
82
+ r'(?:open|read|load|with\s+open)\s*\([\'"]([^\'"]*\.(?:json|yaml|yml|txt|cfg|config|ini))[\'"]',
83
+ r'(?:config|cfg|conf|settings|file|path)(?:_file|_path)?\s*=\s*[\'"]([^\'"]*\.(?:json|yaml|yml|txt|cfg|config|ini))[\'"]',
84
+ r'[\'"]([^\'"]*\.txt)[\'"]',
85
+ r'[\'"]([^\'"]*\.(?:yaml|yml))[\'"]',
86
+ r'from\s+(\S+)\s+import',
87
+ r'import\s+(\S+)'
88
+ ]
89
+ for pattern in patterns:
90
+ matches = re.finditer(pattern, content)
91
+ for match in matches:
92
+ filepath = match.group(1)
93
+ if not os.path.isabs(filepath):
94
+ full_path = os.path.join(os.path.dirname(base_path), filepath)
95
+ else:
96
+ full_path = filepath
97
+ if os.path.exists(full_path):
98
+ self.track_file_access(full_path)
99
+ try:
100
+ with open(full_path, 'r', encoding='utf-8') as f:
101
+ self.find_config_files(f.read(), full_path)
102
+ except (UnicodeDecodeError, IOError):
103
+ pass
104
+
105
+ def analyze_python_imports(self, filepath):
106
+ try:
107
+ with open(filepath, 'r', encoding='utf-8') as file:
108
+ tree = ast.parse(file.read(), filename=filepath)
109
+ for node in ast.walk(tree):
110
+ if isinstance(node, (ast.Import, ast.ImportFrom)):
111
+ if isinstance(node, ast.ImportFrom) and node.module:
112
+ module_name = node.module
113
+ else:
114
+ for name in node.names:
115
+ module_name = name.name.split('.')[0]
116
+ try:
117
+ spec = importlib.util.find_spec(module_name)
118
+ if spec and spec.origin and not spec.origin.startswith(os.path.dirname(importlib.__file__)):
119
+ self.python_imports.add(spec.origin)
120
+ except (ImportError, AttributeError):
121
+ pass
122
+ except Exception as e:
123
+ print(f"Warning: Could not analyze imports in {filepath}: {str(e)}")
124
+
125
+ def create_zip(self, filepaths):
126
+ for filepath in filepaths:
127
+ abs_path = os.path.abspath(filepath)
128
+ self.track_file_access(abs_path)
129
+ try:
130
+ with open(abs_path, 'r', encoding='utf-8') as file:
131
+ content = file.read()
132
+ self.find_config_files(content, abs_path)
133
+ if filepath.endswith('.py'):
134
+ self.analyze_python_imports(abs_path)
135
+ except Exception as e:
136
+ print(f"Warning: Could not process {filepath}: {str(e)}")
137
+
138
+ self.tracked_files.update(self.python_imports)
139
+ hash_contents = []
140
+ for filepath in sorted(self.tracked_files):
141
+ if 'env' in filepath:
142
+ continue
143
+ try:
144
+ with open(filepath, 'rb') as file:
145
+ content = file.read()
146
+ if filepath.endswith('.py'):
147
+ # Temporarily remove raga_catalyst code for hash calculation
148
+ content = remove_package_code(content.decode('utf-8'), 'ragaai_catalyst').encode('utf-8')
149
+ hash_contents.append(content)
150
+ except Exception as e:
151
+ print(f"Warning: Could not read {filepath} for hash calculation: {str(e)}")
152
+
153
+ combined_content = b''.join(hash_contents)
154
+ hash_id = hashlib.sha256(combined_content).hexdigest()
155
+
156
+ zip_filename = os.path.join(self.output_dir, f'{hash_id}.zip')
157
+ common_path = [os.path.abspath(p) for p in self.tracked_files if 'env' not in p]
158
+
159
+ if common_path!=[]:
160
+ base_path = os.path.commonpath(common_path)
161
+ with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
162
+ for filepath in sorted(self.tracked_files):
163
+ if 'env' in filepath:
164
+ continue
165
+ try:
166
+ relative_path = os.path.relpath(filepath, base_path)
167
+ zipf.write(filepath, relative_path)
168
+ print(f"Added to zip: {relative_path}")
169
+ except Exception as e:
170
+ print(f"Warning: Could not add {filepath} to zip: {str(e)}")
171
+
172
+ return hash_id, zip_filename
173
+
174
+ # Main function for creating a zip of unique files
175
+ def zip_list_of_unique_files(filepaths):
176
+ tracker = TraceDependencyTracker()
177
+ return tracker.create_zip(filepaths)
178
+
179
+ # Example usage
180
+ if __name__ == "__main__":
181
+ filepaths = ["script1.py", "script2.py"]
182
+ hash_id, zip_path = zip_list_of_unique_files(filepaths)
183
+ print(f"Created zip file: {zip_path}")
184
+ print(f"Hash ID: {hash_id}")
@@ -7,7 +7,6 @@ from tqdm import tqdm
7
7
  import requests
8
8
  from ...ragaai_catalyst import RagaAICatalyst
9
9
  import shutil
10
- import pdb
11
10
 
12
11
  logger = logging.getLogger(__name__)
13
12
 
@@ -196,7 +195,6 @@ class RagaExporter:
196
195
  return status_code
197
196
 
198
197
  async def get_presigned_url(self, session, num_files):
199
- # pdb.set_trace()
200
198
  """
201
199
  Asynchronously retrieves a presigned URL from the RagaExporter API.
202
200
 
@@ -213,7 +211,6 @@ class RagaExporter:
213
211
  """
214
212
 
215
213
  async def make_request():
216
- # pdb.set_trace()
217
214
 
218
215
  json_data = {
219
216
  "datasetName": self.dataset_name,
@@ -296,8 +293,7 @@ class RagaExporter:
296
293
  return response.status
297
294
 
298
295
  async def upload_file(self, session, url, file_path):
299
- # pdb.set_trace()
300
- # print('url', url)
296
+
301
297
  """
302
298
  Asynchronously uploads a file using the given session, url, and file path.
303
299
  Supports both regular and Azure blob storage URLs.
@@ -345,8 +341,6 @@ class RagaExporter:
345
341
  return response.status
346
342
 
347
343
  async def check_and_upload_files(self, session, file_paths):
348
- # print(file_paths)
349
- # pdb.set_trace()
350
344
  """
351
345
  Checks if there are files to upload, gets presigned URLs, uploads files, and streams them if successful.
352
346
 
@@ -19,11 +19,14 @@ from .instrumentators import (
19
19
  from .utils import get_unique_key
20
20
  # from .llamaindex_callback import LlamaIndexTracer
21
21
  from ..ragaai_catalyst import RagaAICatalyst
22
+ from .agentic_tracing.agentic_tracing import AgenticTracing
23
+ from .agentic_tracing.file_name_tracker import TrackName
24
+ from .agentic_tracing.llm_tracer import LLMTracerMixin
22
25
 
23
26
  logger = logging.getLogger(__name__)
24
27
 
25
28
 
26
- class Tracer:
29
+ class Tracer(AgenticTracing):
27
30
  NUM_PROJECTS = 100
28
31
  TIMEOUT = 10
29
32
  def __init__(
@@ -41,6 +44,7 @@ class Tracer:
41
44
 
42
45
  Args:
43
46
  project_name (str): The name of the project.
47
+ dataset_name (str): The name of the dataset.
44
48
  tracer_type (str, optional): The type of tracer. Defaults to None.
45
49
  pipeline (dict, optional): The pipeline configuration. Defaults to None.
46
50
  metadata (dict, optional): The metadata. Defaults to None.
@@ -50,16 +54,28 @@ class Tracer:
50
54
  Returns:
51
55
  None
52
56
  """
57
+ # Set auto_instrument_llm to True to enable automatic LLM tracing
58
+ user_detail = {
59
+ "project_name": project_name,
60
+ "project_id": None, # Will be set after project validation
61
+ "dataset_name": dataset_name,
62
+ "trace_user_detail": {"metadata": metadata} if metadata else {}
63
+ }
64
+ super().__init__(user_detail=user_detail, auto_instrument_llm=True)
65
+ self.is_active = True
53
66
  self.project_name = project_name
54
67
  self.dataset_name = dataset_name
55
68
  self.tracer_type = tracer_type
56
69
  self.metadata = self._improve_metadata(metadata, tracer_type)
70
+ # self.metadata["total_cost"] = 0.0
71
+ # self.metadata["total_tokens"] = 0
57
72
  self.pipeline = pipeline
58
73
  self.description = description
59
74
  self.upload_timeout = upload_timeout
60
75
  self.base_url = f"{RagaAICatalyst.BASE_URL}"
61
76
  self.timeout = 10
62
77
  self.num_projects = 100
78
+ self.start_time = datetime.datetime.now(datetime.timezone.utc)
63
79
 
64
80
  try:
65
81
  response = requests.get(
@@ -81,6 +97,9 @@ class Tracer:
81
97
  self.project_id = [
82
98
  project["id"] for project in response.json()["data"]["content"] if project["name"] == project_name
83
99
  ][0]
100
+ # super().__init__(user_detail=self._pass_user_data())
101
+ # self.file_tracker = TrackName()
102
+ self._pass_user_data()
84
103
 
85
104
  except requests.exceptions.RequestException as e:
86
105
  logger.error(f"Failed to retrieve projects list: {e}")
@@ -98,7 +117,9 @@ class Tracer:
98
117
  from .llamaindex_callback import LlamaIndexTracer
99
118
 
100
119
  else:
101
- raise ValueError (f"Currently supported tracer types are 'langchain' and 'llamaindex'.")
120
+ self._upload_task = None
121
+ # raise ValueError (f"Currently supported tracer types are 'langchain' and 'llamaindex'.")
122
+
102
123
 
103
124
  def _improve_metadata(self, metadata, tracer_type):
104
125
  if metadata is None:
@@ -157,7 +178,9 @@ class Tracer:
157
178
  elif self.tracer_type == "llamaindex":
158
179
  from .llamaindex_callback import LlamaIndexTracer
159
180
  return LlamaIndexTracer(self._pass_user_data()).start()
160
-
181
+ else:
182
+ super().start()
183
+ return self
161
184
 
162
185
  def stop(self):
163
186
  """Stop the tracer and initiate trace upload."""
@@ -172,7 +195,9 @@ class Tracer:
172
195
  return "Trace upload initiated. Use get_upload_status() to check the status."
173
196
  elif self.tracer_type == "llamaindex":
174
197
  from .llamaindex_callback import LlamaIndexTracer
175
- return LlamaIndexTracer().stop()
198
+ return LlamaIndexTracer(self._pass_user_data()).stop()
199
+ else:
200
+ super().stop()
176
201
 
177
202
  def get_upload_status(self):
178
203
  """Check the status of the trace upload."""
@@ -262,6 +287,7 @@ class Tracer:
262
287
  # Reset instrumentation flag
263
288
  self.is_instrumented = False
264
289
  # Note: We're not resetting all attributes here to allow for upload status checking
290
+
265
291
  def _pass_user_data(self):
266
292
  return {"project_name":self.project_name,
267
293
  "project_id": self.project_id,
@@ -0,0 +1,127 @@
1
+ import requests
2
+ import json
3
+ import os
4
+ from datetime import datetime
5
+
6
+
7
+ class UploadTraces:
8
+ def __init__(self,
9
+ json_file_path,
10
+ project_name,
11
+ project_id,
12
+ dataset_name,
13
+ user_detail,
14
+ base_url):
15
+ self.json_file_path = json_file_path
16
+ self.project_name = project_name
17
+ self.project_id = project_id
18
+ self.dataset_name = dataset_name
19
+ self.user_detail = user_detail
20
+ self.base_url = base_url
21
+ self.timeout = 10
22
+
23
+ def _create_dataset_schema_with_trace(self):
24
+ SCHEMA_MAPPING_NEW = {
25
+ "trace_id": {"columnType": "traceId"},
26
+ "trace_uri": {"columnType": "traceUri"},
27
+ "prompt": {"columnType": "prompt"},
28
+ "response":{"columnType": "response"},
29
+ "context": {"columnType": "context"},
30
+ "llm_model": {"columnType":"pipeline"},
31
+ "recorded_on": {"columnType": "metadata"},
32
+ "embed_model": {"columnType":"pipeline"},
33
+ "log_source": {"columnType": "metadata"},
34
+ "vector_store":{"columnType":"pipeline"},
35
+ "feedback": {"columnType":"feedBack"}
36
+ }
37
+ def make_request():
38
+ headers = {
39
+ "Content-Type": "application/json",
40
+ "Authorization": f"Bearer {os.getenv('RAGAAI_CATALYST_TOKEN')}",
41
+ "X-Project-Name": self.project_name,
42
+ }
43
+ payload = json.dumps({
44
+ "datasetName": self.dataset_name,
45
+ "schemaMapping": SCHEMA_MAPPING_NEW,
46
+ "traceFolderUrl": None,
47
+ })
48
+ response = requests.request("POST",
49
+ f"{self.base_url}/v1/llm/dataset/logs",
50
+ headers=headers,
51
+ data=payload,
52
+ timeout=self.timeout
53
+ )
54
+
55
+ return response
56
+
57
+ response = make_request()
58
+
59
+ if response.status_code == 401:
60
+ # get_token() # Fetch a new token and set it in the environment
61
+ response = make_request() # Retry the request
62
+ if response.status_code != 200:
63
+ return response.status_code
64
+ return response.status_code
65
+
66
+ def _get_presigned_url(self):
67
+ payload = json.dumps({
68
+ "datasetName": self.dataset_name,
69
+ "numFiles": 1,
70
+ })
71
+ headers = {
72
+ "Content-Type": "application/json",
73
+ "Authorization": f"Bearer {os.getenv('RAGAAI_CATALYST_TOKEN')}",
74
+ "X-Project-Name": self.project_name,
75
+ }
76
+
77
+ response = requests.request("GET",
78
+ f"{self.base_url}/v1/llm/presigned-url",
79
+ headers=headers,
80
+ data=payload,
81
+ timeout=self.timeout)
82
+ if response.status_code == 200:
83
+ presignedUrls = response.json()["data"]["presignedUrls"][0]
84
+ return presignedUrls
85
+
86
+ def _put_presigned_url(self, presignedUrl, filename):
87
+ headers = {
88
+ "Content-Type": "application/json",
89
+ }
90
+
91
+ if "blob.core.windows.net" in presignedUrl: # Azure
92
+ headers["x-ms-blob-type"] = "BlockBlob"
93
+ print(f"Uploading traces...")
94
+ with open(filename) as f:
95
+ payload = f.read().replace("\n", "").replace("\r", "").encode()
96
+
97
+
98
+ response = requests.request("PUT",
99
+ presignedUrl,
100
+ headers=headers,
101
+ data=payload,
102
+ timeout=self.timeout)
103
+ if response.status_code != 200 or response.status_code != 201:
104
+ return response, response.status_code
105
+
106
+ def _insert_traces(self, presignedUrl):
107
+ headers = {
108
+ "Authorization": f"Bearer {os.getenv('RAGAAI_CATALYST_TOKEN')}",
109
+ "Content-Type": "application/json",
110
+ "X-Project-Name": self.project_name,
111
+ }
112
+ payload = json.dumps({
113
+ "datasetName": self.dataset_name,
114
+ "presignedUrl": presignedUrl,
115
+ })
116
+ response = requests.request("POST",
117
+ f"{self.base_url}/v1/llm/insert/trace",
118
+ headers=headers,
119
+ data=payload,
120
+ timeout=self.timeout)
121
+
122
+ def upload_traces(self):
123
+ self._create_dataset_schema_with_trace()
124
+ presignedUrl = self._get_presigned_url()
125
+ self._put_presigned_url(presignedUrl, self.json_file_path)
126
+ self._insert_traces(presignedUrl)
127
+ print("Traces uplaoded")
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.1
2
+ Name: ragaai_catalyst
3
+ Version: 2.1b2
4
+ Summary: RAGA AI CATALYST
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
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: aiohttp>=3.10.2
9
+ Requires-Dist: opentelemetry-api==1.25.0
10
+ Requires-Dist: opentelemetry-sdk==1.25.0
11
+ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc==1.25.0
12
+ Requires-Dist: opentelemetry-instrumentation==0.46b0
13
+ Requires-Dist: opentelemetry-instrumentation-fastapi==0.46b0
14
+ Requires-Dist: opentelemetry-instrumentation-asgi==0.46b0
15
+ Requires-Dist: opentelemetry-semantic-conventions==0.46b0
16
+ Requires-Dist: opentelemetry-util-http==0.46b0
17
+ Requires-Dist: opentelemetry-instrumentation-langchain~=0.24.0
18
+ Requires-Dist: opentelemetry-instrumentation-openai~=0.24.0
19
+ Requires-Dist: langchain-core>=0.2.11
20
+ Requires-Dist: langchain>=0.2.11
21
+ Requires-Dist: openai>=1.57.0
22
+ Requires-Dist: pandas>=2.1.1
23
+ Requires-Dist: groq>=0.11.0
24
+ Requires-Dist: PyPDF2>=3.0.1
25
+ Requires-Dist: google-generativeai>=0.8.2
26
+ Requires-Dist: Markdown>=3.7
27
+ Requires-Dist: litellm==1.51.1
28
+ Requires-Dist: tenacity==8.3.0
29
+ Requires-Dist: tqdm>=4.66.5
30
+ Requires-Dist: llama-index==0.10.0
31
+ Requires-Dist: pyopenssl==24.2.1
32
+ Requires-Dist: psutil~=6.0.0
33
+ Requires-Dist: py-cpuinfo~=9.0.0
34
+ Requires-Dist: requests~=2.32.3
35
+ Requires-Dist: GPUtil~=1.4.0
36
+ Requires-Dist: astor==0.8.1
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest; extra == "dev"
39
+ Requires-Dist: pytest-cov; extra == "dev"
40
+ Requires-Dist: black; extra == "dev"
41
+ Requires-Dist: isort; extra == "dev"
42
+ Requires-Dist: mypy; extra == "dev"
43
+ Requires-Dist: flake8; extra == "dev"
@@ -0,0 +1,56 @@
1
+ ragaai_catalyst/__init__.py,sha256=BdIJ_UUre0uEnRTsLw_hE0C0muWk6XWNZqdVOel22R4,537
2
+ ragaai_catalyst/_version.py,sha256=JKt9KaVNOMVeGs8ojO6LvIZr7ZkMzNN-gCcvryy4x8E,460
3
+ ragaai_catalyst/dataset.py,sha256=On-iOhD5R7iLusph6dLAGS1dOnNtb1koiKxKjTH90pE,10660
4
+ ragaai_catalyst/evaluation.py,sha256=34H2bYZNSrcu0jMQgDZw1OLVbQU80PaVLo2avju8POM,20311
5
+ ragaai_catalyst/experiment.py,sha256=8KvqgJg5JVnt9ghhGDJvdb4mN7ETBX_E5gNxBT0Nsn8,19010
6
+ ragaai_catalyst/guard_executor.py,sha256=llPbE3DyVtrybojXknzBZj8-dtUrGBQwi9-ZiPJxGRo,3762
7
+ ragaai_catalyst/guardrails_manager.py,sha256=DILMOAASK57FH9BLq_8yC1AQzRJ8McMFLwCXgYwNAd4,11904
8
+ ragaai_catalyst/internal_api_completion.py,sha256=DdICI5yfEudiOAIC8L4oxH0Qz7kX-BZCdo9IWsi2gNo,2965
9
+ ragaai_catalyst/prompt_manager.py,sha256=W8ypramzOprrJ7-22d5vkBXIuIQ8v9XAzKDGxKsTK28,16550
10
+ ragaai_catalyst/proxy_call.py,sha256=CHxldeceZUaLU-to_hs_Kf1z_b2vHMssLS_cOBedu78,5499
11
+ ragaai_catalyst/ragaai_catalyst.py,sha256=FdqMzwuQLqS2-3JJDsTQ8uh2itllOxfPrRUjb8Kwmn0,17428
12
+ ragaai_catalyst/synthetic_data_generation.py,sha256=uDV9tNwto2xSkWg5XHXUvjErW-4P34CTrxaJpRfezyA,19250
13
+ ragaai_catalyst/utils.py,sha256=TlhEFwLyRU690HvANbyoRycR3nQ67lxVUQoUOfTPYQ0,3772
14
+ ragaai_catalyst/tracers/__init__.py,sha256=yxepo7iVjTNI_wFdk3Z6Ghu64SazVyszCPEHYrX5WQk,50
15
+ ragaai_catalyst/tracers/llamaindex_callback.py,sha256=vPE7MieKjfwLrLUnnPs20Df0xNYqoCCj-Mt2NbiuiKU,14023
16
+ ragaai_catalyst/tracers/tracer.py,sha256=dGYQfo0RXms6w-sAJf04gqTo1zOXTqreGXaJlnvK48A,12463
17
+ ragaai_catalyst/tracers/upload_traces.py,sha256=hs0PEmit3n3_uUqrdbwcBdyK5Nbkik3JQVwJMEwYTd4,4796
18
+ ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=6QyQI8P7aNFHTantNJOP1ZdSNrDKBLhlg_gGNj7tm1c,73
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=xnd9jE_aEh56iSharHuMlHxBvPcSQD8KtihPLjKn5Mc,14199
22
+ ragaai_catalyst/tracers/agentic_tracing/data_structure.py,sha256=qyfCI1oGQ461WbS6BYBiAEUmgpw9xFsccpjsi_mVX3c,7152
23
+ ragaai_catalyst/tracers/agentic_tracing/file_name_tracker.py,sha256=515NNDQJTyy3O-2rdlUYUoWL9qSwLIfvV3sMB9BtHp8,1366
24
+ ragaai_catalyst/tracers/agentic_tracing/llm_tracer.py,sha256=PTOnyj4AVEyUqyQK1fY-Beckt0v_-BvJfGwIEoIxca4,32561
25
+ ragaai_catalyst/tracers/agentic_tracing/network_tracer.py,sha256=6FTA15xMnum9omM_0Jd9cMIuWdKu1gR5Tc8fOXAkP8E,10068
26
+ ragaai_catalyst/tracers/agentic_tracing/sample.py,sha256=S4rCcKzU_5SB62BYEbNn_1VbbTdG4396N8rdZ3ZNGcE,5654
27
+ ragaai_catalyst/tracers/agentic_tracing/tool_tracer.py,sha256=Yc4x82rk0hCANwXUt4M66Qv_4OdpsXsjlq6OIOef1io,8763
28
+ ragaai_catalyst/tracers/agentic_tracing/unique_decorator.py,sha256=DQHjcEuqEKsNSWaNs7SoOaq50yK4Jsl966S7mBnV-zA,5723
29
+ ragaai_catalyst/tracers/agentic_tracing/unique_decorator_test.py,sha256=Xk1cLzs-2A3dgyBwRRnCWs7Eubki40FVonwd433hPN8,4805
30
+ ragaai_catalyst/tracers/agentic_tracing/upload_agentic_traces.py,sha256=ydaWAbrSS5B6ijabzTnUVxlW8m6eX5dsEJnzl06ZDFU,7539
31
+ ragaai_catalyst/tracers/agentic_tracing/upload_code.py,sha256=u9bRWcM5oDezJupEQoHUXrKz7YvZJK9IZf10ejBWoa4,4254
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=qlK-7HtybA7Z0xvK0iiVE7lC0gsDgwvdO0MJ9a37f2w,7486
34
+ ragaai_catalyst/tracers/agentic_tracing/examples/FinancialAnalysisSystem.ipynb,sha256=0qZxjWqYCTAVvdo3Tsp544D8Am48wfeMQ9RKpKgAL8g,34291
35
+ ragaai_catalyst/tracers/agentic_tracing/examples/GameActivityEventPlanner.ipynb,sha256=QCMFJYbGX0fd9eMW4PqyQLZjyWuTXo7n1nqO_hMLf0s,4225
36
+ ragaai_catalyst/tracers/agentic_tracing/examples/TravelPlanner.ipynb,sha256=fU3inXoemJbdTkGAQl_N1UwVEZ10LrKv4gCEpbQ4ISg,43481
37
+ ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py,sha256=XdB3X_ufe4RVvGorxSqAiB9dYv4UD7Hvvuw3bsDUppY,60
38
+ ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py,sha256=JyNCbfpW-w4O9CjtemTqmor2Rh1WGpQwhRaDSRmBxw8,689
39
+ ragaai_catalyst/tracers/agentic_tracing/utils/data_classes.py,sha256=gFOadWzUORETaH3Y_HerHXs_aVFEt5ry2NQ36domW58,1267
40
+ ragaai_catalyst/tracers/agentic_tracing/utils/generic.py,sha256=WwXT01xmp8MSr7KinuDCSK9a1ifpLcT7ajFkvYviG_A,1190
41
+ ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=7lHJ84kbe7kn4Hbd6MT8KeSl-We7nc_yq2xkfgxgl2E,5769
42
+ ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=6wnDtkBH-uwJeZm9FtyeXuUWux8u-skT3lmrtFwsReI,286298
43
+ ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py,sha256=9cFzfFqIA968bUG7LNTjdN7zbdEXUtcvRKg883ade2c,2586
44
+ ragaai_catalyst/tracers/exporters/__init__.py,sha256=kVA8zp05h3phu4e-iHSlnznp_PzMRczB7LphSsZgUjg,138
45
+ ragaai_catalyst/tracers/exporters/file_span_exporter.py,sha256=RgGteu-NVGprXKkynvyIO5yOjpbtA41R3W_NzCjnkwE,6445
46
+ ragaai_catalyst/tracers/exporters/raga_exporter.py,sha256=pU9EH6Fn1Z757bpM3VaXPDHuJ5wyUrMObGaACiztvTU,18014
47
+ ragaai_catalyst/tracers/instrumentators/__init__.py,sha256=FgnMQupoRTzmVsG9YKsLQera2Pfs-AluZv8CxwavoyQ,253
48
+ ragaai_catalyst/tracers/instrumentators/langchain.py,sha256=yMN0qVF0pUVk6R5M1vJoUXezDo1ejs4klCFRlE8x4vE,574
49
+ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hakE8rkrWHxMlmtmWD-AX6TeByc,416
50
+ ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
51
+ ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
52
+ ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
53
+ ragaai_catalyst-2.1b2.dist-info/METADATA,sha256=Epkb-INU3JO8UmJXpehYK4lT3iqr62xjmf3nU1YbUI4,1795
54
+ ragaai_catalyst-2.1b2.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
55
+ ragaai_catalyst-2.1b2.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
56
+ ragaai_catalyst-2.1b2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.4.0)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5