ragaai-catalyst 2.0.5__tar.gz → 2.0.6b1__tar.gz
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-2.0.5 → ragaai_catalyst-2.0.6b1}/PKG-INFO +139 -72
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/README.md +135 -71
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/pyproject.toml +5 -2
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/__init__.py +3 -1
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/dataset.py +49 -60
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/evaluation.py +47 -29
- ragaai_catalyst-2.0.6b1/ragaai_catalyst/guard_executor.py +97 -0
- ragaai_catalyst-2.0.6b1/ragaai_catalyst/guardrails_manager.py +259 -0
- ragaai_catalyst-2.0.6b1/ragaai_catalyst/internal_api_completion.py +83 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/proxy_call.py +1 -1
- ragaai_catalyst-2.0.6b1/ragaai_catalyst/synthetic_data_generation.py +452 -0
- ragaai_catalyst-2.0.6b1/ragaai_catalyst/tracers/llamaindex_callback.py +361 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/tracer.py +62 -28
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst.egg-info/PKG-INFO +139 -72
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst.egg-info/SOURCES.txt +4 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst.egg-info/requires.txt +3 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/requirements.txt +2 -1
- ragaai_catalyst-2.0.5/ragaai_catalyst/synthetic_data_generation.py +0 -323
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/.gitignore +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/__init__.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/docs/dataset_management.md +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/docs/prompt_management.md +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/examples/prompt_management_litellm.ipynb +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/examples/prompt_management_openai.ipynb +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/_version.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/experiment.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/prompt_manager.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/ragaai_catalyst.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/__init__.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/exporters/__init__.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/exporters/file_span_exporter.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/exporters/raga_exporter.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/instrumentators/__init__.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/instrumentators/langchain.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/instrumentators/llamaindex.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/instrumentators/openai.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/utils/__init__.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/tracers/utils/utils.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst/utils.py +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst.egg-info/dependency_links.txt +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/ragaai_catalyst.egg-info/top_level.txt +0 -0
- {ragaai_catalyst-2.0.5 → ragaai_catalyst-2.0.6b1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.6b1
|
4
4
|
Summary: RAGA AI CATALYST
|
5
5
|
Author-email: Kiran Scaria <kiran.scaria@raga.ai>, Kedar Gaikwad <kedar.gaikwad@raga.ai>, Dushyant Mahajan <dushyant.mahajan@raga.ai>, Siddhartha Kosti <siddhartha.kosti@raga.ai>, Ritika Goel <ritika.goel@raga.ai>, Vijay Chaurasia <vijay.chaurasia@raga.ai>
|
6
6
|
Requires-Python: >=3.9
|
@@ -24,7 +24,10 @@ Requires-Dist: groq>=0.11.0
|
|
24
24
|
Requires-Dist: PyPDF2>=3.0.1
|
25
25
|
Requires-Dist: google-generativeai>=0.8.2
|
26
26
|
Requires-Dist: Markdown>=3.7
|
27
|
+
Requires-Dist: litellm==1.51.1
|
27
28
|
Requires-Dist: tenacity==8.3.0
|
29
|
+
Requires-Dist: tqdm>=4.66.5
|
30
|
+
Requires-Dist: llama-index==0.10.0
|
28
31
|
Provides-Extra: dev
|
29
32
|
Requires-Dist: pytest; extra == "dev"
|
30
33
|
Requires-Dist: pytest-cov; extra == "dev"
|
@@ -45,10 +48,11 @@ RagaAI Catalyst is a powerful tool for managing and optimizing LLM projects. It
|
|
45
48
|
- [Configuration](#configuration)
|
46
49
|
- [Usage](#usage)
|
47
50
|
- [Project Management](#project-management)
|
48
|
-
- [Trace Management](#trace-management)
|
49
|
-
- [Experiment Management](#experiment-management)
|
50
51
|
- [Dataset Management](#dataset-management)
|
52
|
+
- [Evaluation Management](#evaluation)
|
53
|
+
- [Trace Management](#trace-management)
|
51
54
|
- [Prompt Management](#prompt-management)
|
55
|
+
- [Synthetic Data Generation](#synthetic-data-generation)
|
52
56
|
|
53
57
|
## Installation
|
54
58
|
|
@@ -84,145 +88,208 @@ Create and manage projects using RagaAI Catalyst:
|
|
84
88
|
# Create a project
|
85
89
|
project = catalyst.create_project(
|
86
90
|
project_name="Test-RAG-App-1",
|
87
|
-
|
91
|
+
usecase="Chatbot"
|
88
92
|
)
|
89
93
|
|
94
|
+
# Get project usecases
|
95
|
+
catalyst.project_use_cases()
|
96
|
+
|
90
97
|
# List projects
|
91
98
|
projects = catalyst.list_projects()
|
92
99
|
print(projects)
|
93
100
|
```
|
94
101
|
|
95
|
-
###
|
102
|
+
### Dataset Management
|
103
|
+
Manage datasets efficiently for your projects:
|
96
104
|
|
97
|
-
|
105
|
+
```py
|
106
|
+
from ragaai_catalyst import Dataset
|
98
107
|
|
99
|
-
|
100
|
-
|
108
|
+
# Initialize Dataset management for a specific project
|
109
|
+
dataset_manager = Dataset(project_name="project_name")
|
101
110
|
|
102
|
-
#
|
103
|
-
|
104
|
-
|
105
|
-
metadata={"key1": "value1", "key2": "value2"},
|
106
|
-
tracer_type="langchain",
|
107
|
-
pipeline={
|
108
|
-
"llm_model": "gpt-3.5-turbo",
|
109
|
-
"vector_store": "faiss",
|
110
|
-
"embed_model": "text-embedding-ada-002",
|
111
|
-
}
|
112
|
-
).start()
|
111
|
+
# List existing datasets
|
112
|
+
datasets = dataset_manager.list_datasets()
|
113
|
+
print("Existing Datasets:", datasets)
|
113
114
|
|
114
|
-
#
|
115
|
+
# Create a dataset from CSV
|
116
|
+
dataset_manager.create_from_csv(
|
117
|
+
csv_path='path/to/your.csv',
|
118
|
+
dataset_name='MyDataset',
|
119
|
+
schema_mapping={'column1': 'schema_element1', 'column2': 'schema_element2'}
|
120
|
+
)
|
115
121
|
|
116
|
-
#
|
117
|
-
|
122
|
+
# Get project schema mapping
|
123
|
+
dataset_manager.get_schema_mapping()
|
118
124
|
|
119
|
-
# Alternatively, use a context manager
|
120
|
-
with tracer.trace():
|
121
|
-
# Your code here
|
122
125
|
```
|
123
126
|
|
124
|
-
|
127
|
+
For more detailed information on Dataset Management, including CSV schema handling and advanced usage, please refer to the [Dataset Management documentation](docs/dataset_management.md).
|
128
|
+
|
129
|
+
|
130
|
+
### Evaluation
|
125
131
|
|
126
|
-
Create and manage
|
132
|
+
Create and manage metric evaluation of your RAG application:
|
127
133
|
|
128
134
|
```python
|
129
|
-
from ragaai_catalyst import
|
135
|
+
from ragaai_catalyst import Evaluation
|
130
136
|
|
131
137
|
# Create an experiment
|
132
|
-
|
138
|
+
evaluation = Evaluation(
|
133
139
|
project_name="Test-RAG-App-1",
|
134
|
-
|
135
|
-
experiment_description="Experiment Description",
|
136
|
-
dataset_name="Dataset Created from UI",
|
140
|
+
dataset_name="MyDataset",
|
137
141
|
)
|
138
142
|
|
143
|
+
# Get list of available metrics
|
144
|
+
evaluation.list_metrics()
|
145
|
+
|
139
146
|
# Add metrics to the experiment
|
140
|
-
|
147
|
+
schema_mapping={
|
148
|
+
'Query': 'prompt',
|
149
|
+
'response': 'response',
|
150
|
+
'Context': 'context',
|
151
|
+
'expectedResponse': 'expected_response'
|
152
|
+
}
|
153
|
+
|
154
|
+
# Add single metric
|
155
|
+
evaluation.add_metrics(
|
141
156
|
metrics=[
|
142
|
-
{"name": "
|
157
|
+
{"name": "Faithfulness", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"gte": 0.232323}}, "column_name": "Faithfulness_v1", "schema_mapping": schema_mapping},
|
158
|
+
|
143
159
|
]
|
144
160
|
)
|
145
161
|
|
146
162
|
# Add multiple metrics
|
147
|
-
|
163
|
+
evaluation.add_metrics(
|
148
164
|
metrics=[
|
149
|
-
{"name": "
|
150
|
-
{"name": "
|
151
|
-
{"name": "
|
165
|
+
{"name": "Faithfulness", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"gte": 0.323}}, "column_name": "Faithfulness_gte", "schema_mapping": schema_mapping},
|
166
|
+
{"name": "Hallucination", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"lte": 0.323}}, "column_name": "Hallucination_lte", "schema_mapping": schema_mapping},
|
167
|
+
{"name": "Hallucination", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"eq": 0.323}}, "column_name": "Hallucination_eq", "schema_mapping": schema_mapping},
|
152
168
|
]
|
153
169
|
)
|
154
170
|
|
155
171
|
# Get the status of the experiment
|
156
|
-
status =
|
172
|
+
status = evaluation.get_status()
|
157
173
|
print("Experiment Status:", status)
|
158
174
|
|
159
175
|
# Get the results of the experiment
|
160
|
-
results =
|
176
|
+
results = evaluation.get_results()
|
161
177
|
print("Experiment Results:", results)
|
162
178
|
```
|
163
179
|
|
164
180
|
|
165
181
|
|
166
|
-
|
167
|
-
Manage datasets efficiently for your projects:
|
182
|
+
### Trace Management
|
168
183
|
|
169
|
-
|
170
|
-
from ragaai_catalyst import Dataset
|
184
|
+
Record and analyze traces of your RAG application:
|
171
185
|
|
172
|
-
|
173
|
-
|
186
|
+
```python
|
187
|
+
from ragaai_catalyst import Tracer
|
174
188
|
|
175
|
-
#
|
176
|
-
|
177
|
-
|
189
|
+
# Start a trace recording
|
190
|
+
tracer = Tracer(
|
191
|
+
project_name="Test-RAG-App-1",
|
192
|
+
dataset_name="tracer_dataset_name"
|
193
|
+
metadata={"key1": "value1", "key2": "value2"},
|
194
|
+
tracer_type="langchain",
|
195
|
+
pipeline={
|
196
|
+
"llm_model": "gpt-3.5-turbo",
|
197
|
+
"vector_store": "faiss",
|
198
|
+
"embed_model": "text-embedding-ada-002",
|
199
|
+
}
|
200
|
+
).start()
|
178
201
|
|
179
|
-
#
|
180
|
-
dataset_manager.create_from_trace(
|
181
|
-
dataset_name='Test-dataset-1',
|
182
|
-
filter_list=[
|
183
|
-
{"name": "llm_model", "values": ["gpt-3.5-turbo", "gpt-4"]},
|
184
|
-
{"name": "prompt_length", "lte": 27, "gte": 23}
|
185
|
-
]
|
186
|
-
)
|
202
|
+
# Your code here
|
187
203
|
|
188
|
-
#
|
189
|
-
|
190
|
-
csv_path='path/to/your.csv',
|
191
|
-
dataset_name='MyDataset',
|
192
|
-
schema_mapping={'column1': 'schema_element1', 'column2': 'schema_element2'}
|
193
|
-
)
|
204
|
+
# Stop the trace recording
|
205
|
+
tracer.stop()
|
194
206
|
```
|
195
207
|
|
196
|
-
For more detailed information on Dataset Management, including CSV schema handling and advanced usage, please refer to the [Dataset Management documentation](docs/dataset_management.md).
|
197
208
|
|
198
|
-
|
209
|
+
### Prompt Management
|
199
210
|
|
200
211
|
Manage and use prompts efficiently in your projects:
|
201
212
|
|
202
213
|
```py
|
203
|
-
from ragaai_catalyst
|
214
|
+
from ragaai_catalyst import PromptManager
|
204
215
|
|
205
216
|
# Initialize PromptManager
|
206
|
-
prompt_manager = PromptManager("
|
217
|
+
prompt_manager = PromptManager(project_name="Test-RAG-App-1")
|
207
218
|
|
208
219
|
# List available prompts
|
209
220
|
prompts = prompt_manager.list_prompts()
|
210
221
|
print("Available prompts:", prompts)
|
211
222
|
|
212
|
-
# Get
|
223
|
+
# Get default prompt by prompt_name
|
213
224
|
prompt_name = "your_prompt_name"
|
214
225
|
prompt = prompt_manager.get_prompt(prompt_name)
|
215
226
|
|
227
|
+
# Get specific version of prompt by prompt_name and version
|
228
|
+
prompt_name = "your_prompt_name"
|
229
|
+
version = "v1"
|
230
|
+
prompt = prompt_manager.get_prompt(prompt_name,version)
|
231
|
+
|
232
|
+
# Get variables in a prompt
|
233
|
+
variable = prompt.get_variables()
|
234
|
+
print("variable:",variable)
|
235
|
+
|
236
|
+
# Get prompt content
|
237
|
+
prompt_content = prompt.get_prompt_content()
|
238
|
+
print("prompt_content:", prompt_content)
|
239
|
+
|
216
240
|
# Compile a prompt with variables
|
217
241
|
compiled_prompt = prompt.compile(query="What's the weather?", context="sunny", llm_response="It's sunny today")
|
218
242
|
print("Compiled prompt:", compiled_prompt)
|
219
243
|
|
220
|
-
#
|
221
|
-
|
222
|
-
|
223
|
-
|
244
|
+
# implement compiled_prompt with openai
|
245
|
+
import openai
|
246
|
+
def get_openai_response(prompt):
|
247
|
+
client = openai.OpenAI()
|
248
|
+
response = client.chat.completions.create(
|
249
|
+
model="gpt-4o-mini",
|
250
|
+
messages=prompt
|
251
|
+
)
|
252
|
+
return response.choices[0].message.content
|
253
|
+
openai_response = get_openai_response(compiled_prompt)
|
254
|
+
print("openai_response:", openai_response)
|
255
|
+
|
256
|
+
# implement compiled_prompt with litellm
|
257
|
+
import litellm
|
258
|
+
def get_litellm_response(prompt):
|
259
|
+
response = litellm.completion(
|
260
|
+
model="gpt-4o-mini",
|
261
|
+
messages=prompt
|
262
|
+
)
|
263
|
+
return response.choices[0].message.content
|
264
|
+
litellm_response = get_litellm_response(compiled_prompt)
|
265
|
+
print("litellm_response:", litellm_response)
|
224
266
|
|
267
|
+
```
|
225
268
|
For more detailed information on Prompt Management, please refer to the [Prompt Management documentation](docs/prompt_management.md).
|
226
269
|
|
227
270
|
|
271
|
+
### Synthetic Data Generation
|
272
|
+
|
273
|
+
```py
|
274
|
+
from ragaai_catalyst import SyntheticDataGeneration
|
275
|
+
|
276
|
+
# Initialize Synthetic Data Generation
|
277
|
+
sdg = SyntheticDataGeneration()
|
278
|
+
|
279
|
+
# Process your file
|
280
|
+
text = sdg.process_document(input_data="file_path")
|
281
|
+
|
282
|
+
# Generate results
|
283
|
+
result = sdg.generate_qna(text, question_type ='simple',model_config={"provider":"openai","model":"gpt-4o-mini"},n=20)
|
284
|
+
|
285
|
+
# Get supported Q&A types
|
286
|
+
sdg.get_supported_qna()
|
287
|
+
|
288
|
+
# Get supported providers
|
289
|
+
sdg.get_supported_providers()
|
290
|
+
```
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
228
295
|
|
@@ -10,10 +10,11 @@ RagaAI Catalyst is a powerful tool for managing and optimizing LLM projects. It
|
|
10
10
|
- [Configuration](#configuration)
|
11
11
|
- [Usage](#usage)
|
12
12
|
- [Project Management](#project-management)
|
13
|
-
- [Trace Management](#trace-management)
|
14
|
-
- [Experiment Management](#experiment-management)
|
15
13
|
- [Dataset Management](#dataset-management)
|
14
|
+
- [Evaluation Management](#evaluation)
|
15
|
+
- [Trace Management](#trace-management)
|
16
16
|
- [Prompt Management](#prompt-management)
|
17
|
+
- [Synthetic Data Generation](#synthetic-data-generation)
|
17
18
|
|
18
19
|
## Installation
|
19
20
|
|
@@ -49,145 +50,208 @@ Create and manage projects using RagaAI Catalyst:
|
|
49
50
|
# Create a project
|
50
51
|
project = catalyst.create_project(
|
51
52
|
project_name="Test-RAG-App-1",
|
52
|
-
|
53
|
+
usecase="Chatbot"
|
53
54
|
)
|
54
55
|
|
56
|
+
# Get project usecases
|
57
|
+
catalyst.project_use_cases()
|
58
|
+
|
55
59
|
# List projects
|
56
60
|
projects = catalyst.list_projects()
|
57
61
|
print(projects)
|
58
62
|
```
|
59
63
|
|
60
|
-
###
|
64
|
+
### Dataset Management
|
65
|
+
Manage datasets efficiently for your projects:
|
61
66
|
|
62
|
-
|
67
|
+
```py
|
68
|
+
from ragaai_catalyst import Dataset
|
63
69
|
|
64
|
-
|
65
|
-
|
70
|
+
# Initialize Dataset management for a specific project
|
71
|
+
dataset_manager = Dataset(project_name="project_name")
|
66
72
|
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
metadata={"key1": "value1", "key2": "value2"},
|
71
|
-
tracer_type="langchain",
|
72
|
-
pipeline={
|
73
|
-
"llm_model": "gpt-3.5-turbo",
|
74
|
-
"vector_store": "faiss",
|
75
|
-
"embed_model": "text-embedding-ada-002",
|
76
|
-
}
|
77
|
-
).start()
|
73
|
+
# List existing datasets
|
74
|
+
datasets = dataset_manager.list_datasets()
|
75
|
+
print("Existing Datasets:", datasets)
|
78
76
|
|
79
|
-
#
|
77
|
+
# Create a dataset from CSV
|
78
|
+
dataset_manager.create_from_csv(
|
79
|
+
csv_path='path/to/your.csv',
|
80
|
+
dataset_name='MyDataset',
|
81
|
+
schema_mapping={'column1': 'schema_element1', 'column2': 'schema_element2'}
|
82
|
+
)
|
80
83
|
|
81
|
-
#
|
82
|
-
|
84
|
+
# Get project schema mapping
|
85
|
+
dataset_manager.get_schema_mapping()
|
83
86
|
|
84
|
-
# Alternatively, use a context manager
|
85
|
-
with tracer.trace():
|
86
|
-
# Your code here
|
87
87
|
```
|
88
88
|
|
89
|
-
|
89
|
+
For more detailed information on Dataset Management, including CSV schema handling and advanced usage, please refer to the [Dataset Management documentation](docs/dataset_management.md).
|
90
|
+
|
91
|
+
|
92
|
+
### Evaluation
|
90
93
|
|
91
|
-
Create and manage
|
94
|
+
Create and manage metric evaluation of your RAG application:
|
92
95
|
|
93
96
|
```python
|
94
|
-
from ragaai_catalyst import
|
97
|
+
from ragaai_catalyst import Evaluation
|
95
98
|
|
96
99
|
# Create an experiment
|
97
|
-
|
100
|
+
evaluation = Evaluation(
|
98
101
|
project_name="Test-RAG-App-1",
|
99
|
-
|
100
|
-
experiment_description="Experiment Description",
|
101
|
-
dataset_name="Dataset Created from UI",
|
102
|
+
dataset_name="MyDataset",
|
102
103
|
)
|
103
104
|
|
105
|
+
# Get list of available metrics
|
106
|
+
evaluation.list_metrics()
|
107
|
+
|
104
108
|
# Add metrics to the experiment
|
105
|
-
|
109
|
+
schema_mapping={
|
110
|
+
'Query': 'prompt',
|
111
|
+
'response': 'response',
|
112
|
+
'Context': 'context',
|
113
|
+
'expectedResponse': 'expected_response'
|
114
|
+
}
|
115
|
+
|
116
|
+
# Add single metric
|
117
|
+
evaluation.add_metrics(
|
106
118
|
metrics=[
|
107
|
-
{"name": "
|
119
|
+
{"name": "Faithfulness", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"gte": 0.232323}}, "column_name": "Faithfulness_v1", "schema_mapping": schema_mapping},
|
120
|
+
|
108
121
|
]
|
109
122
|
)
|
110
123
|
|
111
124
|
# Add multiple metrics
|
112
|
-
|
125
|
+
evaluation.add_metrics(
|
113
126
|
metrics=[
|
114
|
-
{"name": "
|
115
|
-
{"name": "
|
116
|
-
{"name": "
|
127
|
+
{"name": "Faithfulness", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"gte": 0.323}}, "column_name": "Faithfulness_gte", "schema_mapping": schema_mapping},
|
128
|
+
{"name": "Hallucination", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"lte": 0.323}}, "column_name": "Hallucination_lte", "schema_mapping": schema_mapping},
|
129
|
+
{"name": "Hallucination", "config": {"model": "gpt-4o-mini", "provider": "openai", "threshold": {"eq": 0.323}}, "column_name": "Hallucination_eq", "schema_mapping": schema_mapping},
|
117
130
|
]
|
118
131
|
)
|
119
132
|
|
120
133
|
# Get the status of the experiment
|
121
|
-
status =
|
134
|
+
status = evaluation.get_status()
|
122
135
|
print("Experiment Status:", status)
|
123
136
|
|
124
137
|
# Get the results of the experiment
|
125
|
-
results =
|
138
|
+
results = evaluation.get_results()
|
126
139
|
print("Experiment Results:", results)
|
127
140
|
```
|
128
141
|
|
129
142
|
|
130
143
|
|
131
|
-
|
132
|
-
Manage datasets efficiently for your projects:
|
144
|
+
### Trace Management
|
133
145
|
|
134
|
-
|
135
|
-
from ragaai_catalyst import Dataset
|
146
|
+
Record and analyze traces of your RAG application:
|
136
147
|
|
137
|
-
|
138
|
-
|
148
|
+
```python
|
149
|
+
from ragaai_catalyst import Tracer
|
139
150
|
|
140
|
-
#
|
141
|
-
|
142
|
-
|
151
|
+
# Start a trace recording
|
152
|
+
tracer = Tracer(
|
153
|
+
project_name="Test-RAG-App-1",
|
154
|
+
dataset_name="tracer_dataset_name"
|
155
|
+
metadata={"key1": "value1", "key2": "value2"},
|
156
|
+
tracer_type="langchain",
|
157
|
+
pipeline={
|
158
|
+
"llm_model": "gpt-3.5-turbo",
|
159
|
+
"vector_store": "faiss",
|
160
|
+
"embed_model": "text-embedding-ada-002",
|
161
|
+
}
|
162
|
+
).start()
|
143
163
|
|
144
|
-
#
|
145
|
-
dataset_manager.create_from_trace(
|
146
|
-
dataset_name='Test-dataset-1',
|
147
|
-
filter_list=[
|
148
|
-
{"name": "llm_model", "values": ["gpt-3.5-turbo", "gpt-4"]},
|
149
|
-
{"name": "prompt_length", "lte": 27, "gte": 23}
|
150
|
-
]
|
151
|
-
)
|
164
|
+
# Your code here
|
152
165
|
|
153
|
-
#
|
154
|
-
|
155
|
-
csv_path='path/to/your.csv',
|
156
|
-
dataset_name='MyDataset',
|
157
|
-
schema_mapping={'column1': 'schema_element1', 'column2': 'schema_element2'}
|
158
|
-
)
|
166
|
+
# Stop the trace recording
|
167
|
+
tracer.stop()
|
159
168
|
```
|
160
169
|
|
161
|
-
For more detailed information on Dataset Management, including CSV schema handling and advanced usage, please refer to the [Dataset Management documentation](docs/dataset_management.md).
|
162
170
|
|
163
|
-
|
171
|
+
### Prompt Management
|
164
172
|
|
165
173
|
Manage and use prompts efficiently in your projects:
|
166
174
|
|
167
175
|
```py
|
168
|
-
from ragaai_catalyst
|
176
|
+
from ragaai_catalyst import PromptManager
|
169
177
|
|
170
178
|
# Initialize PromptManager
|
171
|
-
prompt_manager = PromptManager("
|
179
|
+
prompt_manager = PromptManager(project_name="Test-RAG-App-1")
|
172
180
|
|
173
181
|
# List available prompts
|
174
182
|
prompts = prompt_manager.list_prompts()
|
175
183
|
print("Available prompts:", prompts)
|
176
184
|
|
177
|
-
# Get
|
185
|
+
# Get default prompt by prompt_name
|
178
186
|
prompt_name = "your_prompt_name"
|
179
187
|
prompt = prompt_manager.get_prompt(prompt_name)
|
180
188
|
|
189
|
+
# Get specific version of prompt by prompt_name and version
|
190
|
+
prompt_name = "your_prompt_name"
|
191
|
+
version = "v1"
|
192
|
+
prompt = prompt_manager.get_prompt(prompt_name,version)
|
193
|
+
|
194
|
+
# Get variables in a prompt
|
195
|
+
variable = prompt.get_variables()
|
196
|
+
print("variable:",variable)
|
197
|
+
|
198
|
+
# Get prompt content
|
199
|
+
prompt_content = prompt.get_prompt_content()
|
200
|
+
print("prompt_content:", prompt_content)
|
201
|
+
|
181
202
|
# Compile a prompt with variables
|
182
203
|
compiled_prompt = prompt.compile(query="What's the weather?", context="sunny", llm_response="It's sunny today")
|
183
204
|
print("Compiled prompt:", compiled_prompt)
|
184
205
|
|
185
|
-
#
|
186
|
-
|
187
|
-
|
188
|
-
|
206
|
+
# implement compiled_prompt with openai
|
207
|
+
import openai
|
208
|
+
def get_openai_response(prompt):
|
209
|
+
client = openai.OpenAI()
|
210
|
+
response = client.chat.completions.create(
|
211
|
+
model="gpt-4o-mini",
|
212
|
+
messages=prompt
|
213
|
+
)
|
214
|
+
return response.choices[0].message.content
|
215
|
+
openai_response = get_openai_response(compiled_prompt)
|
216
|
+
print("openai_response:", openai_response)
|
217
|
+
|
218
|
+
# implement compiled_prompt with litellm
|
219
|
+
import litellm
|
220
|
+
def get_litellm_response(prompt):
|
221
|
+
response = litellm.completion(
|
222
|
+
model="gpt-4o-mini",
|
223
|
+
messages=prompt
|
224
|
+
)
|
225
|
+
return response.choices[0].message.content
|
226
|
+
litellm_response = get_litellm_response(compiled_prompt)
|
227
|
+
print("litellm_response:", litellm_response)
|
189
228
|
|
229
|
+
```
|
190
230
|
For more detailed information on Prompt Management, please refer to the [Prompt Management documentation](docs/prompt_management.md).
|
191
231
|
|
192
232
|
|
233
|
+
### Synthetic Data Generation
|
234
|
+
|
235
|
+
```py
|
236
|
+
from ragaai_catalyst import SyntheticDataGeneration
|
237
|
+
|
238
|
+
# Initialize Synthetic Data Generation
|
239
|
+
sdg = SyntheticDataGeneration()
|
240
|
+
|
241
|
+
# Process your file
|
242
|
+
text = sdg.process_document(input_data="file_path")
|
243
|
+
|
244
|
+
# Generate results
|
245
|
+
result = sdg.generate_qna(text, question_type ='simple',model_config={"provider":"openai","model":"gpt-4o-mini"},n=20)
|
246
|
+
|
247
|
+
# Get supported Q&A types
|
248
|
+
sdg.get_supported_qna()
|
249
|
+
|
250
|
+
# Get supported providers
|
251
|
+
sdg.get_supported_providers()
|
252
|
+
```
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
193
257
|
|
@@ -8,7 +8,7 @@ description = "RAGA AI CATALYST"
|
|
8
8
|
readme = "README.md"
|
9
9
|
requires-python = ">=3.9"
|
10
10
|
# license = {file = "LICENSE"}
|
11
|
-
version = "2.0.
|
11
|
+
version = "2.0.6.beta.1"
|
12
12
|
authors = [
|
13
13
|
{name = "Kiran Scaria", email = "kiran.scaria@raga.ai"},
|
14
14
|
{name = "Kedar Gaikwad", email = "kedar.gaikwad@raga.ai"},
|
@@ -37,8 +37,11 @@ dependencies = [
|
|
37
37
|
"groq>=0.11.0",
|
38
38
|
"PyPDF2>=3.0.1",
|
39
39
|
"google-generativeai>=0.8.2",
|
40
|
-
"Markdown>=3.7",
|
40
|
+
"Markdown>=3.7",
|
41
|
+
"litellm==1.51.1",
|
41
42
|
"tenacity==8.3.0",
|
43
|
+
"tqdm>=4.66.5",
|
44
|
+
"llama-index==0.10.0"
|
42
45
|
]
|
43
46
|
|
44
47
|
[project.optional-dependencies]
|
@@ -6,6 +6,8 @@ from .dataset import Dataset
|
|
6
6
|
from .prompt_manager import PromptManager
|
7
7
|
from .evaluation import Evaluation
|
8
8
|
from .synthetic_data_generation import SyntheticDataGeneration
|
9
|
+
from .guardrails_manager import GuardrailsManager
|
10
|
+
from .guard_executor import GuardExecutor
|
9
11
|
|
10
12
|
|
11
|
-
__all__ = ["Experiment", "RagaAICatalyst", "Tracer", "PromptManager", "Evaluation","SyntheticDataGeneration"]
|
13
|
+
__all__ = ["Experiment", "RagaAICatalyst", "Tracer", "PromptManager", "Evaluation","SyntheticDataGeneration", "GuardrailsManager"]
|