ragaai-catalyst 1.0.6.1b8__py3-none-any.whl → 1.0.7__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 +2 -2
- ragaai_catalyst/experiment.py +95 -18
- {ragaai_catalyst-1.0.6.1b8.dist-info → ragaai_catalyst-1.0.7.dist-info}/METADATA +14 -8
- {ragaai_catalyst-1.0.6.1b8.dist-info → ragaai_catalyst-1.0.7.dist-info}/RECORD +6 -6
- {ragaai_catalyst-1.0.6.1b8.dist-info → ragaai_catalyst-1.0.7.dist-info}/WHEEL +0 -0
- {ragaai_catalyst-1.0.6.1b8.dist-info → ragaai_catalyst-1.0.7.dist-info}/top_level.txt +0 -0
ragaai_catalyst/dataset.py
CHANGED
@@ -18,7 +18,7 @@ class Dataset:
|
|
18
18
|
Dataset.BASE_URL = (
|
19
19
|
os.getenv("RAGAAI_CATALYST_BASE_URL")
|
20
20
|
if os.getenv("RAGAAI_CATALYST_BASE_URL")
|
21
|
-
else "https://llm-platform.
|
21
|
+
else "https://llm-platform.prod5.ragaai.ai/api"
|
22
22
|
)
|
23
23
|
|
24
24
|
def list_datasets(self):
|
@@ -36,7 +36,7 @@ class Dataset:
|
|
36
36
|
headers = {
|
37
37
|
"accept": "application/json, text/plain, */*",
|
38
38
|
"authorization": f"Bearer {os.getenv('RAGAAI_CATALYST_TOKEN')}",
|
39
|
-
"X-Project-Name": self.project_name
|
39
|
+
"X-Project-Name": self.project_name,
|
40
40
|
}
|
41
41
|
params = {
|
42
42
|
"projectName": self.project_name,
|
ragaai_catalyst/experiment.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import os
|
2
2
|
import requests
|
3
3
|
import logging
|
4
|
+
import pandas as pd
|
4
5
|
from .utils import response_checker
|
5
6
|
from .ragaai_catalyst import RagaAICatalyst
|
6
7
|
|
@@ -32,7 +33,7 @@ class Experiment:
|
|
32
33
|
Experiment.BASE_URL = (
|
33
34
|
os.getenv("RAGAAI_CATALYST_BASE_URL")
|
34
35
|
if os.getenv("RAGAAI_CATALYST_BASE_URL")
|
35
|
-
else "https://llm-platform.
|
36
|
+
else "https://llm-platform.prod5.ragaai.ai/api"
|
36
37
|
)
|
37
38
|
self.project_name = project_name
|
38
39
|
self.experiment_name = experiment_name
|
@@ -66,7 +67,7 @@ class Experiment:
|
|
66
67
|
def make_request():
|
67
68
|
headers = {
|
68
69
|
"authorization": f"Bearer {os.getenv('RAGAAI_CATALYST_TOKEN')}",
|
69
|
-
"X-Project-Name": self.project_name
|
70
|
+
"X-Project-Name": self.project_name,
|
70
71
|
}
|
71
72
|
params = {
|
72
73
|
"name": self.project_name,
|
@@ -179,7 +180,7 @@ class Experiment:
|
|
179
180
|
response_checker(response, "Experiment.run_tests"),
|
180
181
|
)
|
181
182
|
|
182
|
-
def get_status(self):
|
183
|
+
def get_status(self, job_id=None):
|
183
184
|
"""
|
184
185
|
Retrieves the status of a job based on the provided job ID.
|
185
186
|
|
@@ -190,13 +191,18 @@ class Experiment:
|
|
190
191
|
"Authorization": f'Bearer {os.getenv("RAGAAI_CATALYST_TOKEN")}',
|
191
192
|
"X-Project-Name": self.project_name,
|
192
193
|
}
|
193
|
-
if
|
194
|
+
if job_id is not None:
|
195
|
+
job_id_to_check = job_id
|
196
|
+
else:
|
197
|
+
job_id_to_check = self.job_id
|
198
|
+
|
199
|
+
if job_id_to_check is None:
|
194
200
|
logger.warning("Attempt to fetch status without a valid job ID.")
|
195
201
|
return "Please run an experiment test first"
|
196
202
|
json_data = {
|
197
|
-
"jobId":
|
203
|
+
"jobId": job_id_to_check,
|
198
204
|
}
|
199
|
-
logger.debug(f"Fetching status for Job ID: {
|
205
|
+
logger.debug(f"Fetching status for Job ID: {job_id_to_check}")
|
200
206
|
response = requests.get(
|
201
207
|
f"{Experiment.BASE_URL}/job/status",
|
202
208
|
headers=headers,
|
@@ -205,11 +211,10 @@ class Experiment:
|
|
205
211
|
)
|
206
212
|
status_code = response_checker(response, "Experiment.get_status")
|
207
213
|
if status_code == 200:
|
208
|
-
# print(f"Status retrieved: Job ID {self.job_id} is active.")
|
209
214
|
test_response = response.json()
|
210
215
|
jobs = test_response["data"]["content"]
|
211
216
|
for job in jobs:
|
212
|
-
if job["id"] ==
|
217
|
+
if job["id"] == job_id_to_check:
|
213
218
|
return job["status"]
|
214
219
|
elif status_code == 401:
|
215
220
|
headers = {
|
@@ -239,7 +244,7 @@ class Experiment:
|
|
239
244
|
response_checker(response, "Experiment.get_status"),
|
240
245
|
)
|
241
246
|
|
242
|
-
def get_results(self):
|
247
|
+
def get_results(self, job_id=None):
|
243
248
|
"""
|
244
249
|
A function that retrieves results based on the experiment ID.
|
245
250
|
It makes a POST request to the BASE_URL to fetch results using the provided JSON data.
|
@@ -247,15 +252,19 @@ class Experiment:
|
|
247
252
|
If the status code is 401, it retries the request and returns the test response if successful.
|
248
253
|
If the status is neither 200 nor 401, it logs an error and returns the response checker result.
|
249
254
|
"""
|
255
|
+
if job_id is not None:
|
256
|
+
job_id_to_use = job_id
|
257
|
+
else:
|
258
|
+
job_id_to_use = self.job_id
|
250
259
|
|
251
|
-
if
|
260
|
+
if job_id_to_use is None:
|
252
261
|
logger.warning("Results fetch attempted without prior job execution.")
|
253
262
|
return "Please run an experiment test first"
|
254
263
|
|
255
264
|
headers = {
|
256
265
|
"Content-Type": "application/json",
|
257
266
|
"Authorization": f'Bearer {os.getenv("RAGAAI_CATALYST_TOKEN")}',
|
258
|
-
"X-Project-Id": self.project_id
|
267
|
+
"X-Project-Id": str(self.project_id),
|
259
268
|
}
|
260
269
|
|
261
270
|
json_data = {
|
@@ -266,7 +275,7 @@ class Experiment:
|
|
266
275
|
"filterList": [],
|
267
276
|
}
|
268
277
|
|
269
|
-
status_json = self.get_status()
|
278
|
+
status_json = self.get_status(job_id_to_use)
|
270
279
|
if status_json == "Failed":
|
271
280
|
return print("Job failed. No results to fetch.")
|
272
281
|
elif status_json == "In Progress":
|
@@ -280,16 +289,32 @@ class Experiment:
|
|
280
289
|
json=json_data,
|
281
290
|
timeout=Experiment.TIMEOUT,
|
282
291
|
)
|
283
|
-
# status_code = response_checker(response, "Experiment.get_test_results")
|
284
292
|
if response.status_code == 200:
|
285
|
-
print(
|
293
|
+
print("Results successfully retrieved.")
|
286
294
|
test_response = response.json()
|
287
|
-
|
295
|
+
|
296
|
+
if test_response["success"]:
|
297
|
+
parse_success, parsed_response = self.parse_response(test_response)
|
298
|
+
if parse_success:
|
299
|
+
return parsed_response
|
300
|
+
else:
|
301
|
+
logger.error(f"Failed to parse response: {test_response}")
|
302
|
+
raise FailedToRetrieveResults(
|
303
|
+
f"Failed to parse response: {test_response}"
|
304
|
+
)
|
305
|
+
|
306
|
+
else:
|
307
|
+
logger.error(f"Failed to retrieve results for job: {job_id_to_use}")
|
308
|
+
raise FailedToRetrieveResults(
|
309
|
+
f"Failed to retrieve results for job: {job_id_to_use}"
|
310
|
+
)
|
311
|
+
|
312
|
+
return parsed_response
|
288
313
|
elif response.status_code == 401:
|
289
314
|
headers = {
|
290
315
|
"Content-Type": "application/json",
|
291
316
|
"Authorization": f'Bearer {os.getenv("RAGAAI_CATALYST_TOKEN")}',
|
292
|
-
"X-Project-Id": self.project_id
|
317
|
+
"X-Project-Id": str(self.project_id),
|
293
318
|
}
|
294
319
|
response = requests.post(
|
295
320
|
f"{Experiment.BASE_URL}/v1/llm/docs",
|
@@ -297,7 +322,6 @@ class Experiment:
|
|
297
322
|
json=json_data,
|
298
323
|
timeout=Experiment.TIMEOUT,
|
299
324
|
)
|
300
|
-
# status_code = response_checker(response, "Experiment.get_test_results")
|
301
325
|
if response.status_code == 200:
|
302
326
|
test_response = response.json()
|
303
327
|
return test_response
|
@@ -305,8 +329,61 @@ class Experiment:
|
|
305
329
|
logger.error("Endpoint not responsive after retry attempts.")
|
306
330
|
return response_checker(response, "Experiment.get_test_results")
|
307
331
|
else:
|
308
|
-
|
309
332
|
return (
|
310
333
|
"Error in running tests",
|
311
334
|
response_checker(response, "Experiment.get_test_results"),
|
312
335
|
)
|
336
|
+
|
337
|
+
def parse_response(self, response):
|
338
|
+
"""
|
339
|
+
Parse the response to get the results
|
340
|
+
"""
|
341
|
+
try:
|
342
|
+
x = pd.DataFrame(response["data"]["docs"])
|
343
|
+
|
344
|
+
column_names_to_replace = [
|
345
|
+
{item["columnName"]: item["displayName"]}
|
346
|
+
for item in response["data"]["columns"]
|
347
|
+
]
|
348
|
+
|
349
|
+
if column_names_to_replace:
|
350
|
+
for item in column_names_to_replace:
|
351
|
+
x = x.rename(columns=item)
|
352
|
+
|
353
|
+
dict_cols = [
|
354
|
+
col
|
355
|
+
for col in x.columns
|
356
|
+
if x[col].dtype == "object"
|
357
|
+
and x[col].apply(lambda y: isinstance(y, dict)).any()
|
358
|
+
]
|
359
|
+
|
360
|
+
for dict_col in dict_cols:
|
361
|
+
x[f"{dict_col}_reason"] = x[dict_col].apply(
|
362
|
+
lambda y: y.get("reason") if isinstance(y, dict) else None
|
363
|
+
)
|
364
|
+
x[f"{dict_col}_metric_config"] = x[dict_col].apply(
|
365
|
+
lambda y: (
|
366
|
+
y.get("metric_config") if isinstance(y, dict) else None
|
367
|
+
)
|
368
|
+
)
|
369
|
+
x[f"{dict_col}_status"] = x[dict_col].apply(
|
370
|
+
lambda y: y.get("status") if isinstance(y, dict) else None
|
371
|
+
)
|
372
|
+
|
373
|
+
x = x.drop(columns=[dict_col])
|
374
|
+
|
375
|
+
x.columns = x.columns.str.replace("_reason_reason", "_reason")
|
376
|
+
x.columns = x.columns.str.replace("_reason_metric_config", "_metric_config")
|
377
|
+
x.columns = x.columns.str.replace("_reason_status", "_status")
|
378
|
+
|
379
|
+
x = x.drop(columns=["trace_uri"])
|
380
|
+
|
381
|
+
return True, x
|
382
|
+
|
383
|
+
except Exception as e:
|
384
|
+
logger.error(f"Failed to parse response: {e}", exc_info=True)
|
385
|
+
return False, pd.DataFrame()
|
386
|
+
|
387
|
+
|
388
|
+
class FailedToRetrieveResults(Exception):
|
389
|
+
pass
|
@@ -1,20 +1,26 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ragaai_catalyst
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.7
|
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>
|
6
6
|
Requires-Python: >=3.9
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
Requires-Dist: aiohttp>=3.10.2
|
9
|
-
Requires-Dist: opentelemetry-
|
10
|
-
Requires-Dist: opentelemetry-
|
11
|
-
Requires-Dist: opentelemetry-
|
12
|
-
Requires-Dist: opentelemetry-instrumentation
|
13
|
-
Requires-Dist: opentelemetry-
|
14
|
-
Requires-Dist: opentelemetry-
|
9
|
+
Requires-Dist: opentelemetry-api==1.25.0
|
10
|
+
Requires-Dist: opentelemetry-sdk==1.25.0
|
11
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc==1.25.0
|
12
|
+
Requires-Dist: opentelemetry-instrumentation==0.46b0
|
13
|
+
Requires-Dist: opentelemetry-instrumentation-fastapi==0.46b0
|
14
|
+
Requires-Dist: opentelemetry-instrumentation-asgi==0.46b0
|
15
|
+
Requires-Dist: opentelemetry-semantic-conventions==0.46b0
|
16
|
+
Requires-Dist: opentelemetry-util-http==0.46b0
|
17
|
+
Requires-Dist: opentelemetry-instrumentation-langchain~=0.24.0
|
18
|
+
Requires-Dist: opentelemetry-instrumentation-openai~=0.24.0
|
15
19
|
Requires-Dist: langchain-core~=0.2.11
|
16
20
|
Requires-Dist: langchain~=0.2.11
|
17
|
-
Requires-Dist: openai>=1.
|
21
|
+
Requires-Dist: openai>=1.35.10
|
22
|
+
Requires-Dist: pandas>=2.1.1
|
23
|
+
Requires-Dist: tenacity==8.3.0
|
18
24
|
Provides-Extra: dev
|
19
25
|
Requires-Dist: pytest; extra == "dev"
|
20
26
|
Requires-Dist: pytest-cov; extra == "dev"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
ragaai_catalyst/__init__.py,sha256=0hf_H1xkhrpGnUWTbjvYOXXQta1S4JO2yud1Eqydt-I,226
|
2
2
|
ragaai_catalyst/_version.py,sha256=JKt9KaVNOMVeGs8ojO6LvIZr7ZkMzNN-gCcvryy4x8E,460
|
3
|
-
ragaai_catalyst/dataset.py,sha256=
|
4
|
-
ragaai_catalyst/experiment.py,sha256=
|
3
|
+
ragaai_catalyst/dataset.py,sha256=g0YH0QGDpCiJ4VULB3tukGFNLpWGw0ZRwLMP07ay2IE,3560
|
4
|
+
ragaai_catalyst/experiment.py,sha256=dlp2S7kGHhz0IOjJ6vUnGGbZQ52U3PZbfFbWFiT26AM,14665
|
5
5
|
ragaai_catalyst/ragaai_catalyst.py,sha256=DqEApmjxQufZZT4ap-IzoBmp3AX6RWMq7HXQ5kO0wsI,16468
|
6
6
|
ragaai_catalyst/utils.py,sha256=TlhEFwLyRU690HvANbyoRycR3nQ67lxVUQoUOfTPYQ0,3772
|
7
7
|
ragaai_catalyst/tracers/__init__.py,sha256=NppmJhD3sQ5R1q6teaZLS7rULj08Gb6JT8XiPRIe_B0,49
|
@@ -15,7 +15,7 @@ ragaai_catalyst/tracers/instrumentators/llamaindex.py,sha256=SMrRlR4xM7k9HK43hak
|
|
15
15
|
ragaai_catalyst/tracers/instrumentators/openai.py,sha256=14R4KW9wQCR1xysLfsP_nxS7cqXrTPoD8En4MBAaZUU,379
|
16
16
|
ragaai_catalyst/tracers/utils/__init__.py,sha256=KeMaZtYaTojilpLv65qH08QmpYclfpacDA0U3wg6Ybw,64
|
17
17
|
ragaai_catalyst/tracers/utils/utils.py,sha256=ViygfJ7vZ7U0CTSA1lbxVloHp4NSlmfDzBRNCJuMhis,2374
|
18
|
-
ragaai_catalyst-1.0.
|
19
|
-
ragaai_catalyst-1.0.
|
20
|
-
ragaai_catalyst-1.0.
|
21
|
-
ragaai_catalyst-1.0.
|
18
|
+
ragaai_catalyst-1.0.7.dist-info/METADATA,sha256=fBubovTWPHax6eI9LinGIRuVz4k_AU4U8yAp4wilAjY,5119
|
19
|
+
ragaai_catalyst-1.0.7.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
20
|
+
ragaai_catalyst-1.0.7.dist-info/top_level.txt,sha256=HpgsdRgEJMk8nqrU6qdCYk3di7MJkDL0B19lkc7dLfM,16
|
21
|
+
ragaai_catalyst-1.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|