Spaces:
No application file
No application file
File size: 2,981 Bytes
26ce7c2 7863c7d 064ac70 26ce7c2 064ac70 e19314e 4cad79d 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 7863c7d 064ac70 7863c7d 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 064ac70 26ce7c2 |
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 |
import os
import streamlit as st
from deep_translator import GoogleTranslator
from groq import Client # Assuming correct Groq API client import
# Ensure the API key is set
API_KEY = os.environ.get("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")
if not API_KEY:
st.error("API key is missing. Please set the GROQ_API_KEY environment variable.")
st.stop()
# Initialize the Groq client
client = Client(api_key=API_KEY)
# Streamlit App
st.set_page_config(page_title="AI-Powered Opportunity Finder", layout="wide")
st.title("AI-Powered Opportunity Finder for Youth")
# Sidebar for inputs
st.sidebar.header("Provide your details to find opportunities")
interests = st.sidebar.text_input("Your Interests (e.g., AI, Robotics, Software Engineering):")
skills = st.sidebar.text_input("Your Skills (e.g., Python, Data Science, Web Development):")
location = st.sidebar.text_input("Your Location (e.g., Gujrat, Pakistan):")
# Language selection for translation
languages = {
"English": "en",
"Spanish": "es",
"French": "fr",
"German": "de",
"Italian": "it",
"Chinese": "zh-cn",
"Japanese": "ja",
"Urdu": "ur",
}
selected_language = st.sidebar.selectbox("Select your preferred language:", list(languages.keys()))
# Main functionality
def fetch_opportunities(user_interests, user_skills, user_location):
query = (
f"Based on the user's interests in {user_interests}, skills in {user_skills}, "
f"and location of {user_location}, find scholarships, internships, online courses, and career advice."
)
try:
response = client.chat.completions.create(
messages=[{"role": "user", "content": query}],
model="llama-3.3-70b-versatile",
)
return response.choices[0].message.content
except Exception as e:
st.error(f"Error fetching opportunities: {e}")
return None
def translate_text(text, target_language):
try:
translator = GoogleTranslator(target=target_language)
return translator.translate(text)
except Exception as e:
st.error(f"Error translating text: {e}")
return text
# Button to fetch opportunities
if st.sidebar.button("Find Opportunities"):
if interests and skills and location:
with st.spinner("Fetching opportunities..."):
opportunities = fetch_opportunities(interests, skills, location)
if opportunities:
translated_opportunities = translate_text(opportunities, languages[selected_language])
st.subheader("Recommended Opportunities")
st.write(translated_opportunities)
else:
st.sidebar.error("Please fill in all fields.")
# Footer
st.markdown("""
<footer style="text-align:center; padding: 20px; font-size: 1rem; background-color: #f0f0f5;">
<p>Powered by Groq, Google Translator, and Streamlit</p>
<p>Contact: [email protected]</p>
</footer>
""", unsafe_allow_html=True)
|