refac/fix: reranking function

This commit is contained in:
Timothy Jaeryang Baek 2025-07-16 13:56:02 +04:00
parent ae716bddee
commit abe280f0a3
2 changed files with 18 additions and 10 deletions

View file

@ -2050,11 +2050,13 @@ def query_doc_handler(
),
k=form_data.k if form_data.k else request.app.state.config.TOP_K,
reranking_function=(
lambda sentences: (
request.app.state.RERANKING_FUNCTION(sentences, user=user)
if request.app.state.RERANKING_FUNCTION
else None
(
lambda sentences: request.app.state.RERANKING_FUNCTION(
sentences, user=user
)
)
if request.app.state.RERANKING_FUNCTION
else None
),
k_reranker=form_data.k_reranker
or request.app.state.config.TOP_K_RERANKER,
@ -2112,8 +2114,14 @@ def query_collection_handler(
query, prefix=prefix, user=user
),
k=form_data.k if form_data.k else request.app.state.config.TOP_K,
reranking_function=lambda sentences: request.app.state.RERANKING_FUNCTION(
sentences, user=user
reranking_function=(
(
lambda sentences: request.app.state.RERANKING_FUNCTION(
sentences, user=user
)
)
if request.app.state.RERANKING_FUNCTION
else None
),
k_reranker=form_data.k_reranker
or request.app.state.config.TOP_K_RERANKER,

View file

@ -653,13 +653,13 @@ async def chat_completion_files_handler(
),
k=request.app.state.config.TOP_K,
reranking_function=(
lambda sentences: (
request.app.state.RERANKING_FUNCTION(
(
lambda sentences: request.app.state.RERANKING_FUNCTION(
sentences, user=user
)
if request.app.state.RERANKING_FUNCTION
else None
)
if request.app.state.RERANKING_FUNCTION
else None
),
k_reranker=request.app.state.config.TOP_K_RERANKER,
r=request.app.state.config.RELEVANCE_THRESHOLD,