Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ from matching import calculate_local_matches
|
|
| 15 |
from feedback import save_feedback
|
| 16 |
from ui_styles import BASE_CSS
|
| 17 |
|
| 18 |
-
#
|
| 19 |
st.set_page_config(
|
| 20 |
page_title="AI Skill Swap",
|
| 21 |
page_icon="π€",
|
|
@@ -24,26 +24,9 @@ st.set_page_config(
|
|
| 24 |
|
| 25 |
st.markdown(f"<style>{BASE_CSS}</style>", unsafe_allow_html=True)
|
| 26 |
|
| 27 |
-
# ---------------- Session State Defaults ----------------
|
| 28 |
-
def init_session_state():
|
| 29 |
-
defaults = {
|
| 30 |
-
"username_input": "",
|
| 31 |
-
"offers_text_input": "",
|
| 32 |
-
"wants_text_input": "",
|
| 33 |
-
"availability_input": "",
|
| 34 |
-
"preferences_input": "",
|
| 35 |
-
"feedback_input": "",
|
| 36 |
-
}
|
| 37 |
-
for k, v in defaults.items():
|
| 38 |
-
if k not in st.session_state:
|
| 39 |
-
st.session_state[k] = v
|
| 40 |
-
|
| 41 |
-
init_session_state()
|
| 42 |
-
|
| 43 |
-
# ---------------- Store ----------------
|
| 44 |
store = ProfileStore()
|
| 45 |
|
| 46 |
-
#
|
| 47 |
col_logo, col_title = st.columns([1, 6])
|
| 48 |
with col_logo:
|
| 49 |
st.image(
|
|
@@ -54,161 +37,176 @@ with col_title:
|
|
| 54 |
st.title("AI Skill Swap")
|
| 55 |
st.caption("Teach what you know β’ Learn what you love β’ Match intelligently")
|
| 56 |
|
| 57 |
-
#
|
| 58 |
-
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
st.header("π₯ Community Profiles")
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
offers_text = st.text_area(
|
| 82 |
-
"Skills you can teach",
|
| 83 |
-
height=80,
|
| 84 |
-
value=st.session_state["offers_text_input"],
|
| 85 |
-
placeholder="Python, React, Data Science",
|
| 86 |
-
key="offers_text_input"
|
| 87 |
-
)
|
| 88 |
-
wants_text = st.text_area(
|
| 89 |
-
"Skills you want to learn",
|
| 90 |
-
height=80,
|
| 91 |
-
value=st.session_state["wants_text_input"],
|
| 92 |
-
placeholder="LLMs, DevOps, UI Design",
|
| 93 |
-
key="wants_text_input"
|
| 94 |
-
)
|
| 95 |
-
availability = st.text_input(
|
| 96 |
-
"Availability",
|
| 97 |
-
placeholder="Evenings / Weekends",
|
| 98 |
-
value=st.session_state["availability_input"],
|
| 99 |
-
key="availability_input"
|
| 100 |
-
)
|
| 101 |
-
preferences = st.text_input(
|
| 102 |
-
"Language / Preferences",
|
| 103 |
-
placeholder="English, Hindi, Urdu",
|
| 104 |
-
value=st.session_state["preferences_input"],
|
| 105 |
-
key="preferences_input"
|
| 106 |
-
)
|
| 107 |
-
avatar_file = st.file_uploader(
|
| 108 |
-
"Upload Avatar (Max 800MB)",
|
| 109 |
-
type=["png", "jpg", "jpeg"]
|
| 110 |
-
)
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
)
|
|
|
|
|
|
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
st.
|
|
|
|
|
|
|
| 167 |
else:
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
profiles = store.load_all()
|
|
|
|
| 201 |
if not profiles:
|
| 202 |
-
st.info("No profiles yet. Create one from the
|
| 203 |
else:
|
| 204 |
for p in profiles:
|
| 205 |
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
| 206 |
cols = st.columns([1, 4])
|
|
|
|
| 207 |
with cols[0]:
|
| 208 |
if p.avatar and Path(p.avatar).exists():
|
| 209 |
st.image(p.avatar, width=120)
|
| 210 |
else:
|
| 211 |
-
st.image(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
with cols[1]:
|
| 213 |
st.markdown(f"**{p.username}**")
|
| 214 |
st.caption(f"{p.availability} β’ {p.preferences}")
|
|
@@ -216,26 +214,32 @@ with tabs[0]:
|
|
| 216 |
st.markdown(f"π― **Wants:** {', '.join(p.wants) or 'β'}")
|
| 217 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 218 |
|
| 219 |
-
#
|
| 220 |
-
with
|
| 221 |
-
st.
|
| 222 |
-
|
| 223 |
if not profiles:
|
| 224 |
st.info("Add profiles to enable matchmaking.")
|
| 225 |
else:
|
| 226 |
-
pick = st.selectbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
if st.button("β¨ Find Best Matches"):
|
| 228 |
with st.spinner("Analyzing profiles..."):
|
| 229 |
current = store.find_by_username(pick)
|
|
|
|
| 230 |
try:
|
| 231 |
sys_msg, user_msg = make_prompt_for_matching(current, profiles, 3)
|
| 232 |
matches = ask_groq_for_matches(sys_msg, user_msg)
|
| 233 |
except Exception:
|
| 234 |
matches = calculate_local_matches(
|
| 235 |
-
current,
|
|
|
|
|
|
|
| 236 |
)
|
| 237 |
|
| 238 |
-
st.subheader("Top Matches")
|
| 239 |
for m in matches:
|
| 240 |
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
| 241 |
st.markdown(f"### {m.get('username')}")
|
|
@@ -245,57 +249,21 @@ with tabs[1]:
|
|
| 245 |
st.caption(m.get("reason", "AI Match"))
|
| 246 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 247 |
|
| 248 |
-
#
|
| 249 |
-
with tabs[2]:
|
| 250 |
-
st.header("βΉοΈ About AI Skill Swap")
|
| 251 |
-
st.markdown("""
|
| 252 |
-
**AI Skill Swap** is a platform designed to help people **teach and learn skills** from each other.
|
| 253 |
-
|
| 254 |
-
**Purpose:**
|
| 255 |
-
- Connect learners with mentors in your community.
|
| 256 |
-
- Discover new skills efficiently using AI matchmaking.
|
| 257 |
-
- Encourage skill exchange without formal courses.
|
| 258 |
-
|
| 259 |
-
**Features:**
|
| 260 |
-
- Create, Update, Delete personal profiles with skills, availability, and preferences.
|
| 261 |
-
- AI-based matchmaking to find top compatible skill partners.
|
| 262 |
-
- Community tab to see all profiles.
|
| 263 |
-
- Feedback submission for continuous improvement.
|
| 264 |
-
|
| 265 |
-
**Technologies Used:**
|
| 266 |
-
- Python, Streamlit (Frontend & Backend)
|
| 267 |
-
- Groq API / Local AI Matching
|
| 268 |
-
- File handling for avatar uploads
|
| 269 |
-
- Persistent storage (ProfileStore)
|
| 270 |
-
|
| 271 |
-
**Why it's helpful:**
|
| 272 |
-
- Makes skill exchange easy and organized.
|
| 273 |
-
- Learners and teachers connect automatically with AI suggestions.
|
| 274 |
-
- Saves time compared to manually searching for mentors or learners.
|
| 275 |
-
|
| 276 |
-
**How to Use:**
|
| 277 |
-
1. Create a profile in the Community tab.
|
| 278 |
-
2. View other community profiles.
|
| 279 |
-
3. Go to AI Matchmaking tab to find best skill partners.
|
| 280 |
-
4. Submit feedback via sidebar form.
|
| 281 |
-
|
| 282 |
-
*Enjoy teaching, learning, and growing together!*
|
| 283 |
-
""")
|
| 284 |
-
|
| 285 |
-
# ---------------- Feedback Sidebar ----------------
|
| 286 |
with st.sidebar:
|
| 287 |
st.markdown("---")
|
| 288 |
with st.expander("π¬ Feedback"):
|
| 289 |
-
fb = st.text_area("Your feedback"
|
| 290 |
-
if st.button("Submit Feedback"
|
| 291 |
if fb.strip():
|
| 292 |
-
save_feedback(
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
st.
|
|
|
|
| 300 |
else:
|
| 301 |
st.warning("Please write feedback.")
|
|
|
|
| 15 |
from feedback import save_feedback
|
| 16 |
from ui_styles import BASE_CSS
|
| 17 |
|
| 18 |
+
# ---------- Streamlit Config ----------
|
| 19 |
st.set_page_config(
|
| 20 |
page_title="AI Skill Swap",
|
| 21 |
page_icon="π€",
|
|
|
|
| 24 |
|
| 25 |
st.markdown(f"<style>{BASE_CSS}</style>", unsafe_allow_html=True)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
store = ProfileStore()
|
| 28 |
|
| 29 |
+
# ---------- Header ----------
|
| 30 |
col_logo, col_title = st.columns([1, 6])
|
| 31 |
with col_logo:
|
| 32 |
st.image(
|
|
|
|
| 37 |
st.title("AI Skill Swap")
|
| 38 |
st.caption("Teach what you know β’ Learn what you love β’ Match intelligently")
|
| 39 |
|
| 40 |
+
# ---------- Sidebar: Profile Management ----------
|
| 41 |
+
with st.sidebar:
|
| 42 |
+
st.header("π€ Profile Manager")
|
| 43 |
|
| 44 |
+
profiles = store.load_all()
|
| 45 |
+
usernames = [p.username for p in profiles]
|
|
|
|
| 46 |
|
| 47 |
+
selected_user = st.selectbox(
|
| 48 |
+
"Select profile",
|
| 49 |
+
["β Create New β"] + usernames,
|
| 50 |
+
)
|
| 51 |
|
| 52 |
+
st.markdown("### π Profile Details")
|
| 53 |
+
username = st.text_input(
|
| 54 |
+
"Username",
|
| 55 |
+
value="" if selected_user == "β Create New β" else selected_user,
|
| 56 |
+
)
|
| 57 |
|
| 58 |
+
offers_text = st.text_area(
|
| 59 |
+
"Skills you can teach",
|
| 60 |
+
height=90,
|
| 61 |
+
value=st.session_state.get("offers_text", ""),
|
| 62 |
+
placeholder="Python, React, Data Science",
|
| 63 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
wants_text = st.text_area(
|
| 66 |
+
"Skills you want to learn",
|
| 67 |
+
height=90,
|
| 68 |
+
value=st.session_state.get("wants_text", ""),
|
| 69 |
+
placeholder="LLMs, DevOps, UI Design",
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
availability = st.text_input(
|
| 73 |
+
"Availability",
|
| 74 |
+
placeholder="Evenings / Weekends",
|
| 75 |
+
value=st.session_state.get("availability", ""),
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
preferences = st.text_input(
|
| 79 |
+
"Language / Preferences",
|
| 80 |
+
placeholder="English, Hindi, Urdu",
|
| 81 |
+
value=st.session_state.get("preferences", ""),
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
avatar_file = st.file_uploader(
|
| 85 |
+
"Upload Avatar (Max 800MB)",
|
| 86 |
+
type=["png", "jpg", "jpeg"],
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
# ---------- Avatar Preview ----------
|
| 90 |
+
if avatar_file:
|
| 91 |
+
st.image(avatar_file, width=150, caption="Preview of avatar")
|
| 92 |
+
if avatar_file.size > 800 * 1024 * 1024:
|
| 93 |
+
st.error("File exceeds maximum size of 800MB!")
|
| 94 |
+
avatar_file = None
|
| 95 |
+
|
| 96 |
+
st.markdown("---")
|
| 97 |
+
col_create, col_update = st.columns(2)
|
| 98 |
+
|
| 99 |
+
# ---------- CREATE PROFILE ----------
|
| 100 |
+
with col_create:
|
| 101 |
+
if st.button("β Create", use_container_width=True):
|
| 102 |
+
if not username.strip():
|
| 103 |
+
st.error("Username is required!")
|
| 104 |
+
elif store.find_by_username(username):
|
| 105 |
+
st.error("Profile already exists. Use Update.")
|
| 106 |
+
else:
|
| 107 |
+
avatar_path = None
|
| 108 |
+
if avatar_file:
|
| 109 |
+
safe = re.sub(r"[^A-Za-z0-9_.-]", "_", username)
|
| 110 |
+
ext = Path(avatar_file.name).suffix
|
| 111 |
+
avatar_path = str(
|
| 112 |
+
AVATAR_DIR / f"{safe}_{int(time.time())}{ext}"
|
| 113 |
)
|
| 114 |
+
with open(avatar_path, "wb") as f:
|
| 115 |
+
f.write(avatar_file.getbuffer())
|
| 116 |
|
| 117 |
+
profile = Profile(
|
| 118 |
+
id=str(uuid.uuid4()),
|
| 119 |
+
username=username.strip(),
|
| 120 |
+
offers=normalize_skill_list(offers_text),
|
| 121 |
+
wants=normalize_skill_list(wants_text),
|
| 122 |
+
availability=availability.strip(),
|
| 123 |
+
preferences=preferences.strip(),
|
| 124 |
+
avatar=avatar_path,
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
ok, msg = store.add_or_update(profile)
|
| 128 |
+
if ok:
|
| 129 |
+
st.success(msg)
|
| 130 |
+
# Clear all fields after creation
|
| 131 |
+
st.session_state["username"] = ""
|
| 132 |
+
st.session_state["offers_text"] = ""
|
| 133 |
+
st.session_state["wants_text"] = ""
|
| 134 |
+
st.session_state["availability"] = ""
|
| 135 |
+
st.session_state["preferences"] = ""
|
| 136 |
+
st.rerun()
|
| 137 |
else:
|
| 138 |
+
st.error(msg)
|
| 139 |
+
|
| 140 |
+
# ---------- UPDATE PROFILE ----------
|
| 141 |
+
with col_update:
|
| 142 |
+
if st.button("πΎ Update", use_container_width=True):
|
| 143 |
+
existing = store.find_by_username(username)
|
| 144 |
+
if not existing:
|
| 145 |
+
st.error("Profile does not exist. Use Create.")
|
| 146 |
+
else:
|
| 147 |
+
existing.offers = normalize_skill_list(offers_text)
|
| 148 |
+
existing.wants = normalize_skill_list(wants_text)
|
| 149 |
+
existing.availability = availability.strip()
|
| 150 |
+
existing.preferences = preferences.strip()
|
| 151 |
+
|
| 152 |
+
if avatar_file:
|
| 153 |
+
safe = re.sub(r"[^A-Za-z0-9_.-]", "_", username)
|
| 154 |
+
ext = Path(avatar_file.name).suffix
|
| 155 |
+
avatar_path = str(
|
| 156 |
+
AVATAR_DIR / f"{safe}_{int(time.time())}{ext}"
|
| 157 |
+
)
|
| 158 |
+
with open(avatar_path, "wb") as f:
|
| 159 |
+
f.write(avatar_file.getbuffer())
|
| 160 |
+
existing.avatar = avatar_path
|
| 161 |
+
|
| 162 |
+
store.add_or_update(existing)
|
| 163 |
+
st.success("Profile updated")
|
| 164 |
+
# Keep fields after update
|
| 165 |
+
st.session_state["username"] = username
|
| 166 |
+
st.session_state["offers_text"] = offers_text
|
| 167 |
+
st.session_state["wants_text"] = wants_text
|
| 168 |
+
st.session_state["availability"] = availability
|
| 169 |
+
st.session_state["preferences"] = preferences
|
| 170 |
+
st.rerun()
|
| 171 |
+
|
| 172 |
+
# ---------- DELETE PROFILE ----------
|
| 173 |
+
if selected_user != "β Create New β":
|
| 174 |
+
if st.button("ποΈ Delete Profile", type="secondary"):
|
| 175 |
+
store.delete(selected_user)
|
| 176 |
+
st.warning("Profile deleted")
|
| 177 |
+
# Clear fields after deletion
|
| 178 |
+
st.session_state["username"] = ""
|
| 179 |
+
st.session_state["offers_text"] = ""
|
| 180 |
+
st.session_state["wants_text"] = ""
|
| 181 |
+
st.session_state["availability"] = ""
|
| 182 |
+
st.session_state["preferences"] = ""
|
| 183 |
+
time.sleep(0.3)
|
| 184 |
+
st.rerun()
|
| 185 |
+
|
| 186 |
+
# ---------- MAIN CONTENT ----------
|
| 187 |
+
left, right = st.columns([2, 3])
|
| 188 |
+
|
| 189 |
+
# ---------- COMMUNITY PROFILES ----------
|
| 190 |
+
with left:
|
| 191 |
+
st.subheader("π Community Profiles")
|
| 192 |
profiles = store.load_all()
|
| 193 |
+
|
| 194 |
if not profiles:
|
| 195 |
+
st.info("No profiles yet. Create one from the sidebar.")
|
| 196 |
else:
|
| 197 |
for p in profiles:
|
| 198 |
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
| 199 |
cols = st.columns([1, 4])
|
| 200 |
+
|
| 201 |
with cols[0]:
|
| 202 |
if p.avatar and Path(p.avatar).exists():
|
| 203 |
st.image(p.avatar, width=120)
|
| 204 |
else:
|
| 205 |
+
st.image(
|
| 206 |
+
"https://via.placeholder.com/120",
|
| 207 |
+
width=120,
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
with cols[1]:
|
| 211 |
st.markdown(f"**{p.username}**")
|
| 212 |
st.caption(f"{p.availability} β’ {p.preferences}")
|
|
|
|
| 214 |
st.markdown(f"π― **Wants:** {', '.join(p.wants) or 'β'}")
|
| 215 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 216 |
|
| 217 |
+
# ---------- AI MATCHMAKING ----------
|
| 218 |
+
with right:
|
| 219 |
+
st.subheader("π€ AI Matchmaking")
|
| 220 |
+
|
| 221 |
if not profiles:
|
| 222 |
st.info("Add profiles to enable matchmaking.")
|
| 223 |
else:
|
| 224 |
+
pick = st.selectbox(
|
| 225 |
+
"Choose your profile",
|
| 226 |
+
[p.username for p in profiles],
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
if st.button("β¨ Find Best Matches"):
|
| 230 |
with st.spinner("Analyzing profiles..."):
|
| 231 |
current = store.find_by_username(pick)
|
| 232 |
+
|
| 233 |
try:
|
| 234 |
sys_msg, user_msg = make_prompt_for_matching(current, profiles, 3)
|
| 235 |
matches = ask_groq_for_matches(sys_msg, user_msg)
|
| 236 |
except Exception:
|
| 237 |
matches = calculate_local_matches(
|
| 238 |
+
current,
|
| 239 |
+
[p for p in profiles if p.id != current.id],
|
| 240 |
+
3,
|
| 241 |
)
|
| 242 |
|
|
|
|
| 243 |
for m in matches:
|
| 244 |
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
| 245 |
st.markdown(f"### {m.get('username')}")
|
|
|
|
| 249 |
st.caption(m.get("reason", "AI Match"))
|
| 250 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 251 |
|
| 252 |
+
# ---------- FEEDBACK ----------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
with st.sidebar:
|
| 254 |
st.markdown("---")
|
| 255 |
with st.expander("π¬ Feedback"):
|
| 256 |
+
fb = st.text_area("Your feedback")
|
| 257 |
+
if st.button("Submit Feedback"):
|
| 258 |
if fb.strip():
|
| 259 |
+
save_feedback(
|
| 260 |
+
{
|
| 261 |
+
"timestamp": time.time(),
|
| 262 |
+
"feedback": fb,
|
| 263 |
+
"username": st.session_state.get("username", "anonymous"),
|
| 264 |
+
}
|
| 265 |
+
)
|
| 266 |
+
st.success("Thank you!")
|
| 267 |
+
st.rerun()
|
| 268 |
else:
|
| 269 |
st.warning("Please write feedback.")
|