rdune71 commited on
Commit
3371ef4
·
1 Parent(s): 260a069

Fix Redis SSL connection issues and Hugging Face provider deprecated parameters

Browse files
core/providers/huggingface.py CHANGED
@@ -25,7 +25,7 @@ class HuggingFaceProvider(LLMProvider):
25
  if not config.hf_token:
26
  raise ValueError("HF_TOKEN not set - required for Hugging Face provider")
27
 
28
- # Fixed OpenAI client instantiation - removed deprecated proxies parameter
29
  self.client = OpenAI(
30
  base_url=config.hf_api_url,
31
  api_key=config.hf_token
 
25
  if not config.hf_token:
26
  raise ValueError("HF_TOKEN not set - required for Hugging Face provider")
27
 
28
+ # Make sure NO proxies parameter is included
29
  self.client = OpenAI(
30
  base_url=config.hf_api_url,
31
  api_key=config.hf_token
core/redis_client.py CHANGED
@@ -25,17 +25,24 @@ class RedisClient:
25
 
26
  def _connect(self):
27
  """Establish Redis connection with proper error handling"""
 
 
 
 
 
 
 
28
  if not config.redis_host or config.redis_host == "localhost":
29
  logger.info("Redis not configured, skipping connection")
30
  return None
31
-
32
  try:
33
  # Parse host and port if port is included in host
34
  host, port = self._parse_host_port(config.redis_host, config.redis_port)
35
 
36
  logger.info(f"Connecting to Redis at {host}:{port}")
37
 
38
- # Try SSL connection first (required for Redis Cloud)
39
  self._redis_client = redis.Redis(
40
  host=host,
41
  port=port,
@@ -44,20 +51,18 @@ class RedisClient:
44
  decode_responses=True,
45
  socket_connect_timeout=5,
46
  socket_timeout=5,
47
- ssl=True,
48
- ssl_cert_reqs=None, # Skip cert verification for Redis Cloud
49
  retry_on_timeout=True,
50
  health_check_interval=30
51
  )
52
 
53
  # Test connection
54
  self._redis_client.ping()
55
- logger.info("Successfully connected to Redis with SSL")
56
 
57
  except Exception as e:
58
- logger.warning(f"SSL connection failed: {e}, trying without SSL")
59
  try:
60
- # Fallback to non-SSL connection
61
  host, port = self._parse_host_port(config.redis_host, config.redis_port)
62
 
63
  self._redis_client = redis.Redis(
@@ -68,13 +73,15 @@ class RedisClient:
68
  decode_responses=True,
69
  socket_connect_timeout=5,
70
  socket_timeout=5,
 
 
71
  retry_on_timeout=True,
72
  health_check_interval=30
73
  )
74
 
75
  # Test connection
76
  self._redis_client.ping()
77
- logger.info("Successfully connected to Redis without SSL")
78
 
79
  except Exception as e2:
80
  logger.error(f"Could not connect to Redis: {e2}")
 
25
 
26
  def _connect(self):
27
  """Establish Redis connection with proper error handling"""
28
+ logger.info(f"Attempting Redis connection with:")
29
+ logger.info(f" Host: {config.redis_host}")
30
+ logger.info(f" Port: {config.redis_port}")
31
+ logger.info(f" Username: {'SET' if config.redis_username else 'NOT SET'}")
32
+ logger.info(f" Password: {'SET' if config.redis_password else 'NOT SET'}")
33
+ logger.info(f" Disable SSL: {config.redis_disable_ssl}")
34
+
35
  if not config.redis_host or config.redis_host == "localhost":
36
  logger.info("Redis not configured, skipping connection")
37
  return None
38
+
39
  try:
40
  # Parse host and port if port is included in host
41
  host, port = self._parse_host_port(config.redis_host, config.redis_port)
42
 
43
  logger.info(f"Connecting to Redis at {host}:{port}")
44
 
45
+ # Try connection WITHOUT SSL first for Redis Cloud (most common setup)
46
  self._redis_client = redis.Redis(
47
  host=host,
48
  port=port,
 
51
  decode_responses=True,
52
  socket_connect_timeout=5,
53
  socket_timeout=5,
 
 
54
  retry_on_timeout=True,
55
  health_check_interval=30
56
  )
57
 
58
  # Test connection
59
  self._redis_client.ping()
60
+ logger.info("Successfully connected to Redis without SSL")
61
 
62
  except Exception as e:
63
+ logger.warning(f"Non-SSL connection failed: {e}, trying with SSL")
64
  try:
65
+ # Fallback to SSL connection
66
  host, port = self._parse_host_port(config.redis_host, config.redis_port)
67
 
68
  self._redis_client = redis.Redis(
 
73
  decode_responses=True,
74
  socket_connect_timeout=5,
75
  socket_timeout=5,
76
+ ssl=True,
77
+ ssl_cert_reqs=None, # Skip cert verification for Redis Cloud
78
  retry_on_timeout=True,
79
  health_check_interval=30
80
  )
81
 
82
  # Test connection
83
  self._redis_client.ping()
84
+ logger.info("Successfully connected to Redis with SSL")
85
 
86
  except Exception as e2:
87
  logger.error(f"Could not connect to Redis: {e2}")
utils/config.py CHANGED
@@ -27,6 +27,7 @@ class Config:
27
  self.redis_password = os.getenv("REDIS_PASSWORD", "")
28
  self.redis_retries = int(os.getenv("REDIS_RETRIES", "3"))
29
  self.redis_retry_delay = int(os.getenv("REDIS_RETRY_DELAY", "1"))
 
30
 
31
  # Local model configuration
32
  self.local_model_name = os.getenv("LOCAL_MODEL_NAME", "mistral:latest")
 
27
  self.redis_password = os.getenv("REDIS_PASSWORD", "")
28
  self.redis_retries = int(os.getenv("REDIS_RETRIES", "3"))
29
  self.redis_retry_delay = int(os.getenv("REDIS_RETRY_DELAY", "1"))
30
+ self.redis_disable_ssl = os.getenv("REDIS_DISABLE_SSL", "false").lower() == "true"
31
 
32
  # Local model configuration
33
  self.local_model_name = os.getenv("LOCAL_MODEL_NAME", "mistral:latest")