File size: 2,598 Bytes
571af42 5c7d03b 571af42 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 71 |
import os
import streamlit as st
from groq import Groq
# Securely set Groq API key (replace with your method for storing keys securely)
GROQ_API_KEY = "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" # Replace with your Groq API key
os.environ["GROQ_API_KEY"] = GROQ_API_KEY
# Initialize Groq client
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
# Title and Introduction
st.title("Career Counselor App")
st.write("I’m here to guide you toward the perfect career based on your skills, interests, and experience.")
# User Input Section
st.header("Tell us about yourself")
age = st.number_input("Age:", min_value=18, max_value=65, step=1)
education = st.text_input("Educational Background:")
skills = st.text_area("List your skills (e.g., Python, teamwork, CAD):")
interests = st.text_area("What areas of interest do you have? (e.g., AI, design, civil engineering):")
experience = st.text_area("Describe your experience (if any):")
# Function to get career suggestions from Groq
def suggest_careers_groq(skills, interests, experience):
try:
# Prepare the prompt for Groq's chat model
prompt = f"""
Based on the following details, suggest suitable career paths, job market trends, and necessary qualifications:
Skills: {skills}
Interests: {interests}
Experience: {experience}
"""
# Call the Groq API
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": prompt,
}
],
model="llama-3.3-70b-versatile", # Specify the model
stream=False,
)
# Extract and return the response
response_content = chat_completion.choices[0].message.content
return response_content
except Exception as e:
st.error(f"An error occurred while contacting Groq API: {e}")
return None
# Display recommendations based on user input
if st.button("Get Career Advice"):
if not skills or not interests:
st.error("Please provide your skills and interests to get career advice.")
else:
st.subheader("Career Recommendations")
response = suggest_careers_groq(skills, interests, experience)
if response:
st.write(response)
else:
st.write("No recommendations available. Please try again later.")
# Footer
st.markdown("---")
st.markdown(
"<p style='text-align: center; font-size: 14px;'>Designed by: </p>",
unsafe_allow_html=True
) |