alaselababatunde commited on
Commit
8806dd4
·
1 Parent(s): be6e828

fix: refine scroll logic, mobile layout, and AI formatting tone

Browse files
Files changed (2) hide show
  1. frontend/src/App.tsx +22 -14
  2. main.py +13 -11
frontend/src/App.tsx CHANGED
@@ -31,10 +31,17 @@ const App: React.FC = () => {
31
  setVerse(VERSES[dayOfYear % VERSES.length]);
32
  }, []);
33
 
34
- // Automatic scroll removed as per user request for manual control
35
- // useEffect(() => {
36
- // chatEndRef.current?.scrollIntoView({ behavior: 'smooth' });
37
- // }, [messages]);
 
 
 
 
 
 
 
38
 
39
  const handleSend = async () => {
40
  if (!input.trim() || isLoading) return;
@@ -70,27 +77,27 @@ const App: React.FC = () => {
70
  };
71
 
72
  return (
73
- <div className="h-screen bg-[#002B22] flex flex-col items-center justify-center p-0 md:p-4 font-outfit text-white overflow-hidden relative">
74
  {/* Dynamic Background Elements */}
75
  <div className="absolute top-[-20%] left-[-10%] w-[60%] h-[60%] bg-[#007055]/20 rounded-full blur-[150px] animate-pulse pointer-events-none"></div>
76
  <div className="absolute bottom-[-20%] right-[-10%] w-[60%] h-[60%] bg-[#FDFBD4]/5 rounded-full blur-[150px] pointer-events-none"></div>
77
 
78
- <div className="w-full max-w-5xl h-screen md:h-[92vh] flex flex-col md:flex-row relative z-10 bg-black/20 backdrop-blur-2xl md:rounded-[2.5rem] overflow-hidden border border-white/5 shadow-[0_32px_64px_-12px_rgba(0,0,0,0.5)]">
79
 
80
  {/* Modern Sidebar-style Header (Desktop) / Top Header (Mobile) */}
81
- <aside className="w-full md:w-80 bg-[#00362B]/80 p-6 md:p-8 flex flex-col items-center md:items-start space-y-6 md:space-y-8 border-b md:border-b-0 md:border-r border-white/5 shrink-0">
82
- <div className="relative group">
83
- <div className="absolute -inset-1 bg-gradient-to-tr from-[#FDFBD4] to-[#007055] rounded-3xl blur opacity-25 group-hover:opacity-50 transition duration-1000 group-hover:duration-200"></div>
84
- <div className="relative w-20 h-20 md:w-32 md:h-32 rounded-[2rem] overflow-hidden border border-white/10 shadow-2xl transform transition-transform group-hover:scale-105 duration-500">
85
  <img src="/assets/logo.jpg" alt="CLCC Logo" className="w-full h-full object-cover" />
86
  </div>
87
  </div>
88
- <div className="text-center md:text-left space-y-2">
89
- <h1 className="text-3xl md:text-4xl font-black tracking-tighter bg-clip-text text-transparent bg-gradient-to-br from-white via-[#FDFBD4] to-[#007055]">
90
  Theo AI
91
  </h1>
92
- <div className="inline-flex items-center px-3 py-1 bg-[#FDFBD4]/10 rounded-full border border-[#FDFBD4]/20">
93
- <span className="text-[9px] md:text-[10px] font-bold text-[#FDFBD4] uppercase tracking-widest whitespace-nowrap">
94
  CLCC - TECHDISCIPLES
95
  </span>
96
  </div>
@@ -148,6 +155,7 @@ const App: React.FC = () => {
148
  }`}>
149
  <div className={`markdown-content prose prose-invert prose-sm max-w-none
150
  prose-p:leading-relaxed prose-headings:text-[#FDFBD4] prose-strong:text-[#FDFBD4]
 
151
  ${msg.role === 'assistant' ? 'selection:bg-[#FDFBD4]/30' : 'selection:bg-white/20'}
152
  `}>
153
  <ReactMarkdown>{msg.content}</ReactMarkdown>
 
31
  setVerse(VERSES[dayOfYear % VERSES.length]);
32
  }, []);
33
 
34
+ const isFirstRender = useRef(true);
35
+
36
+ useEffect(() => {
37
+ if (isFirstRender.current) {
38
+ isFirstRender.current = false;
39
+ return;
40
+ }
41
+ if (messages.length > 0) {
42
+ chatEndRef.current?.scrollIntoView({ behavior: 'smooth' });
43
+ }
44
+ }, [messages]);
45
 
46
  const handleSend = async () => {
47
  if (!input.trim() || isLoading) return;
 
77
  };
78
 
79
  return (
80
+ <div className="h-[100dvh] bg-[#002B22] flex flex-col items-center justify-center p-0 md:p-4 font-outfit text-white overflow-hidden relative">
81
  {/* Dynamic Background Elements */}
82
  <div className="absolute top-[-20%] left-[-10%] w-[60%] h-[60%] bg-[#007055]/20 rounded-full blur-[150px] animate-pulse pointer-events-none"></div>
83
  <div className="absolute bottom-[-20%] right-[-10%] w-[60%] h-[60%] bg-[#FDFBD4]/5 rounded-full blur-[150px] pointer-events-none"></div>
84
 
85
+ <div className="w-full max-w-5xl h-full md:h-[92vh] flex flex-col md:flex-row relative z-10 bg-black/20 backdrop-blur-2xl md:rounded-[2.5rem] overflow-hidden border border-white/5 shadow-[0_32px_64px_-12px_rgba(0,0,0,0.5)]">
86
 
87
  {/* Modern Sidebar-style Header (Desktop) / Top Header (Mobile) */}
88
+ <aside className="w-full md:w-80 bg-[#00362B]/80 p-4 md:p-8 flex flex-row md:flex-col items-center md:items-start space-x-4 md:space-x-0 md:space-y-8 border-b md:border-b-0 md:border-r border-white/5 shrink-0">
89
+ <div className="relative group shrink-0">
90
+ <div className="absolute -inset-1 bg-gradient-to-tr from-[#FDFBD4] to-[#007055] rounded-2xl md:rounded-3xl blur opacity-25 group-hover:opacity-50 transition duration-1000 group-hover:duration-200"></div>
91
+ <div className="relative w-12 h-12 md:w-32 md:h-32 rounded-xl md:rounded-[2rem] overflow-hidden border border-white/10 shadow-2xl transform transition-transform group-hover:scale-105 duration-500">
92
  <img src="/assets/logo.jpg" alt="CLCC Logo" className="w-full h-full object-cover" />
93
  </div>
94
  </div>
95
+ <div className="flex-1 md:flex-none text-left space-y-1 md:space-y-2">
96
+ <h1 className="text-xl md:text-4xl font-black tracking-tighter bg-clip-text text-transparent bg-gradient-to-br from-white via-[#FDFBD4] to-[#007055]">
97
  Theo AI
98
  </h1>
99
+ <div className="inline-flex items-center px-2 py-0.5 md:px-3 md:py-1 bg-[#FDFBD4]/10 rounded-full border border-[#FDFBD4]/20">
100
+ <span className="text-[8px] md:text-[10px] font-bold text-[#FDFBD4] uppercase tracking-widest whitespace-nowrap">
101
  CLCC - TECHDISCIPLES
102
  </span>
103
  </div>
 
155
  }`}>
156
  <div className={`markdown-content prose prose-invert prose-sm max-w-none
157
  prose-p:leading-relaxed prose-headings:text-[#FDFBD4] prose-strong:text-[#FDFBD4]
158
+ prose-li:text-white/90 prose-ul:my-2
159
  ${msg.role === 'assistant' ? 'selection:bg-[#FDFBD4]/30' : 'selection:bg-white/20'}
160
  `}>
161
  <ReactMarkdown>{msg.content}</ReactMarkdown>
main.py CHANGED
@@ -65,21 +65,23 @@ search = DuckDuckGoSearchRun()
65
  # =====================================================
66
  # PROMPT TEMPLATE
67
  # =====================================================
68
- SYSTEM_PROMPT = """You are Theo — a warm, spiritual, and insightful Christian AI assistant created by TechDisciples CLCC.
69
- Your purpose is to offer Biblical guidance, Christian reflections, and empathetic counsel.
 
 
 
 
70
 
71
  CORE GUIDELINES:
72
- 1. BIBLICAL ONLY: Always relate your responses to scripture or Christian principles. For any personal or sensitive issues (including distress or suicidal thoughts), offer comfort and hope using the Holy Bible ONLY.
73
- 2. NIGERIAN PERSPECTIVE: Speak with a Nigerian heartbeat, using simple, clear, and relatable English that is easy for everyone to understand.
74
- 3. EMPATHY & WISDOM: Be compassionate, non-judgmental, and wise like a trusted pastor or Christian counsellor.
75
- 4. FORMATTING: Use clean Markdown (bolding, lists, tables) to make your replies easy to read.
76
- 5. UNKNOWN TOPICS: If you encounter a question you cannot answer with your spiritual knowledge or if it's a factual query outside your training, you MUST conduct a web search to provide accurate information, while still maintaining your Christian tone.
77
 
78
- AI Name: Theo
79
- Provider: TechDisciples CLCC
80
- Logo: [CLCC logo](https://raw.githubusercontent.com/Alasela/Theo/main/assests/logo.png) (Internal reference for link)
81
 
82
- Remember: Your goal is to lead people to the truth of God's word with love and clarity."""
83
 
84
  # =====================================================
85
  # MEMORY
 
65
  # =====================================================
66
  # PROMPT TEMPLATE
67
  # =====================================================
68
+ SYSTEM_PROMPT = """You are Theo — a warm, friendly, and deeply insightful Christian companion created by TechDisciples CLCC.
69
+
70
+ TONE & STYLE:
71
+ 1. CHATTY & WARM: Speak like a loving friend or a caring elder. Use a conversational, "chatty" tone that feels personal and welcoming.
72
+ 2. PARAGRAPHS: NEVER send a single wall of text. Break your thoughts into 2-4 short, readable paragraphs. Each point should have its own breathing space.
73
+ 3. NIGERIAN HEARTBEAT: Use simple, relatable English with a gentle Nigerian inflection. Be clear and accessible to everyone.
74
 
75
  CORE GUIDELINES:
76
+ 1. BIBLICAL FOCUS: Root your wisdom and encouragement in the Holy Bible. Use scripture to offer hope, especially for those in distress.
77
+ 2. FORMATTING: Use Markdown (bolding for emphasis, short lists if needed) to keep your replies professional yet approachable.
78
+ 3. UNKNOWN TOPICS: If you lack specific knowledge, use your web search tool to find facts, then wrap that information in your warm Christian perspective.
 
 
79
 
80
+ Identity: Theo
81
+ Creators: TechDisciples CLCC
82
+ Logo: [CLCC logo](https://raw.githubusercontent.com/Alasela/Theo/main/assests/logo.png)
83
 
84
+ Remember: Be a beacon of God's love. Keep your messages structured with clear paragraphs so they are easy to read in a chat window."""
85
 
86
  # =====================================================
87
  # MEMORY