Spaces:
Sleeping
Sleeping
Add Redis fallback to NoOpCache
Browse files
app/presentation/api/v1/endpoints.py
CHANGED
|
@@ -56,7 +56,17 @@ async def get_query_use_case() -> QueryProcessingUseCase:
|
|
| 56 |
)
|
| 57 |
llm = GeminiLLM(api_key=settings.gemini_api_key, model_name=settings.gemini_model)
|
| 58 |
prompt_builder = DefaultPromptBuilder()
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
# For now, using a simple reranker (in production use cross-encoder)
|
| 62 |
from app.infrastructure.external.simple_reranker import SimpleReranker
|
|
|
|
| 56 |
)
|
| 57 |
llm = GeminiLLM(api_key=settings.gemini_api_key, model_name=settings.gemini_model)
|
| 58 |
prompt_builder = DefaultPromptBuilder()
|
| 59 |
+
|
| 60 |
+
# Use NoOpCache if Redis unavailable
|
| 61 |
+
try:
|
| 62 |
+
from app.infrastructure.cache.redis_cache import RedisCache
|
| 63 |
+
cache = RedisCache(redis_url=settings.redis_url)
|
| 64 |
+
# Test connection
|
| 65 |
+
await cache.get("test_key")
|
| 66 |
+
except Exception:
|
| 67 |
+
logger.warning("redis_unavailable", msg="Falling back to NoOpCache")
|
| 68 |
+
from app.infrastructure.cache.noop_cache import NoOpCache
|
| 69 |
+
cache = NoOpCache()
|
| 70 |
|
| 71 |
# For now, using a simple reranker (in production use cross-encoder)
|
| 72 |
from app.infrastructure.external.simple_reranker import SimpleReranker
|