llumo 0.2.43__tar.gz → 0.2.44__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.
- {llumo-0.2.43/llumo.egg-info → llumo-0.2.44}/PKG-INFO +1 -1
- {llumo-0.2.43 → llumo-0.2.44}/llumo/client.py +38 -146
- {llumo-0.2.43 → llumo-0.2.44}/llumo/helpingFuntions.py +77 -14
- {llumo-0.2.43 → llumo-0.2.44/llumo.egg-info}/PKG-INFO +1 -1
- {llumo-0.2.43 → llumo-0.2.44}/LICENSE +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/MANIFEST.in +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/README.md +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/__init__.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/callback.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/callbacks-0.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/chains.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/exceptions.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/execution.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/functionCalling.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/google.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/llumoLogger.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/llumoSessionContext.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/models.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/openai.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo/sockets.py +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo.egg-info/SOURCES.txt +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo.egg-info/dependency_links.txt +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo.egg-info/requires.txt +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/llumo.egg-info/top_level.txt +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/setup.cfg +0 -0
- {llumo-0.2.43 → llumo-0.2.44}/setup.py +0 -0
|
@@ -2231,7 +2231,9 @@ class LlumoClient:
|
|
|
2231
2231
|
multiTurnChat=False,
|
|
2232
2232
|
createMultipleLogs=True
|
|
2233
2233
|
):
|
|
2234
|
+
|
|
2234
2235
|
# print("Evaluating multiple data with evals:", data, evals)
|
|
2236
|
+
rawData = data.copy()
|
|
2235
2237
|
try:
|
|
2236
2238
|
self.validateApiKey()
|
|
2237
2239
|
except Exception as e:
|
|
@@ -2303,91 +2305,47 @@ class LlumoClient:
|
|
|
2303
2305
|
|
|
2304
2306
|
# print("payload", payload)
|
|
2305
2307
|
|
|
2306
|
-
# Create evaluation
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
"Content-Type": "application/json",
|
|
2312
|
-
"Authorization": f"Bearer {self.apiKey}",
|
|
2313
|
-
},
|
|
2308
|
+
# Create evaluation + Poll results (moved to helper)
|
|
2309
|
+
final_result_data = dataPollingFuncForEval(
|
|
2310
|
+
api_key=self.apiKey,
|
|
2311
|
+
payload=payload,
|
|
2312
|
+
data=data,
|
|
2314
2313
|
)
|
|
2315
|
-
|
|
2316
|
-
final_result_data = []
|
|
2317
|
-
|
|
2318
|
-
cursor = "0-0"
|
|
2319
|
-
limit = 10
|
|
2320
|
-
all_data_fetched = False
|
|
2321
|
-
|
|
2322
|
-
print("✅ Evaluation Started...")
|
|
2323
|
-
while not all_data_fetched:
|
|
2324
|
-
try:
|
|
2325
|
-
response = requests.get(
|
|
2326
|
-
"https://backend-api.llumo.ai/api/v1/sdk/poll",
|
|
2327
|
-
params={
|
|
2328
|
-
"cursor": cursor,
|
|
2329
|
-
"dataID": dataID,
|
|
2330
|
-
"limit": limit,
|
|
2331
|
-
},
|
|
2332
|
-
)
|
|
2333
|
-
|
|
2334
|
-
response_data = response.json()
|
|
2335
|
-
result_data = response_data.get("debugLog", {})
|
|
2336
|
-
# print("resultData", result_data)
|
|
2337
|
-
|
|
2338
|
-
results = result_data.get("results", [])
|
|
2339
|
-
final_result_data.extend(results)
|
|
2340
|
-
|
|
2341
|
-
cursor = result_data.get("nextCursor")
|
|
2342
|
-
|
|
2343
|
-
if len(final_result_data) == len(data):
|
|
2344
|
-
all_data_fetched = True
|
|
2345
|
-
|
|
2346
|
-
time.sleep(10)
|
|
2347
|
-
|
|
2348
|
-
except Exception as error:
|
|
2349
|
-
print("error", error)
|
|
2350
|
-
all_data_fetched = True
|
|
2351
|
-
|
|
2352
2314
|
# Shape results
|
|
2353
2315
|
formatted_results = []
|
|
2354
2316
|
|
|
2317
|
+
|
|
2355
2318
|
for row in final_result_data:
|
|
2356
|
-
|
|
2357
|
-
|
|
2319
|
+
# print("ROW: ",row)
|
|
2320
|
+
result = []
|
|
2358
2321
|
|
|
2359
|
-
|
|
2360
|
-
|
|
2322
|
+
# Extract numeric keys ("0", "1", "2", ...)
|
|
2323
|
+
numeric_keys = sorted(
|
|
2324
|
+
[key for key in row.keys() if str(key).strip() != "" and str(key).isdigit()],
|
|
2325
|
+
key=lambda x: int(x)
|
|
2326
|
+
)
|
|
2361
2327
|
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
score[eval_name] = details.get("value")
|
|
2365
|
-
else:
|
|
2366
|
-
score[eval_name] = details.get("score")
|
|
2367
|
-
reasoning[eval_name] = details.get("reasoning", "")
|
|
2328
|
+
for key in numeric_keys:
|
|
2329
|
+
result.append(row[key])
|
|
2368
2330
|
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
reasoning[eval_name] = row.get("reasoning", "")
|
|
2374
|
-
else:
|
|
2375
|
-
score[eval_name] = None
|
|
2376
|
-
reasoning[eval_name] = ""
|
|
2377
|
-
|
|
2378
|
-
formatted_row = {
|
|
2379
|
-
"query": row.get("query", ""),
|
|
2380
|
-
"context": row.get("context", ""),
|
|
2381
|
-
"output": row.get("output", ""),
|
|
2382
|
-
"score": score,
|
|
2383
|
-
"reasoning": reasoning,
|
|
2384
|
-
}
|
|
2331
|
+
evalData={}
|
|
2332
|
+
for key in row:
|
|
2333
|
+
if key not in numeric_keys:
|
|
2334
|
+
evalData[key]=row[key]
|
|
2385
2335
|
|
|
2386
|
-
#
|
|
2387
|
-
|
|
2336
|
+
# evalResultDict = {"evaluation": result}
|
|
2337
|
+
evalData = {}
|
|
2338
|
+
for key in row:
|
|
2339
|
+
if key not in numeric_keys:
|
|
2340
|
+
evalData[key] = row[key]
|
|
2388
2341
|
|
|
2389
|
-
|
|
2342
|
+
# evalResultDict = {"evaluation": result}
|
|
2390
2343
|
|
|
2344
|
+
evalData["evaluation"] = result
|
|
2345
|
+
formatted_results.append(evalData)
|
|
2346
|
+
|
|
2347
|
+
return {"llumoEval": formatted_results}
|
|
2348
|
+
# return formatted_results
|
|
2391
2349
|
|
|
2392
2350
|
def getInsights(self,logs:List,userAim:List[str],promptTemplate:str = ""
|
|
2393
2351
|
,systemInstructions:str="",multiTurnChat=False,createMultipleLogs=True):
|
|
@@ -2456,80 +2414,14 @@ class LlumoClient:
|
|
|
2456
2414
|
# 1. Create Report
|
|
2457
2415
|
print("✅ Generating Insights Now....")
|
|
2458
2416
|
dataID = uuid.uuid4().hex[:36]
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
}
|
|
2465
|
-
create_url = "https://backend-api.llumo.ai/api/v1/sdk/create-insight-report"
|
|
2466
|
-
response = requests.post(create_url, json=payload)
|
|
2467
|
-
|
|
2468
|
-
# Check if request was successful
|
|
2469
|
-
response.raise_for_status()
|
|
2470
|
-
|
|
2471
|
-
# print(f"Create Response: {response.json()}")
|
|
2472
|
-
except requests.exceptions.RequestException as e:
|
|
2473
|
-
# Check for response data in the error
|
|
2474
|
-
error_data = e.response.json() if e.response else str(e)
|
|
2475
|
-
print(f"Error in create request: {error_data}")
|
|
2476
|
-
return
|
|
2417
|
+
payload = {
|
|
2418
|
+
"data":logs,
|
|
2419
|
+
"userAim":userAim,
|
|
2420
|
+
"dataID":dataID
|
|
2421
|
+
}
|
|
2477
2422
|
|
|
2478
2423
|
# 2. Poll for Results
|
|
2479
|
-
|
|
2480
|
-
cursor = '0-0'
|
|
2481
|
-
is_complete = False
|
|
2482
|
-
max_polls = 20
|
|
2483
|
-
poll_count = 0
|
|
2484
|
-
|
|
2485
|
-
insight_result = []
|
|
2486
|
-
while not is_complete and poll_count < max_polls:
|
|
2487
|
-
poll_count += 1
|
|
2488
|
-
|
|
2489
|
-
try:
|
|
2490
|
-
poll_params = {
|
|
2491
|
-
'dataID': dataID,
|
|
2492
|
-
'cursor': cursor,
|
|
2493
|
-
'limit': 10
|
|
2494
|
-
}
|
|
2495
|
-
poll_url = f"https://backend-api.llumo.ai/api/v1/sdk/poll-insight-report"
|
|
2496
|
-
poll_response = requests.get(poll_url, params=poll_params)
|
|
2497
|
-
poll_response.raise_for_status()
|
|
2498
|
-
|
|
2499
|
-
data = poll_response.json()
|
|
2500
|
-
# Accessing nested data: pollResponse.data.debugLog
|
|
2501
|
-
debug_log = data.get('debugLog', {})
|
|
2502
|
-
results = debug_log.get('results', [])
|
|
2503
|
-
next_cursor = debug_log.get('nextCursor')
|
|
2504
|
-
|
|
2505
|
-
if results:
|
|
2506
|
-
insight_result.extend(results)
|
|
2507
|
-
|
|
2508
|
-
# Logic to handle cursor movement
|
|
2509
|
-
if next_cursor == cursor and not results:
|
|
2510
|
-
# print("Long poll returned empty (timeout). Continuing...")
|
|
2511
|
-
pass
|
|
2512
|
-
else:
|
|
2513
|
-
cursor = next_cursor
|
|
2514
|
-
|
|
2515
|
-
# Break condition for test (heuristic)
|
|
2516
|
-
if len(insight_result):
|
|
2517
|
-
break
|
|
2518
|
-
|
|
2519
|
-
except requests.exceptions.RequestException as e:
|
|
2520
|
-
error_msg = e.response.json() if e.response else str(e)
|
|
2521
|
-
# print(f"Error in poll request: {error_msg}")
|
|
2522
|
-
|
|
2523
|
-
if e.response is not None and e.response.status_code == 404:
|
|
2524
|
-
# print("Resource not ready yet...")
|
|
2525
|
-
pass
|
|
2526
|
-
else:
|
|
2527
|
-
# Fatal error, break the loop
|
|
2528
|
-
break
|
|
2529
|
-
|
|
2530
|
-
# Small delay to prevent tight loop (Equivalent to await sleep(1000))
|
|
2531
|
-
time.sleep(1)
|
|
2532
|
-
|
|
2424
|
+
insight_result = dataPollingFuncForInsight(payload)
|
|
2533
2425
|
# llumoInsight = formattedInsightResponse(llmResponse=insight_result)
|
|
2534
2426
|
|
|
2535
2427
|
return {"llumoInsight": insight_result}
|
|
@@ -862,48 +862,111 @@ def addPromptAndInstructionInLogs(logData=None,promptTemplate= "",systemInstruct
|
|
|
862
862
|
return logDataWithPrompt
|
|
863
863
|
|
|
864
864
|
|
|
865
|
-
def dataPollingFuncForEval(
|
|
866
|
-
|
|
867
|
-
pollUrl = "https://backend-api.llumo.ai/api/v1/sdk/poll"
|
|
868
|
-
|
|
869
|
-
# Create evaluation
|
|
865
|
+
def dataPollingFuncForEval(api_key, payload, data, poll_interval=10, limit=10):
|
|
866
|
+
# Create evaluation (POST)
|
|
870
867
|
requests.post(
|
|
871
|
-
|
|
872
|
-
json=
|
|
873
|
-
headers=
|
|
868
|
+
"https://backend-api.llumo.ai/api/v1/sdk/create-evaluation-Multiple",
|
|
869
|
+
json=payload,
|
|
870
|
+
headers={
|
|
871
|
+
"Content-Type": "application/json",
|
|
872
|
+
"Authorization": f"Bearer {api_key}",
|
|
873
|
+
},
|
|
874
874
|
)
|
|
875
|
-
# print("payload", payload)
|
|
876
875
|
|
|
877
876
|
final_result_data = []
|
|
877
|
+
|
|
878
|
+
cursor = "0-0"
|
|
878
879
|
all_data_fetched = False
|
|
879
880
|
|
|
880
881
|
print("✅ Evaluation Started...")
|
|
881
882
|
while not all_data_fetched:
|
|
882
883
|
try:
|
|
883
884
|
response = requests.get(
|
|
884
|
-
|
|
885
|
-
params=
|
|
885
|
+
"https://backend-api.llumo.ai/api/v1/sdk/poll",
|
|
886
|
+
params={
|
|
887
|
+
"cursor": cursor,
|
|
888
|
+
"dataID": payload["dataID"],
|
|
889
|
+
"limit": limit,
|
|
890
|
+
},
|
|
886
891
|
)
|
|
887
892
|
|
|
888
893
|
response_data = response.json()
|
|
889
894
|
result_data = response_data.get("debugLog", {})
|
|
890
|
-
# print("resultData", result_data)
|
|
891
895
|
|
|
892
896
|
results = result_data.get("results", [])
|
|
893
897
|
final_result_data.extend(results)
|
|
894
898
|
|
|
895
899
|
cursor = result_data.get("nextCursor")
|
|
896
900
|
|
|
897
|
-
if len(final_result_data) ==
|
|
901
|
+
if len(final_result_data) == len(data):
|
|
898
902
|
all_data_fetched = True
|
|
899
903
|
|
|
900
|
-
time.sleep(
|
|
904
|
+
time.sleep(poll_interval)
|
|
901
905
|
|
|
902
906
|
except Exception as error:
|
|
903
907
|
print("error", error)
|
|
904
908
|
all_data_fetched = True
|
|
909
|
+
|
|
905
910
|
return final_result_data
|
|
906
911
|
|
|
912
|
+
def dataPollingFuncForInsight(payload, poll_interval=1, limit=10, max_polls=20):
|
|
913
|
+
dataID = payload["dataID"]
|
|
914
|
+
|
|
915
|
+
# -------------------------------
|
|
916
|
+
# 1. Create Insight Report (POST)
|
|
917
|
+
# -------------------------------
|
|
918
|
+
try:
|
|
919
|
+
create_url = "https://backend-api.llumo.ai/api/v1/sdk/create-insight-report"
|
|
920
|
+
response = requests.post(create_url, json=payload)
|
|
921
|
+
response.raise_for_status()
|
|
922
|
+
except requests.exceptions.RequestException as e:
|
|
923
|
+
error_data = e.response.json() if e.response else str(e)
|
|
924
|
+
print(f"Error in create request: {error_data}")
|
|
925
|
+
return None
|
|
926
|
+
|
|
927
|
+
# -------------------------------
|
|
928
|
+
# 2. Poll Insight Results (GET)
|
|
929
|
+
# -------------------------------
|
|
930
|
+
cursor = "0-0"
|
|
931
|
+
poll_count = 0
|
|
932
|
+
insight_result = []
|
|
933
|
+
|
|
934
|
+
while poll_count < max_polls:
|
|
935
|
+
poll_count += 1
|
|
936
|
+
|
|
937
|
+
try:
|
|
938
|
+
poll_params = {
|
|
939
|
+
"dataID": dataID,
|
|
940
|
+
"cursor": cursor,
|
|
941
|
+
"limit": limit,
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
poll_url = "https://backend-api.llumo.ai/api/v1/sdk/poll-insight-report"
|
|
945
|
+
poll_response = requests.get(poll_url, params=poll_params)
|
|
946
|
+
poll_response.raise_for_status()
|
|
947
|
+
|
|
948
|
+
data = poll_response.json()
|
|
949
|
+
debug_log = data.get("debugLog", {})
|
|
950
|
+
results = debug_log.get("results", [])
|
|
951
|
+
next_cursor = debug_log.get("nextCursor")
|
|
952
|
+
|
|
953
|
+
if results:
|
|
954
|
+
insight_result.extend(results)
|
|
955
|
+
break # same heuristic as original
|
|
956
|
+
|
|
957
|
+
if next_cursor != cursor:
|
|
958
|
+
cursor = next_cursor
|
|
959
|
+
|
|
960
|
+
except requests.exceptions.RequestException as e:
|
|
961
|
+
if e.response is not None and e.response.status_code == 404:
|
|
962
|
+
pass
|
|
963
|
+
else:
|
|
964
|
+
break
|
|
965
|
+
|
|
966
|
+
time.sleep(poll_interval)
|
|
967
|
+
|
|
968
|
+
return insight_result
|
|
969
|
+
|
|
907
970
|
def formattedInsightResponse(llmResponse):
|
|
908
971
|
try:
|
|
909
972
|
response = llmResponse
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|