llumo 0.2.43__py3-none-any.whl → 0.2.44__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.
llumo/client.py CHANGED
@@ -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
- requests.post(
2308
- "https://backend-api.llumo.ai/api/v1/sdk/create-evaluation-Multiple",
2309
- json=payload,
2310
- headers={
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
- score: Dict[str, float | None] = {}
2357
- reasoning: Dict[str, str] = {}
2319
+ # print("ROW: ",row)
2320
+ result = []
2358
2321
 
2359
- for eval_name in evals:
2360
- details = row.get(eval_name)
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
- if isinstance(details, dict):
2363
- if isinstance(details.get("value"), (int, float)):
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
- elif "score" in row:
2370
- score[eval_name] = (
2371
- row["score"] if isinstance(row["score"], (int, float)) else None
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
- # print(formatted_row)
2387
- formatted_results.append(formatted_row)
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
- return {"llumoEval": formatted_results}
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
- try:
2460
- payload = {
2461
- "data":logs,
2462
- "userAim":userAim,
2463
- "dataID":dataID
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
- # print("\n--- Starting Polling ---")
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}
llumo/helpingFuntions.py CHANGED
@@ -862,48 +862,111 @@ def addPromptAndInstructionInLogs(logData=None,promptTemplate= "",systemInstruct
862
862
  return logDataWithPrompt
863
863
 
864
864
 
865
- def dataPollingFuncForEval(headers,post_payload,poll_params,data_len:int):
866
- postUrl = "https://backend-api.llumo.ai/api/v1/sdk/create-evaluation-Multiple"
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
- url= postUrl,
872
- json=post_payload,
873
- headers=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
- pollUrl,
885
- params=poll_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) == data_len:
901
+ if len(final_result_data) == len(data):
898
902
  all_data_fetched = True
899
903
 
900
- time.sleep(10)
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llumo
3
- Version: 0.2.43
3
+ Version: 0.2.44
4
4
  Summary: Python SDK for interacting with the Llumo ai API.
5
5
  Home-page: https://www.llumo.ai/
6
6
  Author: Llumo
@@ -2,19 +2,19 @@ llumo/__init__.py,sha256=kkuppu7ZPiVZFdnYzJ9BM3syMbYHOSZLpwKwAvGHsnY,311
2
2
  llumo/callback.py,sha256=XQbImLnd64_B2Iir-FCaJcL5Kmpm3RlXJH2zDRXk_yk,25135
3
3
  llumo/callbacks-0.py,sha256=TEIOCWRvk2UYsTmBMBsnlgpqWvr-2y3a6d0w_e96NRM,8958
4
4
  llumo/chains.py,sha256=6lCgLseh04RUgc6SahhmvQj82quay2Mi1j8gPUlx8Es,2923
5
- llumo/client.py,sha256=yuvh81zxkck-QvgqRSwTSGtLohkNBj28B_wsSf27NuQ,95904
5
+ llumo/client.py,sha256=bXaLQc6n43GgxEEkrDZi-G7L3-1vQ7eBMozSlkyVluY,91891
6
6
  llumo/exceptions.py,sha256=lUugHX1EorGse_5dU4vBRU82TNkN6VDaAq6JGOcfzaA,2381
7
7
  llumo/execution.py,sha256=nWbJ7AvWuUPcOb6i-JzKRna_PvF-ewZTiK8skS-5n3w,1380
8
8
  llumo/functionCalling.py,sha256=D5jYapu1rIvdIJNUYPYMTyhQ1H-6nkwoOLMi6eekfUE,7241
9
9
  llumo/google.py,sha256=6y9YnDFDRHv6-sQNT5LIsV9p31BCN0B9eow5KTRBWfM,2185
10
- llumo/helpingFuntions.py,sha256=4ompFeWq-mr67NkbiSUGvqFnQPtffIXUIYzGyihOqLs,33083
10
+ llumo/helpingFuntions.py,sha256=9W6q-GzrBUaHZubTVTGvcpUL9KH92CdM0ShkUScLYDM,35081
11
11
  llumo/llumoLogger.py,sha256=syFerZgosq1xm2EkE-o6xBhEg7zE07X9ASao39ZEECQ,2256
12
12
  llumo/llumoSessionContext.py,sha256=QaiQtB13dITTVINpzEAEVlO-fpW362XkgMjM1W4EHoo,14891
13
13
  llumo/models.py,sha256=aVEZsOOoQx5LeNtwSyBxqvrINq0izH3QWu_YjsMPE6o,2910
14
14
  llumo/openai.py,sha256=VstBzaORe8Tq0feUIIEszzcN1oq6TJfkPviaCr5d3Bw,8950
15
15
  llumo/sockets.py,sha256=pfWz1zTEiwqJhdbSy3i3_Y4WlIdJ3cuac11wMePeBS0,6130
16
- llumo-0.2.43.dist-info/licenses/LICENSE,sha256=tF9yAcfPV9xGT3ViWmC8hPvOo8BEk4ZICbUfcEo8Dlk,182
17
- llumo-0.2.43.dist-info/METADATA,sha256=z1TDEUY-imh53V2TxceOUO9_XXEmMuynH6RpfYEQPEc,1662
18
- llumo-0.2.43.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- llumo-0.2.43.dist-info/top_level.txt,sha256=d5zUTMI99llPtLRB8rtSrqELm_bOqX-bNC5IcwlDk88,6
20
- llumo-0.2.43.dist-info/RECORD,,
16
+ llumo-0.2.44.dist-info/licenses/LICENSE,sha256=tF9yAcfPV9xGT3ViWmC8hPvOo8BEk4ZICbUfcEo8Dlk,182
17
+ llumo-0.2.44.dist-info/METADATA,sha256=bUsfxsgHPfVE1YuLET9yzfyHruYMt1QSe14hVi_BQQA,1662
18
+ llumo-0.2.44.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ llumo-0.2.44.dist-info/top_level.txt,sha256=d5zUTMI99llPtLRB8rtSrqELm_bOqX-bNC5IcwlDk88,6
20
+ llumo-0.2.44.dist-info/RECORD,,
File without changes