|
import os
|
|
import streamlit as st
|
|
import google.generativeai as genai
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
load_dotenv()
|
|
api_key = os.getenv("GEMINI_API_KEY")
|
|
|
|
|
|
if not api_key:
|
|
st.error("API key not found. Please set GEMINI_API_KEY in your .env file.")
|
|
st.stop()
|
|
|
|
|
|
genai.configure(api_key=api_key)
|
|
generation_config = {
|
|
"temperature": 1,
|
|
"top_p": 0.95,
|
|
"top_k": 64,
|
|
"max_output_tokens": 8192,
|
|
"response_mime_type": "text/plain",
|
|
}
|
|
|
|
try:
|
|
model = genai.GenerativeModel(
|
|
model_name="gemini-1.5-flash",
|
|
generation_config=generation_config
|
|
)
|
|
except Exception as e:
|
|
st.error(f"Failed to load model: {str(e)}")
|
|
st.stop()
|
|
|
|
|
|
def main():
|
|
st.title("Career Path Recommendation System")
|
|
|
|
|
|
questions = [
|
|
"Tell me about yourself. (Your characteristics, your preferred working environment, your likings, your dislikings, your team work nature, your dedication level etc.)",
|
|
"Tell me something about your career interests.",
|
|
"What types of work satisfy you most?",
|
|
"How many specific skills do you have and what are those?",
|
|
"Elaborate the best professional skill you have.",
|
|
"Elaborate the lowest professional skill you have.",
|
|
"What are your long-term goals?"
|
|
]
|
|
|
|
|
|
responses = {q: st.text_area(q, "") for q in questions}
|
|
|
|
|
|
if st.button("Get Career Path Recommendation"):
|
|
if all(responses.values()):
|
|
with st.spinner("Generating recommendations..."):
|
|
try:
|
|
|
|
chat_session = model.start_chat(
|
|
history=[{"role": "user", "parts": [{"text": f"{q}: {a}"} for q, a in responses.items()]}]
|
|
)
|
|
response = chat_session.send_message("Based on the answers provided, what career path should the user choose?")
|
|
recommendation = response.text.strip()
|
|
|
|
|
|
st.subheader("Career Path Recommendation:")
|
|
st.write(recommendation)
|
|
except Exception as e:
|
|
st.error(f"An error occurred while generating recommendations: {str(e)}")
|
|
else:
|
|
st.error("Please answer all the questions to get a recommendation.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|