Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,51 +1,39 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
from
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
st.title("AI-powered Opportunity Finder for Youth")
|
10 |
-
st.write("Find scholarships, internships, competitions, and more based on your skills and interests using AI!")
|
11 |
-
|
12 |
-
# Collect user input
|
13 |
-
interests = st.text_input("Enter your interests (e.g., AI, web development, etc.)")
|
14 |
-
skills = st.text_input("Enter your skills (e.g., Python, Data Analysis, etc.)")
|
15 |
-
location = st.text_input("Enter your location")
|
16 |
-
|
17 |
-
# Button to trigger the AI recommendations
|
18 |
-
if st.button("Find Opportunities"):
|
19 |
-
# Combine the input into a prompt for the language model
|
20 |
-
prompt = f"Find scholarships, internships, competitions, and online courses for a person interested in {interests}, skilled in {skills}, and located in {location}. Provide recommendations with details like title, link, and description."
|
21 |
-
|
22 |
-
# Use the language model to generate recommendations
|
23 |
-
response = generator(prompt, max_length=150, num_return_sequences=1)
|
24 |
|
25 |
-
#
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
-
st.write("Recommended Opportunities based on your input:")
|
30 |
-
st.write(recommendations)
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
# Make sure to replace the placeholder with your Groq API endpoint and parameters
|
35 |
-
try:
|
36 |
-
api_response = requests.post("https://api.groq.com/recommendations", json={
|
37 |
-
"interests": interests,
|
38 |
-
"skills": skills,
|
39 |
-
"location": location
|
40 |
-
})
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
st.write(f"- {rec['title']}: {rec['link']}")
|
47 |
-
else:
|
48 |
-
st.write("Unable to fetch recommendations from Groq API.")
|
49 |
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import os
|
3 |
+
from groq import Groq
|
4 |
|
5 |
+
# Function to get recommendations from Groq AI based on user input
|
6 |
+
def get_opportunities(user_interests, user_skills, user_location):
|
7 |
+
# Initialize Groq client using API key from environment variable
|
8 |
+
client = Groq(api_key=os.environ.get("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"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
# Call Groq's recommendation system (chat API or similar)
|
11 |
+
response = client.chat.completions.create(
|
12 |
+
messages=[{
|
13 |
+
"role": "user",
|
14 |
+
"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}"
|
15 |
+
}],
|
16 |
+
model="llama-3.3-70b-versatile", # You can adjust the model if needed
|
17 |
+
)
|
18 |
|
19 |
+
return response.choices[0].message.content
|
|
|
|
|
20 |
|
21 |
+
# Streamlit App Interface
|
22 |
+
st.title("AI-Powered Opportunity Finder for Youth")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
# Collect user input for interests, skills, and location
|
25 |
+
interests = st.text_input("Enter your interests (e.g., AI, Robotics, Software Engineering):")
|
26 |
+
skills = st.text_input("Enter your skills (e.g., Python, Data Science, Web Development):")
|
27 |
+
location = st.text_input("Enter your location (e.g., Gujrat, Pakistan):")
|
|
|
|
|
|
|
28 |
|
29 |
+
# Button to fetch opportunities
|
30 |
+
if st.button("Find Opportunities"):
|
31 |
+
if interests and skills and location:
|
32 |
+
# Fetch recommendations using the Groq API
|
33 |
+
opportunities = get_opportunities(interests, skills, location)
|
34 |
+
|
35 |
+
# Display the opportunities
|
36 |
+
st.subheader("Recommended Opportunities")
|
37 |
+
st.write(opportunities)
|
38 |
+
else:
|
39 |
+
st.error("Please fill all fields.")
|