diff --git a/dspy/retrieve/databricks_rm.py b/dspy/retrieve/databricks_rm.py index 249b3856d..0334154dd 100644 --- a/dspy/retrieve/databricks_rm.py +++ b/dspy/retrieve/databricks_rm.py @@ -273,11 +273,12 @@ def forward( # Extracting the results items = [] - for _, data_row in enumerate(results["result"]["data_array"]): - item = {} - for col_name, val in zip(col_names, data_row): - item[col_name] = val - items += [item] + if "data_array" in results["result"]: + for _, data_row in enumerate(results["result"]["data_array"]): + item = {} + for col_name, val in zip(col_names, data_row): + item[col_name] = val + items += [item] # Sorting results by score in descending order sorted_docs = sorted(items, key=lambda x: x["score"], reverse=True)[: self.k]