Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
-
import
|
2 |
import streamlit as st
|
3 |
-
from googletrans import Translator
|
4 |
from groq import Groq
|
5 |
-
import
|
6 |
|
7 |
# Function to get recommendations from Groq AI based on user input
|
8 |
def get_opportunities(user_interests, user_skills, user_location):
|
@@ -19,23 +18,12 @@ def get_opportunities(user_interests, user_skills, user_location):
|
|
19 |
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."
|
20 |
|
21 |
# Request to Groq API
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
# Debugging: Check the response
|
29 |
-
st.write(response) # Display the raw response for debugging
|
30 |
-
|
31 |
-
if response and hasattr(response, 'choices') and response.choices:
|
32 |
-
content = response.choices[0].message.content
|
33 |
-
return content
|
34 |
-
else:
|
35 |
-
return "Sorry, no opportunities found at the moment."
|
36 |
-
except Exception as e:
|
37 |
-
st.error(f"Error while fetching data: {e}")
|
38 |
-
return "Sorry, we encountered an issue fetching the data."
|
39 |
|
40 |
# Function to translate text into the selected language
|
41 |
def translate_text(text, target_language):
|
@@ -66,7 +54,7 @@ skills = st.sidebar.text_input("Your Skills (e.g., Python, Data Science, Web Dev
|
|
66 |
location = st.sidebar.text_input("Your Location (e.g., Gujrat, Pakistan):")
|
67 |
|
68 |
# Language selection
|
69 |
-
languages =
|
70 |
"English": "English",
|
71 |
"Spanish": "Spanish",
|
72 |
"French": "French",
|
@@ -89,10 +77,6 @@ if st.sidebar.button("Find Opportunities"):
|
|
89 |
# Fetch recommendations using the Groq API
|
90 |
opportunities = get_opportunities(interests, skills, location)
|
91 |
|
92 |
-
# Display the raw opportunities for debugging
|
93 |
-
st.subheader("Raw Opportunities Data:")
|
94 |
-
st.write(opportunities) # Display raw data
|
95 |
-
|
96 |
# Translate the opportunities based on the selected language
|
97 |
translated_opportunities = translate_text(opportunities, languages[selected_language])
|
98 |
|
@@ -101,3 +85,18 @@ if st.sidebar.button("Find Opportunities"):
|
|
101 |
results_container.write(translated_opportunities)
|
102 |
else:
|
103 |
st.sidebar.error("Please fill all fields.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
|
|
3 |
from groq import Groq
|
4 |
+
from googletrans import Translator
|
5 |
|
6 |
# Function to get recommendations from Groq AI based on user input
|
7 |
def get_opportunities(user_interests, user_skills, user_location):
|
|
|
18 |
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."
|
19 |
|
20 |
# Request to Groq API
|
21 |
+
response = client.chat.completions.create(
|
22 |
+
messages=[{"role": "user", "content": query}],
|
23 |
+
model="llama-3.3-70b-versatile",
|
24 |
+
)
|
25 |
+
|
26 |
+
return response.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
# Function to translate text into the selected language
|
29 |
def translate_text(text, target_language):
|
|
|
54 |
location = st.sidebar.text_input("Your Location (e.g., Gujrat, Pakistan):")
|
55 |
|
56 |
# Language selection
|
57 |
+
languages = {
|
58 |
"English": "English",
|
59 |
"Spanish": "Spanish",
|
60 |
"French": "French",
|
|
|
77 |
# Fetch recommendations using the Groq API
|
78 |
opportunities = get_opportunities(interests, skills, location)
|
79 |
|
|
|
|
|
|
|
|
|
80 |
# Translate the opportunities based on the selected language
|
81 |
translated_opportunities = translate_text(opportunities, languages[selected_language])
|
82 |
|
|
|
85 |
results_container.write(translated_opportunities)
|
86 |
else:
|
87 |
st.sidebar.error("Please fill all fields.")
|
88 |
+
|
89 |
+
# Add a footer with contact info and clickable links
|
90 |
+
st.markdown("""
|
91 |
+
<footer style="text-align:center; padding: 20px; font-size: 1rem; background-color: #f0f0f5;">
|
92 |
+
<p>Powered by Groq, Google Translate, and Streamlit</p>
|
93 |
+
<p>For more opportunities, visit:</p>
|
94 |
+
<ul style="list-style-type:none; padding: 0;">
|
95 |
+
<li><a href="https://www.groq.com" target="_blank">Groq - AI Solutions</a></li>
|
96 |
+
<li><a href="https://www.scholarships.com" target="_blank">Scholarships.com</a></li>
|
97 |
+
<li><a href="https://www.coursera.org" target="_blank">Coursera - Online Courses</a></li>
|
98 |
+
<li><a href="https://www.linkedin.com/jobs" target="_blank">LinkedIn Jobs</a></li>
|
99 |
+
</ul>
|
100 |
+
<p>Contact: support@example.com</p>
|
101 |
+
</footer>
|
102 |
+
""", unsafe_allow_html=True)
|