Improved logging on connection fail to redis

This commit is contained in:
Eesa Hamza
2023-04-12 23:13:34 +03:00
parent 5982f29c18
commit a850c27dd5

View File

@@ -7,6 +7,8 @@ from redis.commands.search.indexDefinition import IndexDefinition, IndexType
import numpy as np
from memory.base import MemoryProviderSingleton, get_ada_embedding
from logger import logger
from colorama import Fore, Style
SCHEMA = [
@@ -44,6 +46,18 @@ class RedisMemory(MemoryProviderSingleton):
db=0 # Cannot be changed
)
self.cfg = cfg
# Check redis connection
try:
self.redis.ping()
except redis.ConnectionError as e:
logger.typewriter_log("FAILED TO CONNECT TO REDIS", Fore.RED, Style.BRIGHT + str(e) + Style.RESET_ALL)
logger.typewriter_log("DOUBLE CHECK CONFIGURATION",
Fore.YELLOW,
"Please ensure you have setup and configured redis properly for use. " +
f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#redis-setup{Style.RESET_ALL} to ensure you've set up everything correctly.")
exit(1)
if cfg.wipe_redis_on_start:
self.redis.flushall()
try: