Only create model directory if the optional field is set in SearchConfig

This commit is contained in:
Debanjum Singh Solanky 2023-01-06 16:57:59 -03:00
parent 2fe37a090f
commit 6a30a13326

View file

@ -27,11 +27,12 @@ def initialize_model(search_config: TextSearchConfig):
# Number of entries we want to retrieve with the bi-encoder
top_k = 15
# Convert model directory to absolute path
search_config.model_directory = resolve_absolute_path(search_config.model_directory)
# Create model directory if it doesn't exist
search_config.model_directory.parent.mkdir(parents=True, exist_ok=True)
# If model directory is configured
if search_config.model_directory:
# Convert model directory to absolute path
search_config.model_directory = resolve_absolute_path(search_config.model_directory)
# Create model directory if it doesn't exist
search_config.model_directory.parent.mkdir(parents=True, exist_ok=True)
# The bi-encoder encodes all entries to use for semantic search
bi_encoder = load_model(