ragaai-catalyst 2.1.5b19__py3-none-any.whl → 2.1.5b21__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 +54 -1
- ragaai_catalyst/evaluation.py +25 -6
- ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py +1 -2
- ragaai_catalyst/tracers/tracer.py +22 -2
- ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py +5 -3
- {ragaai_catalyst-2.1.5b19.dist-info → ragaai_catalyst-2.1.5b21.dist-info}/METADATA +2 -2
- {ragaai_catalyst-2.1.5b19.dist-info → ragaai_catalyst-2.1.5b21.dist-info}/RECORD +10 -10
- {ragaai_catalyst-2.1.5b19.dist-info → ragaai_catalyst-2.1.5b21.dist-info}/LICENSE +0 -0
- {ragaai_catalyst-2.1.5b19.dist-info → ragaai_catalyst-2.1.5b21.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-2.1.5b19.dist-info → ragaai_catalyst-2.1.5b21.dist-info}/top_level.txt +0 -0
ragaai_catalyst/dataset.py
CHANGED
@@ -9,6 +9,10 @@ import pandas as pd
|
|
9
9
|
logger = logging.getLogger(__name__)
|
10
10
|
get_token = RagaAICatalyst.get_token
|
11
11
|
|
12
|
+
# Job status constants
|
13
|
+
JOB_STATUS_FAILED = "failed"
|
14
|
+
JOB_STATUS_IN_PROGRESS = "in_progress"
|
15
|
+
JOB_STATUS_COMPLETED = "success"
|
12
16
|
|
13
17
|
class Dataset:
|
14
18
|
BASE_URL = None
|
@@ -18,6 +22,7 @@ class Dataset:
|
|
18
22
|
self.project_name = project_name
|
19
23
|
self.num_projects = 99999
|
20
24
|
Dataset.BASE_URL = RagaAICatalyst.BASE_URL
|
25
|
+
self.jobId = None
|
21
26
|
headers = {
|
22
27
|
"Authorization": f'Bearer {os.getenv("RAGAAI_CATALYST_TOKEN")}',
|
23
28
|
}
|
@@ -219,7 +224,6 @@ class Dataset:
|
|
219
224
|
try:
|
220
225
|
|
221
226
|
put_csv_response = put_csv_to_presignedUrl(url)
|
222
|
-
print(put_csv_response)
|
223
227
|
if put_csv_response.status_code not in (200, 201):
|
224
228
|
raise ValueError('Unable to put csv to the presignedUrl')
|
225
229
|
except Exception as e:
|
@@ -269,6 +273,7 @@ class Dataset:
|
|
269
273
|
raise ValueError('Unable to upload csv')
|
270
274
|
else:
|
271
275
|
print(upload_csv_response['message'])
|
276
|
+
self.jobId = upload_csv_response['data']['jobId']
|
272
277
|
except Exception as e:
|
273
278
|
logger.error(f"Error in create_from_csv: {e}")
|
274
279
|
raise
|
@@ -436,6 +441,7 @@ class Dataset:
|
|
436
441
|
response_data = response.json()
|
437
442
|
if response_data.get('success', False):
|
438
443
|
print(f"{response_data['message']}")
|
444
|
+
self.jobId = response_data['data']['jobId']
|
439
445
|
else:
|
440
446
|
raise ValueError(response_data.get('message', 'Failed to add rows'))
|
441
447
|
|
@@ -594,6 +600,7 @@ class Dataset:
|
|
594
600
|
|
595
601
|
if response_data.get('success', False):
|
596
602
|
print(f"Column '{column_name}' added successfully to dataset '{dataset_name}'")
|
603
|
+
self.jobId = response_data['data']['jobId']
|
597
604
|
else:
|
598
605
|
raise ValueError(response_data.get('message', 'Failed to add column'))
|
599
606
|
|
@@ -601,3 +608,49 @@ class Dataset:
|
|
601
608
|
print(f"Error adding column: {e}")
|
602
609
|
raise
|
603
610
|
|
611
|
+
def get_status(self):
|
612
|
+
headers = {
|
613
|
+
'Content-Type': 'application/json',
|
614
|
+
"Authorization": f"Bearer {os.getenv('RAGAAI_CATALYST_TOKEN')}",
|
615
|
+
'X-Project-Id': str(self.project_id),
|
616
|
+
}
|
617
|
+
try:
|
618
|
+
response = requests.get(
|
619
|
+
f'{Dataset.BASE_URL}/job/status',
|
620
|
+
headers=headers,
|
621
|
+
timeout=30)
|
622
|
+
response.raise_for_status()
|
623
|
+
if response.json()["success"]:
|
624
|
+
|
625
|
+
status_json = [item["status"] for item in response.json()["data"]["content"] if item["id"]==self.jobId]
|
626
|
+
status_json = status_json[0]
|
627
|
+
if status_json == "Failed":
|
628
|
+
print("Job failed. No results to fetch.")
|
629
|
+
return JOB_STATUS_FAILED
|
630
|
+
elif status_json == "In Progress":
|
631
|
+
print(f"Job in progress. Please wait while the job completes.\nVisit Job Status: {Dataset.BASE_URL.removesuffix('/api')}/projects/job-status?projectId={self.project_id} to track")
|
632
|
+
return JOB_STATUS_IN_PROGRESS
|
633
|
+
elif status_json == "Completed":
|
634
|
+
print(f"Job completed. Fetching results.\nVisit Job Status: {Dataset.BASE_URL.removesuffix('/api')}/projects/job-status?projectId={self.project_id} to check")
|
635
|
+
return JOB_STATUS_COMPLETED
|
636
|
+
else:
|
637
|
+
logger.error(f"Unknown status received: {status_json}")
|
638
|
+
return JOB_STATUS_FAILED
|
639
|
+
else:
|
640
|
+
logger.error("Request was not successful")
|
641
|
+
return JOB_STATUS_FAILED
|
642
|
+
except requests.exceptions.HTTPError as http_err:
|
643
|
+
logger.error(f"HTTP error occurred: {http_err}")
|
644
|
+
return JOB_STATUS_FAILED
|
645
|
+
except requests.exceptions.ConnectionError as conn_err:
|
646
|
+
logger.error(f"Connection error occurred: {conn_err}")
|
647
|
+
return JOB_STATUS_FAILED
|
648
|
+
except requests.exceptions.Timeout as timeout_err:
|
649
|
+
logger.error(f"Timeout error occurred: {timeout_err}")
|
650
|
+
return JOB_STATUS_FAILED
|
651
|
+
except requests.exceptions.RequestException as req_err:
|
652
|
+
logger.error(f"An error occurred: {req_err}")
|
653
|
+
return JOB_STATUS_FAILED
|
654
|
+
except Exception as e:
|
655
|
+
logger.error(f"An unexpected error occurred: {e}")
|
656
|
+
return JOB_STATUS_FAILED
|
ragaai_catalyst/evaluation.py
CHANGED
@@ -7,6 +7,11 @@ import logging
|
|
7
7
|
|
8
8
|
logger = logging.getLogger(__name__)
|
9
9
|
|
10
|
+
# Job status constants
|
11
|
+
JOB_STATUS_FAILED = "failed"
|
12
|
+
JOB_STATUS_IN_PROGRESS = "in_progress"
|
13
|
+
JOB_STATUS_COMPLETED = "success"
|
14
|
+
|
10
15
|
class Evaluation:
|
11
16
|
|
12
17
|
def __init__(self, project_name, dataset_name):
|
@@ -366,22 +371,36 @@ class Evaluation:
|
|
366
371
|
response.raise_for_status()
|
367
372
|
if response.json()["success"]:
|
368
373
|
status_json = [item["status"] for item in response.json()["data"]["content"] if item["id"]==self.jobId][0]
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
374
|
+
if status_json == "Failed":
|
375
|
+
print("Job failed. No results to fetch.")
|
376
|
+
return JOB_STATUS_FAILED
|
377
|
+
elif status_json == "In Progress":
|
378
|
+
print(f"Job in progress. Please wait while the job completes.\nVisit Job Status: {self.base_url.removesuffix('/api')}/projects/job-status?projectId={self.project_id} to track")
|
379
|
+
return JOB_STATUS_IN_PROGRESS
|
380
|
+
elif status_json == "Completed":
|
381
|
+
print(f"Job completed. Fetching results.\nVisit Job Status: {self.base_url.removesuffix('/api')}/projects/job-status?projectId={self.project_id} to check")
|
382
|
+
return JOB_STATUS_COMPLETED
|
383
|
+
else:
|
384
|
+
logger.error(f"Unknown status received: {status_json}")
|
385
|
+
return JOB_STATUS_FAILED
|
386
|
+
else:
|
387
|
+
logger.error("Request was not successful")
|
388
|
+
return JOB_STATUS_FAILED
|
375
389
|
except requests.exceptions.HTTPError as http_err:
|
376
390
|
logger.error(f"HTTP error occurred: {http_err}")
|
391
|
+
return JOB_STATUS_FAILED
|
377
392
|
except requests.exceptions.ConnectionError as conn_err:
|
378
393
|
logger.error(f"Connection error occurred: {conn_err}")
|
394
|
+
return JOB_STATUS_FAILED
|
379
395
|
except requests.exceptions.Timeout as timeout_err:
|
380
396
|
logger.error(f"Timeout error occurred: {timeout_err}")
|
397
|
+
return JOB_STATUS_FAILED
|
381
398
|
except requests.exceptions.RequestException as req_err:
|
382
399
|
logger.error(f"An error occurred: {req_err}")
|
400
|
+
return JOB_STATUS_FAILED
|
383
401
|
except Exception as e:
|
384
402
|
logger.error(f"An unexpected error occurred: {e}")
|
403
|
+
return JOB_STATUS_FAILED
|
385
404
|
|
386
405
|
def get_results(self):
|
387
406
|
|
@@ -128,6 +128,7 @@ class Tracer(AgenticTracing):
|
|
128
128
|
self.num_projects = 100
|
129
129
|
self.start_time = datetime.datetime.now().astimezone().isoformat()
|
130
130
|
self.model_cost_dict = load_model_costs()
|
131
|
+
self.user_context = "" # Initialize user_context to store context from add_context
|
131
132
|
|
132
133
|
if update_llm_cost:
|
133
134
|
# First update the model costs file from GitHub
|
@@ -318,7 +319,7 @@ class Tracer(AgenticTracing):
|
|
318
319
|
if additional_metadata:
|
319
320
|
combined_metadata.update(additional_metadata)
|
320
321
|
|
321
|
-
langchain_traces = langchain_tracer_extraction(data)
|
322
|
+
langchain_traces = langchain_tracer_extraction(data, self.user_context)
|
322
323
|
final_result = convert_langchain_callbacks_output(langchain_traces)
|
323
324
|
|
324
325
|
# Safely set required fields in final_result
|
@@ -463,4 +464,23 @@ class Tracer(AgenticTracing):
|
|
463
464
|
}
|
464
465
|
}
|
465
466
|
}
|
466
|
-
return user_detail
|
467
|
+
return user_detail
|
468
|
+
|
469
|
+
def add_context(self, context):
|
470
|
+
"""
|
471
|
+
Add context information to the trace. This method is only supported for 'langchain' and 'llamaindex' tracer types.
|
472
|
+
|
473
|
+
Args:
|
474
|
+
context: Additional context information to be added to the trace. Can be a string.
|
475
|
+
|
476
|
+
Raises:
|
477
|
+
ValueError: If tracer_type is not 'langchain' or 'llamaindex'.
|
478
|
+
"""
|
479
|
+
if self.tracer_type not in ["langchain", "llamaindex"]:
|
480
|
+
raise ValueError("add_context is only supported for 'langchain' and 'llamaindex' tracer types")
|
481
|
+
|
482
|
+
# Convert string context to string if needed
|
483
|
+
if isinstance(context, str):
|
484
|
+
self.user_context = context
|
485
|
+
else:
|
486
|
+
raise TypeError("context must be a string")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import json
|
2
2
|
import uuid
|
3
3
|
|
4
|
-
def langchain_tracer_extraction(data):
|
4
|
+
def langchain_tracer_extraction(data, user_context=""):
|
5
5
|
trace_aggregate = {}
|
6
6
|
import uuid
|
7
7
|
|
@@ -55,7 +55,9 @@ def langchain_tracer_extraction(data):
|
|
55
55
|
response = llm_end_response["text"]
|
56
56
|
return response.strip()
|
57
57
|
|
58
|
-
def get_context(data):
|
58
|
+
def get_context(data, user_context):
|
59
|
+
if user_context:
|
60
|
+
return user_context
|
59
61
|
if "retriever_actions" in data and data["retriever_actions"] != []:
|
60
62
|
for item in data["retriever_actions"]:
|
61
63
|
if item["event"] == "retriever_end":
|
@@ -72,7 +74,7 @@ def langchain_tracer_extraction(data):
|
|
72
74
|
|
73
75
|
prompt = get_prompt(data)
|
74
76
|
response = get_response(data)
|
75
|
-
context = get_context(data)
|
77
|
+
context = get_context(data, user_context)
|
76
78
|
|
77
79
|
trace_aggregate["data"]["prompt"]=prompt
|
78
80
|
trace_aggregate["data"]["response"]=response
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.5b21
|
4
4
|
Summary: RAGA AI CATALYST
|
5
|
-
Author-email: Kiran Scaria <kiran.scaria@raga.ai>,
|
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
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
License-File: LICENSE
|
@@ -1,7 +1,7 @@
|
|
1
1
|
ragaai_catalyst/__init__.py,sha256=tvESV8UuVtth14E89wQxgf0WvQZSApWfDeLiIdmMhkE,791
|
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=VPfFt7dLUiQ9xmHZ0WhcRNJyMs2KHuOtawow-2Lujrw,26183
|
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
|
7
7
|
ragaai_catalyst/guardrails_manager.py,sha256=DILMOAASK57FH9BLq_8yC1AQzRJ8McMFLwCXgYwNAd4,11904
|
@@ -15,7 +15,7 @@ ragaai_catalyst/tracers/__init__.py,sha256=LfgTes-nHpazssbGKnn8kyLZNr49kIPrlkrqq
|
|
15
15
|
ragaai_catalyst/tracers/distributed.py,sha256=AIRvS5Ur4jbFDXsUkYuCTmtGoHHx3LOG4n5tWOh610U,10330
|
16
16
|
ragaai_catalyst/tracers/langchain_callback.py,sha256=ZXN378gloGh5EVpTJuUScHD964WuIeVeE4_hp60gxG4,30686
|
17
17
|
ragaai_catalyst/tracers/llamaindex_callback.py,sha256=ZY0BJrrlz-P9Mg2dX-ZkVKG3gSvzwqBtk7JL_05MiYA,14028
|
18
|
-
ragaai_catalyst/tracers/tracer.py,sha256=
|
18
|
+
ragaai_catalyst/tracers/tracer.py,sha256=_WSX0XS4XflHdQdMaqarTAoW2iz2lux0IxhTibZsD8k,21048
|
19
19
|
ragaai_catalyst/tracers/upload_traces.py,sha256=2TWdRTN6FMaX-dqDv8BJWQS0xrCGYKkXEYOi2kK3Z3Y,5487
|
20
20
|
ragaai_catalyst/tracers/agentic_tracing/README.md,sha256=X4QwLb7-Jg7GQMIXj-SerZIgDETfw-7VgYlczOR8ZeQ,4508
|
21
21
|
ragaai_catalyst/tracers/agentic_tracing/__init__.py,sha256=yf6SKvOPSpH-9LiKaoLKXwqj5sez8F_5wkOb91yp0oE,260
|
@@ -33,7 +33,7 @@ ragaai_catalyst/tracers/agentic_tracing/tracers/base.py,sha256=xzJKOpL0Wm5hAIJp8
|
|
33
33
|
ragaai_catalyst/tracers/agentic_tracing/tracers/custom_tracer.py,sha256=OHet_Cphyrsq2CP4WiooTsWSgg3Rc1n8QsOl1s2vqdY,13480
|
34
34
|
ragaai_catalyst/tracers/agentic_tracing/tracers/langgraph_tracer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
35
|
ragaai_catalyst/tracers/agentic_tracing/tracers/llm_tracer.py,sha256=OSRGwftAYpylvziXD50HGjEfEMe8k11-3SRSZKw2tHI,35255
|
36
|
-
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=
|
36
|
+
ragaai_catalyst/tracers/agentic_tracing/tracers/main_tracer.py,sha256=ZAG5aKBAr0O7oWd_EXcljH9PpSIo6QpWnZWH4NhKgAE,18315
|
37
37
|
ragaai_catalyst/tracers/agentic_tracing/tracers/network_tracer.py,sha256=m8CxYkl7iMiFya_lNwN1ykBc3Pmo-2pR_2HmpptwHWQ,10352
|
38
38
|
ragaai_catalyst/tracers/agentic_tracing/tracers/tool_tracer.py,sha256=nmgkE3jRlTpq_uk6FYw0hTv2VgT8ejxvvBRL7gso39I,21037
|
39
39
|
ragaai_catalyst/tracers/agentic_tracing/tracers/user_interaction_tracer.py,sha256=bhSUhNQCuJXKjgJAXhjKEYjnHMpYN90FSZdR84fNIKU,4614
|
@@ -64,10 +64,10 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
|
|
64
64
|
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
65
65
|
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
66
66
|
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=
|
67
|
+
ragaai_catalyst/tracers/utils/langchain_tracer_extraction_logic.py,sha256=LxJaZYErYlG8Zc4LfPHuX1_TgAYvT7sb28OZl9iBxC0,3163
|
68
68
|
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.
|
69
|
+
ragaai_catalyst-2.1.5b21.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
70
|
+
ragaai_catalyst-2.1.5b21.dist-info/METADATA,sha256=2SR-RpaHL2T7-q3useysaBDwhDQpPqCNZVAyfrD-T6c,12796
|
71
|
+
ragaai_catalyst-2.1.5b21.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
72
|
+
ragaai_catalyst-2.1.5b21.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
73
|
+
ragaai_catalyst-2.1.5b21.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|