Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,8 +2,11 @@ import streamlit as st
|
|
2 |
import os
|
3 |
from groq import Groq
|
4 |
|
|
|
|
|
|
|
5 |
# Set the Groq API key
|
6 |
-
os.environ["GROQ_API_KEY"] = "
|
7 |
|
8 |
# Initialize Groq client
|
9 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
@@ -50,17 +53,14 @@ def mental_health_check_in(feelings):
|
|
50 |
# Initialize session state if not already set
|
51 |
if 'responses' not in st.session_state:
|
52 |
st.session_state['responses'] = {
|
53 |
-
"
|
54 |
-
"
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"
|
58 |
-
"
|
59 |
}
|
60 |
|
61 |
-
# Set up page configuration
|
62 |
-
st.set_page_config(page_title="EduNexus", page_icon=":book:", layout="wide")
|
63 |
-
|
64 |
# Add custom styling using Streamlit
|
65 |
st.markdown("""
|
66 |
<style>
|
@@ -92,7 +92,7 @@ st.markdown("""
|
|
92 |
color: #ffffff; /* White */
|
93 |
}
|
94 |
.stTextInput::placeholder, .stTextArea::placeholder {
|
95 |
-
color:
|
96 |
}
|
97 |
.stSidebar {
|
98 |
background-color: #000000; /* Royal Black */
|
@@ -126,22 +126,25 @@ st.markdown("""
|
|
126 |
</style>
|
127 |
""", unsafe_allow_html=True)
|
128 |
|
129 |
-
#
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
132 |
"π Personalized Learning Assistant",
|
133 |
"π€ AI Coding Mentor",
|
134 |
"π Smart Document Summarizer",
|
135 |
"ποΈ Interactive Study Planner",
|
136 |
"π¬ Real-Time Q&A Support",
|
137 |
"π§ Mental Health Check-In"
|
138 |
-
|
139 |
|
140 |
selected_task = st.sidebar.radio("Select a task", tasks)
|
141 |
|
142 |
# Main layout based on selected task
|
143 |
-
if selected_task == "Personalized Learning Assistant":
|
144 |
-
st.
|
145 |
with st.form(key="personalized_learning_assistant_form"):
|
146 |
topic = st.text_area("Enter the topic you want to learn about")
|
147 |
submit_button = st.form_submit_button("Get Explanation")
|
@@ -149,8 +152,8 @@ if selected_task == "Personalized Learning Assistant":
|
|
149 |
response = personalized_learning_assistant(topic)
|
150 |
st.write(response)
|
151 |
|
152 |
-
elif selected_task == "AI Coding Mentor":
|
153 |
-
st.
|
154 |
with st.form(key="ai_coding_mentor_form"):
|
155 |
code_snippet = st.text_area("Paste your code snippet here")
|
156 |
submit_button = st.form_submit_button("Get Review")
|
@@ -158,8 +161,8 @@ elif selected_task == "AI Coding Mentor":
|
|
158 |
response = ai_coding_mentor(code_snippet)
|
159 |
st.write(response)
|
160 |
|
161 |
-
elif selected_task == "Smart Document Summarizer":
|
162 |
-
st.
|
163 |
with st.form(key="smart_document_summarizer_form"):
|
164 |
document_text = st.text_area("Paste your document text here")
|
165 |
submit_button = st.form_submit_button("Get Summary")
|
@@ -167,8 +170,8 @@ elif selected_task == "Smart Document Summarizer":
|
|
167 |
response = smart_document_summarizer(document_text)
|
168 |
st.write(response)
|
169 |
|
170 |
-
elif selected_task == "Interactive Study Planner":
|
171 |
-
st.
|
172 |
with st.form(key="interactive_study_planner_form"):
|
173 |
exam_schedule = st.text_area("Enter your exam schedule here")
|
174 |
submit_button = st.form_submit_button("Create Study Plan")
|
@@ -176,8 +179,8 @@ elif selected_task == "Interactive Study Planner":
|
|
176 |
response = interactive_study_planner(exam_schedule)
|
177 |
st.write(response)
|
178 |
|
179 |
-
elif selected_task == "Real-Time Q&A Support":
|
180 |
-
st.
|
181 |
with st.form(key="real_time_qa_support_form"):
|
182 |
question = st.text_area("Ask your academic question here")
|
183 |
submit_button = st.form_submit_button("Get Answer")
|
@@ -185,14 +188,21 @@ elif selected_task == "Real-Time Q&A Support":
|
|
185 |
response = real_time_qa_support(question)
|
186 |
st.write(response)
|
187 |
|
188 |
-
elif selected_task == "Mental Health Check-In":
|
189 |
-
st.
|
190 |
with st.form(key="mental_health_check_in_form"):
|
191 |
feelings = st.text_area("Share how you are feeling today")
|
192 |
-
|
|
|
|
|
|
|
|
|
193 |
if submit_button:
|
194 |
response = mental_health_check_in(feelings)
|
195 |
st.write(response)
|
|
|
|
|
|
|
196 |
|
197 |
# Footer
|
198 |
st.markdown("""
|
|
|
2 |
import os
|
3 |
from groq import Groq
|
4 |
|
5 |
+
# Set up page configuration
|
6 |
+
st.set_page_config(page_title="EduNexus", page_icon=":book:", layout="wide")
|
7 |
+
|
8 |
# Set the Groq API key
|
9 |
+
os.environ["GROQ_API_KEY"] = "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"
|
10 |
|
11 |
# Initialize Groq client
|
12 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
|
|
53 |
# Initialize session state if not already set
|
54 |
if 'responses' not in st.session_state:
|
55 |
st.session_state['responses'] = {
|
56 |
+
"personalized_learning_assistant": "",
|
57 |
+
"ai_coding_mentor": "",
|
58 |
+
"smart_document_summarizer": "",
|
59 |
+
"interactive_study_planner": "",
|
60 |
+
"real_time_qa_support": "",
|
61 |
+
"mental_health_check_in": ""
|
62 |
}
|
63 |
|
|
|
|
|
|
|
64 |
# Add custom styling using Streamlit
|
65 |
st.markdown("""
|
66 |
<style>
|
|
|
92 |
color: #ffffff; /* White */
|
93 |
}
|
94 |
.stTextInput::placeholder, .stTextArea::placeholder {
|
95 |
+
color: #a0a0a0; /* Gray */
|
96 |
}
|
97 |
.stSidebar {
|
98 |
background-color: #000000; /* Royal Black */
|
|
|
126 |
</style>
|
127 |
""", unsafe_allow_html=True)
|
128 |
|
129 |
+
# Display main title
|
130 |
+
st.title("EduNexus")
|
131 |
+
|
132 |
+
# Sidebar with tasks
|
133 |
+
st.sidebar.title("Tasks")
|
134 |
+
tasks = [
|
135 |
"π Personalized Learning Assistant",
|
136 |
"π€ AI Coding Mentor",
|
137 |
"π Smart Document Summarizer",
|
138 |
"ποΈ Interactive Study Planner",
|
139 |
"π¬ Real-Time Q&A Support",
|
140 |
"π§ Mental Health Check-In"
|
141 |
+
]
|
142 |
|
143 |
selected_task = st.sidebar.radio("Select a task", tasks)
|
144 |
|
145 |
# Main layout based on selected task
|
146 |
+
if selected_task == "π Personalized Learning Assistant":
|
147 |
+
st.header("Personalized Learning Assistant")
|
148 |
with st.form(key="personalized_learning_assistant_form"):
|
149 |
topic = st.text_area("Enter the topic you want to learn about")
|
150 |
submit_button = st.form_submit_button("Get Explanation")
|
|
|
152 |
response = personalized_learning_assistant(topic)
|
153 |
st.write(response)
|
154 |
|
155 |
+
elif selected_task == "π€ AI Coding Mentor":
|
156 |
+
st.header("AI Coding Mentor")
|
157 |
with st.form(key="ai_coding_mentor_form"):
|
158 |
code_snippet = st.text_area("Paste your code snippet here")
|
159 |
submit_button = st.form_submit_button("Get Review")
|
|
|
161 |
response = ai_coding_mentor(code_snippet)
|
162 |
st.write(response)
|
163 |
|
164 |
+
elif selected_task == "π Smart Document Summarizer":
|
165 |
+
st.header("Smart Document Summarizer")
|
166 |
with st.form(key="smart_document_summarizer_form"):
|
167 |
document_text = st.text_area("Paste your document text here")
|
168 |
submit_button = st.form_submit_button("Get Summary")
|
|
|
170 |
response = smart_document_summarizer(document_text)
|
171 |
st.write(response)
|
172 |
|
173 |
+
elif selected_task == "ποΈ Interactive Study Planner":
|
174 |
+
st.header("Interactive Study Planner")
|
175 |
with st.form(key="interactive_study_planner_form"):
|
176 |
exam_schedule = st.text_area("Enter your exam schedule here")
|
177 |
submit_button = st.form_submit_button("Create Study Plan")
|
|
|
179 |
response = interactive_study_planner(exam_schedule)
|
180 |
st.write(response)
|
181 |
|
182 |
+
elif selected_task == "π¬ Real-Time Q&A Support":
|
183 |
+
st.header("Real-Time Q&A Support")
|
184 |
with st.form(key="real_time_qa_support_form"):
|
185 |
question = st.text_area("Ask your academic question here")
|
186 |
submit_button = st.form_submit_button("Get Answer")
|
|
|
188 |
response = real_time_qa_support(question)
|
189 |
st.write(response)
|
190 |
|
191 |
+
elif selected_task == "π§ Mental Health Check-In":
|
192 |
+
st.header("Mental Health Check-In")
|
193 |
with st.form(key="mental_health_check_in_form"):
|
194 |
feelings = st.text_area("Share how you are feeling today")
|
195 |
+
col1, col2 = st.columns([2, 1])
|
196 |
+
with col1:
|
197 |
+
submit_button = st.form_submit_button("Get Advice")
|
198 |
+
with col2:
|
199 |
+
clear_button = st.button("Clear")
|
200 |
if submit_button:
|
201 |
response = mental_health_check_in(feelings)
|
202 |
st.write(response)
|
203 |
+
if clear_button:
|
204 |
+
st.session_state['responses']['mental_health_check_in'] = ""
|
205 |
+
st.experimental_rerun()
|
206 |
|
207 |
# Footer
|
208 |
st.markdown("""
|