Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
|
2 |
# Set the Groq API key
|
3 |
os.environ["GROQ_API_KEY"] = "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"
|
@@ -5,11 +8,6 @@ os.environ["GROQ_API_KEY"] = "gsk_BYXg06vIXpWdFjwDMLnFWGdyb3FYjlovjvzUzo5jtu5A1I
|
|
5 |
# Initialize Groq client
|
6 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
7 |
|
8 |
-
import os
|
9 |
-
import streamlit as st
|
10 |
-
from groq import Groq
|
11 |
-
|
12 |
-
|
13 |
# Define the LLaMA model to be used
|
14 |
MODEL_NAME = "llama3-8b-8192"
|
15 |
|
@@ -80,26 +78,37 @@ st.set_page_config(page_title="EduNexus", page_icon=":book:", layout="wide")
|
|
80 |
# Add custom styling using Streamlit
|
81 |
st.markdown("""
|
82 |
<style>
|
83 |
-
.css-1o7k8tt {
|
84 |
-
background-color: #
|
85 |
color: #ffffff;
|
86 |
}
|
87 |
.css-1o7k8tt h1 {
|
88 |
-
color: #
|
89 |
}
|
90 |
.stButton {
|
91 |
-
background-color: #
|
92 |
color: #000000;
|
93 |
border-radius: 12px;
|
94 |
padding: 10px 20px;
|
95 |
font-size: 16px;
|
96 |
}
|
97 |
.stButton:hover {
|
98 |
-
background-color: #
|
99 |
}
|
100 |
.stTextInput, .stTextArea {
|
101 |
-
border: 1px solid #
|
102 |
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
104 |
</style>
|
105 |
""", unsafe_allow_html=True)
|
@@ -112,9 +121,10 @@ def clear_chat():
|
|
112 |
st.session_state['interactive_study_planner'] = ""
|
113 |
st.session_state['real_time_qa_support'] = ""
|
114 |
st.session_state['mental_health_check_in'] = ""
|
|
|
115 |
|
116 |
# Add Clear Chat button
|
117 |
-
if st.button("Clear All", key="clear_button"):
|
118 |
clear_chat()
|
119 |
|
120 |
# Navigation sidebar
|
@@ -126,6 +136,8 @@ selected_tool = st.sidebar.radio(
|
|
126 |
)
|
127 |
|
128 |
# Display tool based on selection
|
|
|
|
|
129 |
if selected_tool == "Personalized Learning Assistant":
|
130 |
st.header("Personalized Learning Assistant")
|
131 |
with st.form(key="learning_form"):
|
@@ -133,7 +145,9 @@ if selected_tool == "Personalized Learning Assistant":
|
|
133 |
submit_button = st.form_submit_button("Get Explanation")
|
134 |
if submit_button:
|
135 |
explanation = personalized_learning_assistant(topic_input)
|
|
|
136 |
st.write(explanation)
|
|
|
137 |
|
138 |
elif selected_tool == "AI Coding Mentor":
|
139 |
st.header("AI Coding Mentor")
|
@@ -142,7 +156,9 @@ elif selected_tool == "AI Coding Mentor":
|
|
142 |
submit_button = st.form_submit_button("Review Code")
|
143 |
if submit_button:
|
144 |
review = ai_coding_mentor(code_input)
|
|
|
145 |
st.write(review)
|
|
|
146 |
|
147 |
elif selected_tool == "Smart Document Summarizer":
|
148 |
st.header("Smart Document Summarizer")
|
@@ -151,32 +167,48 @@ elif selected_tool == "Smart Document Summarizer":
|
|
151 |
submit_button = st.form_submit_button("Summarize Document")
|
152 |
if submit_button:
|
153 |
summary = smart_document_summarizer(document_input)
|
|
|
154 |
st.write(summary)
|
|
|
155 |
|
156 |
elif selected_tool == "Interactive Study Planner":
|
157 |
st.header("Interactive Study Planner")
|
158 |
with st.form(key="planner_form"):
|
159 |
-
|
160 |
submit_button = st.form_submit_button("Generate Study Plan")
|
161 |
if submit_button:
|
162 |
-
|
163 |
-
st.
|
|
|
|
|
164 |
|
165 |
elif selected_tool == "Real-Time Q&A Support":
|
166 |
st.header("Real-Time Q&A Support")
|
167 |
with st.form(key="qa_form"):
|
168 |
-
question_input = st.text_input("
|
169 |
submit_button = st.form_submit_button("Get Answer")
|
170 |
if submit_button:
|
171 |
answer = real_time_qa_support(question_input)
|
|
|
172 |
st.write(answer)
|
|
|
173 |
|
174 |
elif selected_tool == "Mental Health Check-In":
|
175 |
st.header("Mental Health Check-In")
|
176 |
-
with st.form(key="
|
177 |
feelings_input = st.text_area("How are you feeling?", placeholder="e.g., Stressed about exams")
|
178 |
-
submit_button = st.form_submit_button("
|
179 |
if submit_button:
|
180 |
advice = mental_health_check_in(feelings_input)
|
|
|
181 |
st.write(advice)
|
|
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
from groq import Groq
|
4 |
|
5 |
# Set the Groq API key
|
6 |
os.environ["GROQ_API_KEY"] = "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"
|
|
|
8 |
# Initialize Groq client
|
9 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
# Define the LLaMA model to be used
|
12 |
MODEL_NAME = "llama3-8b-8192"
|
13 |
|
|
|
78 |
# Add custom styling using Streamlit
|
79 |
st.markdown("""
|
80 |
<style>
|
81 |
+
.css-1o7k8tt {
|
82 |
+
background-color: #1e1e2f;
|
83 |
color: #ffffff;
|
84 |
}
|
85 |
.css-1o7k8tt h1 {
|
86 |
+
color: #ff9a8b;
|
87 |
}
|
88 |
.stButton {
|
89 |
+
background-color: #ff9a8b;
|
90 |
color: #000000;
|
91 |
border-radius: 12px;
|
92 |
padding: 10px 20px;
|
93 |
font-size: 16px;
|
94 |
}
|
95 |
.stButton:hover {
|
96 |
+
background-color: #ff6f6f;
|
97 |
}
|
98 |
.stTextInput, .stTextArea {
|
99 |
+
border: 1px solid #ff9a8b;
|
100 |
border-radius: 8px;
|
101 |
+
background-color: #282c34;
|
102 |
+
color: #ffffff;
|
103 |
+
}
|
104 |
+
.stTextInput::placeholder, .stTextArea::placeholder {
|
105 |
+
color: #b0b0b0;
|
106 |
+
}
|
107 |
+
.stSidebar {
|
108 |
+
background-color: #2e2e3e;
|
109 |
+
}
|
110 |
+
.stSidebar .stMarkdown {
|
111 |
+
color: #ffffff;
|
112 |
}
|
113 |
</style>
|
114 |
""", unsafe_allow_html=True)
|
|
|
121 |
st.session_state['interactive_study_planner'] = ""
|
122 |
st.session_state['real_time_qa_support'] = ""
|
123 |
st.session_state['mental_health_check_in'] = ""
|
124 |
+
st.session_state['responses'] = {"personalized_learning_assistant": "", "ai_coding_mentor": "", "smart_document_summarizer": "", "interactive_study_planner": "", "real_time_qa_support": "", "mental_health_check_in": ""}
|
125 |
|
126 |
# Add Clear Chat button
|
127 |
+
if st.sidebar.button("Clear All", key="clear_button"):
|
128 |
clear_chat()
|
129 |
|
130 |
# Navigation sidebar
|
|
|
136 |
)
|
137 |
|
138 |
# Display tool based on selection
|
139 |
+
st.title("EduNexus :book:")
|
140 |
+
|
141 |
if selected_tool == "Personalized Learning Assistant":
|
142 |
st.header("Personalized Learning Assistant")
|
143 |
with st.form(key="learning_form"):
|
|
|
145 |
submit_button = st.form_submit_button("Get Explanation")
|
146 |
if submit_button:
|
147 |
explanation = personalized_learning_assistant(topic_input)
|
148 |
+
st.session_state['responses']['personalized_learning_assistant'] = explanation
|
149 |
st.write(explanation)
|
150 |
+
st.download_button("Download Response", explanation, file_name="explanation.txt")
|
151 |
|
152 |
elif selected_tool == "AI Coding Mentor":
|
153 |
st.header("AI Coding Mentor")
|
|
|
156 |
submit_button = st.form_submit_button("Review Code")
|
157 |
if submit_button:
|
158 |
review = ai_coding_mentor(code_input)
|
159 |
+
st.session_state['responses']['ai_coding_mentor'] = review
|
160 |
st.write(review)
|
161 |
+
st.download_button("Download Response", review, file_name="review.txt")
|
162 |
|
163 |
elif selected_tool == "Smart Document Summarizer":
|
164 |
st.header("Smart Document Summarizer")
|
|
|
167 |
submit_button = st.form_submit_button("Summarize Document")
|
168 |
if submit_button:
|
169 |
summary = smart_document_summarizer(document_input)
|
170 |
+
st.session_state['responses']['smart_document_summarizer'] = summary
|
171 |
st.write(summary)
|
172 |
+
st.download_button("Download Response", summary, file_name="summary.txt")
|
173 |
|
174 |
elif selected_tool == "Interactive Study Planner":
|
175 |
st.header("Interactive Study Planner")
|
176 |
with st.form(key="planner_form"):
|
177 |
+
exam_schedule_input = st.text_area("Enter your exam schedule", placeholder="e.g., 3 exams in one week")
|
178 |
submit_button = st.form_submit_button("Generate Study Plan")
|
179 |
if submit_button:
|
180 |
+
plan = interactive_study_planner(exam_schedule_input)
|
181 |
+
st.session_state['responses']['interactive_study_planner'] = plan
|
182 |
+
st.write(plan)
|
183 |
+
st.download_button("Download Response", plan, file_name="study_plan.txt")
|
184 |
|
185 |
elif selected_tool == "Real-Time Q&A Support":
|
186 |
st.header("Real-Time Q&A Support")
|
187 |
with st.form(key="qa_form"):
|
188 |
+
question_input = st.text_input("Enter your question", placeholder="e.g., What is Newton's third law of motion?")
|
189 |
submit_button = st.form_submit_button("Get Answer")
|
190 |
if submit_button:
|
191 |
answer = real_time_qa_support(question_input)
|
192 |
+
st.session_state['responses']['real_time_qa_support'] = answer
|
193 |
st.write(answer)
|
194 |
+
st.download_button("Download Response", answer, file_name="answer.txt")
|
195 |
|
196 |
elif selected_tool == "Mental Health Check-In":
|
197 |
st.header("Mental Health Check-In")
|
198 |
+
with st.form(key="mental_health_form"):
|
199 |
feelings_input = st.text_area("How are you feeling?", placeholder="e.g., Stressed about exams")
|
200 |
+
submit_button = st.form_submit_button("Get Advice")
|
201 |
if submit_button:
|
202 |
advice = mental_health_check_in(feelings_input)
|
203 |
+
st.session_state['responses']['mental_health_check_in'] = advice
|
204 |
st.write(advice)
|
205 |
+
st.download_button("Download Response", advice, file_name="advice.txt")
|
206 |
|
207 |
+
# Footer with acknowledgments
|
208 |
+
st.markdown("""
|
209 |
+
<footer style="background-color: #1e1e2f; padding: 10px; text-align: center; color: #ffffff;">
|
210 |
+
<p>© 2024 EduNexus. All Rights Reserved.</p>
|
211 |
+
<p>Created with ❤️ by [Your Name]</p>
|
212 |
+
<p><a href="mailto:[email protected]" style="color: #ff9a8b;">Contact Us</a></p>
|
213 |
+
</footer>
|
214 |
+
""", unsafe_allow_html=True)
|