ragaai-catalyst 2.1.5b22__py3-none-any.whl → 2.1.5b24__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 +1 -1
- ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py +39 -33
- ragaai_catalyst/tracers/agentic_tracing/tracers/base.py +208 -46
- ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py +235 -62
- ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py +1 -4
- ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py +5 -0
- ragaai_catalyst/tracers/agentic_tracing/upload/upload_local_metric.py +72 -0
- ragaai_catalyst/tracers/agentic_tracing/upload/upload_trace_metric.py +27 -11
- ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py +3 -0
- ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py +64 -28
- 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/tracer.py +6 -3
- {ragaai_catalyst-2.1.5b22.dist-info → ragaai_catalyst-2.1.5b24.dist-info}/METADATA +37 -2
- {ragaai_catalyst-2.1.5b22.dist-info → ragaai_catalyst-2.1.5b24.dist-info}/RECORD +21 -19
- {ragaai_catalyst-2.1.5b22.dist-info → ragaai_catalyst-2.1.5b24.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b22.dist-info → ragaai_catalyst-2.1.5b24.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b22.dist-info → ragaai_catalyst-2.1.5b24.dist-info}/top_level.txt +0 -0
@@ -1,27 +1,39 @@
|
|
1
|
+
import logging
|
2
|
+
|
1
3
|
import requests
|
2
4
|
import os
|
3
5
|
import json
|
4
6
|
from ....ragaai_catalyst import RagaAICatalyst
|
5
7
|
from ..utils.get_user_trace_metrics import get_user_trace_metrics
|
6
8
|
|
9
|
+
logger = logging.getLogger(__name__)
|
10
|
+
logging_level = (
|
11
|
+
logger.setLevel(logging.DEBUG)
|
12
|
+
if os.getenv("DEBUG")
|
13
|
+
else logger.setLevel(logging.INFO)
|
14
|
+
)
|
15
|
+
|
16
|
+
|
7
17
|
def upload_trace_metric(json_file_path, dataset_name, project_name):
|
8
18
|
try:
|
9
19
|
with open(json_file_path, "r") as f:
|
10
20
|
traces = json.load(f)
|
11
|
-
|
21
|
+
|
12
22
|
metrics = get_trace_metrics_from_trace(traces)
|
13
23
|
metrics = _change_metrics_format_for_payload(metrics)
|
14
24
|
|
15
25
|
user_trace_metrics = get_user_trace_metrics(project_name, dataset_name)
|
16
26
|
if user_trace_metrics:
|
17
27
|
user_trace_metrics_list = [metric["displayName"] for metric in user_trace_metrics]
|
18
|
-
|
28
|
+
|
19
29
|
if user_trace_metrics:
|
20
30
|
for metric in metrics:
|
21
31
|
if metric["displayName"] in user_trace_metrics_list:
|
22
|
-
metricConfig = next((user_metric["metricConfig"] for user_metric in user_trace_metrics if
|
32
|
+
metricConfig = next((user_metric["metricConfig"] for user_metric in user_trace_metrics if
|
33
|
+
user_metric["displayName"] == metric["displayName"]), None)
|
23
34
|
if not metricConfig or metricConfig.get("Metric Source", {}).get("value") != "user":
|
24
|
-
raise ValueError(
|
35
|
+
raise ValueError(
|
36
|
+
f"Metrics {metric['displayName']} already exist in dataset {dataset_name} of project {project_name}.")
|
25
37
|
headers = {
|
26
38
|
"Content-Type": "application/json",
|
27
39
|
"Authorization": f"Bearer {os.getenv('RAGAAI_CATALYST_TOKEN')}",
|
@@ -31,9 +43,9 @@ def upload_trace_metric(json_file_path, dataset_name, project_name):
|
|
31
43
|
"datasetName": dataset_name,
|
32
44
|
"metrics": metrics
|
33
45
|
})
|
34
|
-
response = requests.request("POST",
|
35
|
-
f"{RagaAICatalyst.BASE_URL}/v1/llm/trace/metrics",
|
36
|
-
headers=headers,
|
46
|
+
response = requests.request("POST",
|
47
|
+
f"{RagaAICatalyst.BASE_URL}/v1/llm/trace/metrics",
|
48
|
+
headers=headers,
|
37
49
|
data=payload,
|
38
50
|
timeout=10)
|
39
51
|
if response.status_code != 200:
|
@@ -78,14 +90,18 @@ def get_trace_metrics_from_trace(traces):
|
|
78
90
|
metrics.extend(metric)
|
79
91
|
return metrics
|
80
92
|
|
93
|
+
|
81
94
|
def _change_metrics_format_for_payload(metrics):
|
82
95
|
formatted_metrics = []
|
83
96
|
for metric in metrics:
|
84
|
-
if any(m["name"] == metric["name"
|
97
|
+
if any(m["name"] == metric.get("displayName") or m['name'] == metric.get("name") for m in formatted_metrics):
|
85
98
|
continue
|
99
|
+
metric_display_name = metric["name"]
|
100
|
+
if metric.get("displayName"):
|
101
|
+
metric_display_name = metric['displayName']
|
86
102
|
formatted_metrics.append({
|
87
|
-
"name":
|
88
|
-
"displayName":
|
103
|
+
"name": metric_display_name,
|
104
|
+
"displayName": metric_display_name,
|
89
105
|
"config": {"source": "user"},
|
90
106
|
})
|
91
|
-
return formatted_metrics
|
107
|
+
return formatted_metrics
|
@@ -71,6 +71,9 @@ def extract_parameters(kwargs):
|
|
71
71
|
# Remove messages key in parameters (OpenAI message)
|
72
72
|
if 'messages' in parameters:
|
73
73
|
del parameters['messages']
|
74
|
+
|
75
|
+
if 'run_manager' in parameters:
|
76
|
+
del parameters['run_manager']
|
74
77
|
|
75
78
|
if 'generation_config' in parameters:
|
76
79
|
generation_config = parameters['generation_config']
|
@@ -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,15 +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"]
|
21
23
|
self.gt = None
|
22
|
-
self.context =
|
24
|
+
self.context = None
|
23
25
|
|
24
26
|
def add_tags(self, tags: str | List[str]):
|
25
27
|
if isinstance(tags, str):
|
@@ -32,14 +34,14 @@ class SpanAttributes:
|
|
32
34
|
logger.debug(f"Added metadata: {metadata}")
|
33
35
|
|
34
36
|
def add_metrics(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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] = {},
|
43
45
|
):
|
44
46
|
self.metrics.append(
|
45
47
|
{
|
@@ -60,6 +62,53 @@ class SpanAttributes:
|
|
60
62
|
self.feedback = feedback
|
61
63
|
logger.debug(f"Added feedback: {self.feedback}")
|
62
64
|
|
65
|
+
# TODO: Add validation to check if all the required parameters are present
|
66
|
+
def execute_metrics(self, **kwargs: Any):
|
67
|
+
name = kwargs.get("name")
|
68
|
+
model = kwargs.get("model")
|
69
|
+
provider = kwargs.get("provider")
|
70
|
+
display_name = kwargs.get("display_name", None)
|
71
|
+
mapping = kwargs.get("mapping", None)
|
72
|
+
|
73
|
+
if isinstance(name, str):
|
74
|
+
metrics = [{
|
75
|
+
"name": name
|
76
|
+
}]
|
77
|
+
else:
|
78
|
+
metrics = name if isinstance(name, list) else [name] if isinstance(name, dict) else []
|
79
|
+
|
80
|
+
for metric in metrics:
|
81
|
+
if not isinstance(metric, dict):
|
82
|
+
raise ValueError(f"Expected dict, got {type(metric)}")
|
83
|
+
|
84
|
+
if "name" not in metric:
|
85
|
+
raise ValueError("Metric must contain 'name'")
|
86
|
+
|
87
|
+
metric_name = metric["name"]
|
88
|
+
if metric_name in self.local_metrics:
|
89
|
+
count = sum(1 for m in self.local_metrics if m.startswith(metric_name))
|
90
|
+
metric_name = f"{metric_name}_{count + 1}"
|
91
|
+
|
92
|
+
prompt =None
|
93
|
+
context = None
|
94
|
+
response = None
|
95
|
+
# if mapping is not None:
|
96
|
+
# prompt = mapping['prompt']
|
97
|
+
# context = mapping['context']
|
98
|
+
# response = mapping['response']
|
99
|
+
new_metric = {
|
100
|
+
"name": metric_name,
|
101
|
+
"model": model,
|
102
|
+
"provider": provider,
|
103
|
+
"project_id": self.project_id,
|
104
|
+
# "prompt": prompt,
|
105
|
+
# "context": context,
|
106
|
+
# "response": response,
|
107
|
+
"displayName": display_name,
|
108
|
+
"mapping": mapping
|
109
|
+
}
|
110
|
+
self.local_metrics.append(new_metric)
|
111
|
+
|
63
112
|
def add_gt(self, gt: Any):
|
64
113
|
if not isinstance(gt, (str, int, float, bool, list, dict)):
|
65
114
|
raise TypeError(f"Unsupported type for gt: {type(gt)}")
|
@@ -68,27 +117,14 @@ class SpanAttributes:
|
|
68
117
|
self.gt = gt
|
69
118
|
logger.debug(f"Added gt: {self.gt}")
|
70
119
|
|
71
|
-
def add_context(self, context:
|
120
|
+
def add_context(self, context: Any):
|
72
121
|
if isinstance(context, str):
|
73
122
|
if not context.strip():
|
74
123
|
logger.warning("Empty or whitespace-only context string provided")
|
75
|
-
|
76
|
-
elif isinstance(context, list):
|
77
|
-
fin_context = []
|
78
|
-
for cntxt in context:
|
79
|
-
if not isinstance(cntxt, str):
|
80
|
-
try:
|
81
|
-
cntxt = str(cntxt)
|
82
|
-
except Exception as e:
|
83
|
-
logger.warning('Cannot cast an element to string... Skipping')
|
84
|
-
fin_context.append(cntxt)
|
85
|
-
if not any(c for c in fin_context if c and c.strip()):
|
86
|
-
logger.warning("No valid context strings provided")
|
124
|
+
self.context = str(context)
|
87
125
|
else:
|
88
|
-
fin_context = []
|
89
126
|
try:
|
90
|
-
|
127
|
+
self.context = str(context)
|
91
128
|
except Exception as e:
|
92
129
|
logger.warning('Cannot cast the context to string... Skipping')
|
93
|
-
self.context
|
94
|
-
logger.debug(f"Added context: {self.context}")
|
130
|
+
logger.debug(f"Added context: {self.context}")
|
@@ -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}")
|
@@ -169,6 +169,7 @@ class Tracer(AgenticTracing):
|
|
169
169
|
self._upload_task = None
|
170
170
|
elif tracer_type == "llamaindex":
|
171
171
|
self._upload_task = None
|
172
|
+
self.llamaindex_tracer = None
|
172
173
|
from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
173
174
|
|
174
175
|
else:
|
@@ -256,7 +257,8 @@ class Tracer(AgenticTracing):
|
|
256
257
|
return self.langchain_tracer.start()
|
257
258
|
elif self.tracer_type == "llamaindex":
|
258
259
|
from ragaai_catalyst.tracers.llamaindex_callback import LlamaIndexTracer
|
259
|
-
|
260
|
+
self.llamaindex_tracer = LlamaIndexTracer(self._pass_user_data())
|
261
|
+
return self.llamaindex_tracer.start()
|
260
262
|
else:
|
261
263
|
super().start()
|
262
264
|
return self
|
@@ -348,8 +350,9 @@ class Tracer(AgenticTracing):
|
|
348
350
|
return
|
349
351
|
|
350
352
|
elif self.tracer_type == "llamaindex":
|
351
|
-
|
352
|
-
|
353
|
+
if self.llamaindex_tracer is None:
|
354
|
+
raise ValueError("LlamaIndex tracer was not started")
|
355
|
+
return self.llamaindex_tracer.stop()
|
353
356
|
else:
|
354
357
|
super().stop()
|
355
358
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b24
|
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
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=
|
32
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/agent_tracer.py,sha256=kxZPdaSgNY0-ykyvIEF1d6qjXlR7TV81k2Nbc1k0icg,27131
|
33
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=WpeSzPrCwsMyDQrF7juJjTV5nrP3ewR5IiMcwVqHDtg,46095
|
33
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=69A33Hyv7j9lCSX9yDTdUJeMOtPE6AD-zO38KXETxGY,48048
|
37
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=hbyKvuCeL084vlUk5fBeBnWkzPEjmdHJ_HTZtuw5TxM,18149
|
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=G7IEr0neJWg4w-ffaAhs_Wo3BSJn1VJuECPUc9zCEVA,21804
|
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=PJMwYSL9TKw0LgP--hghSbosuJF5ju5K7zUltEHfQ34,2561
|
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
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=
|
52
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/llm_utils.py,sha256=gbPqWtJINW8JVlkM41UmF5zGR8oj8Q6g9KQIS3moQYM,20439
|
51
53
|
ragaai_catalyst/tracers/agentic_tracing/utils/model_costs.json,sha256=2tzGw_cKCTPcfjEm7iGvFE6pTw7gMTPzeBov_MTaXNY,321336
|
52
|
-
ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py,sha256=
|
54
|
+
ragaai_catalyst/tracers/agentic_tracing/utils/span_attributes.py,sha256=qmODERcFZhc8MX24boFCXkkh6sJ-vZngRHPvxhyWFeE,4347
|
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
57
|
ragaai_catalyst/tracers/agentic_tracing/utils/trace_utils.py,sha256=go7FVnofviATDph-j8sk2juv09CGSRt1Vq4U868Fhd8,2259
|
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=
|
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
|
@@ -66,8 +68,8 @@ ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpa
|
|
66
68
|
ragaai_catalyst/tracers/utils/convert_langchain_callbacks_output.py,sha256=ofrNrxf2b1hpjDh_zeaxiYq86azn1MF3kW8-ViYPEg0,1641
|
67
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.5b24.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
72
|
+
ragaai_catalyst-2.1.5b24.dist-info/METADATA,sha256=b_RiCZulVnUEc2NpbCUsN1-eMICHLEqLv4VG_8kWiRI,13874
|
73
|
+
ragaai_catalyst-2.1.5b24.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
74
|
+
ragaai_catalyst-2.1.5b24.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
75
|
+
ragaai_catalyst-2.1.5b24.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|