File size: 4,256 Bytes
ff81b3c
851c6af
 
ff81b3c
6c5bb66
ab78615
08caf0d
 
 
2b29334
08caf0d
 
 
 
 
 
 
 
 
 
 
ff81b3c
 
 
 
 
 
f0837ca
6c5bb66
 
fd6e650
6c5bb66
fd6e650
dc944de
995bd60
08caf0d
 
995bd60
08caf0d
 
 
 
 
 
 
 
 
995bd60
08caf0d
 
dc944de
08caf0d
 
 
 
dc944de
08caf0d
ff81b3c
fd6e650
 
 
 
 
 
 
 
 
 
08caf0d
f0837ca
08caf0d
 
851c6af
08caf0d
 
 
 
 
 
995bd60
6c5bb66
 
08caf0d
 
 
 
 
 
ff81b3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import streamlit as st
from groq import Groq
from googletrans import Translator
import asyncio

# Function to get recommendations from Groq AI based on user input
def get_opportunities(user_interests, user_skills, user_location):
    # Fetch the API key from the environment variable
    api_key = "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"
    
    if not api_key:
        raise ValueError("API key is missing. Make sure to set the GROQ_API_KEY environment variable.")
    
    # Initialize the Groq client with the API key
    client = Groq(api_key=api_key)
    
    # Construct the query
    query = f"Based on the user's interests in {user_interests}, skills in {user_skills}, and location of {user_location}, find scholarships, internships, online courses, and career advice suitable for them."
    
    # Request to Groq API
    response = client.chat.completions.create(
        messages=[{"role": "user", "content": query}],
        model="llama-3.3-70b-versatile",
    )
    
    return response.choices[0].message.content

# Function to translate text into the selected language (async version)
async def translate_text(text, target_language):
    translator = Translator()
    translated = await translator.translate(text, dest=target_language)
    return translated.text

# Streamlit App Interface
st.set_page_config(page_title="AI-Powered Opportunity Finder", page_icon=":bulb:", layout="wide")
st.title("AI-Powered Opportunity Finder for Youth")

# Custom CSS for improving the UI
st.markdown("""
    <style>
        .css-1v0mbdj {padding-top: 30px; font-size: 1.5rem;}
        .css-1wa3m6h {padding: 10px; background-color: #f0f0f5;}
        .css-1w4t6pm {border: 1px solid #ccc; padding: 10px; background-color: #fff;}
        .css-1f4y1re {font-size: 1.2rem;}
    </style>
""", unsafe_allow_html=True)

# Sidebar for input fields
st.sidebar.header("Provide your details to find opportunities")

# Collect user input for interests, skills, and location in the sidebar
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
languages = {
    "English": "English",
    "Spanish": "Spanish",
    "French": "French",
    "German": "German",
    "Italian": "Italian",
    "Chinese": "Chinese",
    "Japanese": "Japanese",
    "Urdu": "Urdu"  # Full word for Urdu
}

selected_language = st.sidebar.selectbox("Select your preferred language:", list(languages.keys()))

# Container to display results
results_container = st.container()

# Button to fetch opportunities
if st.sidebar.button("Find Opportunities"):
    if interests and skills and location:
        with st.spinner("Fetching opportunities..."):
            # Fetch recommendations using the Groq API
            opportunities = get_opportunities(interests, skills, location)
            
            # Run the async translate function and get the translated text
            translated_opportunities = asyncio.run(translate_text(opportunities, languages[selected_language]))
        
        # Display the opportunities
        results_container.subheader("Recommended Opportunities")
        results_container.write(translated_opportunities)
    else:
        st.sidebar.error("Please fill all fields.")

# Add a footer with contact info and clickable links
st.markdown("""
    <footer style="text-align:center; padding: 20px; font-size: 1rem; background-color: #f0f0f5;">
        <p>Powered by Groq, Google Translate, and Streamlit</p>
        <p>For more opportunities, visit:</p>
        <ul style="list-style-type:none; padding: 0;">
            <li><a href="https://www.groq.com" target="_blank">Groq - AI Solutions</a></li>
            <li><a href="https://www.scholarships.com" target="_blank">Scholarships.com</a></li>
            <li><a href="https://www.coursera.org" target="_blank">Coursera - Online Courses</a></li>
            <li><a href="https://www.linkedin.com/jobs" target="_blank">LinkedIn Jobs</a></li>
        </ul>
        <p>Contact: support@example.com</p>
    </footer>
""", unsafe_allow_html=True)