Spaces:
Running
Running
import streamlit as st | |
import os | |
from groq import Groq | |
# Function to get recommendations from Groq AI based on user input | |
def get_opportunities(user_interests, user_skills, user_location): | |
# Initialize Groq client using API key from environment variable | |
client = Groq(api_key="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") | |
# Call Groq's recommendation system (chat API or similar) | |
response = client.chat.completions.create( | |
messages=[{ | |
"role": "user", | |
"content": f"Find me opportunities like scholarships, internships, online courses, and career advice based on my interests: {user_interests}, skills: {user_skills}, and location: {user_location}" | |
}], | |
model="llama-3.3-70b-versatile", # You can adjust the model if needed | |
) | |
return response.choices[0].message.content | |
# Streamlit App Interface | |
st.title("AI-Powered Opportunity Finder for Youth") | |
# Collect user input for interests, skills, and location | |
interests = st.text_input("Enter your interests (e.g., AI, Robotics, Software Engineering):") | |
skills = st.text_input("Enter your skills (e.g., Python, Data Science, Web Development):") | |
location = st.text_input("Enter your location (e.g., Gujrat, Pakistan):") | |
# Button to fetch opportunities | |
if st.button("Find Opportunities"): | |
if interests and skills and location: | |
# Fetch recommendations using the Groq API | |
opportunities = get_opportunities(interests, skills, location) | |
# Display the opportunities | |
st.subheader("Recommended Opportunities") | |
st.write(opportunities) | |
else: | |
st.error("Please fill all fields.") | |