llumo 0.2.16b2__py3-none-any.whl → 0.2.17__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
@@ -406,6 +406,11 @@ class LlumoClient:
406
406
 
407
407
  def compressor(self, data, prompt_template):
408
408
  results = []
409
+ if isinstance(data, dict):
410
+ data = [data]
411
+ elif not isinstance(data, list):
412
+ raise ValueError("Data should be a dict or a list of dicts.")
413
+
409
414
  dataframe = pd.DataFrame(data)
410
415
 
411
416
  try:
@@ -612,12 +617,17 @@ class LlumoClient:
612
617
  self,
613
618
  data,
614
619
  evals: list, # list of eval metric names
615
- prompt_template="",
620
+ prompt_template="Give answer to the given query: {{query}} using the given context: {{context}}.",
616
621
  outputColName="output",
617
622
  createExperiment: bool = False,
618
623
  getDataFrame:bool =False,
619
624
  _tocheck=True,
620
625
  ):
626
+ if isinstance(data, dict):
627
+ data = [data]
628
+ elif not isinstance(data, list):
629
+ raise ValueError("Data should be a dict or a list of dicts.")
630
+
621
631
  self.socket = LlumoSocketClient(socketUrl)
622
632
  dataframe = pd.DataFrame(data).astype(str)
623
633
  workspaceID = None
@@ -868,130 +878,76 @@ class LlumoClient:
868
878
  def promptSweep(
869
879
  self,
870
880
  templates: List[str],
871
- dataset: Dict[str, List[str]],
881
+ data,
872
882
  model_aliases: List[AVAILABLEMODELS],
873
883
  apiKey: str,
874
884
  evals=["Response Correctness"],
875
885
  toEvaluate: bool = False,
876
886
  createExperiment: bool = False,
877
- getDataFrame = False
878
-
879
-
887
+ getDataFrame=False
880
888
  ) -> pd.DataFrame:
881
-
889
+ if isinstance(data, dict):
890
+ data = [data]
891
+ # Check if data is now a list of dictionaries
892
+ if isinstance(data, list) and all(isinstance(item, dict) for item in data):
893
+ working_df= pd.DataFrame(data).astype(str)
894
+ else:
895
+ raise ValueError("Data must be a dictionary or a list of dictionaries.")
882
896
  modelStatus = validateModels(model_aliases=model_aliases)
883
- if modelStatus["status"]== False:
897
+ if modelStatus["status"] == False:
884
898
  raise LlumoAIError.providerError(modelStatus["message"])
885
899
 
886
900
  self.validateApiKey()
887
901
  workspaceID = self.workspaceID
888
902
  email = self.email
889
903
  executor = ModelExecutor(apiKey)
890
- keys = list(dataset.keys())
891
- value_combinations = list(itertools.product(*dataset.values()))
892
- combinations = [dict(zip(keys, values)) for values in value_combinations]
893
-
894
- results = []
895
-
896
- for combo in combinations:
897
- for template in templates:
898
- prompt = template
899
- for k, v in combo.items():
900
- prompt = prompt.replace(f"{{{{{k}}}}}", v)
901
-
902
- row = {
903
- "prompt": prompt,
904
- **combo,
905
- }
906
-
907
- for i, model in enumerate(model_aliases, 1):
908
- try:
909
- provider = getProviderFromModel(model)
910
- response = executor.execute(
911
- provider, model.value, prompt, apiKey
912
- )
913
- outputKey = f"output_{i}"
914
- row[outputKey] = response
915
- except Exception as e:
916
- row[f"output_{i}"] = str(e)
917
-
918
- results.append(row)
919
-
920
- df = pd.DataFrame(results)
921
-
922
- if toEvaluate == True:
923
- dfWithEvals = df.copy()
924
- for i, model in enumerate(model_aliases, 1):
925
- outputColName = f"output_{i}"
926
- try:
927
- res = self.evaluateMultiple(
928
- df.to_dict("records"),
929
- evals=evals,
930
- prompt_template=str(templates[0]),
931
- outputColName=outputColName,
932
- _tocheck=False,
933
- getDataFrame=True,
934
- createExperiment = False
935
- )
936
-
937
- # Rename all new columns with _i+1 (e.g., _1, _2)
938
- for evalMetric in evals:
939
- scoreCol = f"{evalMetric}"
940
- reasonCol = f"{evalMetric} Reason"
941
- if scoreCol in res.columns:
942
- res = res.rename(columns={scoreCol: f"{scoreCol}_{i}"})
943
- if reasonCol in res.columns:
944
- res = res.rename(columns={reasonCol: f"{reasonCol}_{i}"})
945
-
946
- # Drop duplicated columns from df (like prompt, variables, etc.)
947
- newCols = [
948
- col for col in res.columns if col not in dfWithEvals.columns
949
- ]
950
- dfWithEvals = pd.concat([dfWithEvals, res[newCols]], axis=1)
904
+ prompt_template = templates[0]
905
+
906
+ working_df = self._outputForStream(working_df, model_aliases, prompt_template, apiKey)
951
907
 
952
- except Exception as e:
953
- print(f"Evaluation failed for model {model.value}: {str(e)}")
908
+ # Optional evaluation
909
+ outputEvalMapping = None
910
+ if toEvaluate:
911
+ for evalName in evals:
912
+ # Validate API and dependencies
913
+ self.validateApiKey(evalName=evalName)
914
+ metricDependencies = checkDependency(
915
+ evalName, list(working_df.columns), tocheck=False
916
+ )
917
+ if not metricDependencies["status"]:
918
+ raise LlumoAIError.dependencyError(metricDependencies["message"])
954
919
 
955
- if createExperiment:
956
- pd.set_option("future.no_silent_downcasting", True)
957
- dfWithEvals = dfWithEvals.fillna("Some error occurred")
958
- if createPlayground(
959
- email,
960
- workspaceID,
961
- dfWithEvals,
962
- promptText=templates[0],
920
+ working_df, outputEvalMapping = self._evaluateForStream(working_df, evals, model_aliases, prompt_template,generateOutput=True)
921
+ if createExperiment:
922
+ # df = working_df.fillna("Some error occured").astype(object)
923
+ with warnings.catch_warnings():
924
+ warnings.simplefilter(action='ignore', category=FutureWarning)
925
+ df = working_df.fillna("Some error occurred").astype(str)
926
+ if createPlayground(
927
+ email, workspaceID, df,
928
+ promptText=prompt_template,
963
929
  definationMapping=self.definationMapping,
964
- ):
930
+ evalOutputMap=outputEvalMapping
931
+ ):
932
+ print(
933
+ "LLUMO’s intuitive UI is ready—start exploring and experimenting with your logs now. Visit https://llumo.ai/evallm to see the results.")
934
+ else:
935
+ if getDataFrame == True and toEvaluate == True:
936
+ return LlumoDataFrameResults(working_df, evals=self.evals, evalData=self.evalData,
937
+ definationMapping=self.definationMapping)
965
938
 
966
- print(
967
- "LLUMO’s intuitive UI is ready—start exploring and experimenting with your logs now. Visit https://llumo.ai/evallm to see the results."
968
- )
969
- else:
970
- if getDataFrame:
971
- return LlumoDataFrameResults(dfWithEvals, evals=self.evals, evalData=self.evalData,
972
- definationMapping=self.definationMapping)
973
- else:
974
- data = dfWithEvals.to_dict(orient="records")
975
- return LlumoDictResults(data, evals=self.evals, evalData=self.evalData,definationMapping=self.definationMapping)
939
+ elif getDataFrame == False and toEvaluate == True:
940
+ data = working_df.to_dict(orient="records")
941
+ return LlumoDictResults(data, evals=self.evals, evalData=self.evalData,
942
+ definationMapping=self.definationMapping)
976
943
 
944
+ elif getDataFrame== True and toEvaluate == False:
945
+ return working_df
946
+
947
+ elif getDataFrame == False and toEvaluate == False :
948
+ return working_df.to_dict(orient = "records")
977
949
 
978
- else:
979
- if createExperiment == True:
980
- pd.set_option("future.no_silent_downcasting", True)
981
- df = df.fillna("Some error occurred")
982
950
 
983
- if createPlayground(email, workspaceID, df, promptText=templates[0]):
984
- print(
985
- "LLUMO’s intuitive UI is ready—start exploring and experimenting with your logs now. Visit https://llumo.ai/evallm to see the results."
986
- )
987
- else:
988
- if getDataFrame:
989
- return LlumoDataFrameResults(df, evals=self.evals, evalData=self.evalData,
990
- definationMapping=self.definationMapping)
991
- else:
992
- data = df.to_dict(orient="records")
993
- return LlumoDictResults(data, evals=self.evals, evalData=self.evalData,
994
- definationMapping=self.definationMapping)
995
951
 
996
952
 
997
953
 
@@ -1008,6 +964,11 @@ class LlumoClient:
1008
964
  getDataFrame:bool = False
1009
965
 
1010
966
  ):
967
+ if isinstance(data, dict):
968
+ data = [data]
969
+ elif not isinstance(data, list):
970
+ raise ValueError("Data should be a dict or a list of dicts.")
971
+
1011
972
  if model.lower() not in ["openai", "google"]:
1012
973
  raise ValueError("Model must be 'openai' or 'google'")
1013
974
 
@@ -1057,6 +1018,10 @@ class LlumoClient:
1057
1018
  outputColName="output"
1058
1019
 
1059
1020
  ):
1021
+ if isinstance(data, dict):
1022
+ data = [data]
1023
+ elif not isinstance(data, list):
1024
+ raise ValueError("Data should be a dict or a list of dicts.")
1060
1025
 
1061
1026
  dataframe = pd.DataFrame(data)
1062
1027
 
@@ -1103,6 +1068,11 @@ class LlumoClient:
1103
1068
  generateOutput=True,
1104
1069
  getDataFrame = False
1105
1070
  ):
1071
+ if isinstance(data, dict):
1072
+ data = [data]
1073
+ elif not isinstance(data, list):
1074
+ raise ValueError("Data should be a dict or a list of dicts.")
1075
+
1106
1076
  # Validate required parameters
1107
1077
  if generateOutput:
1108
1078
  if not modelAliases:
@@ -1238,7 +1208,6 @@ class LlumoClient:
1238
1208
 
1239
1209
 
1240
1210
  self.socket.disconnect()
1241
-
1242
1211
  # Create experiment if required
1243
1212
  if createExperiment:
1244
1213
  # df = working_df.fillna("Some error occured").astype(object)
@@ -1368,6 +1337,10 @@ class LlumoClient:
1368
1337
  getDataFrame = False
1369
1338
  ):
1370
1339
 
1340
+ if isinstance(data, dict):
1341
+ data = [data]
1342
+ elif not isinstance(data, list):
1343
+ raise ValueError("Data should be a dict or a list of dicts.")
1371
1344
 
1372
1345
  # Copy the original dataframe
1373
1346
  original_df = pd.DataFrame(data)
@@ -1508,7 +1481,7 @@ class LlumoClient:
1508
1481
  except Exception as e:
1509
1482
  raise "Some error ocuured please check your API key"
1510
1483
 
1511
- def upload(self, file_path):
1484
+ def uploadfile(self, file_path):
1512
1485
 
1513
1486
  workspaceID = None
1514
1487
  email = None
@@ -1550,8 +1523,97 @@ class LlumoClient:
1550
1523
 
1551
1524
  except Exception as e:
1552
1525
  print(f"Error: {e}")
1526
+
1527
+ def upload(self,data):
1528
+ try:
1529
+ if isinstance(data, dict):
1530
+ data = [data]
1531
+ # Check if data is now a list of dictionaries
1532
+ if isinstance(data, list) and all(isinstance(item, dict) for item in data):
1533
+ dataframe = pd.DataFrame(data).astype(str)
1534
+ else:
1535
+ raise ValueError("Data must be a dictionary or a list of dictionaries.")
1536
+ self.validateApiKey()
1537
+ if createPlayground(self.email, self.workspaceID, dataframe):
1538
+ print(
1539
+ "LLUMO’s intuitive UI is ready—start exploring and experimenting with your logs now. Visit https://llumo.ai/evallm to see the results."
1540
+ )
1541
+ return True
1542
+
1543
+ except Exception as e:
1544
+ print(f"Error: {e}")
1545
+ return False
1546
+
1547
+
1548
+ def createExperimentWithEvals(
1549
+ self,
1550
+ data,
1551
+ evals: list, # list of eval metric names
1552
+ prompt_template="Give answer to the given query: {{query}} using the given context: {{context}}.",
1553
+ outputColName="output",
1554
+ createExperiment: bool = False,
1555
+ getDataFrame:bool =False,
1556
+ _tocheck=True,
1557
+ ):
1558
+ if isinstance(data, dict):
1559
+ data = [data]
1560
+ elif not isinstance(data, list):
1561
+ raise ValueError("Data should be a dict or a list of dicts.")
1562
+ print("reciving data")
1563
+ dataframe = pd.DataFrame(data).astype(str)
1564
+ workspaceID = None
1565
+ email = None
1566
+ self.evalData=[]
1567
+ self.evals=evals
1568
+ self.allBatches = []
1569
+ rowIdMapping = {} # (rowID-columnID-columnID -> (index, evalName))
1570
+ print("single eval validate")
1571
+ self.validateApiKey(evalName=evals[0])
1572
+ if createExperiment:
1573
+ activePlayground = str(createEvalPlayground(email=self.email, workspaceID=self.workspaceID))
1574
+
1575
+ else:
1576
+ activePlayground = f"{int(time.time() * 1000)}{uuid.uuid4()}".replace(
1577
+ "-", ""
1578
+ )
1579
+ for evalName in evals:
1580
+ print("validate in loop")
1581
+ self.validateApiKey(evalName=evalName)
1553
1582
 
1583
+
1584
+ print("convertinf to dict")
1585
+ self.evalData =dataframe.to_dict(orient="records")
1586
+
1587
+ if createExperiment:
1588
+ print("heading to upload")
1589
+ pd.set_option("future.no_silent_downcasting", True)
1590
+ # df = dataframe.fillna("Some error occured").astype(object)
1591
+ with warnings.catch_warnings():
1592
+ warnings.simplefilter(action='ignore', category=FutureWarning)
1593
+ df = dataframe.fillna("Some error occurred").astype(str)
1594
+
1595
+ df = dataframe.fillna("Some error occured").infer_objects(copy=False)
1596
+ if createPlayground(
1597
+ self.email,
1598
+ self.workspaceID,
1599
+ df,
1600
+ promptText=prompt_template,
1601
+ definationMapping=self.definationMapping,
1602
+ outputColName=outputColName,
1603
+ activePlayground= activePlayground
1604
+ ):
1605
+ print(
1606
+ "LLUMO’s intuitive UI is ready—start exploring and experimenting with your logs now. Visit https://llumo.ai/evallm to see the results."
1607
+ )
1608
+
1609
+ else:
1610
+ if getDataFrame:
1611
+ return LlumoDataFrameResults(dataframe,evals=self.evals,evalData=self.evalData,definationMapping=self.definationMapping)
1612
+ else:
1613
+ data=dataframe.to_dict(orient="records")
1614
+ return LlumoDictResults(data,evals=self.evals,evalData=self.evalData,definationMapping=self.definationMapping)
1554
1615
 
1616
+
1555
1617
  class SafeDict(dict):
1556
1618
  def __missing__(self, key):
1557
1619
  return ""
llumo/google.py CHANGED
@@ -59,7 +59,7 @@ class genai:
59
59
  evaluation = None
60
60
 
61
61
  if evaluation is None:
62
- print("Cannot process your request, please check your api and try again later.")
62
+ print("Cannot process your request for evaluation, please check your api and try again later.")
63
63
  return response
64
64
 
65
65
 
llumo/helpingFuntions.py CHANGED
@@ -233,8 +233,7 @@ def createColumn(workspaceID, dataframe, playgroundID, promptText=None,queryColN
233
233
 
234
234
  # Create a mapping of column names to unique column IDs
235
235
  columnIDMapping = {}
236
- print("Def Mapping: ")
237
- print(definationMapping)
236
+
238
237
  # Iterate over each column in the dataframe
239
238
  for indx, col in enumerate(dataframe.columns):
240
239
  # Generate a unique column ID using uuid
@@ -336,7 +335,7 @@ def createColumn(workspaceID, dataframe, playgroundID, promptText=None,queryColN
336
335
  "groundTruth": None if "groundTruth" not in columnIDMapping.keys() else columnIDMapping["groundTruth"],
337
336
  "dataStream": None,
338
337
  "context":None if "context" not in columnIDMapping.keys() else columnIDMapping["context"],
339
- "dependency":[ columnIDMapping[dep] for dep in evalDependencies[ col.rsplit("_",1)[0]]],
338
+ "dependency":[columnIDMapping[col] if dep == "output" else columnIDMapping[dep] for dep in evalDependencies[col.rsplit("_", 1)[0]]],
340
339
  "query": None if "query" not in columnIDMapping.keys() else columnIDMapping["query"],
341
340
  "tools":None if "tools" not in columnIDMapping.keys() else columnIDMapping["tools"],
342
341
  "messageHistory":None if "messageHistory" not in columnIDMapping.keys() else columnIDMapping["messageHistory"],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llumo
3
- Version: 0.2.16b2
3
+ Version: 0.2.17
4
4
  Summary: Python SDK for interacting with the Llumo ai API.
5
5
  Home-page: https://www.llumo.ai/
6
6
  Author: Llumo
@@ -0,0 +1,16 @@
1
+ llumo/__init__.py,sha256=YVBkF1fiXFBd_zzySi9BDWgX8MJuLBJ-oF8538MrnDU,256
2
+ llumo/chains.py,sha256=6lCgLseh04RUgc6SahhmvQj82quay2Mi1j8gPUlx8Es,2923
3
+ llumo/client.py,sha256=LhvBPxKCbt1TXcrmDbd7u_hOXldiC34NHTlRwlAG5VI,63133
4
+ llumo/exceptions.py,sha256=Vp_MnanHbnd1Yjuoi6WLrKiwwZbJL3znCox2URMmGU4,2032
5
+ llumo/execution.py,sha256=nWbJ7AvWuUPcOb6i-JzKRna_PvF-ewZTiK8skS-5n3w,1380
6
+ llumo/functionCalling.py,sha256=D5jYapu1rIvdIJNUYPYMTyhQ1H-6nkwoOLMi6eekfUE,7241
7
+ llumo/google.py,sha256=3S_aRtbtlctCXPGR0u4baLlkyFrsjd02vlUCkoRPA5U,2147
8
+ llumo/helpingFuntions.py,sha256=ORBM5xPPMHc3ENnJOg4i3Enxtor4En5oDj1d0Zu1mLk,25284
9
+ llumo/models.py,sha256=aVEZsOOoQx5LeNtwSyBxqvrINq0izH3QWu_YjsMPE6o,2910
10
+ llumo/openai.py,sha256=DGhEwQIJIIycGpw3hYQnyxdj6RFVpZ-gay-fZGqtkhU,3013
11
+ llumo/sockets.py,sha256=I2JO_eNEctRo_ikgvFVp5zDd-m0VDu04IEUhhsa1Tic,5950
12
+ llumo-0.2.17.dist-info/licenses/LICENSE,sha256=tF9yAcfPV9xGT3ViWmC8hPvOo8BEk4ZICbUfcEo8Dlk,182
13
+ llumo-0.2.17.dist-info/METADATA,sha256=3rw1KKwWOUFZMT3JaBAqGAugsPxB011FhGGccVBCNTY,1519
14
+ llumo-0.2.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ llumo-0.2.17.dist-info/top_level.txt,sha256=d5zUTMI99llPtLRB8rtSrqELm_bOqX-bNC5IcwlDk88,6
16
+ llumo-0.2.17.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- llumo/__init__.py,sha256=YVBkF1fiXFBd_zzySi9BDWgX8MJuLBJ-oF8538MrnDU,256
2
- llumo/chains.py,sha256=6lCgLseh04RUgc6SahhmvQj82quay2Mi1j8gPUlx8Es,2923
3
- llumo/client.py,sha256=rOTbw8QGi5CnQ77QKS4rKh-dSBSVoyVAORrK1i_b5EQ,60339
4
- llumo/exceptions.py,sha256=Vp_MnanHbnd1Yjuoi6WLrKiwwZbJL3znCox2URMmGU4,2032
5
- llumo/execution.py,sha256=nWbJ7AvWuUPcOb6i-JzKRna_PvF-ewZTiK8skS-5n3w,1380
6
- llumo/functionCalling.py,sha256=D5jYapu1rIvdIJNUYPYMTyhQ1H-6nkwoOLMi6eekfUE,7241
7
- llumo/google.py,sha256=F-n7DCQ7mvORGyK_yGliL14N0AGyVGmjKgO60FqOOKI,2132
8
- llumo/helpingFuntions.py,sha256=0W2JNdLyOV92lgESgB_JyJmOUvW5ooRdZyjN5LKDSX0,25296
9
- llumo/models.py,sha256=aVEZsOOoQx5LeNtwSyBxqvrINq0izH3QWu_YjsMPE6o,2910
10
- llumo/openai.py,sha256=DGhEwQIJIIycGpw3hYQnyxdj6RFVpZ-gay-fZGqtkhU,3013
11
- llumo/sockets.py,sha256=I2JO_eNEctRo_ikgvFVp5zDd-m0VDu04IEUhhsa1Tic,5950
12
- llumo-0.2.16b2.dist-info/licenses/LICENSE,sha256=tF9yAcfPV9xGT3ViWmC8hPvOo8BEk4ZICbUfcEo8Dlk,182
13
- llumo-0.2.16b2.dist-info/METADATA,sha256=5Nys3GS9XTD0fE9K4_1IxjD2YG1JpC1Fl2M1q93orf4,1521
14
- llumo-0.2.16b2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- llumo-0.2.16b2.dist-info/top_level.txt,sha256=d5zUTMI99llPtLRB8rtSrqELm_bOqX-bNC5IcwlDk88,6
16
- llumo-0.2.16b2.dist-info/RECORD,,