Skip to content

Commit 680aeb7

Browse files
committed
docs(semantic-cache): fix distance threshold range in docstrings
- Update SemanticCache.__init__ docstring to specify [0-2] range instead of [0-1] - Update SemanticCache.set_threshold docstring to specify [0-2] range - Enhance distance_threshold parameter docs to clarify Redis COSINE units - Fixes inconsistency between docstrings and actual validation logic Relates to #407
1 parent caa9621 commit 680aeb7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

redisvl/extensions/cache/llm/semantic.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ def __init__(
6161
Args:
6262
name (str, optional): The name of the semantic cache search index.
6363
Defaults to "llmcache".
64-
distance_threshold (float, optional): Semantic threshold for the
65-
cache. Defaults to 0.1.
64+
distance_threshold (float, optional): Semantic distance threshold for the
65+
cache in Redis COSINE units [0-2], where lower values indicate stricter
66+
matching. Defaults to 0.1.
6667
ttl (Optional[int], optional): The time-to-live for records cached
6768
in Redis. Defaults to None.
6869
vectorizer (Optional[BaseVectorizer], optional): The vectorizer for the cache.
@@ -80,7 +81,7 @@ def __init__(
8081
Raises:
8182
TypeError: If an invalid vectorizer is provided.
8283
TypeError: If the TTL value is not an int.
83-
ValueError: If the threshold is not between 0 and 1.
84+
ValueError: If the threshold is not between 0 and 2 (Redis COSINE distance).
8485
ValueError: If existing schema does not match new schema and overwrite is False.
8586
"""
8687
# Call parent class with all shared parameters
@@ -243,7 +244,7 @@ def set_threshold(self, distance_threshold: float) -> None:
243244
the cache.
244245
245246
Raises:
246-
ValueError: If the threshold is not between 0 and 1.
247+
ValueError: If the threshold is not between 0 and 2 (Redis COSINE distance).
247248
"""
248249
if not 0 <= float(distance_threshold) <= 2:
249250
raise ValueError(

0 commit comments

Comments
 (0)