Akshayram1 commited on
Commit
49bd39d
Β·
verified Β·
1 Parent(s): d5effd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -22
app.py CHANGED
@@ -34,26 +34,82 @@ Link: {row['Link']}\n\n"""
34
  def get_rag_model():
35
  return genai.GenerativeModel('gemini-1.5-pro')
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  # Streamlit app
38
  def main():
39
- st.title("AI Scholarship Advisor πŸŽ“")
40
-
 
 
 
 
 
 
 
 
 
41
  # Load data and create RAG context
42
  df = load_scholarships()
43
  rag_context = create_rag_context(df)
44
-
45
  # User input form
46
  with st.form("profile_form"):
47
- st.header("Student Profile")
48
- age = st.number_input("Age", 16, 50, 20)
49
- citizenship = st.selectbox("Citizenship", ["India", "Other"])
50
- income = st.number_input("Annual Family Income (β‚Ή)", 0, 10000000, 300000)
51
- education = st.selectbox("Education Level",
52
- ["High School", "Undergraduate", "Postgraduate", "PhD"])
53
- category = st.selectbox("Category",
54
- ["General", "OBC", "SC", "ST", "EWS", "Minority"])
 
 
 
55
 
56
- submitted = st.form_submit_button("Get Recommendations")
57
 
58
  if submitted:
59
  # Create user profile
@@ -65,14 +121,14 @@ def main():
65
  - Education Level: {education}
66
  - Category: {category}
67
  """
68
-
69
  # Generate response using RAG
70
  model = get_rag_model()
71
  prompt = f"""
72
  {rag_context}
73
-
74
  {user_profile}
75
-
76
  Task:
77
  1. Analyze the student profile against all scholarships
78
  2. Identify top 5 most relevant scholarships with priority order
@@ -81,14 +137,14 @@ def main():
81
  - Explain why it's a good match
82
  - Provide direct application link
83
  4. Format response with markdown headers and bullet points
84
-
85
  Important:
86
  - Be specific about eligibility matches
87
  - Highlight deadlines if available
88
  - Never invent scholarships not in the database
89
  """
90
-
91
- with st.spinner("Analyzing 50+ scholarships..."):
92
  response = model.generate_content(
93
  prompt,
94
  generation_config=GenerationConfig(
@@ -97,12 +153,13 @@ def main():
97
  max_output_tokens=2000
98
  )
99
  )
100
-
101
- st.subheader("Personalized Recommendations")
 
102
  st.markdown(response.text)
103
-
104
  # Show raw data for transparency
105
- with st.expander("View Full Scholarship Database"):
106
  st.dataframe(df)
107
 
108
  if __name__ == "__main__":
 
34
  def get_rag_model():
35
  return genai.GenerativeModel('gemini-1.5-pro')
36
 
37
+ # Custom CSS for styling
38
+ def load_css():
39
+ st.markdown("""
40
+ <style>
41
+ .stApp {
42
+ background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
43
+ }
44
+ .stHeader {
45
+ color: #2c3e50;
46
+ font-size: 2.5rem;
47
+ font-weight: bold;
48
+ }
49
+ .stForm {
50
+ background: white;
51
+ padding: 20px;
52
+ border-radius: 10px;
53
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
54
+ }
55
+ .stButton button {
56
+ background-color: #3498db;
57
+ color: white;
58
+ border-radius: 5px;
59
+ padding: 10px 20px;
60
+ font-size: 1rem;
61
+ border: none;
62
+ }
63
+ .stButton button:hover {
64
+ background-color: #2980b9;
65
+ }
66
+ .stMarkdown h3 {
67
+ color: #2c3e50;
68
+ margin-top: 20px;
69
+ }
70
+ .stExpander {
71
+ background: white;
72
+ border-radius: 10px;
73
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
74
+ }
75
+ .stDataFrame {
76
+ border-radius: 10px;
77
+ }
78
+ </style>
79
+ """, unsafe_allow_html=True)
80
+
81
  # Streamlit app
82
  def main():
83
+ # Load custom CSS
84
+ load_css()
85
+
86
+ # Hero Section
87
+ st.markdown("""
88
+ <div style="text-align: center; padding: 50px 0;">
89
+ <h1 style="color: #2c3e50; font-size: 3rem;">πŸŽ“ AI Scholarship Advisor</h1>
90
+ <p style="color: #34495e; font-size: 1.2rem;">Find the best scholarships tailored just for you!</p>
91
+ </div>
92
+ """, unsafe_allow_html=True)
93
+
94
  # Load data and create RAG context
95
  df = load_scholarships()
96
  rag_context = create_rag_context(df)
97
+
98
  # User input form
99
  with st.form("profile_form"):
100
+ st.markdown("### πŸ“ Student Profile")
101
+ col1, col2 = st.columns(2)
102
+ with col1:
103
+ age = st.number_input("Age", 16, 50, 20)
104
+ citizenship = st.selectbox("Citizenship", ["India", "Other"])
105
+ income = st.number_input("Annual Family Income (β‚Ή)", 0, 10000000, 300000)
106
+ with col2:
107
+ education = st.selectbox("Education Level",
108
+ ["High School", "Undergraduate", "Postgraduate", "PhD"])
109
+ category = st.selectbox("Category",
110
+ ["General", "OBC", "SC", "ST", "EWS", "Minority"])
111
 
112
+ submitted = st.form_submit_button("πŸš€ Get Recommendations")
113
 
114
  if submitted:
115
  # Create user profile
 
121
  - Education Level: {education}
122
  - Category: {category}
123
  """
124
+
125
  # Generate response using RAG
126
  model = get_rag_model()
127
  prompt = f"""
128
  {rag_context}
129
+
130
  {user_profile}
131
+
132
  Task:
133
  1. Analyze the student profile against all scholarships
134
  2. Identify top 5 most relevant scholarships with priority order
 
137
  - Explain why it's a good match
138
  - Provide direct application link
139
  4. Format response with markdown headers and bullet points
140
+
141
  Important:
142
  - Be specific about eligibility matches
143
  - Highlight deadlines if available
144
  - Never invent scholarships not in the database
145
  """
146
+
147
+ with st.spinner("πŸ” Analyzing 50+ scholarships..."):
148
  response = model.generate_content(
149
  prompt,
150
  generation_config=GenerationConfig(
 
153
  max_output_tokens=2000
154
  )
155
  )
156
+
157
+ # Display recommendations
158
+ st.markdown("### πŸŽ‰ Personalized Recommendations")
159
  st.markdown(response.text)
160
+
161
  # Show raw data for transparency
162
+ with st.expander("πŸ“Š View Full Scholarship Database"):
163
  st.dataframe(df)
164
 
165
  if __name__ == "__main__":