refac: better reranking model error handling

This commit is contained in:
Timothy J. Baek 2024-09-14 20:58:42 +01:00
parent 2f9f568dd9
commit 869063c743

View File

@ -195,11 +195,16 @@ def update_reranking_model(
if reranking_model: if reranking_model:
import sentence_transformers import sentence_transformers
app.state.sentence_transformer_rf = sentence_transformers.CrossEncoder( try:
get_model_path(reranking_model, update_model), app.state.sentence_transformer_rf = sentence_transformers.CrossEncoder(
device=DEVICE_TYPE, get_model_path(reranking_model, update_model),
trust_remote_code=RAG_RERANKING_MODEL_TRUST_REMOTE_CODE, device=DEVICE_TYPE,
) trust_remote_code=RAG_RERANKING_MODEL_TRUST_REMOTE_CODE,
)
except:
log.error("CrossEncoder error")
app.state.sentence_transformer_rf = None
app.state.config.ENABLE_RAG_HYBRID_SEARCH = False
else: else:
app.state.sentence_transformer_rf = None app.state.sentence_transformer_rf = None