Skip to content

Commit

Permalink
Allow returning empty results when nothing is retrieved from Databric…
Browse files Browse the repository at this point in the history
…ksRM (#1995)

* raise error when databricks index is not ready

* don't fail on non-existing data_array
  • Loading branch information
chenmoneygithub authored Dec 27, 2024
1 parent 45a4d15 commit 06f4551
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dspy/retrieve/databricks_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 06f4551

Please sign in to comment.