diff --git a/backend/danswer/db/search_settings.py b/backend/danswer/db/search_settings.py index d34ef22b7ca..23729841b28 100644 --- a/backend/danswer/db/search_settings.py +++ b/backend/danswer/db/search_settings.py @@ -31,44 +31,11 @@ logger = setup_logger() -def create_or_fetch_search_settings( +def create_search_settings( search_settings: SavedSearchSettings, db_session: Session, status: IndexModelStatus = IndexModelStatus.FUTURE, ) -> SearchSettings: - # Check if a SearchSettings instance with the same model_name and provider_type already exists - existing_settings = ( - db_session.query(SearchSettings) - .filter( - SearchSettings.model_name == search_settings.model_name, - SearchSettings.provider_type == search_settings.provider_type, - ) - .first() - ) - - if existing_settings: - # Update all values of the existing settings manually - existing_settings.model_dim = search_settings.model_dim - existing_settings.normalize = search_settings.normalize - existing_settings.query_prefix = search_settings.query_prefix - existing_settings.passage_prefix = search_settings.passage_prefix - existing_settings.status = status - existing_settings.index_name = search_settings.index_name - existing_settings.multipass_indexing = search_settings.multipass_indexing - existing_settings.multilingual_expansion = ( - search_settings.multilingual_expansion - ) - existing_settings.disable_rerank_for_streaming = ( - search_settings.disable_rerank_for_streaming - ) - existing_settings.rerank_model_name = search_settings.rerank_model_name - existing_settings.rerank_provider_type = search_settings.rerank_provider_type - existing_settings.rerank_api_key = search_settings.rerank_api_key - existing_settings.num_rerank = search_settings.num_rerank - - db_session.commit() - return existing_settings - embedding_model = SearchSettings( model_name=search_settings.model_name, model_dim=search_settings.model_dim, diff --git a/backend/danswer/server/manage/search_settings.py b/backend/danswer/server/manage/search_settings.py index b5152fb0cc7..c8433467f6c 100644 --- a/backend/danswer/server/manage/search_settings.py +++ b/backend/danswer/server/manage/search_settings.py @@ -13,7 +13,7 @@ from danswer.db.index_attempt import expire_index_attempts from danswer.db.models import IndexModelStatus from danswer.db.models import User -from danswer.db.search_settings import create_or_fetch_search_settings +from danswer.db.search_settings import create_search_settings from danswer.db.search_settings import delete_search_settings from danswer.db.search_settings import get_current_search_settings from danswer.db.search_settings import get_embedding_provider_from_provider_type @@ -90,7 +90,7 @@ def set_new_search_settings( db_session=db_session, ) - new_search_settings = create_or_fetch_search_settings( + new_search_settings = create_search_settings( search_settings=new_search_settings_request, db_session=db_session )