1+ import sys
2+
13import pytest
24
5+ if sys .version_info .major == 3 and sys .version_info .minor < 10 :
6+ pytest .skip ("Test requires Python 3.10 or higher" , allow_module_level = True )
7+
38from redisvl .extensions .llmcache import SemanticCache
49from redisvl .extensions .router import Route , SemanticRouter
510from redisvl .extensions .router .schema import RoutingConfig
@@ -114,6 +119,7 @@ def test_routes_different_distance_thresholds_optimizer_default(
114119def test_routes_different_distance_thresholds_optimizer_precision (
115120 semantic_router , routes , redis_url , test_data_optimization
116121):
122+
117123 redis_version = semantic_router ._index .client .info ()["redis_version" ]
118124 if not compare_versions (redis_version , "7.0.0" ):
119125 pytest .skip ("Not using a late enough version of Redis" )
@@ -189,6 +195,10 @@ def test_optimize_threshold_cache_default(redis_url):
189195 distance_threshold = null_threshold ,
190196 )
191197
198+ redis_version = cache .client .info ()["redis_version" ]
199+ if not compare_versions (redis_version , "7.0.0" ):
200+ pytest .skip ("Not using a late enough version of Redis" )
201+
192202 paris_key = cache .store (prompt = "what is the capital of france?" , response = "paris" )
193203 rabat_key = cache .store (prompt = "what is the capital of morocco?" , response = "rabat" )
194204
@@ -213,6 +223,10 @@ def test_optimize_threshold_cache_precision(redis_url):
213223 distance_threshold = null_threshold ,
214224 )
215225
226+ redis_version = cache .client .info ()["redis_version" ]
227+ if not compare_versions (redis_version , "7.0.0" ):
228+ pytest .skip ("Not using a late enough version of Redis" )
229+
216230 paris_key = cache .store (prompt = "what is the capital of france?" , response = "paris" )
217231 rabat_key = cache .store (prompt = "what is the capital of morocco?" , response = "rabat" )
218232
@@ -237,6 +251,10 @@ def test_optimize_threshold_cache_recall(redis_url):
237251 distance_threshold = null_threshold ,
238252 )
239253
254+ redis_version = cache .client .info ()["redis_version" ]
255+ if not compare_versions (redis_version , "7.0.0" ):
256+ pytest .skip ("Not using a late enough version of Redis" )
257+
240258 paris_key = cache .store (prompt = "what is the capital of france?" , response = "paris" )
241259 rabat_key = cache .store (prompt = "what is the capital of morocco?" , response = "rabat" )
242260
0 commit comments