Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,90 +1,51 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
st.write("Find Scholarships, Internships, Online Courses, and more!")
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
headers = {
|
12 |
-
"Authorization": "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", # Replace with your actual API key
|
13 |
-
}
|
14 |
-
|
15 |
-
# Define the query parameters
|
16 |
-
params = {
|
17 |
-
"location": location,
|
18 |
-
"interests": interests,
|
19 |
-
}
|
20 |
-
|
21 |
-
# Send GET request to the Groq API (Use your specific endpoint from Groq's API)
|
22 |
-
response = requests.get("https://api.groq.ai/scholarships", headers=headers, params=params)
|
23 |
-
|
24 |
-
if response.status_code == 200:
|
25 |
-
return response.json() # This assumes the response is a list of scholarships in JSON format
|
26 |
-
else:
|
27 |
-
st.error(f"Error fetching scholarships: {response.status_code}")
|
28 |
-
return []
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
-
#
|
38 |
-
|
39 |
-
"location": location,
|
40 |
-
"interests": interests,
|
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 |
-
st.write("No scholarships found based on your criteria.")
|
71 |
-
|
72 |
-
# Fetch internships based on user input
|
73 |
-
internships = get_internships(location, interests)
|
74 |
-
|
75 |
-
# Display internships if available
|
76 |
-
if internships:
|
77 |
-
st.write("Internships found:")
|
78 |
-
for internship in internships:
|
79 |
-
st.write(f"Title: {internship['jobtitle']}")
|
80 |
-
st.write(f"Company: {internship['company']}")
|
81 |
-
st.write(f"Location: {internship['location']}")
|
82 |
-
st.write(f"Snippet: {internship['snippet']}")
|
83 |
-
st.write("---")
|
84 |
-
else:
|
85 |
-
st.write("No internships found.")
|
86 |
-
|
87 |
-
# AI-based recommendations (can use Groq API or other AI methods)
|
88 |
-
if st.sidebar.button("Get AI Recommendations"):
|
89 |
-
# Example AI recommendation logic (replace with actual Groq API or custom logic)
|
90 |
-
st.write("AI Recommendations coming soon...")
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
+
# Initialize the language model (Hugging Face's pre-trained model for text generation)
|
6 |
+
generator = pipeline('text-generation', model='gpt-2') # You can choose any suitable language model
|
|
|
7 |
|
8 |
+
# Title and Description of the App
|
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 |
+
# Parse and display the generated text
|
26 |
+
recommendations = response[0]['generated_text']
|
27 |
|
28 |
+
# Display the generated recommendations
|
29 |
+
st.write("Recommended Opportunities based on your input:")
|
30 |
+
st.write(recommendations)
|
31 |
+
|
32 |
+
# Example to further integrate Groq API (if you need more personalized results)
|
33 |
+
# You can replace the following code with an actual API request to Groq for more detailed results
|
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 |
+
if api_response.status_code == 200:
|
43 |
+
api_recommendations = api_response.json()
|
44 |
+
st.write("Groq API Recommendations:")
|
45 |
+
for rec in api_recommendations:
|
46 |
+
st.write(f"- {rec['title']}: {rec['link']}")
|
47 |
+
else:
|
48 |
+
st.write("Unable to fetch recommendations from Groq API.")
|
49 |
+
|
50 |
+
except Exception as e:
|
51 |
+
st.write(f"Error while fetching recommendations from Groq API: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|