Skip to content

Conversation

@HarleyQeen
Copy link

The method was expected to return either a List[str] or List[List[str]] depending on whether a single or multiple queries were passed.

However, the implementation returned a single concatenated string using "\n".join(...), which contradicted the type hint and docstring

This led to:

Type mismatches

Unexpected behavior when consuming reranked outputs programmatically

Fix: The return logic is now explicitly conditional based on whether the query is a single string or a list of strings:
results = self.rerank(query, documents, top_k, normalize)
if isinstance(query, str):
return [x["document"].strip() for x in results]
return [[x["document"].strip() for x in query_results] for query_results in results]

Result: Respects the documented return type

Enables reliable use in both single- and multi-query scenarios

No behavioral change for existing rerank logic — only return structure is corrected

The method was expected to return either a List[str] or List[List[str]] depending on whether a single or multiple queries were passed.

However, the implementation returned a single concatenated string using "\n".join(...), which contradicted the type hint and docstring

This led to:

Type mismatches

Unexpected behavior when consuming reranked outputs programmatically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant