Spaces:
Sleeping
Sleeping
Testing
#1
by
arjunverma2004
- opened
- src/streamlit_app.py +3 -10
src/streamlit_app.py
CHANGED
|
@@ -42,7 +42,7 @@ def fetch_notion_database():
|
|
| 42 |
"keywords": [k.strip() for k in keywords_str.split(',')],
|
| 43 |
"content": content
|
| 44 |
})
|
| 45 |
-
|
| 46 |
return results
|
| 47 |
except Exception as e:
|
| 48 |
st.error(f"Failed to connect to Notion: {e}")
|
|
@@ -90,7 +90,7 @@ def generate_response(query: str, context: str) -> str:
|
|
| 90 |
# --- 3. STREAMLIT UI (No changes here) ---
|
| 91 |
st.set_page_config(page_title="Campus Helper Bot", page_icon="π€")
|
| 92 |
st.title("π€ Campus Helper Bot")
|
| 93 |
-
st.caption("Your AI-powered guide!")
|
| 94 |
|
| 95 |
if "messages" not in st.session_state:
|
| 96 |
st.session_state.messages = [
|
|
@@ -101,21 +101,14 @@ for message in st.session_state.messages:
|
|
| 101 |
with st.chat_message(message["role"]):
|
| 102 |
st.markdown(message["content"])
|
| 103 |
|
| 104 |
-
# Main chat input logic
|
| 105 |
if prompt := st.chat_input("Ask about fee deadlines, scholarships, etc."):
|
| 106 |
-
# Add user message to session state and display it
|
| 107 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 108 |
with st.chat_message("user"):
|
| 109 |
st.markdown(prompt)
|
| 110 |
|
| 111 |
-
# Get and display bot response
|
| 112 |
with st.chat_message("assistant"):
|
| 113 |
-
with st.spinner("
|
| 114 |
-
# 1. Retrieve context
|
| 115 |
context = get_context(prompt)
|
| 116 |
-
# 2. Generate response
|
| 117 |
response = generate_response(prompt, context)
|
| 118 |
-
# 3. Display response INSIDE the bubble
|
| 119 |
st.markdown(response)
|
| 120 |
-
# 4. Add the response to the history for the next re-run
|
| 121 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
|
| 42 |
"keywords": [k.strip() for k in keywords_str.split(',')],
|
| 43 |
"content": content
|
| 44 |
})
|
| 45 |
+
st.success("Successfully connected to Notion!")
|
| 46 |
return results
|
| 47 |
except Exception as e:
|
| 48 |
st.error(f"Failed to connect to Notion: {e}")
|
|
|
|
| 90 |
# --- 3. STREAMLIT UI (No changes here) ---
|
| 91 |
st.set_page_config(page_title="Campus Helper Bot", page_icon="π€")
|
| 92 |
st.title("π€ Campus Helper Bot")
|
| 93 |
+
st.caption("Your AI-powered guide, now connected to Notion!")
|
| 94 |
|
| 95 |
if "messages" not in st.session_state:
|
| 96 |
st.session_state.messages = [
|
|
|
|
| 101 |
with st.chat_message(message["role"]):
|
| 102 |
st.markdown(message["content"])
|
| 103 |
|
|
|
|
| 104 |
if prompt := st.chat_input("Ask about fee deadlines, scholarships, etc."):
|
|
|
|
| 105 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 106 |
with st.chat_message("user"):
|
| 107 |
st.markdown(prompt)
|
| 108 |
|
|
|
|
| 109 |
with st.chat_message("assistant"):
|
| 110 |
+
with st.spinner("Searching Notion..."):
|
|
|
|
| 111 |
context = get_context(prompt)
|
|
|
|
| 112 |
response = generate_response(prompt, context)
|
|
|
|
| 113 |
st.markdown(response)
|
|
|
|
| 114 |
st.session_state.messages.append({"role": "assistant", "content": response})
|