Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import traceback
|
2 |
+
import streamlit as st
|
3 |
+
from langchain_core.prompts import ChatPromptTemplate
|
4 |
+
from langchain_core.output_parsers import StrOutputParser
|
5 |
+
from langchain_openai import ChatOpenAI
|
6 |
+
from langchain_anthropic import ChatAnthropic
|
7 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
8 |
+
|
9 |
+
###### dotenv を利用する場合 ######
|
10 |
+
try:
|
11 |
+
from dotenv import load_dotenv
|
12 |
+
load_dotenv()
|
13 |
+
except ImportError:
|
14 |
+
import warnings
|
15 |
+
warnings.warn("dotenv not found. Please make sure to set your environment variables manually.", ImportWarning)
|
16 |
+
################################################
|
17 |
+
|
18 |
+
|
19 |
+
PROMPT = """
|
20 |
+
## Task: Provide detailed and personalized career advice based on the user's current situation and aspirations.
|
21 |
+
## User Information:
|
22 |
+
- Current Career Status: {input_status}
|
23 |
+
- Career Goals: {input_goal}
|
24 |
+
- Skills and Experience: {input_skill}
|
25 |
+
- Interests: {input_interest}
|
26 |
+
- Preferred Work Environment: {input_environment}
|
27 |
+
- Location: {input_location}
|
28 |
+
- Challenges: {input_challenges}
|
29 |
+
|
30 |
+
## Objective: Offer actionable and supportive career advice that helps the user achieve both their short-term and long-term goals. Include strategies for overcoming challenges, leveraging skills, and aligning with their interests and preferred work environment. Provide specific tips and recommendations tailored to the user's unique context.
|
31 |
+
|
32 |
+
## Additional: Ensure the advice is clear, practical, and tailored to assist the user in making informed decisions about their career path.
|
33 |
+
"""
|
34 |
+
|
35 |
+
def init_page():
|
36 |
+
st.set_page_config(
|
37 |
+
page_title="Career Advice AI Agent",
|
38 |
+
page_icon="🧘"
|
39 |
+
)
|
40 |
+
st.header("Career Advice AI Agent🧘")
|
41 |
+
|
42 |
+
|
43 |
+
def select_model(temperature=0):
|
44 |
+
models = ("GPT-4o","GPT-4o-mini", "Claude 3.5 Sonnet", "Gemini 1.5 Pro")
|
45 |
+
model_choice = st.radio("Choose a model:", models)
|
46 |
+
if model_choice == "GPT-4o":
|
47 |
+
return ChatOpenAI(temperature=temperature, model_name="gpt-4o")
|
48 |
+
elif model_choice == "GPT-4o-mini":
|
49 |
+
return ChatOpenAI(temperature=temperature, model_name="gpt-4o-mini")
|
50 |
+
elif model_choice == "Claude 3.5 Sonnet":
|
51 |
+
return ChatAnthropic(temperature=temperature, model_name="claude-3-5-sonnet-20240620")
|
52 |
+
elif model_choice == "Gemini 1.5 Pro":
|
53 |
+
return ChatGoogleGenerativeAI(temperature=temperature, model="gemini-1.5-pro-latest")
|
54 |
+
|
55 |
+
def init_chain():
|
56 |
+
llm = select_model()
|
57 |
+
prompt = ChatPromptTemplate.from_messages([
|
58 |
+
("user", PROMPT),
|
59 |
+
])
|
60 |
+
output_parser = StrOutputParser()
|
61 |
+
chain = prompt | llm | output_parser
|
62 |
+
return chain
|
63 |
+
|
64 |
+
def main():
|
65 |
+
init_page()
|
66 |
+
chain = init_chain()
|
67 |
+
if chain:
|
68 |
+
input_status = st.selectbox("Current Career Status",("Student", "Entry-Level Employee", "Senior-Level Employee", "Career Changer", "Unemployed/Job Seeker", "Entrepreneur"),key="input_status")
|
69 |
+
input_goal = st.text_input("Career Goals (e.g., Become recognized as an expert in digital marketing field)", key="input_goal")
|
70 |
+
input_skill = st.text_input("Skills and Experience (e.g., SEO and digital marketing)", key="input_skill")
|
71 |
+
input_interest = st.text_input("Interests (e.g., Data Science and Python)", key="input_interest")
|
72 |
+
input_environment = st.selectbox("Preferred work environment",("Corporate Office", "Startup", "Remote Work", "Freelance/Contract", "Government/Public Sector"),key="input_environment")
|
73 |
+
input_location = st.text_input("Location (e.g., Tokyo)", key="input_location")
|
74 |
+
input_challenges = st.text_input("Challenges (e.g., High competition for jobs in the field, making it difficult to stand out to employers.)", key="input_challenges")
|
75 |
+
if st.button("Submit"):
|
76 |
+
result = chain.stream({"input_status": input_status, "input_goal": input_goal, "input_skill": input_skill, "input_interest": input_interest, "input_environment": input_environment, "input_location": input_location, "input_challenges": input_challenges})
|
77 |
+
st.write(result)
|
78 |
+
|
79 |
+
if __name__ == '__main__':
|
80 |
+
main()
|
81 |
+
|
82 |
+
# Style adjustments (optional, remove if not needed)
|
83 |
+
st.markdown(
|
84 |
+
"""
|
85 |
+
<style>
|
86 |
+
/* Custom style adjustments */
|
87 |
+
.st-emotion-cache-iiif1v { display: none !important; }
|
88 |
+
</style>
|
89 |
+
""",
|
90 |
+
unsafe_allow_html=True,
|
91 |
+
)
|
92 |
+
|
93 |
+
|