Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
import
|
| 3 |
from groq import Groq
|
| 4 |
from googletrans import Translator
|
| 5 |
import asyncio
|
|
@@ -51,84 +51,79 @@ def get_chatbot_response(user_message):
|
|
| 51 |
|
| 52 |
return response.choices[0].message.content
|
| 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 |
-
# Container to display results
|
| 91 |
-
results_container = st.container()
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
|
|
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
|
| 107 |
-
results_container.subheader("Recommended Opportunities")
|
| 108 |
-
results_container.write(translated_opportunities)
|
| 109 |
-
else:
|
| 110 |
-
st.sidebar.error("Please fill all fields.")
|
| 111 |
|
| 112 |
-
#
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
chatbot_response = get_chatbot_response(user_message)
|
| 119 |
-
st.write(f"**Chatbot Response**: {chatbot_response}")
|
| 120 |
|
| 121 |
-
#
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
<p>Powered by Groq, Google Translate, and Streamlit</p>
|
| 125 |
-
<p>For more opportunities, visit:</p>
|
| 126 |
-
<ul style="list-style-type:none; padding: 0;">
|
| 127 |
-
<li><a href="https://www.groq.com" target="_blank">Groq - AI Solutions</a></li>
|
| 128 |
-
<li><a href="https://www.scholarships.com" target="_blank">Scholarships.com</a></li>
|
| 129 |
-
<li><a href="https://www.coursera.org" target="_blank">Coursera - Online Courses</a></li>
|
| 130 |
-
<li><a href="https://www.linkedin.com/jobs" target="_blank">LinkedIn Jobs</a></li>
|
| 131 |
-
</ul>
|
| 132 |
-
<p>Contact: support@example.com</p>
|
| 133 |
-
</footer>
|
| 134 |
-
""", unsafe_allow_html=True)
|
|
|
|
| 1 |
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
from groq import Groq
|
| 4 |
from googletrans import Translator
|
| 5 |
import asyncio
|
|
|
|
| 51 |
|
| 52 |
return response.choices[0].message.content
|
| 53 |
|
| 54 |
+
# Gradio interface
|
| 55 |
+
with gr.Blocks(css="""
|
| 56 |
+
.gradio-container {
|
| 57 |
+
background-color: #f0f0f5;
|
| 58 |
+
color: #333;
|
| 59 |
+
font-family: 'Roboto', sans-serif;
|
| 60 |
+
padding: 20px;
|
| 61 |
+
border-radius: 10px;
|
| 62 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 63 |
+
}
|
| 64 |
+
.gradio-container .button {
|
| 65 |
+
background-color: #007bff;
|
| 66 |
+
color: white;
|
| 67 |
+
padding: 12px;
|
| 68 |
+
font-size: 16px;
|
| 69 |
+
border-radius: 10px;
|
| 70 |
+
border: none;
|
| 71 |
+
}
|
| 72 |
+
.gradio-container .button:hover {
|
| 73 |
+
background-color: #0056b3;
|
| 74 |
+
}
|
| 75 |
+
.gradio-container .textbox {
|
| 76 |
+
font-size: 16px;
|
| 77 |
+
padding: 12px;
|
| 78 |
+
border-radius: 10px;
|
| 79 |
+
border: 1px solid #ccc;
|
| 80 |
+
}
|
| 81 |
+
""") as demo:
|
| 82 |
+
gr.Markdown("""
|
| 83 |
+
<h1 style="text-align:center;">AI-Powered Opportunity Finder for Youth</h1>
|
| 84 |
+
<p style="text-align:center;">Find scholarships, internships, online courses, and career advice based on your interests, skills, and location.</p>
|
| 85 |
+
""")
|
| 86 |
+
|
| 87 |
+
# Sidebar for input fields
|
| 88 |
+
with gr.Column():
|
| 89 |
+
gr.Markdown("### Provide your details to find opportunities")
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
interests = gr.Textbox(label="Your Interests (e.g., AI, Robotics, Software Engineering):")
|
| 92 |
+
skills = gr.Textbox(label="Your Skills (e.g., Python, Data Science, Web Development):")
|
| 93 |
+
location = gr.Textbox(label="Your Location (e.g., Gujrat, Pakistan):")
|
| 94 |
|
| 95 |
+
languages = gr.Dropdown(
|
| 96 |
+
label="Select your preferred language:",
|
| 97 |
+
choices=["English", "Spanish", "French", "German", "Italian", "Chinese", "Japanese", "Urdu"],
|
| 98 |
+
value="English"
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
find_button = gr.Button("Find Opportunities")
|
| 102 |
+
|
| 103 |
+
# Chatbot Section
|
| 104 |
+
with gr.Column():
|
| 105 |
+
gr.Markdown("### AI Chatbot")
|
| 106 |
+
user_message = gr.Textbox(label="Ask anything to the chatbot:", lines=2)
|
| 107 |
+
chatbot_output = gr.Textbox(label="Chatbot Response:", interactive=False)
|
| 108 |
+
|
| 109 |
+
# Function to handle finding opportunities
|
| 110 |
+
def find_opportunities_and_chat(interests, skills, location, language, user_message):
|
| 111 |
+
# Fetch opportunities
|
| 112 |
+
opportunities = get_opportunities(interests, skills, location)
|
| 113 |
+
translated_opportunities = asyncio.run(translate_text(opportunities, language))
|
| 114 |
+
|
| 115 |
+
# Get chatbot response
|
| 116 |
+
chatbot_response = get_chatbot_response(user_message) if user_message else "Ask me anything!"
|
| 117 |
|
| 118 |
+
return translated_opportunities, chatbot_response
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
# Connect the button to the function
|
| 121 |
+
find_button.click(
|
| 122 |
+
find_opportunities_and_chat,
|
| 123 |
+
inputs=[interests, skills, location, languages, user_message],
|
| 124 |
+
outputs=[gr.Textbox(label="Recommended Opportunities"), chatbot_output]
|
| 125 |
+
)
|
|
|
|
|
|
|
| 126 |
|
| 127 |
+
# Launch the Gradio app
|
| 128 |
+
if __name__ == "__main__":
|
| 129 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|