saherPervaiz commited on
Commit
995bd60
·
verified ·
1 Parent(s): 3990d00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -21
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import asyncio
 
2
  import streamlit as st
3
  from googletrans import Translator
4
  from groq import Groq
5
- import os
6
 
7
  # Initialize the Groq API client
8
  client = Groq(api_key="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")
@@ -34,17 +34,31 @@ async def get_translated_opportunities(opportunities, selected_language):
34
 
35
  return translated_opportunities
36
 
37
- # Main Streamlit UI code
38
  def main():
39
- st.title("Opportunity Finder for Youth")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- # User input for interests, skills, and location
42
- interests = st.text_input("Enter your interests (e.g., technology, science)")
43
- skills = st.text_input("Enter your skills (e.g., coding, research)")
44
- location = st.text_input("Enter your location (e.g., Lahore, Pakistan)")
45
 
46
- # Dropdown to select language
47
- language_options = {
48
  "English": "English",
49
  "Spanish": "Spanish",
50
  "French": "French",
@@ -55,22 +69,42 @@ def main():
55
  "Urdu": "Urdu" # Full word for Urdu
56
  }
57
 
58
- selected_language = st.selectbox("Select your language", list(language_options.keys()))
59
 
60
- # Fetch opportunities based on user input
61
- if st.button("Find Opportunities"):
62
- if interests and skills and location:
63
- opportunities = get_opportunities(interests, skills, location)
64
-
65
- # Async translation of opportunities
66
- translated_opportunities = asyncio.run(get_translated_opportunities(opportunities, language_options[selected_language]))
67
 
68
- # Display translated opportunities
69
- st.subheader(f"Opportunities in {selected_language}:")
 
 
 
 
 
 
 
 
 
 
70
  for opportunity_type, translated_text in translated_opportunities.items():
71
- st.markdown(f"**{opportunity_type.capitalize()}**: {translated_text}")
72
  else:
73
- st.error("Please fill out all fields (interests, skills, location) to get recommendations.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  # Run the app
76
  if __name__ == "__main__":
 
1
  import asyncio
2
+ import os
3
  import streamlit as st
4
  from googletrans import Translator
5
  from groq import Groq
 
6
 
7
  # Initialize the Groq API client
8
  client = Groq(api_key="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")
 
34
 
35
  return translated_opportunities
36
 
37
+ # Streamlit App Interface
38
  def main():
39
+ st.set_page_config(page_title="AI-Powered Opportunity Finder", page_icon=":bulb:", layout="wide")
40
+ st.title("AI-Powered Opportunity Finder for Youth")
41
+
42
+ # Custom CSS for improving the UI
43
+ st.markdown("""
44
+ <style>
45
+ .css-1v0mbdj {padding-top: 30px; font-size: 1.5rem;}
46
+ .css-1wa3m6h {padding: 10px; background-color: #f0f0f5;}
47
+ .css-1w4t6pm {border: 1px solid #ccc; padding: 10px; background-color: #fff;}
48
+ .css-1f4y1re {font-size: 1.2rem;}
49
+ </style>
50
+ """, unsafe_allow_html=True)
51
+
52
+ # Sidebar for input fields
53
+ st.sidebar.header("Provide your details to find opportunities")
54
 
55
+ # Collect user input for interests, skills, and location in the sidebar
56
+ interests = st.sidebar.text_input("Your Interests (e.g., AI, Robotics, Software Engineering):")
57
+ skills = st.sidebar.text_input("Your Skills (e.g., Python, Data Science, Web Development):")
58
+ location = st.sidebar.text_input("Your Location (e.g., Gujrat, Pakistan):")
59
 
60
+ # Language selection
61
+ languages = {
62
  "English": "English",
63
  "Spanish": "Spanish",
64
  "French": "French",
 
69
  "Urdu": "Urdu" # Full word for Urdu
70
  }
71
 
72
+ selected_language = st.sidebar.selectbox("Select your preferred language:", list(languages.keys()))
73
 
74
+ # Container to display results
75
+ results_container = st.container()
 
 
 
 
 
76
 
77
+ # Button to fetch opportunities
78
+ if st.sidebar.button("Find Opportunities"):
79
+ if interests and skills and location:
80
+ with st.spinner("Fetching opportunities..."):
81
+ # Fetch recommendations using the Groq API
82
+ opportunities = get_opportunities(interests, skills, location)
83
+
84
+ # Async translation of opportunities
85
+ translated_opportunities = asyncio.run(get_translated_opportunities(opportunities, languages[selected_language]))
86
+
87
+ # Display the opportunities
88
+ results_container.subheader(f"Recommended Opportunities in {selected_language}")
89
  for opportunity_type, translated_text in translated_opportunities.items():
90
+ results_container.markdown(f"**{opportunity_type.capitalize()}**: {translated_text}")
91
  else:
92
+ st.sidebar.error("Please fill all fields.")
93
+
94
+ # Add a footer with contact info and clickable links
95
+ st.markdown("""
96
+ <footer style="text-align:center; padding: 20px; font-size: 1rem; background-color: #f0f0f5;">
97
+ <p>Powered by Groq, Google Translate, and Streamlit</p>
98
+ <p>For more opportunities, visit:</p>
99
+ <ul style="list-style-type:none; padding: 0;">
100
+ <li><a href="https://www.groq.com" target="_blank">Groq - AI Solutions</a></li>
101
+ <li><a href="https://www.scholarships.com" target="_blank">Scholarships.com</a></li>
102
+ <li><a href="https://www.coursera.org" target="_blank">Coursera - Online Courses</a></li>
103
+ <li><a href="https://www.linkedin.com/jobs" target="_blank">LinkedIn Jobs</a></li>
104
+ </ul>
105
+ <p>Contact: support@example.com</p>
106
+ </footer>
107
+ """, unsafe_allow_html=True)
108
 
109
  # Run the app
110
  if __name__ == "__main__":