carrer / app.py
ASNVS's picture
kk
5c7d03b verified
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
)