Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow returning empty results when nothing is retrieved from DatabricksRM #1995

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading