Skip to content

Commit 278e770

Browse files
committed
Fixing rebase issue.
1 parent b0fbc78 commit 278e770

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

app/routes/document_routes.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -805,42 +805,3 @@ async def extract_text_from_file(
805805
)
806806
finally:
807807
await cleanup_temp_file_async(temp_file_path)
808-
809-
@router.post("/rerank")
810-
async def rerank_documents_by_query(request: Request, body: QueryMultipleDocs):
811-
try:
812-
rk = Reranker(
813-
body.config.get("model_name", "flashrank"),
814-
model_type=body.config.get("model_type"),
815-
lang=body.config.get("lang"),
816-
api_provider=body.config.get("api_provider"),
817-
api_key=body.config.get("api_key"),
818-
)
819-
820-
docs = []
821-
for i, d in enumerate(body.docs):
822-
if isinstance(d, str):
823-
docs.append(ReRankDocument(text=d, doc_id=i))
824-
else:
825-
docs.append(
826-
ReRankDocument(
827-
text=d.get("text", ""),
828-
doc_id=d.get("doc_id", i),
829-
metadata=d.get("metadata", {}) or {},
830-
)
831-
)
832-
833-
top_k = body.k
834-
835-
results = rk.rank(query=body.query, docs=docs)
836-
items = results.top_k(top_k) if top_k else results
837-
838-
return [[getattr(r.document, "text", None), r.score] for r in items]
839-
except Exception as e:
840-
logger.error(
841-
"Error in reranking documents | Query: %s | Error: %s | Traceback: %s",
842-
body.query,
843-
str(e),
844-
traceback.format_exc(),
845-
)
846-
raise HTTPException(status_code=500, detail=str(e))

0 commit comments

Comments
 (0)