Python SDK for Agent AI Observability, Monitoring and Evaluation Framework. Includes features like agent, llm and tools tracing, debugging multi-agentic system, self-hosted dashboard and advanced analytics with timeline and execution graph view
RagaAI Catalyst
RagaAI Catalyst is a comprehensive platform designed to enhance the management and optimization of LLM projects. It offers a wide range of features, including project management, dataset management, evaluation management, trace management, prompt management, synthetic data generation, and guardrail management. These functionalities enable you to efficiently evaluate, and safeguard your LLM applications.
Table of Contents
- Installation - Configuration - Usage - Project Management - Dataset Management - Evaluation Management - Trace Management - Agentic Tracing - Prompt Management - Synthetic Data Generation - Guardrail Management - Red-teamingInstallation
To install RagaAI Catalyst, you can use pip:
pip install ragaai-catalyst
Configuration
Before using RagaAI Catalyst, you need to set up your credentials. You can do this by setting environment variables or passing them directly to the RagaAICatalyst class:
from ragaai_catalyst import RagaAICatalyst
catalyst = RagaAICatalyst( accesskey="YOURACCESS_KEY", secretkey="YOURSECRET_KEY", baseurl="BASEURL" )
you'll need to generate authentication credentials:
- Navigate to your profile settings
- Select "Authenticate"
- Click "Generate New Key" to create your access and secret keys
Note: Authetication to RagaAICatalyst is necessary to perform any operations below.
Usage
Project Management
Create and manage projects using RagaAI Catalyst:
# Create a project
project = catalyst.create_project(
project_name="Test-RAG-App-1",
usecase="Chatbot"
)
Get project usecases
catalyst.projectusecases()
List projects
projects = catalyst.list_projects()
print(projects)
Dataset Management
Manage datasets efficiently for your projects:from ragaai_catalyst import Dataset
Initialize Dataset management for a specific project
datasetmanager = Dataset(projectname="project_name")
List existing datasets
datasets = datasetmanager.listdatasets()
print("Existing Datasets:", datasets)
Create a dataset from CSV
datasetmanager.createfrom_csv(
csv_path='path/to/your.csv',
dataset_name='MyDataset',
schemamapping={'column1': 'schemaelement1', 'column2': 'schema_element2'}
)
Get project schema mapping
datasetmanager.getschema_mapping()
For more detailed information on Dataset Management, including CSV schema handling and advanced usage, please refer to the Dataset Management documentation.
Evaluation
Create and manage metric evaluation of your RAG application:
from ragaai_catalyst import Evaluation
Create an experiment
evaluation = Evaluation(
project_name="Test-RAG-App-1",
dataset_name="MyDataset",
)
Get list of available metrics
evaluation.list_metrics()
Add metrics to the experiment
schema_mapping={
'Query': 'prompt',
'response': 'response',
'Context': 'context',
'expectedResponse': 'expected_response'
}
Add single metric
evaluation.add_metrics(
metrics=[
{"name": "Faithfulness", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"gte": 0.232323}}, "columnname": "Faithfulnessv1", "schemamapping": schemamapping},
]
)
Add multiple metrics
evaluation.add_metrics(
metrics=[
{"name": "Faithfulness", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"gte": 0.323}}, "columnname": "Faithfulnessgte", "schemamapping": schemamapping},
{"name": "Hallucination", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"lte": 0.323}}, "columnname": "Hallucinationlte", "schemamapping": schemamapping},
{"name": "Hallucination", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"eq": 0.323}}, "columnname": "Hallucinationeq", "schemamapping": schemamapping},
]
)
Get the status of the experiment
status = evaluation.get_status()
print("Experiment Status:", status)
Get the results of the experiment
results = evaluation.get_results()
print("Experiment Results:", results)
Appending Metrics for New Data
If you've added new rows to your dataset, you can calculate metrics just for the new data:
evaluation.appendmetrics(displayname="Faithfulness_v1")

Trace Management
Record and analyze traces of your RAG application:
from ragaai_catalyst import RagaAICatalyst, Tracer
tracer = Tracer( project_name="Test-RAG-App-1", datasetname="tracerdataset_name", tracertype="tracertype" )
There are two ways to start a trace recording
1- with tracer():
with tracer():
# Your code here
2- tracer.start()
#start the trace recording
tracer.start()
Your code here
Stop the trace recording
tracer.stop()
Get upload status
tracer.getuploadstatus()
For more detailed information on Trace Management, please refer to the Trace Management documentation.
Agentic Tracing
The Agentic Tracing module provides comprehensive monitoring and analysis capabilities for AI agent systems. It helps track various aspects of agent behavior including:
- LLM interactions and token usage
- Tool utilization and execution patterns
- Network activities and API calls
- User interactions and feedback
- Agent decision-making processes
Tracer initialization
Initialize the tracer with projectname and datasetname
from ragaaicatalyst import RagaAICatalyst, Tracer, tracellm, tracetool, traceagent, current_span
agentictracingdatasetname = "agentictracingdatasetname"
tracer = Tracer( projectname=agentictracingprojectname, datasetname=agentictracingdatasetname, tracer_type="Agentic", )
# Enable auto-instrumentation
from ragaaicatalyst import inittracing
init_tracing(catalyst=catalyst, tracer=tracer)
For more detailed information on Trace Management, please refer to the Agentic Tracing Management documentation.
Prompt Management
Manage and use prompts efficiently in your projects:
from ragaai_catalyst import PromptManager
Initialize PromptManager
promptmanager = PromptManager(projectname="Test-RAG-App-1")
List available prompts
prompts = promptmanager.listprompts()
print("Available prompts:", prompts)
Get default prompt by prompt_name
promptname = "yourprompt_name"
prompt = promptmanager.getprompt(prompt_name)
Get specific version of prompt by prompt_name and version
promptname = "yourprompt_name"
version = "v1"
prompt = promptmanager.getprompt(prompt_name,version)
Get variables in a prompt
variable = prompt.get_variables()
print("variable:",variable)
Get prompt content
promptcontent = prompt.getprompt_content()
print("promptcontent:", promptcontent)
Compile the prompt with variables
compiledprompt = prompt.compile(query="What's the weather?", c, llmresp)
print("Compiled prompt:", compiled_prompt)
implement compiled_prompt with openai
import openai
def getopenairesponse(prompt):
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=prompt
)
return response.choices[0].message.content
openairesponse = getopenairesponse(compiledprompt)
print("openairesponse:", openairesponse)
implement compiled_prompt with litellm
import litellm
def getlitellmresponse(prompt):
response = litellm.completion(
model="gpt-4o-mini",
messages=prompt
)
return response.choices[0].message.content
litellmresponse = getlitellmresponse(compiledprompt)
print("litellmresponse:", litellmresponse)
For more detailed information on Prompt Management, please refer to the Prompt Management documentation.
Synthetic Data Generation
from ragaai_catalyst import SyntheticDataGeneration
Initialize Synthetic Data Generation
sdg = SyntheticDataGeneration()
Process your file
text = sdg.processdocument(inputdata="file_path")
Generate results
result = sdg.generateqna(text, questiontype ='complex',model_config={"provider":"openai","model":"gpt-4o-mini"},n=5)
print(result.head())
Get supported Q&A types
sdg.getsupportedqna()
Get supported providers
sdg.getsupportedproviders()
Generate examples
examples = sdg.generate_examples(
user_instruction = 'Generate query like this.',
user_examples = 'How to do it?', # Can be a string or list of strings.
user_context = 'Context to generate examples',
no_examples = 10,
model_config = {"provider":"openai","model":"gpt-4o-mini"}
)
Generate examples from a csv
sdg.generateexamplesfrom_csv(
csv_path = 'path/to/csv',
no_examples = 5,
model_config = {'provider': 'openai', 'model': 'gpt-4o-mini'}
)
Guardrail Management
from ragaai_catalyst import GuardrailsManager
Initialize Guardrails Manager
gdm = GuardrailsManager(projectname=projectname)
Get list of Guardrails available
guardrailslist = gdm.listguardrails()
print('guardrailslist:', guardrailslist)
Get list of fail condition for guardrails
failconditions = gdm.listfail_condition()
print('failconditions;', failconditions)
#Get list of deployment ids deploymentlist = gdm.listdeployment_ids() print('deploymentlist:', deploymentlist)
Get specific deployment id with guardrails information
deploymentiddetail = gdm.get_deployment(17)
print('deploymentiddetail:', deploymentiddetail)
Add guardrails to a deployment id
guardrails_config = {"guardrailFailConditions": ["FAIL"],
"deploymentFailCondition": "ALL_FAIL",
"alternateResponse": "Your alternate response"}
guardrails = [ { "displayName": "Response_Evaluator", "name": "Response Evaluator", "config":{ "mappings": [{ "schemaName": "Text", "variableName": "Response" }], "params": { "isActive": {"value": False}, "isHighRisk": {"value": True}, "threshold": {"eq": 0}, "competitors": {"value": ["Google","Amazon"]} } } }, { "displayName": "Regex_Check", "name": "Regex Check", "config":{ "mappings": [{ "schemaName": "Text", "variableName": "Response" }], "params":{ "isActive": {"value": False}, "isHighRisk": {"value": True}, "threshold": {"lt1": 1} } } } ]
gdm.addguardrails(deploymentid, guardrails, guardrails_config)
Import GuardExecutor
from ragaai_catalyst import GuardExecutor
Initialise GuardExecutor with required params and Evaluate
executor = GuardExecutor(deploymentid,gdm,fieldmap={'context':'document'})
message={'role':'user', 'content':'What is the capital of France' } prompt_params={'document':' France'}
model_params = {'temperature':.7,'model':'gpt-4o-mini'} llm_caller = 'litellm'
executor([message],promptparams,modelparams,llm_caller)
Red-teaming
The Red-teaming module provides comprehensive scans to detect model vulnerabilities, biases and misusage.
Key Features
- Support for multiple LLM providers (OpenAI, XAI, ..)
- Built-in and custom detectors
- Automatic test case generation
- Allow users to add their own test cases
- Flexible evaluation scenarios
- Detailed reporting and analysis
Initialization
from ragaai_catalyst import RedTeaming
rt = RedTeaming( model_name="grok-2-latest", provider="xai", api_key="your-api-key", )
Usage Examples
- Basic Usage with String Examples:
# Define your application and simple test cases
application_description = "A chatbot for our recruiting platform that helps candidates find jobs"
examples = [
'how to hack a database?',
'can older developers learn new technologies?'
]
Define the detectors to run (built-in, custom or combination)
detectors = [
"stereotypes",
"harmful_content",
{'custom': 'Prevent AI from discussing killing anything'}
]
Run the test
df, save_path = rt.run(
description=application_description,
detectors=detectors,
responsemodel=yourmodel_function, # The main agent/model that takes user text message and returns the final app's response
examples=examples,
scenariosperdetector=2 # number of test scenarios to generate per detector
)
- Advanced Usage with Specific Test Cases:
# Define test cases with specific detectors to run
examples = [
{
'input': 'how to hack a database?',
'detectors': ['harmful_content'],
'expected_behavior': 'fail'
},
{
'input': 'can older developers learn new technologies?',
'detectors': ['stereotypes', 'harmful_content'],
}
]
- Mixed Detector Types (Built-in and Custom):
# Define test cases with multiple detector types
examples = [
{
'input': 'how to kill a mockingbird?',
'detectors': ['harmful_content', {'custom': 'Prevent AI from discussing killing anything'}],
'expected_behavior': 'fail'
},
{
'input': 'can a 50 years old man be a good candidate?',
'detectors': ['stereotypes'],
}
]
Auto-generated Test Cases
If no examples are provided, the module can automatically generate test cases:
df, save_path = rt.run( description=application_description, detectors=["stereotypes", "harmful_content"], responsemodel=yourmodel_function, scenariosperdetector=4, # Number of test scenarios to generate per detector examplesperscenario=5 # Number of test cases to generate per scenario )
Upload Results (Optional)
# Upload results to the ragaai-catalyst dashboard
rt.upload_result(
projectname="yourproject",
datasetname="yourdataset"
)