ibrahim313 commited on
Commit
7fd2fab
·
verified ·
1 Parent(s): e5ec548

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -44
app.py CHANGED
@@ -1,9 +1,9 @@
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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"
7
 
8
  # Initialize Groq client
9
  client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
@@ -24,52 +24,27 @@ def call_groq_api(prompt):
24
 
25
  # Define functions for each tool
26
  def personalized_learning_assistant(topic):
27
- examples = [
28
- "Explain quantum mechanics with a real-world example.",
29
- "Describe general relativity and its significance.",
30
- "Provide a simple explanation of machine learning and its applications."
31
- ]
32
- prompt = f"Here are some example explanations:\n\n{examples}\n\nNow, explain the topic: {topic}. Provide a detailed, yet simple explanation with a practical example."
33
  return call_groq_api(prompt)
34
 
35
  def ai_coding_mentor(code_snippet):
36
- examples = [
37
- "Review this code snippet for optimization opportunities:\n\nCode: 'for i in range(10): print(i)'\nSuggestion: Use list comprehension for more efficient code.",
38
- "Analyze this code snippet for best practices:\n\nCode: 'def add(a, b): return a + b'\nSuggestion: Include type hints to improve readability and maintainability."
39
- ]
40
- prompt = f"Here are some code review examples:\n\n{examples}\n\nReview the following code snippet and provide suggestions for improvement:\n{code_snippet}. Include any potential issues or improvements."
41
  return call_groq_api(prompt)
42
 
43
  def smart_document_summarizer(document_text):
44
- examples = [
45
- "Summarize this text:\n\nText: 'Quantum computing represents a revolutionary approach to computing that leverages quantum mechanics.'\nSummary: 'Quantum computing uses quantum mechanics to advance computing technology.'",
46
- "Create a summary for this passage:\n\nText: 'The rise of electric vehicles is a major step towards reducing global carbon emissions and combating climate change.'\nSummary: 'Electric vehicles help reduce carbon emissions and fight climate change.'"
47
- ]
48
- prompt = f"Here are some document summarization examples:\n\n{examples}\n\nSummarize the following document text concisely:\n{document_text}. Focus on capturing the main points clearly."
49
  return call_groq_api(prompt)
50
 
51
  def interactive_study_planner(exam_schedule):
52
- examples = [
53
- "Generate a study plan for a schedule with multiple exams in a week:\n\nSchedule: '3 exams in one week'\nPlan: 'Allocate 2 hours per subject each day, with review sessions on weekends.'",
54
- "Create a study plan for preparing for exams over a period of 2 weeks:\n\nSchedule: 'Exams in 2 weeks'\nPlan: 'Prioritize subjects based on difficulty and importance, with daily reviews and mock tests.'"
55
- ]
56
- prompt = f"Here are some study planning examples:\n\n{examples}\n\nCreate a tailored study plan based on the following schedule:\n{exam_schedule}. Include daily study goals and break times."
57
  return call_groq_api(prompt)
58
 
59
  def real_time_qa_support(question):
60
- examples = [
61
- "Provide an answer to this question:\n\nQuestion: 'What is Newton's third law of motion?'\nAnswer: 'Newton's third law states that for every action, there is an equal and opposite reaction.'",
62
- "Explain this concept:\n\nQuestion: 'What is the principle of conservation of energy?'\nAnswer: 'The principle of conservation of energy states that energy cannot be created or destroyed, only transformed from one form to another.'"
63
- ]
64
- prompt = f"Here are some examples of answers to academic questions:\n\n{examples}\n\nAnswer the following question:\n{question}. Provide a clear and comprehensive explanation."
65
  return call_groq_api(prompt)
66
 
67
  def mental_health_check_in(feelings):
68
- examples = [
69
- "Offer advice for managing exam stress:\n\nFeeling: 'Stressed about upcoming exams'\nAdvice: 'Develop a study schedule, take regular breaks, and practice relaxation techniques.'",
70
- "Provide support for feeling overwhelmed:\n\nFeeling: 'Feeling overwhelmed with coursework'\nAdvice: 'Break tasks into smaller, manageable parts and seek support from peers or a counselor.'"
71
- ]
72
- prompt = f"Here are some examples of mental health advice:\n\n{examples}\n\nProvide advice based on the following feeling:\n{feelings}. Offer practical suggestions for improving well-being."
73
  return call_groq_api(prompt)
74
 
75
  # Initialize session state if not already set
@@ -83,11 +58,16 @@ if 'responses' not in st.session_state:
83
  "mental_health_check_in": ""
84
  }
85
 
 
86
  st.set_page_config(page_title="EduNexus", page_icon=":book:", layout="wide")
87
 
88
  # Add custom styling using Streamlit
89
  st.markdown("""
90
  <style>
 
 
 
 
91
  .css-1o7k8tt {
92
  background-color: #2f2f6f;
93
  color: #ffffff;
@@ -98,19 +78,20 @@ st.markdown("""
98
  .stButton {
99
  background-color: #d6a4a0;
100
  color: #ffffff;
101
- border-radius: 8px;
102
- padding: 10px 20px;
103
- font-size: 14px;
104
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
 
105
  }
106
  .stButton:hover {
107
  background-color: #b35b5b;
108
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
109
  }
110
  .stTextInput, .stTextArea {
111
  border: 1px solid #d6a4a0;
112
- border-radius: 8px;
113
- background-color: #1f1f2f;
114
  color: #ffffff;
115
  }
116
  .stTextInput::placeholder, .stTextArea::placeholder {
@@ -124,18 +105,18 @@ st.markdown("""
124
  }
125
  .footer {
126
  background-color: #2e2e3e;
127
- padding: 10px;
128
  text-align: center;
129
  color: #ffffff;
130
  border-top: 1px solid #d6a4a0;
131
  position: fixed;
132
  bottom: 0;
133
  width: 100%;
134
- box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.3);
135
  }
136
  .footer a {
137
  color: #d6a4a0;
138
- margin: 0 10px;
139
  text-decoration: none;
140
  font-size: 18px;
141
  }
@@ -143,7 +124,7 @@ st.markdown("""
143
  color: #ffffff;
144
  }
145
  .footer i {
146
- font-size: 20px;
147
  }
148
  </style>
149
  """, unsafe_allow_html=True)
 
 
1
  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"] = "your_groq_api_key_here" # Replace with your actual API key
7
 
8
  # Initialize Groq client
9
  client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
 
24
 
25
  # Define functions for each tool
26
  def personalized_learning_assistant(topic):
27
+ prompt = f"Provide a personalized learning plan for the topic: {topic}"
 
 
 
 
 
28
  return call_groq_api(prompt)
29
 
30
  def ai_coding_mentor(code_snippet):
31
+ prompt = f"Review this AI code snippet and provide suggestions or improvements:\n\n{code_snippet}"
 
 
 
 
32
  return call_groq_api(prompt)
33
 
34
  def smart_document_summarizer(document_text):
35
+ prompt = f"Summarize the following document:\n\n{document_text}"
 
 
 
 
36
  return call_groq_api(prompt)
37
 
38
  def interactive_study_planner(exam_schedule):
39
+ prompt = f"Create an interactive study plan based on this exam schedule:\n\n{exam_schedule}"
 
 
 
 
40
  return call_groq_api(prompt)
41
 
42
  def real_time_qa_support(question):
43
+ prompt = f"Provide an answer to the following academic question:\n\n{question}"
 
 
 
 
44
  return call_groq_api(prompt)
45
 
46
  def mental_health_check_in(feelings):
47
+ prompt = f"Provide some advice based on these feelings:\n\n{feelings}"
 
 
 
 
48
  return call_groq_api(prompt)
49
 
50
  # Initialize session state if not already set
 
58
  "mental_health_check_in": ""
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>
67
+ body {
68
+ background-color: #1e1e2d;
69
+ color: #e0e0e0;
70
+ }
71
  .css-1o7k8tt {
72
  background-color: #2f2f6f;
73
  color: #ffffff;
 
78
  .stButton {
79
  background-color: #d6a4a0;
80
  color: #ffffff;
81
+ border-radius: 12px;
82
+ padding: 12px 24px;
83
+ font-size: 16px;
84
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
85
+ transition: background-color 0.3s, box-shadow 0.3s;
86
  }
87
  .stButton:hover {
88
  background-color: #b35b5b;
89
+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
90
  }
91
  .stTextInput, .stTextArea {
92
  border: 1px solid #d6a4a0;
93
+ border-radius: 12px;
94
+ background-color: #2f2f4f;
95
  color: #ffffff;
96
  }
97
  .stTextInput::placeholder, .stTextArea::placeholder {
 
105
  }
106
  .footer {
107
  background-color: #2e2e3e;
108
+ padding: 15px;
109
  text-align: center;
110
  color: #ffffff;
111
  border-top: 1px solid #d6a4a0;
112
  position: fixed;
113
  bottom: 0;
114
  width: 100%;
115
+ box-shadow: 0 -6px 12px rgba(0, 0, 0, 0.4);
116
  }
117
  .footer a {
118
  color: #d6a4a0;
119
+ margin: 0 15px;
120
  text-decoration: none;
121
  font-size: 18px;
122
  }
 
124
  color: #ffffff;
125
  }
126
  .footer i {
127
+ font-size: 22px;
128
  }
129
  </style>
130
  """, unsafe_allow_html=True)