Upload app.py
Browse files
app.py
CHANGED
|
@@ -36,7 +36,7 @@ st.set_page_config(
|
|
| 36 |
# โโ CSS โ ChatGPT-style, compact font, clean dark theme โโโโโโโโโโโโโ
|
| 37 |
st.markdown("""
|
| 38 |
<style>
|
| 39 |
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
|
| 40 |
|
| 41 |
/* โโ Base โโ */
|
| 42 |
html, body, [class*="css"] {
|
|
@@ -54,36 +54,69 @@ html, body, [class*="css"] {
|
|
| 54 |
/* โโ Header โโ */
|
| 55 |
.saad-header {
|
| 56 |
text-align: center;
|
| 57 |
-
padding: 1.
|
| 58 |
margin-bottom: 0.5rem;
|
| 59 |
}
|
| 60 |
.saad-header h1 {
|
| 61 |
-
font-size:
|
| 62 |
-
font-weight:
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
margin: 0;
|
| 65 |
-
letter-spacing:
|
| 66 |
}
|
| 67 |
.saad-header p {
|
| 68 |
-
font-size: 0.
|
| 69 |
-
color: #
|
| 70 |
-
margin: 0.
|
|
|
|
| 71 |
}
|
| 72 |
.badge-row {
|
| 73 |
display: flex;
|
| 74 |
gap: 0.4rem;
|
| 75 |
justify-content: center;
|
| 76 |
flex-wrap: wrap;
|
| 77 |
-
margin-top: 0.
|
| 78 |
}
|
| 79 |
.badge {
|
| 80 |
-
background: #
|
| 81 |
-
border: 1px solid #
|
| 82 |
-
color: #
|
| 83 |
-
padding:
|
| 84 |
border-radius: 20px;
|
| 85 |
font-size: 0.68rem;
|
| 86 |
font-family: 'JetBrains Mono', monospace;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
/* โโ Chat messages โ override Streamlit defaults โโ */
|
|
@@ -101,7 +134,7 @@ html, body, [class*="css"] {
|
|
| 101 |
}
|
| 102 |
[data-testid="stChatMessage"]:has([data-testid="chatAvatarIcon-user"])
|
| 103 |
[data-testid="stChatMessageContent"] {
|
| 104 |
-
background: #1e3a5f !important;
|
| 105 |
border: 1px solid #2a4a7f !important;
|
| 106 |
border-radius: 18px 4px 18px 18px !important;
|
| 107 |
padding: 0.6rem 0.9rem !important;
|
|
@@ -113,8 +146,8 @@ html, body, [class*="css"] {
|
|
| 113 |
/* Assistant message */
|
| 114 |
[data-testid="stChatMessage"]:has([data-testid="chatAvatarIcon-assistant"])
|
| 115 |
[data-testid="stChatMessageContent"] {
|
| 116 |
-
background: #
|
| 117 |
-
border: 1px solid #
|
| 118 |
border-radius: 4px 18px 18px 18px !important;
|
| 119 |
padding: 0.7rem 1rem !important;
|
| 120 |
font-size: 0.88rem !important;
|
|
@@ -124,11 +157,11 @@ html, body, [class*="css"] {
|
|
| 124 |
|
| 125 |
/* Math display blocks */
|
| 126 |
.katex-display {
|
| 127 |
-
background: #
|
| 128 |
border-left: 3px solid #3b82f6 !important;
|
| 129 |
-
border-radius: 0
|
| 130 |
-
padding: 0.
|
| 131 |
-
margin: 0.
|
| 132 |
overflow-x: auto !important;
|
| 133 |
}
|
| 134 |
.katex { font-size: 1em !important; }
|
|
@@ -142,9 +175,9 @@ html, body, [class*="css"] {
|
|
| 142 |
|
| 143 |
/* โโ Input box โโ */
|
| 144 |
[data-testid="stChatInput"] {
|
| 145 |
-
background: #
|
| 146 |
-
border: 1px solid #
|
| 147 |
-
border-radius:
|
| 148 |
}
|
| 149 |
[data-testid="stChatInput"] textarea {
|
| 150 |
font-size: 0.88rem !important;
|
|
@@ -154,18 +187,53 @@ html, body, [class*="css"] {
|
|
| 154 |
|
| 155 |
/* โโ Sidebar โโ */
|
| 156 |
[data-testid="stSidebar"] {
|
| 157 |
-
background: #
|
| 158 |
-
border-right: 1px solid #
|
| 159 |
}
|
| 160 |
[data-testid="stSidebar"] * {
|
| 161 |
font-size: 0.82rem !important;
|
| 162 |
}
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
/* โโ Buttons โโ */
|
| 165 |
.stButton > button {
|
| 166 |
-
background: #
|
| 167 |
-
border: 1px solid #
|
| 168 |
-
color: #
|
| 169 |
border-radius: 8px !important;
|
| 170 |
font-size: 0.78rem !important;
|
| 171 |
padding: 0.3rem 0.8rem !important;
|
|
@@ -176,14 +244,14 @@ html, body, [class*="css"] {
|
|
| 176 |
.stButton > button:hover {
|
| 177 |
border-color: #3b82f6 !important;
|
| 178 |
color: #ececec !important;
|
| 179 |
-
background: #
|
| 180 |
}
|
| 181 |
|
| 182 |
-
/* โโ Copy button
|
| 183 |
[data-testid="stChatMessage"] .stButton > button {
|
| 184 |
background: transparent !important;
|
| 185 |
-
border: 1px solid #
|
| 186 |
-
color: #
|
| 187 |
border-radius: 6px !important;
|
| 188 |
font-size: 0.75rem !important;
|
| 189 |
padding: 2px 6px !important;
|
|
@@ -195,23 +263,34 @@ html, body, [class*="css"] {
|
|
| 195 |
[data-testid="stChatMessage"] .stButton > button:hover {
|
| 196 |
border-color: #3b82f6 !important;
|
| 197 |
color: #ececec !important;
|
| 198 |
-
background: #
|
| 199 |
}
|
| 200 |
|
| 201 |
-
/* โโ Spinner โโ */
|
| 202 |
.stSpinner > div { border-top-color: #3b82f6 !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
/* โโ Divider โโ */
|
| 205 |
-
hr { border-color: #
|
| 206 |
|
| 207 |
/* โโ Selectbox โโ */
|
| 208 |
.stSelectbox > div > div {
|
| 209 |
-
background: #
|
| 210 |
-
border-color: #
|
| 211 |
color: #ececec !important;
|
| 212 |
border-radius: 8px !important;
|
| 213 |
font-size: 0.82rem !important;
|
| 214 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
</style>
|
| 216 |
""", unsafe_allow_html=True)
|
| 217 |
|
|
@@ -1747,23 +1826,17 @@ def ask_ai(problem: str, sympy_info: dict, history: list) -> str:
|
|
| 1747 |
" โ Never skip this structure. Never merge steps. Never jump to answer without showing work.\n"
|
| 1748 |
" โ If user says plot/draw/graph/sketch/visualize: a real graph renders automatically.\n"
|
| 1749 |
" Do NOT draw ASCII art. Do NOT say you cannot draw.\n"
|
| 1750 |
-
" Give this response โ then graph renders below automatically:\n"
|
| 1751 |
" ๐ **Function:** state f(x) clearly in LaTeX\n"
|
| 1752 |
" ๐ **Key Features:**\n"
|
| 1753 |
" - Domain and range\n"
|
| 1754 |
-
" - x-intercepts: solve f(x)=0
|
| 1755 |
" - y-intercept: f(0)\n"
|
| 1756 |
" - Turning points / vertex if any\n"
|
| 1757 |
" - Behavior as $x \\to \\pm\\infty$\n"
|
| 1758 |
-
"
|
| 1759 |
-
"
|
| 1760 |
-
|
| 1761 |
-
" - Step 3: Mark y-intercept on y-axis\n"
|
| 1762 |
-
" - Step 4: Calculate and plot 3-4 extra points showing the shape\n"
|
| 1763 |
-
" - Step 5: Connect all points smoothly with the correct curve shape\n"
|
| 1764 |
-
" - Step 6: Add arrows at ends if function extends to infinity\n"
|
| 1765 |
-
" โ Give EXACT coordinates for every point. Student must be able to draw without a calculator.\n"
|
| 1766 |
-
" ๐ **Graph** is shown below for verification.\n\n"
|
| 1767 |
"RULE 2 โ LATEX (zero exceptions):\n"
|
| 1768 |
" - Inline math (inside a sentence): $expression$\n"
|
| 1769 |
" - Display math (standalone line, centered): $$expression$$\n"
|
|
@@ -2071,14 +2144,21 @@ with st.sidebar:
|
|
| 2071 |
st.divider()
|
| 2072 |
|
| 2073 |
st.markdown("**๐ฏ Topics**")
|
| 2074 |
-
|
| 2075 |
-
|
| 2076 |
-
|
| 2077 |
-
|
| 2078 |
-
|
| 2079 |
-
|
| 2080 |
-
|
| 2081 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2082 |
|
| 2083 |
st.divider()
|
| 2084 |
st.markdown("**โก Example Problems**")
|
|
@@ -2106,9 +2186,14 @@ with st.sidebar:
|
|
| 2106 |
|
| 2107 |
st.divider()
|
| 2108 |
st.markdown("**๐ง Engine**")
|
| 2109 |
-
st.
|
| 2110 |
-
|
| 2111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2112 |
|
| 2113 |
st.divider()
|
| 2114 |
if st.button("๐๏ธ Clear Chat", use_container_width=True):
|
|
@@ -2125,12 +2210,13 @@ with st.sidebar:
|
|
| 2125 |
st.markdown("""
|
| 2126 |
<div class="saad-header">
|
| 2127 |
<h1>๐ Saad.AI</h1>
|
| 2128 |
-
<p>BSc Mathematics ยท Step-by-Step Solver</p>
|
| 2129 |
<div class="badge-row">
|
| 2130 |
-
<span class="badge">Groq Free</span>
|
| 2131 |
-
<span class="badge">SymPy Verified</span>
|
| 2132 |
-
<span class="badge">Step-by-Step</span>
|
| 2133 |
-
<span class="badge">LaTeX Rendered</span>
|
|
|
|
| 2134 |
</div>
|
| 2135 |
</div>
|
| 2136 |
""", unsafe_allow_html=True)
|
|
@@ -2138,13 +2224,41 @@ st.markdown("""
|
|
| 2138 |
# Welcome message if no chat
|
| 2139 |
if not st.session_state.messages:
|
| 2140 |
st.markdown("""
|
| 2141 |
-
<div style="text-align:center; padding:
|
| 2142 |
-
<div style="font-size:
|
| 2143 |
-
|
| 2144 |
-
|
| 2145 |
-
|
| 2146 |
-
|
| 2147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2148 |
</div>
|
| 2149 |
</div>
|
| 2150 |
""", unsafe_allow_html=True)
|
|
@@ -2194,7 +2308,16 @@ if problem and problem != st.session_state.last_submitted:
|
|
| 2194 |
# Show AI response with streaming
|
| 2195 |
with st.chat_message("assistant", avatar="๐"):
|
| 2196 |
# Step 1: SymPy computation (instant)
|
| 2197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2198 |
sympy_result = run_sympy(problem)
|
| 2199 |
|
| 2200 |
# Step 2: Stream AI response word by word
|
|
|
|
| 36 |
# โโ CSS โ ChatGPT-style, compact font, clean dark theme โโโโโโโโโโโโโ
|
| 37 |
st.markdown("""
|
| 38 |
<style>
|
| 39 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
|
| 40 |
|
| 41 |
/* โโ Base โโ */
|
| 42 |
html, body, [class*="css"] {
|
|
|
|
| 54 |
/* โโ Header โโ */
|
| 55 |
.saad-header {
|
| 56 |
text-align: center;
|
| 57 |
+
padding: 1.4rem 0 0.6rem 0;
|
| 58 |
margin-bottom: 0.5rem;
|
| 59 |
}
|
| 60 |
.saad-header h1 {
|
| 61 |
+
font-size: 2rem !important;
|
| 62 |
+
font-weight: 700;
|
| 63 |
+
background: linear-gradient(135deg, #3b82f6 0%, #a78bfa 50%, #60a5fa 100%);
|
| 64 |
+
-webkit-background-clip: text;
|
| 65 |
+
-webkit-text-fill-color: transparent;
|
| 66 |
+
background-clip: text;
|
| 67 |
margin: 0;
|
| 68 |
+
letter-spacing: 1px;
|
| 69 |
}
|
| 70 |
.saad-header p {
|
| 71 |
+
font-size: 0.82rem;
|
| 72 |
+
color: #555;
|
| 73 |
+
margin: 0.3rem 0 0 0;
|
| 74 |
+
letter-spacing: 0.3px;
|
| 75 |
}
|
| 76 |
.badge-row {
|
| 77 |
display: flex;
|
| 78 |
gap: 0.4rem;
|
| 79 |
justify-content: center;
|
| 80 |
flex-wrap: wrap;
|
| 81 |
+
margin-top: 0.7rem;
|
| 82 |
}
|
| 83 |
.badge {
|
| 84 |
+
background: linear-gradient(135deg, #1a1a2e, #16213e);
|
| 85 |
+
border: 1px solid #2a3a5e;
|
| 86 |
+
color: #60a5fa;
|
| 87 |
+
padding: 3px 10px;
|
| 88 |
border-radius: 20px;
|
| 89 |
font-size: 0.68rem;
|
| 90 |
font-family: 'JetBrains Mono', monospace;
|
| 91 |
+
letter-spacing: 0.3px;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/* โโ Welcome screen cards โโ */
|
| 95 |
+
.subject-grid {
|
| 96 |
+
display: grid;
|
| 97 |
+
grid-template-columns: repeat(3, 1fr);
|
| 98 |
+
gap: 0.5rem;
|
| 99 |
+
margin: 1rem 0;
|
| 100 |
+
}
|
| 101 |
+
.subject-card {
|
| 102 |
+
background: #111827;
|
| 103 |
+
border: 1px solid #1f2937;
|
| 104 |
+
border-radius: 10px;
|
| 105 |
+
padding: 0.6rem 0.5rem;
|
| 106 |
+
text-align: center;
|
| 107 |
+
font-size: 0.75rem;
|
| 108 |
+
color: #9ca3af;
|
| 109 |
+
transition: all 0.2s;
|
| 110 |
+
}
|
| 111 |
+
.subject-card:hover {
|
| 112 |
+
border-color: #3b82f6;
|
| 113 |
+
color: #60a5fa;
|
| 114 |
+
background: #0f172a;
|
| 115 |
+
}
|
| 116 |
+
.subject-card .icon {
|
| 117 |
+
font-size: 1.3rem;
|
| 118 |
+
display: block;
|
| 119 |
+
margin-bottom: 0.2rem;
|
| 120 |
}
|
| 121 |
|
| 122 |
/* โโ Chat messages โ override Streamlit defaults โโ */
|
|
|
|
| 134 |
}
|
| 135 |
[data-testid="stChatMessage"]:has([data-testid="chatAvatarIcon-user"])
|
| 136 |
[data-testid="stChatMessageContent"] {
|
| 137 |
+
background: linear-gradient(135deg, #1e3a5f, #1a2f4a) !important;
|
| 138 |
border: 1px solid #2a4a7f !important;
|
| 139 |
border-radius: 18px 4px 18px 18px !important;
|
| 140 |
padding: 0.6rem 0.9rem !important;
|
|
|
|
| 146 |
/* Assistant message */
|
| 147 |
[data-testid="stChatMessage"]:has([data-testid="chatAvatarIcon-assistant"])
|
| 148 |
[data-testid="stChatMessageContent"] {
|
| 149 |
+
background: #111827 !important;
|
| 150 |
+
border: 1px solid #1f2937 !important;
|
| 151 |
border-radius: 4px 18px 18px 18px !important;
|
| 152 |
padding: 0.7rem 1rem !important;
|
| 153 |
font-size: 0.88rem !important;
|
|
|
|
| 157 |
|
| 158 |
/* Math display blocks */
|
| 159 |
.katex-display {
|
| 160 |
+
background: #0f172a !important;
|
| 161 |
border-left: 3px solid #3b82f6 !important;
|
| 162 |
+
border-radius: 0 8px 8px 0 !important;
|
| 163 |
+
padding: 0.6rem 1rem !important;
|
| 164 |
+
margin: 0.5rem 0 !important;
|
| 165 |
overflow-x: auto !important;
|
| 166 |
}
|
| 167 |
.katex { font-size: 1em !important; }
|
|
|
|
| 175 |
|
| 176 |
/* โโ Input box โโ */
|
| 177 |
[data-testid="stChatInput"] {
|
| 178 |
+
background: #111827 !important;
|
| 179 |
+
border: 1px solid #1f2937 !important;
|
| 180 |
+
border-radius: 14px !important;
|
| 181 |
}
|
| 182 |
[data-testid="stChatInput"] textarea {
|
| 183 |
font-size: 0.88rem !important;
|
|
|
|
| 187 |
|
| 188 |
/* โโ Sidebar โโ */
|
| 189 |
[data-testid="stSidebar"] {
|
| 190 |
+
background: linear-gradient(180deg, #080810 0%, #0a0a14 100%) !important;
|
| 191 |
+
border-right: 1px solid #1a1a2e !important;
|
| 192 |
}
|
| 193 |
[data-testid="stSidebar"] * {
|
| 194 |
font-size: 0.82rem !important;
|
| 195 |
}
|
| 196 |
|
| 197 |
+
/* Sidebar topic chips */
|
| 198 |
+
.topic-chip {
|
| 199 |
+
display: inline-block;
|
| 200 |
+
background: #111827;
|
| 201 |
+
border: 1px solid #1f2937;
|
| 202 |
+
color: #6b7280;
|
| 203 |
+
padding: 3px 10px;
|
| 204 |
+
border-radius: 20px;
|
| 205 |
+
font-size: 0.72rem;
|
| 206 |
+
margin: 2px 2px;
|
| 207 |
+
transition: all 0.15s;
|
| 208 |
+
}
|
| 209 |
+
.topic-chip:hover {
|
| 210 |
+
border-color: #3b82f6;
|
| 211 |
+
color: #60a5fa;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/* Sidebar engine info */
|
| 215 |
+
.engine-row {
|
| 216 |
+
display: flex;
|
| 217 |
+
align-items: center;
|
| 218 |
+
gap: 0.4rem;
|
| 219 |
+
padding: 0.25rem 0;
|
| 220 |
+
color: #4b5563;
|
| 221 |
+
font-size: 0.75rem;
|
| 222 |
+
}
|
| 223 |
+
.engine-dot {
|
| 224 |
+
width: 6px;
|
| 225 |
+
height: 6px;
|
| 226 |
+
border-radius: 50%;
|
| 227 |
+
background: #22c55e;
|
| 228 |
+
flex-shrink: 0;
|
| 229 |
+
box-shadow: 0 0 4px #22c55e;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
/* โโ Buttons โโ */
|
| 233 |
.stButton > button {
|
| 234 |
+
background: #111827 !important;
|
| 235 |
+
border: 1px solid #1f2937 !important;
|
| 236 |
+
color: #6b7280 !important;
|
| 237 |
border-radius: 8px !important;
|
| 238 |
font-size: 0.78rem !important;
|
| 239 |
padding: 0.3rem 0.8rem !important;
|
|
|
|
| 244 |
.stButton > button:hover {
|
| 245 |
border-color: #3b82f6 !important;
|
| 246 |
color: #ececec !important;
|
| 247 |
+
background: #0f172a !important;
|
| 248 |
}
|
| 249 |
|
| 250 |
+
/* โโ Copy button โโ */
|
| 251 |
[data-testid="stChatMessage"] .stButton > button {
|
| 252 |
background: transparent !important;
|
| 253 |
+
border: 1px solid #1f2937 !important;
|
| 254 |
+
color: #4b5563 !important;
|
| 255 |
border-radius: 6px !important;
|
| 256 |
font-size: 0.75rem !important;
|
| 257 |
padding: 2px 6px !important;
|
|
|
|
| 263 |
[data-testid="stChatMessage"] .stButton > button:hover {
|
| 264 |
border-color: #3b82f6 !important;
|
| 265 |
color: #ececec !important;
|
| 266 |
+
background: #0f172a !important;
|
| 267 |
}
|
| 268 |
|
| 269 |
+
/* โโ Spinner โ custom math themed โโ */
|
| 270 |
.stSpinner > div { border-top-color: #3b82f6 !important; }
|
| 271 |
+
.stSpinner p {
|
| 272 |
+
color: #3b82f6 !important;
|
| 273 |
+
font-size: 0.82rem !important;
|
| 274 |
+
font-family: 'JetBrains Mono', monospace !important;
|
| 275 |
+
}
|
| 276 |
|
| 277 |
/* โโ Divider โโ */
|
| 278 |
+
hr { border-color: #1a1a2e !important; }
|
| 279 |
|
| 280 |
/* โโ Selectbox โโ */
|
| 281 |
.stSelectbox > div > div {
|
| 282 |
+
background: #111827 !important;
|
| 283 |
+
border-color: #1f2937 !important;
|
| 284 |
color: #ececec !important;
|
| 285 |
border-radius: 8px !important;
|
| 286 |
font-size: 0.82rem !important;
|
| 287 |
}
|
| 288 |
+
|
| 289 |
+
/* โโ Scrollbar โโ */
|
| 290 |
+
::-webkit-scrollbar { width: 4px; height: 4px; }
|
| 291 |
+
::-webkit-scrollbar-track { background: #0f0f0f; }
|
| 292 |
+
::-webkit-scrollbar-thumb { background: #1f2937; border-radius: 2px; }
|
| 293 |
+
::-webkit-scrollbar-thumb:hover { background: #3b82f6; }
|
| 294 |
</style>
|
| 295 |
""", unsafe_allow_html=True)
|
| 296 |
|
|
|
|
| 1826 |
" โ Never skip this structure. Never merge steps. Never jump to answer without showing work.\n"
|
| 1827 |
" โ If user says plot/draw/graph/sketch/visualize: a real graph renders automatically.\n"
|
| 1828 |
" Do NOT draw ASCII art. Do NOT say you cannot draw.\n"
|
| 1829 |
+
" Give this SHORT response only โ then graph renders below automatically:\n"
|
| 1830 |
" ๐ **Function:** state f(x) clearly in LaTeX\n"
|
| 1831 |
" ๐ **Key Features:**\n"
|
| 1832 |
" - Domain and range\n"
|
| 1833 |
+
" - x-intercepts: solve f(x)=0\n"
|
| 1834 |
" - y-intercept: f(0)\n"
|
| 1835 |
" - Turning points / vertex if any\n"
|
| 1836 |
" - Behavior as $x \\to \\pm\\infty$\n"
|
| 1837 |
+
" ๐ **Graph** is shown below.\n"
|
| 1838 |
+
" Keep it SHORT โ max 8 lines. No long paragraphs. No step-by-step for graph requests.\n\n"
|
| 1839 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1840 |
"RULE 2 โ LATEX (zero exceptions):\n"
|
| 1841 |
" - Inline math (inside a sentence): $expression$\n"
|
| 1842 |
" - Display math (standalone line, centered): $$expression$$\n"
|
|
|
|
| 2144 |
st.divider()
|
| 2145 |
|
| 2146 |
st.markdown("**๐ฏ Topics**")
|
| 2147 |
+
st.markdown("""
|
| 2148 |
+
<div style="padding:0.2rem 0 0.4rem 0; line-height:2;">
|
| 2149 |
+
<span class="topic-chip">๐ Calculus</span>
|
| 2150 |
+
<span class="topic-chip">๐ข Linear Algebra</span>
|
| 2151 |
+
<span class="topic-chip">๐ Number Theory</span>
|
| 2152 |
+
<span class="topic-chip">๐ ODEs</span>
|
| 2153 |
+
<span class="topic-chip">๐งฎ Numerical</span>
|
| 2154 |
+
<span class="topic-chip">๐ Diff. Geometry</span>
|
| 2155 |
+
<span class="topic-chip">๐ Hydro Mechanics</span>
|
| 2156 |
+
<span class="topic-chip">๐ Theory of Numbers</span>
|
| 2157 |
+
<span class="topic-chip">๐ Real Analysis II</span>
|
| 2158 |
+
<span class="topic-chip">๐ Graph Plotting</span>
|
| 2159 |
+
<span class="topic-chip">โ General Math</span>
|
| 2160 |
+
</div>
|
| 2161 |
+
""", unsafe_allow_html=True)
|
| 2162 |
|
| 2163 |
st.divider()
|
| 2164 |
st.markdown("**โก Example Problems**")
|
|
|
|
| 2186 |
|
| 2187 |
st.divider()
|
| 2188 |
st.markdown("**๐ง Engine**")
|
| 2189 |
+
st.markdown("""
|
| 2190 |
+
<div style="padding:0.2rem 0;">
|
| 2191 |
+
<div class="engine-row"><div class="engine-dot"></div>Groq Llama 3.3 70B โ reasoning</div>
|
| 2192 |
+
<div class="engine-row"><div class="engine-dot"></div>SymPy โ verified computation</div>
|
| 2193 |
+
<div class="engine-row"><div class="engine-dot"></div>6 providers โ 46,400 req/day</div>
|
| 2194 |
+
<div class="engine-row"><div class="engine-dot"></div>Zero arithmetic errors</div>
|
| 2195 |
+
</div>
|
| 2196 |
+
""", unsafe_allow_html=True)
|
| 2197 |
|
| 2198 |
st.divider()
|
| 2199 |
if st.button("๐๏ธ Clear Chat", use_container_width=True):
|
|
|
|
| 2210 |
st.markdown("""
|
| 2211 |
<div class="saad-header">
|
| 2212 |
<h1>๐ Saad.AI</h1>
|
| 2213 |
+
<p>BSc Mathematics ยท Step-by-Step Solver ยท SymPy Verified</p>
|
| 2214 |
<div class="badge-row">
|
| 2215 |
+
<span class="badge">โก Groq Free</span>
|
| 2216 |
+
<span class="badge">๐งฎ SymPy Verified</span>
|
| 2217 |
+
<span class="badge">๐ Step-by-Step</span>
|
| 2218 |
+
<span class="badge">โ LaTeX Rendered</span>
|
| 2219 |
+
<span class="badge">๐ Graph Plotting</span>
|
| 2220 |
</div>
|
| 2221 |
</div>
|
| 2222 |
""", unsafe_allow_html=True)
|
|
|
|
| 2224 |
# Welcome message if no chat
|
| 2225 |
if not st.session_state.messages:
|
| 2226 |
st.markdown("""
|
| 2227 |
+
<div style="text-align:center; padding:1.5rem 0 0.5rem 0;">
|
| 2228 |
+
<div style="font-size:0.85rem; color:#4b5563; margin-bottom:1.2rem;">
|
| 2229 |
+
Ask any BSc Mathematics problem โ I'll solve it step by step
|
| 2230 |
+
</div>
|
| 2231 |
+
<div class="subject-grid">
|
| 2232 |
+
<div class="subject-card">
|
| 2233 |
+
<span class="icon">๐</span>Calculus
|
| 2234 |
+
</div>
|
| 2235 |
+
<div class="subject-card">
|
| 2236 |
+
<span class="icon">๐ข</span>Linear Algebra
|
| 2237 |
+
</div>
|
| 2238 |
+
<div class="subject-card">
|
| 2239 |
+
<span class="icon">๐</span>ODEs
|
| 2240 |
+
</div>
|
| 2241 |
+
<div class="subject-card">
|
| 2242 |
+
<span class="icon">๐งฎ</span>Numerical Methods
|
| 2243 |
+
</div>
|
| 2244 |
+
<div class="subject-card">
|
| 2245 |
+
<span class="icon">๐</span>Number Theory
|
| 2246 |
+
</div>
|
| 2247 |
+
<div class="subject-card">
|
| 2248 |
+
<span class="icon">๐</span>Diff. Geometry
|
| 2249 |
+
</div>
|
| 2250 |
+
<div class="subject-card">
|
| 2251 |
+
<span class="icon">๐</span>Hydro Mechanics
|
| 2252 |
+
</div>
|
| 2253 |
+
<div class="subject-card">
|
| 2254 |
+
<span class="icon">๐</span>Real Analysis II
|
| 2255 |
+
</div>
|
| 2256 |
+
<div class="subject-card">
|
| 2257 |
+
<span class="icon">๐</span>Graph Plotting
|
| 2258 |
+
</div>
|
| 2259 |
+
</div>
|
| 2260 |
+
<div style="font-size:0.72rem; color:#374151; margin-top:1rem;">
|
| 2261 |
+
๐ก Tip: Select an example from the sidebar or type your problem below
|
| 2262 |
</div>
|
| 2263 |
</div>
|
| 2264 |
""", unsafe_allow_html=True)
|
|
|
|
| 2308 |
# Show AI response with streaming
|
| 2309 |
with st.chat_message("assistant", avatar="๐"):
|
| 2310 |
# Step 1: SymPy computation (instant)
|
| 2311 |
+
import random
|
| 2312 |
+
spinner_msgs = [
|
| 2313 |
+
"๐งฎ Computing with SymPy...",
|
| 2314 |
+
"โซ Integrating the solution...",
|
| 2315 |
+
"โ Summing it all up...",
|
| 2316 |
+
"๐ Applying the formula...",
|
| 2317 |
+
"๐ข Crunching the numbers...",
|
| 2318 |
+
"๐ Verifying the answer...",
|
| 2319 |
+
]
|
| 2320 |
+
with st.spinner(random.choice(spinner_msgs)):
|
| 2321 |
sympy_result = run_sympy(problem)
|
| 2322 |
|
| 2323 |
# Step 2: Stream AI response word by word
|