ragaai-catalyst 2.1.5b21__py3-none-any.whl → 2.1.5b23__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/__init__.py +3 -1
- ragaai_catalyst/dataset.py +49 -1
- ragaai_catalyst/redteaming.py +171 -0
- ragaai_catalyst/synthetic_data_generation.py +40 -7
- ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py +57 -46
- ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +218 -47
- ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py +17 -7
- ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +327 -62
- ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py +0 -3
- ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py +17 -6
- ragaai_catalyst/tracers/agentic_tracing/upload/upload_local_metric.py +72 -0
- ragaai_catalyst/tracers/agentic_tracing/upload/upload_trace_metric.py +32 -15
- ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py +21 -2
- ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +33 -11
- ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json +1204 -484
- ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py +79 -10
- ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py +0 -32
- ragaai_catalyst/tracers/agentic_tracing/utils/unique_decorator.py +3 -1
- ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py +40 -21
- ragaai_catalyst/tracers/distributed.py +7 -3
- ragaai_catalyst/tracers/tracer.py +9 -9
- ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py +0 -1
- {ragaai_catalyst-2.1.5b21.dist-info → ragaai_catalyst-2.1.5b23.dist-info}/METADATA +37 -2
- {ragaai_catalyst-2.1.5b21.dist-info → ragaai_catalyst-2.1.5b23.dist-info}/RECORD +27 -25
- {ragaai_catalyst-2.1.5b21.dist-info → ragaai_catalyst-2.1.5b23.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b21.dist-info → ragaai_catalyst-2.1.5b23.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b21.dist-info → ragaai_catalyst-2.1.5b23.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
import os
|
2
|
-
from typing import List, Dict, Any
|
2
|
+
from typing import List, Dict, Any, Optional
|
3
3
|
import logging
|
4
4
|
|
5
5
|
logger = logging.getLogger(__name__)
|
@@ -11,13 +11,17 @@ logging_level = (
|
|
11
11
|
|
12
12
|
|
13
13
|
class SpanAttributes:
|
14
|
-
def __init__(self, name):
|
14
|
+
def __init__(self, name, project_id: Optional[int] = None):
|
15
15
|
self.name = name
|
16
16
|
self.tags = []
|
17
17
|
self.metadata = {}
|
18
18
|
self.metrics = []
|
19
|
+
self.local_metrics = []
|
19
20
|
self.feedback = None
|
21
|
+
self.project_id = project_id
|
20
22
|
self.trace_attributes = ["tags", "metadata", "metrics"]
|
23
|
+
self.gt = None
|
24
|
+
self.context = None
|
21
25
|
|
22
26
|
def add_tags(self, tags: str | List[str]):
|
23
27
|
if isinstance(tags, str):
|
@@ -30,14 +34,14 @@ class SpanAttributes:
|
|
30
34
|
logger.debug(f"Added metadata: {metadata}")
|
31
35
|
|
32
36
|
def add_metrics(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
self,
|
38
|
+
name: str,
|
39
|
+
score: float | int,
|
40
|
+
reasoning: str = "",
|
41
|
+
cost: float = None,
|
42
|
+
latency: float = None,
|
43
|
+
metadata: Dict[str, Any] = {},
|
44
|
+
config: Dict[str, Any] = {},
|
41
45
|
):
|
42
46
|
self.metrics.append(
|
43
47
|
{
|
@@ -57,3 +61,68 @@ class SpanAttributes:
|
|
57
61
|
def add_feedback(self, feedback: Any):
|
58
62
|
self.feedback = feedback
|
59
63
|
logger.debug(f"Added feedback: {self.feedback}")
|
64
|
+
|
65
|
+
def execute_metrics(self, **kwargs: Any):
|
66
|
+
name = kwargs.get("name")
|
67
|
+
model = kwargs.get("model")
|
68
|
+
provider = kwargs.get("provider")
|
69
|
+
display_name = kwargs.get("display_name", None)
|
70
|
+
mapping = kwargs.get("mapping", None)
|
71
|
+
|
72
|
+
if isinstance(name, str):
|
73
|
+
metrics = [{
|
74
|
+
"name": name
|
75
|
+
}]
|
76
|
+
else:
|
77
|
+
metrics = name if isinstance(name, list) else [name] if isinstance(name, dict) else []
|
78
|
+
|
79
|
+
for metric in metrics:
|
80
|
+
if not isinstance(metric, dict):
|
81
|
+
raise ValueError(f"Expected dict, got {type(metric)}")
|
82
|
+
|
83
|
+
if "name" not in metric:
|
84
|
+
raise ValueError("Metric must contain 'name'")
|
85
|
+
|
86
|
+
metric_name = metric["name"]
|
87
|
+
if metric_name in self.local_metrics:
|
88
|
+
count = sum(1 for m in self.local_metrics if m.startswith(metric_name))
|
89
|
+
metric_name = f"{metric_name}_{count + 1}"
|
90
|
+
|
91
|
+
prompt =None
|
92
|
+
context = None
|
93
|
+
response = None
|
94
|
+
if mapping is not None:
|
95
|
+
prompt = mapping['prompt']
|
96
|
+
context = mapping['context']
|
97
|
+
response = mapping['response']
|
98
|
+
new_metric = {
|
99
|
+
"name": metric_name,
|
100
|
+
"model": model,
|
101
|
+
"provider": provider,
|
102
|
+
"project_id": self.project_id,
|
103
|
+
"prompt": prompt,
|
104
|
+
"context": context,
|
105
|
+
"response": response,
|
106
|
+
"displayName": display_name
|
107
|
+
}
|
108
|
+
self.local_metrics.append(new_metric)
|
109
|
+
|
110
|
+
def add_gt(self, gt: Any):
|
111
|
+
if not isinstance(gt, (str, int, float, bool, list, dict)):
|
112
|
+
raise TypeError(f"Unsupported type for gt: {type(gt)}")
|
113
|
+
if self.gt:
|
114
|
+
logger.warning(f"GT already exists: {self.gt} \n Overwriting...")
|
115
|
+
self.gt = gt
|
116
|
+
logger.debug(f"Added gt: {self.gt}")
|
117
|
+
|
118
|
+
def add_context(self, context: Any):
|
119
|
+
if isinstance(context, str):
|
120
|
+
if not context.strip():
|
121
|
+
logger.warning("Empty or whitespace-only context string provided")
|
122
|
+
self.context = str(context)
|
123
|
+
else:
|
124
|
+
try:
|
125
|
+
self.context = str(context)
|
126
|
+
except Exception as e:
|
127
|
+
logger.warning('Cannot cast the context to string... Skipping')
|
128
|
+
logger.debug(f"Added context: {self.context}")
|
@@ -59,38 +59,6 @@ def calculate_cost(
|
|
59
59
|
"total": total_cost,
|
60
60
|
}
|
61
61
|
|
62
|
-
|
63
|
-
def load_model_costs():
|
64
|
-
try:
|
65
|
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
66
|
-
model_costs_path = os.path.join(current_dir, "model_costs.json")
|
67
|
-
with open(model_costs_path, "r") as file:
|
68
|
-
return json.load(file)
|
69
|
-
except FileNotFoundError:
|
70
|
-
with resources.open_text("utils", "model_costs.json") as file:
|
71
|
-
return json.load(file)
|
72
|
-
|
73
|
-
|
74
|
-
def update_model_costs_from_github():
|
75
|
-
"""Updates the model_costs.json file with latest costs from GitHub."""
|
76
|
-
try:
|
77
|
-
logger.debug("loading the latest model costs.")
|
78
|
-
response = requests.get(
|
79
|
-
"https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"
|
80
|
-
)
|
81
|
-
if response.status_code == 200:
|
82
|
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
83
|
-
model_costs_path = os.path.join(current_dir, "model_costs.json")
|
84
|
-
with open(model_costs_path, "w") as file:
|
85
|
-
json.dump(response.json(), file, indent=4)
|
86
|
-
logger.debug("Model costs updated successfully.")
|
87
|
-
return True
|
88
|
-
return False
|
89
|
-
except Exception as e:
|
90
|
-
logger.error(f"Failed to update model costs from GitHub: {e}")
|
91
|
-
return False
|
92
|
-
|
93
|
-
|
94
62
|
def log_event(event_data, log_file_path):
|
95
63
|
event_data = asdict(event_data)
|
96
64
|
with open(log_file_path, "a") as f:
|
@@ -56,7 +56,9 @@ def generate_unique_hash(func, *args, **kwargs):
|
|
56
56
|
return '_'.join(f"{normalize_arg(k)}:{normalize_arg(v)}"
|
57
57
|
for k, v in sorted(arg.items()))
|
58
58
|
elif callable(arg):
|
59
|
-
|
59
|
+
if hasattr(arg, "__name__"):
|
60
|
+
return arg.__name__
|
61
|
+
return str(type(arg).__name__)
|
60
62
|
else:
|
61
63
|
return str(type(arg).__name__)
|
62
64
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import os
|
2
|
+
import sys
|
3
|
+
import importlib
|
2
4
|
import hashlib
|
3
5
|
import zipfile
|
4
6
|
import re
|
@@ -6,7 +8,6 @@ import ast
|
|
6
8
|
import importlib.util
|
7
9
|
import json
|
8
10
|
import ipynbname
|
9
|
-
import sys
|
10
11
|
|
11
12
|
from pathlib import Path
|
12
13
|
from IPython import get_ipython
|
@@ -22,7 +23,7 @@ logger = logging.getLogger(__name__)
|
|
22
23
|
logging_level = logger.setLevel(logging.DEBUG) if os.getenv("DEBUG") == "1" else logging.INFO
|
23
24
|
|
24
25
|
|
25
|
-
#
|
26
|
+
# PackageUsageRemover class
|
26
27
|
class PackageUsageRemover(ast.NodeTransformer):
|
27
28
|
def __init__(self, package_name):
|
28
29
|
self.package_name = package_name
|
@@ -48,7 +49,12 @@ class PackageUsageRemover(ast.NodeTransformer):
|
|
48
49
|
return node
|
49
50
|
|
50
51
|
def visit_Assign(self, node):
|
51
|
-
if
|
52
|
+
if isinstance(node.value, ast.Expr):
|
53
|
+
node_value = node.value.body
|
54
|
+
else:
|
55
|
+
node_value = node.value
|
56
|
+
|
57
|
+
if self._uses_package(node_value):
|
52
58
|
return None
|
53
59
|
return node
|
54
60
|
|
@@ -59,8 +65,10 @@ class PackageUsageRemover(ast.NodeTransformer):
|
|
59
65
|
if isinstance(node.func.value, ast.Name) and node.func.value.id in self.imported_names:
|
60
66
|
return None
|
61
67
|
return node
|
62
|
-
|
68
|
+
|
63
69
|
def _uses_package(self, node):
|
70
|
+
if isinstance(node, ast.Expr):
|
71
|
+
return self._uses_package(node.body)
|
64
72
|
if isinstance(node, ast.Name) and node.id in self.imported_names:
|
65
73
|
return True
|
66
74
|
if isinstance(node, ast.Call):
|
@@ -69,13 +77,14 @@ class PackageUsageRemover(ast.NodeTransformer):
|
|
69
77
|
return self._uses_package(node.value)
|
70
78
|
return False
|
71
79
|
|
72
|
-
|
80
|
+
|
81
|
+
# Remove package code from a source code string
|
73
82
|
def remove_package_code(source_code: str, package_name: str) -> str:
|
74
83
|
try:
|
75
84
|
tree = ast.parse(source_code)
|
76
|
-
remover = PackageUsageRemover(package_name)
|
77
|
-
modified_tree = remover.visit(tree)
|
78
|
-
modified_code = ast.unparse(
|
85
|
+
# remover = PackageUsageRemover(package_name)
|
86
|
+
# modified_tree = remover.visit(tree)
|
87
|
+
modified_code = ast.unparse(tree)
|
79
88
|
|
80
89
|
return modified_code
|
81
90
|
except Exception as e:
|
@@ -313,22 +322,29 @@ class TraceDependencyTracker:
|
|
313
322
|
except Exception as e:
|
314
323
|
pass
|
315
324
|
|
325
|
+
def get_env_location(self):
|
326
|
+
return sys.prefix
|
327
|
+
|
328
|
+
def get_catalyst_location(self):
|
329
|
+
try:
|
330
|
+
imported_module = importlib.import_module("ragaai_catalyst")
|
331
|
+
return os.path.dirname(os.path.abspath(imported_module.__file__))
|
332
|
+
except ImportError:
|
333
|
+
logger.error("Error getting Catalyst location")
|
334
|
+
return 'ragaai_catalyst'
|
335
|
+
|
316
336
|
def create_zip(self, filepaths):
|
317
337
|
self.track_jupyter_notebook()
|
318
|
-
# logger.info("Tracked Jupyter notebook and its dependencies")
|
319
338
|
|
320
339
|
# Ensure output directory exists
|
321
340
|
os.makedirs(self.output_dir, exist_ok=True)
|
322
|
-
# logger.info(f"Using output directory: {self.output_dir}")
|
323
341
|
|
324
342
|
# Special handling for Colab
|
325
343
|
if self.jupyter_handler.is_running_in_colab():
|
326
|
-
#
|
327
|
-
# Try to get the Colab notebook path
|
344
|
+
# Get the Colab notebook path
|
328
345
|
colab_notebook = self.jupyter_handler.get_notebook_path()
|
329
346
|
if colab_notebook:
|
330
347
|
self.tracked_files.add(os.path.abspath(colab_notebook))
|
331
|
-
# logger.info(f"Added Colab notebook to tracked files: {colab_notebook}")
|
332
348
|
|
333
349
|
# Get current cell content
|
334
350
|
self.check_environment_and_save()
|
@@ -370,6 +386,9 @@ class TraceDependencyTracker:
|
|
370
386
|
except Exception as e:
|
371
387
|
pass
|
372
388
|
|
389
|
+
env_location = self.get_env_location()
|
390
|
+
catalyst_location = self.get_catalyst_location()
|
391
|
+
|
373
392
|
# Calculate hash and create zip
|
374
393
|
self.tracked_files.update(self.python_imports)
|
375
394
|
hash_contents = []
|
@@ -377,7 +396,7 @@ class TraceDependencyTracker:
|
|
377
396
|
for filepath in sorted(self.tracked_files):
|
378
397
|
if not filepath.endswith('.py'):
|
379
398
|
continue
|
380
|
-
elif
|
399
|
+
elif env_location in filepath or '__init__' in filepath:
|
381
400
|
continue
|
382
401
|
try:
|
383
402
|
with open(filepath, 'rb') as file:
|
@@ -410,7 +429,7 @@ class TraceDependencyTracker:
|
|
410
429
|
|
411
430
|
with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
412
431
|
for filepath in sorted(self.tracked_files):
|
413
|
-
if
|
432
|
+
if env_location in filepath or catalyst_location in filepath:
|
414
433
|
continue
|
415
434
|
try:
|
416
435
|
relative_path = os.path.relpath(filepath, base_path)
|
@@ -447,9 +466,9 @@ def zip_list_of_unique_files(filepaths, output_dir=None):
|
|
447
466
|
return tracker.create_zip(filepaths)
|
448
467
|
|
449
468
|
|
450
|
-
# Example usage
|
451
|
-
if __name__ == "__main__":
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
469
|
+
# # Example usage
|
470
|
+
# if __name__ == "__main__":
|
471
|
+
# filepaths = ["script1.py", "script2.py"]
|
472
|
+
# hash_id, zip_path = zip_list_of_unique_files(filepaths)
|
473
|
+
# print(f"Created zip file: {zip_path}")
|
474
|
+
# print(f"Hash ID: {hash_id}")
|
@@ -9,6 +9,7 @@ from typing import Optional, Dict, Any, List
|
|
9
9
|
from functools import wraps
|
10
10
|
from contextlib import contextmanager
|
11
11
|
import uuid
|
12
|
+
from .agentic_tracing.utils.unique_decorator import generate_unique_hash_simple
|
12
13
|
from datetime import datetime
|
13
14
|
import asyncio
|
14
15
|
|
@@ -86,6 +87,8 @@ def trace_agent(name: str = None, agent_type: str = "generic", version: str = "1
|
|
86
87
|
def decorator(func):
|
87
88
|
is_async = asyncio.iscoroutinefunction(func)
|
88
89
|
span_name = name or func.__name__
|
90
|
+
# Generate hash based on the decorated function
|
91
|
+
top_level_hash_id = generate_unique_hash_simple(func)
|
89
92
|
|
90
93
|
@wraps(func)
|
91
94
|
async def async_wrapper(*args, **kwargs):
|
@@ -104,7 +107,7 @@ def trace_agent(name: str = None, agent_type: str = "generic", version: str = "1
|
|
104
107
|
agent_type,
|
105
108
|
version,
|
106
109
|
None, # capabilities
|
107
|
-
|
110
|
+
top_level_hash_id,
|
108
111
|
*args,
|
109
112
|
**kwargs
|
110
113
|
)
|
@@ -130,6 +133,7 @@ def trace_agent(name: str = None, agent_type: str = "generic", version: str = "1
|
|
130
133
|
agent_type,
|
131
134
|
version,
|
132
135
|
None, # capabilities
|
136
|
+
top_level_hash_id,
|
133
137
|
*args,
|
134
138
|
**kwargs
|
135
139
|
)
|
@@ -158,7 +162,7 @@ def trace_llm(name: str = None, model: str = None, **kwargs):
|
|
158
162
|
|
159
163
|
try:
|
160
164
|
# Just execute the function within the current span
|
161
|
-
result = await func(*args, **kwargs)
|
165
|
+
result = await tracer.file_tracker.trace_wrapper(func)(*args, **kwargs)
|
162
166
|
return result
|
163
167
|
finally:
|
164
168
|
# Reset using the stored token
|
@@ -176,7 +180,7 @@ def trace_llm(name: str = None, model: str = None, **kwargs):
|
|
176
180
|
|
177
181
|
try:
|
178
182
|
# Just execute the function within the current span
|
179
|
-
result = func(*args, **kwargs)
|
183
|
+
result = tracer.file_tracker.trace_wrapper(func)(*args, **kwargs)
|
180
184
|
return result
|
181
185
|
finally:
|
182
186
|
# Reset using the stored token
|
@@ -6,6 +6,8 @@ import logging
|
|
6
6
|
import asyncio
|
7
7
|
import aiohttp
|
8
8
|
import requests
|
9
|
+
from litellm import model_cost
|
10
|
+
|
9
11
|
from contextlib import contextmanager
|
10
12
|
from concurrent.futures import ThreadPoolExecutor
|
11
13
|
from ragaai_catalyst.tracers.langchain_callback import LangchainTracer
|
@@ -30,7 +32,6 @@ from ragaai_catalyst.tracers.utils import get_unique_key
|
|
30
32
|
from ragaai_catalyst import RagaAICatalyst
|
31
33
|
from ragaai_catalyst.tracers.agentic_tracing import AgenticTracing, TrackName
|
32
34
|
from ragaai_catalyst.tracers.agentic_tracing.tracers.llm_tracer import LLMTracerMixin
|
33
|
-
from ragaai_catalyst.tracers.agentic_tracing.utils.trace_utils import load_model_costs, update_model_costs_from_github
|
34
35
|
|
35
36
|
logger = logging.getLogger(__name__)
|
36
37
|
|
@@ -127,12 +128,8 @@ class Tracer(AgenticTracing):
|
|
127
128
|
self.timeout = 30
|
128
129
|
self.num_projects = 100
|
129
130
|
self.start_time = datetime.datetime.now().astimezone().isoformat()
|
130
|
-
self.model_cost_dict =
|
131
|
+
self.model_cost_dict = model_cost
|
131
132
|
self.user_context = "" # Initialize user_context to store context from add_context
|
132
|
-
|
133
|
-
if update_llm_cost:
|
134
|
-
# First update the model costs file from GitHub
|
135
|
-
update_model_costs_from_github()
|
136
133
|
|
137
134
|
try:
|
138
135
|
response = requests.get(
|
@@ -172,6 +169,7 @@ class Tracer(AgenticTracing):
|
|
172
169
|
self._upload_task = None
|
173
170
|
elif tracer_type == "llamaindex":
|
174
171
|
self._upload_task = None
|
172
|
+
self.llamaindex_tracer = None
|
175
173
|
from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
176
174
|
|
177
175
|
else:
|
@@ -259,7 +257,8 @@ class Tracer(AgenticTracing):
|
|
259
257
|
return self.langchain_tracer.start()
|
260
258
|
elif self.tracer_type == "llamaindex":
|
261
259
|
from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
262
|
-
|
260
|
+
self.llamaindex_tracer = LlamaIndexTracer(self._pass_user_data())
|
261
|
+
return self.llamaindex_tracer.start()
|
263
262
|
else:
|
264
263
|
super().start()
|
265
264
|
return self
|
@@ -351,8 +350,9 @@ class Tracer(AgenticTracing):
|
|
351
350
|
return
|
352
351
|
|
353
352
|
elif self.tracer_type == "llamaindex":
|
354
|
-
|
355
|
-
|
353
|
+
if self.llamaindex_tracer is None:
|
354
|
+
raise ValueError("LlamaIndex tracer was not started")
|
355
|
+
return self.llamaindex_tracer.stop()
|
356
356
|
else:
|
357
357
|
super().stop()
|
358
358
|
|
@@ -49,7 +49,6 @@ def langchain_tracer_extraction(data, user_context=""):
|
|
49
49
|
def get_response(data):
|
50
50
|
for item in data["llm_calls"]:
|
51
51
|
if item["event"] == "llm_end":
|
52
|
-
# import pdb; pdb.set_trace()
|
53
52
|
llm_end_responses = item["response"]["generations"][0]
|
54
53
|
for llm_end_response in llm_end_responses:
|
55
54
|
response = llm_end_response["text"]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b23
|
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
|
@@ -36,6 +36,7 @@ Requires-Dist: requests~=2.32.3
|
|
36
36
|
Requires-Dist: GPUtil~=1.4.0
|
37
37
|
Requires-Dist: ipynbname
|
38
38
|
Requires-Dist: tiktoken>=0.7.0
|
39
|
+
Requires-Dist: giskard~=2.16.0
|
39
40
|
Provides-Extra: dev
|
40
41
|
Requires-Dist: pytest; extra == "dev"
|
41
42
|
Requires-Dist: pytest-cov; extra == "dev"
|
@@ -63,6 +64,7 @@ RagaAI Catalyst is a comprehensive platform designed to enhance the management a
|
|
63
64
|
- [Synthetic Data Generation](#synthetic-data-generation)
|
64
65
|
- [Guardrail Management](#guardrail-management)
|
65
66
|
- [Agentic Tracing](#agentic-tracing)
|
67
|
+
- [Red-teaming](#red-teaming)
|
66
68
|
|
67
69
|
## Installation
|
68
70
|
|
@@ -295,7 +297,7 @@ sdg = SyntheticDataGeneration()
|
|
295
297
|
text = sdg.process_document(input_data="file_path")
|
296
298
|
|
297
299
|
# Generate results
|
298
|
-
result = sdg.generate_qna(text, question_type ='complex',model_config={"provider":"openai","model":"
|
300
|
+
result = sdg.generate_qna(text, question_type ='complex',model_config={"provider":"openai","model":"gpt-4o-mini"},n=5)
|
299
301
|
|
300
302
|
print(result.head())
|
301
303
|
|
@@ -429,4 +431,37 @@ tracer = AgenticTracer(
|
|
429
431
|
with tracer:
|
430
432
|
# Agent execution code
|
431
433
|
pass
|
434
|
+
```
|
435
|
+
|
436
|
+
### Red-teaming
|
437
|
+
|
438
|
+
The Red-teaming module provides comprehensive scans for model vulnerabilities:
|
439
|
+
|
440
|
+
- Initialize RedTeaming object requiring optional `provider` (defaulting to OpenAI), `model`, `api_key`, `api_base` and `api_version`.
|
441
|
+
User can set API keys in the environment variables, or optionally pass them to the constructor.
|
442
|
+
|
443
|
+
1. View all supported evaluators
|
444
|
+
```python
|
445
|
+
from ragaai_catalyst import RedTeaming
|
446
|
+
rt = RedTeaming()
|
447
|
+
|
448
|
+
supported_evaluators = rt.get_supported_evaluators()
|
449
|
+
```
|
432
450
|
|
451
|
+
2. Run scan: returns a scan dataframe for the model
|
452
|
+
```python
|
453
|
+
import pandas as pd
|
454
|
+
from ragaai_catalyst import RedTeaming
|
455
|
+
|
456
|
+
rt = RedTeaming("openai", "gpt-4o-mini", "my-api-key")
|
457
|
+
|
458
|
+
def mock_llm_call(query):
|
459
|
+
pass # llm call for the query
|
460
|
+
|
461
|
+
def model(df: pd.DataFrame):
|
462
|
+
# Function which takes in an input dataframe, and returns a list containing LLM outputs for the inputs
|
463
|
+
return [mock_llm_call({"query": question}) for question in df["question"]]
|
464
|
+
|
465
|
+
|
466
|
+
scan_df = rt.run_scan(model=model, evaluators=["llm"], save_report=True)
|
467
|
+
```
|
@@ -1,6 +1,6 @@
|
|
1
|
-
ragaai_catalyst/__init__.py,sha256=
|
1
|
+
ragaai_catalyst/__init__.py,sha256=xGqvQoS_Ir_Lup1YUIVc5VlsIplRMnnh_-6qK_eB0u4,843
|
2
2
|
ragaai_catalyst/_version.py,sha256=JKt9KaVNOMVeGs8ojO6LvIZr7ZkMzNN-gCcvryy4x8E,460
|
3
|
-
ragaai_catalyst/dataset.py,sha256=
|
3
|
+
ragaai_catalyst/dataset.py,sha256=u4QofzdH1_bGsZ-AFc-qFMGq9K-H-YZHqmLSFG8AEDI,28120
|
4
4
|
ragaai_catalyst/evaluation.py,sha256=pcmgCxmrugvIzBApu0BVaiPIueOcFj8uig3F1Br_PKs,21035
|
5
5
|
ragaai_catalyst/experiment.py,sha256=8yQo1phCHlpnJ-4CqCaIbLXg_1ZlAuLGI9kqGBl-OTE,18859
|
6
6
|
ragaai_catalyst/guard_executor.py,sha256=llPbE3DyVtrybojXknzBZj8-dtUrGBQwi9-ZiPJxGRo,3762
|
@@ -9,13 +9,14 @@ ragaai_catalyst/internal_api_completion.py,sha256=DdICI5yfEudiOAIC8L4oxH0Qz7kX-B
|
|
9
9
|
ragaai_catalyst/prompt_manager.py,sha256=W8ypramzOprrJ7-22d5vkBXIuIQ8v9XAzKDGxKsTK28,16550
|
10
10
|
ragaai_catalyst/proxy_call.py,sha256=CHxldeceZUaLU-to_hs_Kf1z_b2vHMssLS_cOBedu78,5499
|
11
11
|
ragaai_catalyst/ragaai_catalyst.py,sha256=5nVg3_-lcvhrXjNkPTeGhe3tdUjm_4ZIctOcqWXBkRA,17939
|
12
|
-
ragaai_catalyst/
|
12
|
+
ragaai_catalyst/redteaming.py,sha256=pvHfwaHZgrq0HYhygEUm6-WotAxA2X9Xg1Kj9NlEzAI,6803
|
13
|
+
ragaai_catalyst/synthetic_data_generation.py,sha256=etqG0AHzC0V1B5fTAOEJxOJ9lhWZyNVmwC9DvTDA-gs,21269
|
13
14
|
ragaai_catalyst/utils.py,sha256=TlhEFwLyRU690HvANbyoRycR3nQ67lxVUQoUOfTPYQ0,3772
|
14
15
|
ragaai_catalyst/tracers/__init__.py,sha256=LfgTes-nHpazssbGKnn8kyLZNr49kIPrlkrqqoTFTfc,301
|
15
|
-
ragaai_catalyst/tracers/distributed.py,sha256=
|
16
|
+
ragaai_catalyst/tracers/distributed.py,sha256=DIthDaZWBIzDKtDShGSE9iCM0qFtGB48ReZKzMXMxtA,10630
|
16
17
|
ragaai_catalyst/tracers/langchain_callback.py,sha256=ZXN378gloGh5EVpTJuUScHD964WuIeVeE4_hp60gxG4,30686
|
17
18
|
ragaai_catalyst/tracers/llamaindex_callback.py,sha256=ZY0BJrrlz-P9Mg2dX-ZkVKG3gSvzwqBtk7JL_05MiYA,14028
|
18
|
-
ragaai_catalyst/tracers/tracer.py,sha256=
|
19
|
+
ragaai_catalyst/tracers/tracer.py,sha256=sPl9di2Ff_qm3MQsU2WMjPfvo1UlqbH47rnqi0I1RX4,20935
|
19
20
|
ragaai_catalyst/tracers/upload_traces.py,sha256=2TWdRTN6FMaX-dqDv8BJWQS0xrCGYKkXEYOi2kK3Z3Y,5487
|
20
21
|
ragaai_catalyst/tracers/agentic_tracing/README.md,sha256=X4QwLb7-Jg7GQMIXj-SerZIgDETfw-7VgYlczOR8ZeQ,4508
|
21
22
|
ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=yf6SKvOPSpH-9LiKaoLKXwqj5sez8F_5wkOb91yp0oE,260
|
@@ -28,33 +29,34 @@ ragaai_catalyst/tracers/agentic_tracing/tests/__init__.py,sha256=47DEQpj8HBSa-_T
|
|
28
29
|
ragaai_catalyst/tracers/agentic_tracing/tests/ai_travel_agent.py,sha256=S4rCcKzU_5SB62BYEbNn_1VbbTdG4396N8rdZ3ZNGcE,5654
|
29
30
|
ragaai_catalyst/tracers/agentic_tracing/tests/unique_decorator_test.py,sha256=Xk1cLzs-2A3dgyBwRRnCWs7Eubki40FVonwd433hPN8,4805
|
30
31
|
ragaai_catalyst/tracers/agentic_tracing/tracers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=
|
32
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=
|
33
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=
|
32
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=983uI_vc6XTBtkUIIHs_FcyUa8VBl40d10JmlPzV6iA,26915
|
33
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=lMhRXfTsnKw_-sibA-LqJNV_nvh284VT-rv6_KF4clA,46621
|
34
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=mR4jCNjsKUPiidJ1pIthoUI5i9KCGGPe3zG5l80FUBo,14060
|
34
35
|
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=
|
36
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=
|
36
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=jnbJqs8ln3YWDYAZ8kqpkU8E8h6HGT1-OspHYrDijIw,48118
|
37
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=KTXiDhfEcF2q0FJ4rJqLXONC93MWQAJCIW_ZOsOIiuo,18139
|
37
38
|
ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=m8CxYkl7iMiFya_lNwN1ykBc3Pmo-2pR_2HmpptwHWQ,10352
|
38
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=
|
39
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=CEbTzedv_AH5zXlChfTGMlQc-8oWATlwrVFb1KcO4c0,21588
|
39
40
|
ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py,sha256=bhSUhNQCuJXKjgJAXhjKEYjnHMpYN90FSZdR84fNIKU,4614
|
40
41
|
ragaai_catalyst/tracers/agentic_tracing/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
42
|
ragaai_catalyst/tracers/agentic_tracing/upload/upload_agentic_traces.py,sha256=1MDKXAAPzOEdxFKWWQrRgrmM3kz--DGXSywGXQmR3lQ,6041
|
42
43
|
ragaai_catalyst/tracers/agentic_tracing/upload/upload_code.py,sha256=HgpMgI-JTWZrizcM7GGUIaAgaZF4aRT3D0dJXVEkblY,4271
|
43
|
-
ragaai_catalyst/tracers/agentic_tracing/upload/
|
44
|
+
ragaai_catalyst/tracers/agentic_tracing/upload/upload_local_metric.py,sha256=qpUjPDfeRIwKh2x-pQFLXJwT4hFRrYBKvzS1bWcJTOo,2437
|
45
|
+
ragaai_catalyst/tracers/agentic_tracing/upload/upload_trace_metric.py,sha256=V9dgYx4DwibPr38Xbk7_SOJk9gONE7xYpb0MPA1oMGI,3943
|
44
46
|
ragaai_catalyst/tracers/agentic_tracing/utils/__init__.py,sha256=XdB3X_ufe4RVvGorxSqAiB9dYv4UD7Hvvuw3bsDUppY,60
|
45
47
|
ragaai_catalyst/tracers/agentic_tracing/utils/api_utils.py,sha256=JyNCbfpW-w4O9CjtemTqmor2Rh1WGpQwhRaDSRmBxw8,689
|
46
48
|
ragaai_catalyst/tracers/agentic_tracing/utils/create_dataset_schema.py,sha256=lgvJL0cakJrX8WGsnU05YGvotequSj6HgSohyR4OJNE,804
|
47
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py,sha256=
|
49
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/file_name_tracker.py,sha256=c1RR5tTm8J_oHu4DrLcDtCALhjk75yEXsiP7f7wf8nE,1953
|
48
50
|
ragaai_catalyst/tracers/agentic_tracing/utils/generic.py,sha256=WwXT01xmp8MSr7KinuDCSK9a1ifpLcT7ajFkvYviG_A,1190
|
49
51
|
ragaai_catalyst/tracers/agentic_tracing/utils/get_user_trace_metrics.py,sha256=vPZ4dn4EHFW0kqd1GyRpsYXbfrRrd0DXCmh-pzsDBNE,1109
|
50
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=
|
51
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=
|
52
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py,sha256=
|
52
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=gbPqWtJINW8JVlkM41UmF5zGR8oj8Q6g9KQIS3moQYM,20439
|
53
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=2tzGw_cKCTPcfjEm7iGvFE6pTw7gMTPzeBov_MTaXNY,321336
|
54
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py,sha256=3zTWcooXLZgbShzQCql2EWWfFkrTK2soTWkMxnzMwnE,4218
|
53
55
|
ragaai_catalyst/tracers/agentic_tracing/utils/supported_llm_provider.toml,sha256=LvFDivDIE96Zasp-fgDEqUJ5GEQZUawQucR3aOcSUTY,926
|
54
56
|
ragaai_catalyst/tracers/agentic_tracing/utils/system_monitor.py,sha256=H8WNsk4v_5T6OUw4TFOzlDLjQhJwjh1nAMyMAoqMEi4,6946
|
55
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py,sha256=
|
56
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/unique_decorator.py,sha256=
|
57
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py,sha256=
|
57
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py,sha256=go7FVnofviATDph-j8sk2juv09CGSRt1Vq4U868Fhd8,2259
|
58
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/unique_decorator.py,sha256=G027toV-Km20JjKrc-Y_PilQ8ABEKrBvvzgLTnqVg7I,5819
|
59
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/zip_list_of_unique_files.py,sha256=VIwoLSmpiqXL9u2nQ8jIIndAG9-TMtepTl63wdzwx9U,19241
|
58
60
|
ragaai_catalyst/tracers/exporters/__init__.py,sha256=kVA8zp05h3phu4e-iHSlnznp_PzMRczB7LphSsZgUjg,138
|
59
61
|
ragaai_catalyst/tracers/exporters/file_span_exporter.py,sha256=RgGteu-NVGprXKkynvyIO5yOjpbtA41R3W_NzCjnkwE,6445
|
60
62
|
ragaai_catalyst/tracers/exporters/raga_exporter.py,sha256=6xvjWXyh8XPkHKSLLmAZUQSvwuyY17ov8pv2VdfI0qA,17875
|
@@ -64,10 +66,10 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
|
|
64
66
|
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
65
67
|
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
66
68
|
ragaai_catalyst/tracers/utils/convert_langchain_callbacks_output.py,sha256=ofrNrxf2b1hpjDh_zeaxiYq86azn1MF3kW8-ViYPEg0,1641
|
67
|
-
ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py,sha256=
|
69
|
+
ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py,sha256=XS2_x2qneqEx9oAighLg-LRiueWcESLwIC2r7eJT-Ww,3117
|
68
70
|
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.
|
71
|
+
ragaai_catalyst-2.1.5b23.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
72
|
+
ragaai_catalyst-2.1.5b23.dist-info/METADATA,sha256=ETuEVrAepDOTKJUD-h2JcNx9lJnJcTCPLunJVg-QRwc,13874
|
73
|
+
ragaai_catalyst-2.1.5b23.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
74
|
+
ragaai_catalyst-2.1.5b23.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
75
|
+
ragaai_catalyst-2.1.5b23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|