Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,6 @@ def call_groq_api(prompt):
|
|
24 |
return f"Error: {str(e)}"
|
25 |
|
26 |
# Define functions with few-shot prompting
|
27 |
-
|
28 |
def personalized_learning_assistant(topic):
|
29 |
examples = [
|
30 |
"Explain quantum mechanics. Example: Quantum mechanics is the study of particles at the atomic level.",
|
@@ -75,60 +74,134 @@ def mental_health_check_in(feelings):
|
|
75 |
return call_groq_api(prompt)
|
76 |
|
77 |
# Define Streamlit app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
st.title("EduNexus: The Ultimate AI-Powered Student Companion")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
# Personalized Learning Assistant
|
81 |
st.header("Personalized Learning Assistant")
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
|
89 |
# AI Coding Mentor
|
90 |
st.header("AI Coding Mentor")
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
97 |
|
98 |
# Smart Document Summarizer
|
99 |
st.header("Smart Document Summarizer")
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
106 |
|
107 |
# Interactive Study Planner
|
108 |
st.header("Interactive Study Planner")
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
115 |
|
116 |
# Real-Time Q&A Support
|
117 |
st.header("Real-Time Q&A Support")
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
124 |
|
125 |
# Mental Health Check-In
|
126 |
st.header("Mental Health Check-In")
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
24 |
return f"Error: {str(e)}"
|
25 |
|
26 |
# Define functions with few-shot prompting
|
|
|
27 |
def personalized_learning_assistant(topic):
|
28 |
examples = [
|
29 |
"Explain quantum mechanics. Example: Quantum mechanics is the study of particles at the atomic level.",
|
|
|
74 |
return call_groq_api(prompt)
|
75 |
|
76 |
# Define Streamlit app
|
77 |
+
st.set_page_config(page_title="EduNexus", page_icon=":book:", layout="wide")
|
78 |
+
|
79 |
+
# Add custom CSS for neon and animated design
|
80 |
+
st.markdown("""
|
81 |
+
<style>
|
82 |
+
body {
|
83 |
+
background: linear-gradient(45deg, #000428, #004e92);
|
84 |
+
color: #fff;
|
85 |
+
font-family: 'Arial', sans-serif;
|
86 |
+
overflow-x: hidden;
|
87 |
+
}
|
88 |
+
.neon-text {
|
89 |
+
font-size: 32px;
|
90 |
+
color: #00FF00;
|
91 |
+
text-shadow: 0 0 5px #00FF00, 0 0 10px #00FF00, 0 0 15px #00FF00, 0 0 20px #00FF00, 0 0 25px #00FF00;
|
92 |
+
margin-bottom: 20px;
|
93 |
+
}
|
94 |
+
.neon-border {
|
95 |
+
border: 2px solid #00FF00;
|
96 |
+
border-radius: 8px;
|
97 |
+
padding: 15px;
|
98 |
+
margin-bottom: 20px;
|
99 |
+
box-shadow: 0 0 15px #00FF00;
|
100 |
+
}
|
101 |
+
.animated-button {
|
102 |
+
animation: pulse 2s infinite;
|
103 |
+
background-color: #00FF00;
|
104 |
+
color: #000;
|
105 |
+
border: none;
|
106 |
+
border-radius: 8px;
|
107 |
+
padding: 10px 20px;
|
108 |
+
font-size: 16px;
|
109 |
+
cursor: pointer;
|
110 |
+
margin: 10px 0;
|
111 |
+
}
|
112 |
+
.animated-button:hover {
|
113 |
+
background-color: #00CC00;
|
114 |
+
}
|
115 |
+
@keyframes pulse {
|
116 |
+
0% { transform: scale(1); }
|
117 |
+
50% { transform: scale(1.05); }
|
118 |
+
100% { transform: scale(1); }
|
119 |
+
}
|
120 |
+
.input-container {
|
121 |
+
margin-bottom: 20px;
|
122 |
+
}
|
123 |
+
</style>
|
124 |
+
""", unsafe_allow_html=True)
|
125 |
+
|
126 |
+
# Title and introduction
|
127 |
st.title("EduNexus: The Ultimate AI-Powered Student Companion")
|
128 |
+
st.markdown("<div class='neon-text'>Welcome to EduNexus! Choose a tool below to get started.</div>", unsafe_allow_html=True)
|
129 |
+
|
130 |
+
# Define function to clear all inputs
|
131 |
+
def clear_chat():
|
132 |
+
st.session_state['personalized_learning_assistant'] = ""
|
133 |
+
st.session_state['ai_coding_mentor'] = ""
|
134 |
+
st.session_state['smart_document_summarizer'] = ""
|
135 |
+
st.session_state['interactive_study_planner'] = ""
|
136 |
+
st.session_state['real_time_qa_support'] = ""
|
137 |
+
st.session_state['mental_health_check_in'] = ""
|
138 |
+
|
139 |
+
# Add Clear Chat button
|
140 |
+
if st.button("Clear All", key="clear_button", css_class="animated-button"):
|
141 |
+
clear_chat()
|
142 |
|
143 |
# Personalized Learning Assistant
|
144 |
st.header("Personalized Learning Assistant")
|
145 |
+
with st.form(key="learning_form"):
|
146 |
+
topic_input = st.text_input("Enter a topic you want to learn about", key="topic_input", placeholder="e.g., Quantum Mechanics")
|
147 |
+
submit_button = st.form_submit_button("Generate Learning Material", key="learning_button", css_class="animated-button")
|
148 |
+
if submit_button:
|
149 |
+
if topic_input:
|
150 |
+
st.write(personalized_learning_assistant(topic_input))
|
151 |
+
else:
|
152 |
+
st.write("Please enter a topic.")
|
153 |
|
154 |
# AI Coding Mentor
|
155 |
st.header("AI Coding Mentor")
|
156 |
+
with st.form(key="coding_form"):
|
157 |
+
code_input = st.text_area("Paste your code snippet", key="code_input", placeholder="e.g., for i in range(10): print(i)")
|
158 |
+
submit_button = st.form_submit_button("Get Coding Assistance", key="coding_button", css_class="animated-button")
|
159 |
+
if submit_button:
|
160 |
+
if code_input:
|
161 |
+
st.write(ai_coding_mentor(code_input))
|
162 |
+
else:
|
163 |
+
st.write("Please paste your code snippet.")
|
164 |
|
165 |
# Smart Document Summarizer
|
166 |
st.header("Smart Document Summarizer")
|
167 |
+
with st.form(key="summary_form"):
|
168 |
+
doc_input = st.text_area("Paste the text of the document", key="doc_input", placeholder="e.g., Quantum computing is...")
|
169 |
+
submit_button = st.form_submit_button("Summarize Document", key="summary_button", css_class="animated-button")
|
170 |
+
if submit_button:
|
171 |
+
if doc_input:
|
172 |
+
st.write(smart_document_summarizer(doc_input))
|
173 |
+
else:
|
174 |
+
st.write("Please paste the document text.")
|
175 |
|
176 |
# Interactive Study Planner
|
177 |
st.header("Interactive Study Planner")
|
178 |
+
with st.form(key="plan_form"):
|
179 |
+
schedule_input = st.text_area("Enter your exam schedule or important dates", key="schedule_input", placeholder="e.g., 3 exams in a week")
|
180 |
+
submit_button = st.form_submit_button("Generate Study Plan", key="plan_button", css_class="animated-button")
|
181 |
+
if submit_button:
|
182 |
+
if schedule_input:
|
183 |
+
st.write(interactive_study_planner(schedule_input))
|
184 |
+
else:
|
185 |
+
st.write("Please enter your exam schedule.")
|
186 |
|
187 |
# Real-Time Q&A Support
|
188 |
st.header("Real-Time Q&A Support")
|
189 |
+
with st.form(key="qa_form"):
|
190 |
+
question_input = st.text_input("Ask any academic question", key="question_input", placeholder="e.g., What is Newton's second law?")
|
191 |
+
submit_button = st.form_submit_button("Get Answer", key="qa_button", css_class="animated-button")
|
192 |
+
if submit_button:
|
193 |
+
if question_input:
|
194 |
+
st.write(real_time_qa_support(question_input))
|
195 |
+
else:
|
196 |
+
st.write("Please ask a question.")
|
197 |
|
198 |
# Mental Health Check-In
|
199 |
st.header("Mental Health Check-In")
|
200 |
+
with st.form(key="checkin_form"):
|
201 |
+
feelings_input = st.text_area("How are you feeling?", key="feelings_input", placeholder="e.g., Stressed about exams")
|
202 |
+
submit_button = st.form_submit_button("Check In", key="checkin_button", css_class="animated-button")
|
203 |
+
if submit_button:
|
204 |
+
if feelings_input:
|
205 |
+
st.write(mental_health_check_in(feelings_input))
|
206 |
+
else:
|
207 |
+
st.write("Please describe your feelings.")
|