ragaai-catalyst 2.0.6b1__py3-none-any.whl → 2.0.7b1__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/dataset.py +1 -1
- ragaai_catalyst/evaluation.py +1 -1
- ragaai_catalyst/guardrails_manager.py +2 -2
- ragaai_catalyst/internal_api_completion.py +1 -1
- ragaai_catalyst/prompt_manager.py +7 -2
- ragaai_catalyst/ragaai_catalyst.py +1 -1
- ragaai_catalyst/synthetic_data_generation.py +1 -0
- {ragaai_catalyst-2.0.6b1.dist-info → ragaai_catalyst-2.0.7b1.dist-info}/METADATA +95 -4
- {ragaai_catalyst-2.0.6b1.dist-info → ragaai_catalyst-2.0.7b1.dist-info}/RECORD +11 -11
- {ragaai_catalyst-2.0.6b1.dist-info → ragaai_catalyst-2.0.7b1.dist-info}/WHEEL +1 -1
- {ragaai_catalyst-2.0.6b1.dist-info → ragaai_catalyst-2.0.7b1.dist-info}/top_level.txt +0 -0
ragaai_catalyst/dataset.py
CHANGED
ragaai_catalyst/evaluation.py
CHANGED
@@ -13,7 +13,7 @@ class GuardrailsManager:
|
|
13
13
|
"""
|
14
14
|
self.project_name = project_name
|
15
15
|
self.timeout = 10
|
16
|
-
self.num_projects =
|
16
|
+
self.num_projects = 99999
|
17
17
|
self.deployment_name = "NA"
|
18
18
|
self.deployment_id = "NA"
|
19
19
|
self.base_url = f"{RagaAICatalyst.BASE_URL}"
|
@@ -31,7 +31,7 @@ class GuardrailsManager:
|
|
31
31
|
:return: A tuple containing a list of project names and a list of dictionaries with project IDs and names.
|
32
32
|
"""
|
33
33
|
headers = {'Authorization': f'Bearer {os.getenv("RAGAAI_CATALYST_TOKEN")}'}
|
34
|
-
response = requests.request("GET", f"{self.base_url}/v2/llm/projects?size=
|
34
|
+
response = requests.request("GET", f"{self.base_url}/v2/llm/projects?size={self.num_projects}", headers=headers, timeout=self.timeout)
|
35
35
|
project_content = response.json()["data"]["content"]
|
36
36
|
list_project = [_["name"] for _ in project_content]
|
37
37
|
project_name_with_id = [{"id": _["id"], "name": _["name"]} for _ in project_content]
|
@@ -36,7 +36,7 @@ def api_completion(messages, model_config, kwargs):
|
|
36
36
|
raise ValueError(response["error"]["message"])
|
37
37
|
else:
|
38
38
|
result= response["choices"][0]["message"]["content"]
|
39
|
-
response1 = result.replace('\n', '')
|
39
|
+
response1 = result.replace('\n', '').replace('```json','').replace('```', '').strip()
|
40
40
|
try:
|
41
41
|
json_data = json.loads(response1)
|
42
42
|
df = pd.DataFrame(json_data)
|
@@ -23,7 +23,7 @@ class PromptManager:
|
|
23
23
|
self.project_name = project_name
|
24
24
|
self.base_url = f"{RagaAICatalyst.BASE_URL}/playground/prompt"
|
25
25
|
self.timeout = 10
|
26
|
-
self.size =
|
26
|
+
self.size = 99999 #Number of projects to fetch
|
27
27
|
|
28
28
|
try:
|
29
29
|
response = requests.get(
|
@@ -432,7 +432,12 @@ class PromptObject:
|
|
432
432
|
Returns:
|
433
433
|
dict: A dictionary of parameters found in the prompt text.
|
434
434
|
"""
|
435
|
-
parameters = {
|
435
|
+
parameters = {}
|
436
|
+
for param in self.parameters:
|
437
|
+
if "value" in param:
|
438
|
+
parameters[param["name"]] = self._convert_value(param["value"], param["type"])
|
439
|
+
else:
|
440
|
+
parameters[param["name"]] = ""
|
436
441
|
parameters["model"] = self.model
|
437
442
|
return parameters
|
438
443
|
|
@@ -287,7 +287,7 @@ class RagaAICatalyst:
|
|
287
287
|
def get_project_id(self, project_name):
|
288
288
|
pass
|
289
289
|
|
290
|
-
def list_projects(self, num_projects=
|
290
|
+
def list_projects(self, num_projects=99999):
|
291
291
|
"""
|
292
292
|
Retrieves a list of projects with the specified number of projects.
|
293
293
|
|
@@ -289,6 +289,7 @@ class SyntheticDataGeneration:
|
|
289
289
|
|
290
290
|
# Extract the content from the response
|
291
291
|
content = response.choices[0].message.content
|
292
|
+
content = content.replace('\n', '').replace('```json','').replace('```', '').strip()
|
292
293
|
|
293
294
|
# Clean the response if needed (remove any prefix before the JSON list)
|
294
295
|
list_start_index = content.find('[')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.7b1
|
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
|
@@ -28,6 +28,7 @@ Requires-Dist: litellm==1.51.1
|
|
28
28
|
Requires-Dist: tenacity==8.3.0
|
29
29
|
Requires-Dist: tqdm>=4.66.5
|
30
30
|
Requires-Dist: llama-index==0.10.0
|
31
|
+
Requires-Dist: pyopenssl==24.2.1
|
31
32
|
Provides-Extra: dev
|
32
33
|
Requires-Dist: pytest; extra == "dev"
|
33
34
|
Requires-Dist: pytest-cov; extra == "dev"
|
@@ -38,7 +39,7 @@ Requires-Dist: flake8; extra == "dev"
|
|
38
39
|
|
39
40
|
# RagaAI Catalyst
|
40
41
|
|
41
|
-
RagaAI Catalyst is a
|
42
|
+
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.
|
42
43
|
|
43
44
|
## Table of Contents
|
44
45
|
|
@@ -53,6 +54,7 @@ RagaAI Catalyst is a powerful tool for managing and optimizing LLM projects. It
|
|
53
54
|
- [Trace Management](#trace-management)
|
54
55
|
- [Prompt Management](#prompt-management)
|
55
56
|
- [Synthetic Data Generation](#synthetic-data-generation)
|
57
|
+
- [Guardrail Management](#guardrail-management)
|
56
58
|
|
57
59
|
## Installation
|
58
60
|
|
@@ -144,6 +146,7 @@ evaluation = Evaluation(
|
|
144
146
|
evaluation.list_metrics()
|
145
147
|
|
146
148
|
# Add metrics to the experiment
|
149
|
+
|
147
150
|
schema_mapping={
|
148
151
|
'Query': 'prompt',
|
149
152
|
'response': 'response',
|
@@ -201,8 +204,12 @@ tracer = Tracer(
|
|
201
204
|
|
202
205
|
# Your code here
|
203
206
|
|
207
|
+
|
204
208
|
# Stop the trace recording
|
205
209
|
tracer.stop()
|
210
|
+
|
211
|
+
# Get upload status
|
212
|
+
tracer.get_upload_status()
|
206
213
|
```
|
207
214
|
|
208
215
|
|
@@ -237,7 +244,7 @@ print("variable:",variable)
|
|
237
244
|
prompt_content = prompt.get_prompt_content()
|
238
245
|
print("prompt_content:", prompt_content)
|
239
246
|
|
240
|
-
# Compile
|
247
|
+
# Compile the prompt with variables
|
241
248
|
compiled_prompt = prompt.compile(query="What's the weather?", context="sunny", llm_response="It's sunny today")
|
242
249
|
print("Compiled prompt:", compiled_prompt)
|
243
250
|
|
@@ -280,7 +287,9 @@ sdg = SyntheticDataGeneration()
|
|
280
287
|
text = sdg.process_document(input_data="file_path")
|
281
288
|
|
282
289
|
# Generate results
|
283
|
-
result = sdg.generate_qna(text, question_type ='
|
290
|
+
result = sdg.generate_qna(text, question_type ='complex',model_config={"provider":"openai","model":"openai/gpt-3.5-turbo"},n=5)
|
291
|
+
|
292
|
+
print(result.head())
|
284
293
|
|
285
294
|
# Get supported Q&A types
|
286
295
|
sdg.get_supported_qna()
|
@@ -291,5 +300,87 @@ sdg.get_supported_providers()
|
|
291
300
|
|
292
301
|
|
293
302
|
|
303
|
+
### Guardrail Management
|
304
|
+
|
305
|
+
```py
|
306
|
+
from ragaai_catalyst import GuardrailsManager
|
307
|
+
|
308
|
+
# Initialize Guardrails Manager
|
309
|
+
gdm = GuardrailsManager(project_name=project_name)
|
310
|
+
|
311
|
+
# Get list of Guardrails available
|
312
|
+
guardrails_list = gdm.list_guardrails()
|
313
|
+
print('guardrails_list:', guardrails_list)
|
314
|
+
|
315
|
+
# Get list of fail condition for guardrails
|
316
|
+
fail_conditions = gdm.list_fail_condition()
|
317
|
+
print('fail_conditions;', fail_conditions)
|
318
|
+
|
319
|
+
#Get list of deployment ids
|
320
|
+
deployment_list = gdm.list_deployment_ids()
|
321
|
+
print('deployment_list:', deployment_list)
|
322
|
+
|
323
|
+
# Get specific deployment id with guardrails information
|
324
|
+
deployment_id_detail = gdm.get_deployment(17)
|
325
|
+
print('deployment_id_detail:', deployment_id_detail)
|
326
|
+
|
327
|
+
# Add guardrails to a deployment id
|
328
|
+
guardrails_config = {"guardrailFailConditions": ["FAIL"],
|
329
|
+
"deploymentFailCondition": "ALL_FAIL",
|
330
|
+
"alternateResponse": "Your alternate response"}
|
331
|
+
|
332
|
+
guardrails = [
|
333
|
+
{
|
334
|
+
"displayName": "Response_Evaluator",
|
335
|
+
"name": "Response Evaluator",
|
336
|
+
"config":{
|
337
|
+
"mappings": [{
|
338
|
+
"schemaName": "Text",
|
339
|
+
"variableName": "Response"
|
340
|
+
}],
|
341
|
+
"params": {
|
342
|
+
"isActive": {"value": False},
|
343
|
+
"isHighRisk": {"value": True},
|
344
|
+
"threshold": {"eq": 0},
|
345
|
+
"competitors": {"value": ["Google","Amazon"]}
|
346
|
+
}
|
347
|
+
}
|
348
|
+
},
|
349
|
+
{
|
350
|
+
"displayName": "Regex_Check",
|
351
|
+
"name": "Regex Check",
|
352
|
+
"config":{
|
353
|
+
"mappings": [{
|
354
|
+
"schemaName": "Text",
|
355
|
+
"variableName": "Response"
|
356
|
+
}],
|
357
|
+
"params":{
|
358
|
+
"isActive": {"value": False},
|
359
|
+
"isHighRisk": {"value": True},
|
360
|
+
"threshold": {"lt1": 1}
|
361
|
+
}
|
362
|
+
}
|
363
|
+
}
|
364
|
+
]
|
365
|
+
|
366
|
+
gdm.add_guardrails(deployment_id, guardrails, guardrails_config)
|
294
367
|
|
295
368
|
|
369
|
+
# Import GuardExecutor
|
370
|
+
from ragaai_catalyst import GuardExecutor
|
371
|
+
|
372
|
+
# Initialise GuardExecutor with required params and Evaluate
|
373
|
+
executor = GuardExecutor(deployment_id,gdm,field_map={'context':'document'})
|
374
|
+
|
375
|
+
|
376
|
+
message={'role':'user',
|
377
|
+
'content':'What is the capital of France'
|
378
|
+
}
|
379
|
+
prompt_params={'document':' France'}
|
380
|
+
|
381
|
+
model_params = {'temperature':.7,'model':'gpt-4o-mini'}
|
382
|
+
llm_caller = 'litellm'
|
383
|
+
|
384
|
+
executor([message],prompt_params,model_params,llm_caller)
|
385
|
+
|
386
|
+
```
|
@@ -1,15 +1,15 @@
|
|
1
1
|
ragaai_catalyst/__init__.py,sha256=BdIJ_UUre0uEnRTsLw_hE0C0muWk6XWNZqdVOel22R4,537
|
2
2
|
ragaai_catalyst/_version.py,sha256=JKt9KaVNOMVeGs8ojO6LvIZr7ZkMzNN-gCcvryy4x8E,460
|
3
|
-
ragaai_catalyst/dataset.py,sha256=
|
4
|
-
ragaai_catalyst/evaluation.py,sha256=
|
3
|
+
ragaai_catalyst/dataset.py,sha256=j_vu3Xkp_8qYW0J9Qnn53Uyh98MsugqYl5zxhOv9EOg,10731
|
4
|
+
ragaai_catalyst/evaluation.py,sha256=EZGISQH6vGB7vP5OmUBRXmEqkqZPIYN_eEUUz1jTrJ8,20285
|
5
5
|
ragaai_catalyst/experiment.py,sha256=8KvqgJg5JVnt9ghhGDJvdb4mN7ETBX_E5gNxBT0Nsn8,19010
|
6
6
|
ragaai_catalyst/guard_executor.py,sha256=llPbE3DyVtrybojXknzBZj8-dtUrGBQwi9-ZiPJxGRo,3762
|
7
|
-
ragaai_catalyst/guardrails_manager.py,sha256=
|
8
|
-
ragaai_catalyst/internal_api_completion.py,sha256=
|
9
|
-
ragaai_catalyst/prompt_manager.py,sha256=
|
7
|
+
ragaai_catalyst/guardrails_manager.py,sha256=DILMOAASK57FH9BLq_8yC1AQzRJ8McMFLwCXgYwNAd4,11904
|
8
|
+
ragaai_catalyst/internal_api_completion.py,sha256=DdICI5yfEudiOAIC8L4oxH0Qz7kX-BZCdo9IWsi2gNo,2965
|
9
|
+
ragaai_catalyst/prompt_manager.py,sha256=W8ypramzOprrJ7-22d5vkBXIuIQ8v9XAzKDGxKsTK28,16550
|
10
10
|
ragaai_catalyst/proxy_call.py,sha256=CHxldeceZUaLU-to_hs_Kf1z_b2vHMssLS_cOBedu78,5499
|
11
|
-
ragaai_catalyst/ragaai_catalyst.py,sha256=
|
12
|
-
ragaai_catalyst/synthetic_data_generation.py,sha256=
|
11
|
+
ragaai_catalyst/ragaai_catalyst.py,sha256=FdqMzwuQLqS2-3JJDsTQ8uh2itllOxfPrRUjb8Kwmn0,17428
|
12
|
+
ragaai_catalyst/synthetic_data_generation.py,sha256=uDV9tNwto2xSkWg5XHXUvjErW-4P34CTrxaJpRfezyA,19250
|
13
13
|
ragaai_catalyst/utils.py,sha256=TlhEFwLyRU690HvANbyoRycR3nQ67lxVUQoUOfTPYQ0,3772
|
14
14
|
ragaai_catalyst/tracers/__init__.py,sha256=NppmJhD3sQ5R1q6teaZLS7rULj08Gb6JT8XiPRIe_B0,49
|
15
15
|
ragaai_catalyst/tracers/llamaindex_callback.py,sha256=vPE7MieKjfwLrLUnnPs20Df0xNYqoCCj-Mt2NbiuiKU,14023
|
@@ -23,7 +23,7 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
|
|
23
23
|
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
24
24
|
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
25
25
|
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
26
|
-
ragaai_catalyst-2.0.
|
27
|
-
ragaai_catalyst-2.0.
|
28
|
-
ragaai_catalyst-2.0.
|
29
|
-
ragaai_catalyst-2.0.
|
26
|
+
ragaai_catalyst-2.0.7b1.dist-info/METADATA,sha256=A_kASl-qN-h-7s3N9NxL8iZAuRKmwPjpAaVmIH0InpQ,11241
|
27
|
+
ragaai_catalyst-2.0.7b1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
28
|
+
ragaai_catalyst-2.0.7b1.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
29
|
+
ragaai_catalyst-2.0.7b1.dist-info/RECORD,,
|
File without changes
|