ibrahim313 commited on
Commit
f9abbe1
Β·
verified Β·
1 Parent(s): 5dc4f4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -31
app.py CHANGED
@@ -3,7 +3,7 @@ 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"] = "your_groq_api_key_here" # Replace with your actual API key
@@ -61,6 +61,9 @@ if 'responses' not in st.session_state:
61
  "mental_health_check_in": ""
62
  }
63
 
 
 
 
64
  # Add custom styling using Streamlit
65
  st.markdown("""
66
  <style>
@@ -143,50 +146,65 @@ tasks = [
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")
 
151
  if submit_button:
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")
160
- if submit_button:
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")
169
- if submit_button:
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")
178
- if submit_button:
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")
187
- if submit_button:
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")
@@ -197,9 +215,12 @@ elif selected_task == "🧠 Mental Health Check-In":
197
  submit_button = st.form_submit_button("Get Advice")
198
  with col2:
199
  clear_button = st.form_submit_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()
 
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"] = "your_groq_api_key_here" # Replace with your actual API key
 
61
  "mental_health_check_in": ""
62
  }
63
 
64
+ if 'clear_all' not in st.session_state:
65
+ st.session_state['clear_all'] = False
66
+
67
  # Add custom styling using Streamlit
68
  st.markdown("""
69
  <style>
 
146
  selected_task = st.sidebar.radio("Select a task", tasks)
147
 
148
  # Main layout based on selected task
149
+ def handle_task_form(task_key, prompt_function, input_label, response_key):
150
+ with st.form(key=f"{task_key}_form"):
151
+ user_input = st.text_area(input_label)
152
+ submit_button = st.form_submit_button("Get Response")
153
+ clear_button = st.form_submit_button("Clear")
154
+
155
  if submit_button:
156
+ response = prompt_function(user_input)
157
+ st.session_state['responses'][response_key] = response
158
  st.write(response)
159
+
160
+ if clear_button:
161
+ st.session_state['responses'][response_key] = ""
162
+ st.experimental_rerun()
163
+
164
+ if selected_task == "πŸ“š Personalized Learning Assistant":
165
+ st.header("Personalized Learning Assistant")
166
+ handle_task_form(
167
+ "personalized_learning_assistant",
168
+ personalized_learning_assistant,
169
+ "Enter the topic you want to learn about",
170
+ "personalized_learning_assistant"
171
+ )
172
 
173
  elif selected_task == "πŸ€– AI Coding Mentor":
174
  st.header("AI Coding Mentor")
175
+ handle_task_form(
176
+ "ai_coding_mentor",
177
+ ai_coding_mentor,
178
+ "Paste your code snippet here",
179
+ "ai_coding_mentor"
180
+ )
181
 
182
  elif selected_task == "πŸ“„ Smart Document Summarizer":
183
  st.header("Smart Document Summarizer")
184
+ handle_task_form(
185
+ "smart_document_summarizer",
186
+ smart_document_summarizer,
187
+ "Paste your document text here",
188
+ "smart_document_summarizer"
189
+ )
190
 
191
  elif selected_task == "πŸ—“οΈ Interactive Study Planner":
192
  st.header("Interactive Study Planner")
193
+ handle_task_form(
194
+ "interactive_study_planner",
195
+ interactive_study_planner,
196
+ "Enter your exam schedule here",
197
+ "interactive_study_planner"
198
+ )
199
 
200
  elif selected_task == "πŸ’¬ Real-Time Q&A Support":
201
  st.header("Real-Time Q&A Support")
202
+ handle_task_form(
203
+ "real_time_qa_support",
204
+ real_time_qa_support,
205
+ "Ask your academic question here",
206
+ "real_time_qa_support"
207
+ )
208
 
209
  elif selected_task == "🧠 Mental Health Check-In":
210
  st.header("Mental Health Check-In")
 
215
  submit_button = st.form_submit_button("Get Advice")
216
  with col2:
217
  clear_button = st.form_submit_button("Clear")
218
+
219
  if submit_button:
220
  response = mental_health_check_in(feelings)
221
+ st.session_state['responses']['mental_health_check_in'] = response
222
  st.write(response)
223
+
224
  if clear_button:
225
  st.session_state['responses']['mental_health_check_in'] = ""
226
  st.experimental_rerun()