💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Update cached_file exception handling, closes #889
davidmezzettie97237ab299b
diff --git a/src/python/txtai/models/pooling/factory.py b/src/python/txtai/models/pooling/factory.pyindex 7e399f0d..d61dabb4 100644--- a/src/python/txtai/models/pooling/factory.py+++ b/src/python/txtai/models/pooling/factory.py@@ -5,6 +5,7 @@ Factory moduleimport jsonimport os+from huggingface_hub.errors import HFValidationErrorfrom transformers.utils import cached_filefrom .base import Pooling@@ -119,7 +120,7 @@ class PoolingFactory:config = json.load(f)# Ignore this error - invalid repo or directory- except OSError:+ except (HFValidationError, OSError):passreturn configdiff --git a/src/python/txtai/pipeline/audio/texttospeech.py b/src/python/txtai/pipeline/audio/texttospeech.pyindex df1320f0..af23a388 100644--- a/src/python/txtai/pipeline/audio/texttospeech.py+++ b/src/python/txtai/pipeline/audio/texttospeech.py@@ -25,6 +25,7 @@ import yamlimport numpy as np+from huggingface_hub.errors import HFValidationErrorfrom transformers import SpeechT5Processorfrom transformers.utils import cached_file@@ -131,7 +132,7 @@ class TextToSpeech(Pipeline):try:# Check if file existsexists = cached_file(path_or_repo_id=path, filename=name) is not None- except OSError:+ except (HFValidationError, OSError):return Falsereturn existsdiff --git a/src/python/txtai/pipeline/text/entity.py b/src/python/txtai/pipeline/text/entity.pyindex 61dde68b..12ec712e 100644--- a/src/python/txtai/pipeline/text/entity.py+++ b/src/python/txtai/pipeline/text/entity.py@@ -10,6 +10,7 @@ try:except ImportError:GLINER = False+from huggingface_hub.errors import HFValidationErrorfrom transformers.utils import cached_filefrom ...models import Models@@ -88,7 +89,7 @@ class Entity(HFPipeline):return cached_file(path_or_repo_id=path, filename="gliner_config.json") is not None# Ignore this error - invalid repo or directory- except OSError:+ except (HFValidationError, OSError):passreturn Falsediff --git a/src/python/txtai/vectors/m2v.py b/src/python/txtai/vectors/m2v.pyindex f46903d0..46c2f18d 100644--- a/src/python/txtai/vectors/m2v.py+++ b/src/python/txtai/vectors/m2v.py@@ -4,6 +4,7 @@ Model2Vec moduleimport json+from huggingface_hub.errors import HFValidationErrorfrom transformers.utils import cached_file# Conditional import@@ -43,7 +44,7 @@ class Model2Vec(Vectors):return config.get("model_type") == "model2vec"# Ignore this error - invalid repo or directory- except OSError:+ except (HFValidationError, OSError):passreturn Falsediff --git a/src/python/txtai/vectors/words.py b/src/python/txtai/vectors/words.pyindex 457cc763..81e6700a 100644--- a/src/python/txtai/vectors/words.py+++ b/src/python/txtai/vectors/words.py@@ -11,6 +11,7 @@ from multiprocessing import Poolimport numpy as np+from huggingface_hub.errors import HFValidationErrorfrom transformers.utils import cached_file# Conditional import@@ -98,7 +99,7 @@ class WordVectors(Vectors):return config.get("model_type") == "staticvectors"# Ignore this error - invalid repo or directory- except OSError:+ except (HFValidationError, OSError):passreturn False