Spaces:
Sleeping
Sleeping
File size: 10,344 Bytes
7688f19 7fd2fab ff92777 1dd4f83 f9abbe1 1dd4f83 ff92777 caefa3d ff92777 caefa3d ff92777 6cedbe6 ff92777 6cedbe6 ff92777 6cedbe6 ff92777 6cedbe6 ff92777 6cedbe6 ff92777 6cedbe6 ff92777 1dd4f83 ff92777 a96770a 2fe0e31 67f281c caefa3d 67f281c f9abbe1 92e3434 728986c 7fd2fab 4e0d894 7fd2fab f00f35c caefa3d 92e3434 4e0d894 7fd2fab 728986c 92e3434 4e0d894 7fd2fab 728986c 92e3434 4e0d894 7fd2fab c62cf6e 7688f19 c62cf6e 542e5e9 7688f19 caefa3d 1933a3f 4e0d894 7fd2fab 1933a3f 4e0d894 e5ec548 1933a3f 4e0d894 7fd2fab 1933a3f 4e0d894 1933a3f 7fd2fab 1933a3f f00f35c caefa3d 728986c 1dd4f83 120ab9c caefa3d 1dd4f83 4e0d894 caefa3d f9abbe1 caefa3d 4e0d894 1dd4f83 caefa3d 4e0d894 1dd4f83 caefa3d f00f35c caefa3d f00f35c caefa3d f00f35c caefa3d f00f35c 7688f19 a16cf0b f00f35c a16cf0b e5ec548 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
import streamlit as st
import os
from groq import Groq
# Set up page configuration
st.set_page_config(page_title="EduNexus", page_icon=":book:", layout="wide")
# Set the Groq API key
os.environ["GROQ_API_KEY"] = "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" # Replace with your actual API key
# Initialize Groq client
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
# Define the LLaMA model to be used
MODEL_NAME = "llama3-8b-8192"
# Function to call Groq API
def call_groq_api(prompt):
try:
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": prompt}],
model=MODEL_NAME
)
return chat_completion.choices[0].message.content
except Exception as e:
return f"Error: {str(e)}"
# Define functions for each tool with few-shot examples
def personalized_learning_assistant(topic):
prompt = f"""
Provide a personalized learning plan for the topic: {topic}.
Example 1: For 'Machine Learning': 'Create a plan with courses on supervised learning, unsupervised learning, and neural networks. Include practical exercises and projects.'
Example 2: For 'Data Science': 'Suggest a plan with a focus on data analysis, visualization, and statistical modeling. Recommend tools like Python, R, and SQL.'
Example 3: For 'Web Development': 'Outline a plan that covers front-end and back-end development, including HTML, CSS, JavaScript, and server-side technologies.'
Example 4: For '{topic}':"""
return call_groq_api(prompt)
def ai_coding_mentor(code_snippet):
prompt = f"""
Review this AI code snippet and provide suggestions or improvements:
{code_snippet}
Example 1: 'In the provided code, consider using a different activation function to improve performance.'
Example 2: 'The code can be optimized by reducing redundant calculations and enhancing readability.'
Example 3: 'Add comments to explain complex sections of the code for better understanding.'
Example 4: 'For the provided snippet, suggest improvements or fixes:'''
return call_groq_api(prompt)
def smart_document_summarizer(document_text):
prompt = f"""
Summarize the following document:
{document_text}
Example 1: 'The document discusses the impact of climate change on global agriculture, emphasizing the need for sustainable practices.'
Example 2: 'It provides an overview of recent advancements in AI technology and its applications in various fields.'
Example 3: 'The text outlines the historical development of renewable energy sources and their future potential.'
Example 4: 'Summarize this document:'''
return call_groq_api(prompt)
def interactive_study_planner(exam_schedule):
prompt = f"""
Create an interactive study plan based on this exam schedule:
{exam_schedule}
Example 1: 'For an exam schedule with subjects A, B, and C, create a plan that allocates study time for each subject and includes breaks.'
Example 2: 'Plan should include daily study goals and revision sessions leading up to the exams.'
Example 3: 'Suggest a study plan that balances subject preparation with relaxation to avoid burnout.'
Example 4: 'Based on the provided schedule, create a study plan:'''
return call_groq_api(prompt)
def real_time_qa_support(question):
prompt = f"""
Provide an answer to the following academic question:
{question}
Example 1: 'Question: What is the capital of France? Answer: Paris.'
Example 2: 'Question: Explain the theory of relativity. Answer: The theory of relativity, developed by Albert Einstein, includes two theories: special relativity and general relativity, explaining the relationship between space, time, and gravity.'
Example 3: 'Question: What is the process of photosynthesis? Answer: Photosynthesis is the process by which green plants use sunlight to synthesize foods with the help of chlorophyll, water, and carbon dioxide.'
Example 4: 'Answer this question:'''
return call_groq_api(prompt)
def mental_health_check_in(feelings):
prompt = f"""
Provide some advice based on these feelings:
{feelings}
Example 1: 'Feeling stressed? Try practicing mindfulness and deep breathing exercises to calm your mind.'
Example 2: 'If you're feeling anxious, consider talking to a trusted friend or counselor for support.'
Example 3: 'Feeling overwhelmed? Break your tasks into smaller steps and focus on completing them one at a time.'
Example 4: 'Based on these feelings, provide advice:'''
return call_groq_api(prompt)
# Initialize session state if not already set
if 'responses' not in st.session_state:
st.session_state['responses'] = {
"personalized_learning_assistant": "",
"ai_coding_mentor": "",
"smart_document_summarizer": "",
"interactive_study_planner": "",
"real_time_qa_support": "",
"mental_health_check_in": ""
}
# Function to clear session state values
def clear_session_state():
for key in st.session_state.keys():
if key.startswith('responses'):
st.session_state[key] = ""
if key in ['personalized_learning_assistant', 'ai_coding_mentor', 'smart_document_summarizer', 'interactive_study_planner', 'real_time_qa_support', 'mental_health_check_in']:
st.session_state[key] = ""
# Add custom styling using Streamlit
st.markdown("""
<style>
body {
background-color: #000000; /* Royal Black */
color: #ffffff; /* White */
}
.custom-class {
background-color: #000000; /* Royal Black */
color: #ffffff; /* White */
}
.stButton {
background-color: #ffffff; /* White */
color: #000000; /* Royal Black */
border-radius: 12px;
padding: 12px 24px;
font-size: 16px;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
transition: background-color 0.3s, box-shadow 0.3s;
}
.stButton:hover {
background-color: #d3d3d3; /* Light Gray */
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}
.stTextInput, .stTextArea {
border: 1px solid #ffffff; /* White */
border-radius: 12px;
background-color: #ffffff; /* White */
color: #000000; /* Royal Black */
}
.stTextInput::placeholder, .stTextArea::placeholder {
color: #000000; /* Royal Black */
font-weight: bold;
}
.stMarkdown, .stTextInput, .stTextArea {
border-radius: 12px;
}
.stSidebar {
background-color: #000000; /* Royal Black */
color: #ffffff; /* White */
}
.stSidebar .stMarkdown {
color: #ffffff; /* White */
}
.footer {
background-color: #000000; /* Royal Black */
padding: 15px;
text-align: center;
color: #ffffff; /* White */
border-top: 1px solid #ffffff; /* White */
position: fixed;
bottom: 0;
width: 100%;
}
.footer a {
color: #ffffff; /* White */
margin: 0 15px;
text-decoration: none;
font-size: 18px;
}
.footer a:hover {
color: #d3d3d3; /* Light Gray */
}
.footer i {
font-size: 22px;
}
.custom-placeholder {
color: #000000; /* Royal Black */
font-weight: bold;
}
</style>
""", unsafe_allow_html=True)
# Display main title
st.title("EduNexus")
# Sidebar with tasks
st.sidebar.title("Tasks")
tasks = [
"π Personalized Learning Assistant",
"π€ AI Coding Mentor",
"π Smart Document Summarizer",
"π Interactive Study Planner",
"β Real-Time Q&A Support",
"π¬ Mental Health Check-In"
]
selected_task = st.sidebar.radio("Select a task", tasks)
# Main content area based on selected task
st.header(f"Selected Task: {selected_task}")
if selected_task == "π Personalized Learning Assistant":
topic = st.text_input("Enter the topic for the learning plan:")
if st.button("Generate Learning Plan"):
st.session_state['responses']["personalized_learning_assistant"] = personalized_learning_assistant(topic)
st.write(st.session_state['responses']["personalized_learning_assistant"])
elif selected_task == "π€ AI Coding Mentor":
code_snippet = st.text_area("Paste your AI code snippet here:")
if st.button("Review Code"):
st.session_state['responses']["ai_coding_mentor"] = ai_coding_mentor(code_snippet)
st.write(st.session_state['responses']["ai_coding_mentor"])
elif selected_task == "π Smart Document Summarizer":
document_text = st.text_area("Paste your document text here:")
if st.button("Summarize Document"):
st.session_state['responses']["smart_document_summarizer"] = smart_document_summarizer(document_text)
st.write(st.session_state['responses']["smart_document_summarizer"])
elif selected_task == "π Interactive Study Planner":
exam_schedule = st.text_area("Enter your exam schedule here:")
if st.button("Create Study Plan"):
st.session_state['responses']["interactive_study_planner"] = interactive_study_planner(exam_schedule)
st.write(st.session_state['responses']["interactive_study_planner"])
elif selected_task == "β Real-Time Q&A Support":
question = st.text_input("Enter your academic question here:")
if st.button("Get Answer"):
st.session_state['responses']["real_time_qa_support"] = real_time_qa_support(question)
st.write(st.session_state['responses']["real_time_qa_support"])
elif selected_task == "π¬ Mental Health Check-In":
feelings = st.text_input("How are you feeling today?")
if st.button("Get Advice"):
st.session_state['responses']["mental_health_check_in"] = mental_health_check_in(feelings)
st.write(st.session_state['responses']["mental_health_check_in"])
# Add a footer with contact information
st.markdown("""
<div class="footer">
<a href="mailto:contact@edunexus.com"><i class="fa fa-envelope"></i> Contact</a>
<a href="https://www.edunexus.com"><i class="fa fa-globe"></i> Website</a>
<a href="https://www.linkedin.com/company/edunexus"><i class="fa fa-linkedin"></i> LinkedIn</a>
<a href="https://twitter.com/edunexus"><i class="fa fa-twitter"></i> Twitter</a>
</div>
""", unsafe_allow_html=True)
|