Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- .env +1 -0
- app.py +74 -0
- requirements.txt +0 -0
.env
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
GEMINI_API_KEY="AIzaSyAf739yDURBsarkWma3No_S_sMDYSEC82o"
|
app.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
import google.generativeai as genai
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
# Load environment variables
|
7 |
+
load_dotenv()
|
8 |
+
api_key = os.getenv("GEMINI_API_KEY")
|
9 |
+
|
10 |
+
# Check if API key is set
|
11 |
+
if not api_key:
|
12 |
+
st.error("API key not found. Please set GEMINI_API_KEY in your .env file.")
|
13 |
+
st.stop()
|
14 |
+
|
15 |
+
# Configure the generative AI model
|
16 |
+
genai.configure(api_key=api_key)
|
17 |
+
generation_config = {
|
18 |
+
"temperature": 1,
|
19 |
+
"top_p": 0.95,
|
20 |
+
"top_k": 64,
|
21 |
+
"max_output_tokens": 8192,
|
22 |
+
"response_mime_type": "text/plain",
|
23 |
+
}
|
24 |
+
|
25 |
+
try:
|
26 |
+
model = genai.GenerativeModel(
|
27 |
+
model_name="gemini-1.5-flash",
|
28 |
+
generation_config=generation_config
|
29 |
+
)
|
30 |
+
except Exception as e:
|
31 |
+
st.error(f"Failed to load model: {str(e)}")
|
32 |
+
st.stop()
|
33 |
+
|
34 |
+
# Main function for Streamlit app
|
35 |
+
def main():
|
36 |
+
st.title("Career Path Recommendation System")
|
37 |
+
|
38 |
+
# List of questions for the user
|
39 |
+
questions = [
|
40 |
+
"Tell me about yourself. (Your characteristics, your preferred working environment, your likings, your dislikings, your team work nature, your dedication level etc.)",
|
41 |
+
"Tell me something about your career interests.",
|
42 |
+
"What types of work satisfy you most?",
|
43 |
+
"How many specific skills do you have and what are those?",
|
44 |
+
"Elaborate the best professional skill you have.",
|
45 |
+
"Elaborate the lowest professional skill you have.",
|
46 |
+
"What are your long-term goals?"
|
47 |
+
]
|
48 |
+
|
49 |
+
# Collect user responses
|
50 |
+
responses = {q: st.text_area(q, "") for q in questions}
|
51 |
+
|
52 |
+
# Button to get recommendations
|
53 |
+
if st.button("Get Career Path Recommendation"):
|
54 |
+
if all(responses.values()):
|
55 |
+
with st.spinner("Generating recommendations..."):
|
56 |
+
try:
|
57 |
+
# Start chat session and send the message
|
58 |
+
chat_session = model.start_chat(
|
59 |
+
history=[{"role": "user", "parts": [{"text": f"{q}: {a}"} for q, a in responses.items()]}]
|
60 |
+
)
|
61 |
+
response = chat_session.send_message("Based on the answers provided, what career path should the user choose?")
|
62 |
+
recommendation = response.text.strip()
|
63 |
+
|
64 |
+
# Display the recommendation
|
65 |
+
st.subheader("Career Path Recommendation:")
|
66 |
+
st.write(recommendation)
|
67 |
+
except Exception as e:
|
68 |
+
st.error(f"An error occurred while generating recommendations: {str(e)}")
|
69 |
+
else:
|
70 |
+
st.error("Please answer all the questions to get a recommendation.")
|
71 |
+
|
72 |
+
# Run the app
|
73 |
+
if __name__ == "__main__":
|
74 |
+
main()
|
requirements.txt
ADDED
Binary file (2.44 kB). View file
|
|