Skip to content

Commit

Permalink
fix: xinference reranker return_documents (#6888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weaxs authored Aug 1, 2024
1 parent 093f902 commit cc4785f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def _invoke(self, model: str, credentials: dict,
documents=docs,
query=query,
top_n=top_n,
return_documents=True
)
except RuntimeError as e:
raise InvokeServerUnavailableError(str(e))
Expand All @@ -66,7 +67,7 @@ def _invoke(self, model: str, credentials: dict,
for idx, result in enumerate(response['results']):
# format document
index = result['index']
page_content = result['document']
page_content = result['document'] if isinstance(result['document'], str) else result['document']['text']
rerank_document = RerankDocument(
index=index,
text=page_content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get(self: Session, url: str, **kwargs):
def _check_cluster_authenticated(self):
self._cluster_authed = True

def rerank(self: RESTfulRerankModelHandle, documents: list[str], query: str, top_n: int) -> dict:
def rerank(self: RESTfulRerankModelHandle, documents: list[str], query: str, top_n: int, return_documents: bool) -> dict:
# check if self._model_uid is a valid uuid
if not re.match(r'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}', self._model_uid) and \
self._model_uid != 'rerank':
Expand Down

0 comments on commit cc4785f

Please sign in to comment.