mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-20 00:11:50 +00:00
fix: raise RuntimeError with clear message when RedisSemanticCache vectorizer init fails
This commit is contained in:
parent
850fe595ac
commit
8ed7aa52ae
1 changed files with 15 additions and 2 deletions
|
|
@ -106,8 +106,21 @@ class RedisSemanticCache(BaseCache):
|
|||
|
||||
print_verbose(f"Redis semantic-cache redis_url: {redis_url}")
|
||||
|
||||
# Initialize the Redis vectorizer and cache
|
||||
cache_vectorizer = CustomTextVectorizer(self._get_embedding)
|
||||
# Initialize the Redis vectorizer and cache.
|
||||
# CustomTextVectorizer calls the embedding function during __init__ to
|
||||
# validate it; if the embedding endpoint is unavailable (e.g. 429 rate
|
||||
# limit, spend cap, network error), it raises ValueError. We surface a
|
||||
# clear RuntimeError so the caller can decide whether to degrade
|
||||
# gracefully or abort.
|
||||
try:
|
||||
cache_vectorizer = CustomTextVectorizer(self._get_embedding)
|
||||
except Exception as e:
|
||||
raise RuntimeError(
|
||||
f"RedisSemanticCache: embedding model validation failed during "
|
||||
f"initialisation ({type(e).__name__}: {e}). "
|
||||
"Check that the configured embedding model is reachable and "
|
||||
"that API credentials are valid."
|
||||
) from e
|
||||
|
||||
self.llmcache = SemanticCache(
|
||||
name=index_name,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue