jonathanjordan21 commited on
Commit
bb2a1eb
1 Parent(s): b4970eb

Update apis/chat_api.py

Browse files
Files changed (1) hide show
  1. apis/chat_api.py +8 -4
apis/chat_api.py CHANGED
@@ -384,17 +384,21 @@ class ChatAPIApp:
384
  class RerankRequest(BaseModel):
385
  model: str
386
  input: str
387
- document: list
388
- top_k: int
389
  return_documents: bool
 
390
 
 
 
 
391
  def get_rerank(self, request: RerankRequest, api_key: str = Depends(extract_api_key)):
392
- return self.rerank[request.model].rank(
393
  request.input,
394
- request.document,
395
  top_k=request.top_k,
396
  return_documents=request.return_documents
397
  )
 
398
 
399
 
400
  def get_readme(self):
 
384
  class RerankRequest(BaseModel):
385
  model: str
386
  input: str
387
+ documents: list
 
388
  return_documents: bool
389
+ top_k: Optional[int]=None
390
 
391
+ def _score_to_list(self, x):
392
+ x['score'] = x['score'].tolist()
393
+ return x
394
  def get_rerank(self, request: RerankRequest, api_key: str = Depends(extract_api_key)):
395
+ ranks = self.rerank[request.model].rank(
396
  request.input,
397
+ request.documents,
398
  top_k=request.top_k,
399
  return_documents=request.return_documents
400
  )
401
+ return [self._score_to_list(x) for x in ranks]
402
 
403
 
404
  def get_readme(self):