Skip to content

Commit

Permalink
minor cosmetic update
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Nov 14, 2024
1 parent 2b7b876 commit fd1a646
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions backend/danswer/natural_language_processing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,15 @@ def _check_tokenizer_cache(
def get_tokenizer(
model_name: str | None, provider_type: EmbeddingProvider | str | None
) -> BaseTokenizer:
if provider_type is not None:
if isinstance(provider_type, str):
try:
provider_type = EmbeddingProvider(provider_type)
except ValueError:
logger.debug(
f"Invalid provider_type '{provider_type}'. Falling back to default tokenizer."
)
return _DEFAULT_TOKENIZER
return _check_tokenizer_cache(provider_type, model_name)
return _DEFAULT_TOKENIZER
if isinstance(provider_type, str):
try:
provider_type = EmbeddingProvider(provider_type)
except ValueError:
logger.debug(
f"Invalid provider_type '{provider_type}'. Falling back to default tokenizer."
)
return _DEFAULT_TOKENIZER
return _check_tokenizer_cache(provider_type, model_name)


def tokenizer_trim_content(
Expand Down

0 comments on commit fd1a646

Please sign in to comment.