rdune71 commited on
Commit
dc8760b
·
1 Parent(s): 4f1a78a

Respect REDIS_DISABLE_SSL setting and fix Streamlit toast compatibility

Browse files
Files changed (2) hide show
  1. app.py +2 -3
  2. core/redis_client.py +29 -4
app.py CHANGED
@@ -101,9 +101,8 @@ with st.sidebar:
101
  if st.button("🔄 Refresh Ollama Status"):
102
  from services.ollama_monitor import check_ollama_status
103
  status = check_ollama_status()
104
- # Fix for Streamlit version - replace st.toast with compatible function
105
- status_text = f"Ollama Status: {'Running' if status['running'] else 'Unavailable'}"
106
- st.sidebar.info(status_text)
107
 
108
  # Main chat interface
109
  st.title("🧠 AI Life Coach")
 
101
  if st.button("🔄 Refresh Ollama Status"):
102
  from services.ollama_monitor import check_ollama_status
103
  status = check_ollama_status()
104
+ # Fix Streamlit toast issue - replace with compatible function
105
+ st.sidebar.info(f"Ollama Status: {'Running' if status['running'] else 'Unavailable'}")
 
106
 
107
  # Main chat interface
108
  st.title("🧠 AI Life Coach")
core/redis_client.py CHANGED
@@ -30,16 +30,42 @@ class RedisClient:
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
 
34
  if not config.redis_host or config.redis_host == "localhost":
35
  logger.info("Redis not configured, skipping connection")
36
  return None
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  try:
39
- host, port = self._parse_host_port(config.redis_host, config.redis_port)
40
  logger.info(f"Connecting to Redis Cloud at {host}:{port} with SSL")
41
-
42
- # Redis Cloud specific connection settings
43
  self._redis_client = redis.Redis(
44
  host=host,
45
  port=port,
@@ -54,7 +80,6 @@ class RedisClient:
54
  retry_on_timeout=True
55
  )
56
 
57
- # Test connection
58
  self._redis_client.ping()
59
  logger.info("Successfully connected to Redis Cloud with SSL")
60
  return
 
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" SSL Disabled: {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
+ # Parse host and port
40
+ host, port = self._parse_host_port(config.redis_host, config.redis_port)
41
+
42
+ if config.redis_disable_ssl:
43
+ # Non-SSL connection
44
+ try:
45
+ logger.info(f"Connecting to Redis at {host}:{port} without SSL")
46
+ self._redis_client = redis.Redis(
47
+ host=host,
48
+ port=port,
49
+ username=config.redis_username if config.redis_username else "default",
50
+ password=config.redis_password,
51
+ decode_responses=True,
52
+ socket_connect_timeout=10,
53
+ socket_timeout=10,
54
+ health_check_interval=30,
55
+ retry_on_timeout=True
56
+ )
57
+
58
+ self._redis_client.ping()
59
+ logger.info("Successfully connected to Redis without SSL")
60
+ return
61
+ except Exception as e:
62
+ logger.error(f"Non-SSL connection failed: {e}")
63
+ self._redis_client = None
64
+ return
65
+
66
+ # SSL connection (default for Redis Cloud)
67
  try:
 
68
  logger.info(f"Connecting to Redis Cloud at {host}:{port} with SSL")
 
 
69
  self._redis_client = redis.Redis(
70
  host=host,
71
  port=port,
 
80
  retry_on_timeout=True
81
  )
82
 
 
83
  self._redis_client.ping()
84
  logger.info("Successfully connected to Redis Cloud with SSL")
85
  return