Yashvj123 commited on
Commit
c5f9d42
·
verified ·
1 Parent(s): cfba62f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -29
app.py CHANGED
@@ -1,58 +1,50 @@
1
  import streamlit as st
2
- from langchain import PromptTemplate
3
- from langchain.chat_models import ChatHuggingFace
4
  import os
5
 
6
  hf_token = os.getenv("HUGGINGFACEHUB_API_KEY")
7
 
8
- # Setup LLM
9
- llm_model = ChatHuggingFace(
10
- model="HuggingFaceH4/zephyr-7b-beta",
11
- huggingfacehub_api_token=hf_token,
 
 
 
12
  model_kwargs={
13
  "temperature": 0.7,
14
- "max_new_tokens": 200,
15
- "task": "conversational",
16
- }
17
  )
18
 
19
-
20
- # repo_id="HuggingFaceH4/zephyr-7b-beta",
21
- # task="conversational",
22
- # temperature=0.7,
23
- # max_new_tokens=300,
24
- # model="huggingface",
25
- # provider="hf-inference"
26
-
27
- # Prompt template
28
  prompt = PromptTemplate.from_template("""
29
  You are an expert career advisor specializing in analyzing job descriptions and providing actionable insights to help job seekers tailor their resumes and skills for maximum impact.
30
 
31
  Given the Job Description below, extract and present the following sections **using markdown formatting**:
32
 
33
- **1. Key Technical Skills**
34
  List the main technical skills required using bullet points.
35
 
36
- **2. Important Soft Skills**
37
  List the soft skills emphasized by the employer using bullet points.
38
 
39
- **3. Suggested Mini Projects**
40
  Recommend mini projects or learning paths to strengthen the candidate’s profile, using bullet points.
41
 
42
- **4. Resume Improvement Tips**
43
  Provide practical and specific tips to improve the candidate's resume, using bullet points.
44
 
45
  Use **bold headings** for each section and markdown bullet points (`- `). Write in a professional yet friendly tone. Be concise, clear, and focused on actionable advice.
46
 
47
- Job Description:
48
  \"\"\"{job_description}\"\"\"
49
 
50
  """)
51
 
52
- # Chain
53
  chain = prompt | llm_model
54
 
55
- # Streamlit UI
56
  st.set_page_config(page_title="JD Analyzer AI")
57
  st.title("📄 JD Analyzer AI")
58
  st.markdown("Paste any job description below and get insights to improve your profile.")
@@ -60,7 +52,13 @@ st.markdown("Paste any job description below and get insights to improve your pr
60
  jd_input = st.text_area("Paste Job Description:", height=300)
61
 
62
  if st.button("Analyze"):
63
- with st.spinner("Analyzing the JD..."):
64
- output = chain.invoke({"job_description": jd_input})
65
- st.markdown("### 🔍 Output")
66
- st.markdown(output)
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from langchain_core.prompts import PromptTemplate
3
+ from langchain_community.chat_models import ChatHuggingFace
4
  import os
5
 
6
  hf_token = os.getenv("HUGGINGFACEHUB_API_KEY")
7
 
8
+ if not hf_token:
9
+ st.error("Hugging Face API token not found. Please set the environment variable 'HUGGINGFACE_API_TOKEN'.")
10
+ st.stop()
11
+
12
+ llm_model = ChatHuggingFace.from_model_id(
13
+ model_id="HuggingFaceH4/zephyr-7b-beta",
14
+ task="conversational",
15
  model_kwargs={
16
  "temperature": 0.7,
17
+ "max_new_tokens": 200
18
+ },
19
+ huggingfacehub_api_token=hf_token
20
  )
21
 
 
 
 
 
 
 
 
 
 
22
  prompt = PromptTemplate.from_template("""
23
  You are an expert career advisor specializing in analyzing job descriptions and providing actionable insights to help job seekers tailor their resumes and skills for maximum impact.
24
 
25
  Given the Job Description below, extract and present the following sections **using markdown formatting**:
26
 
27
+ **1. Key Technical Skills**
28
  List the main technical skills required using bullet points.
29
 
30
+ **2. Important Soft Skills**
31
  List the soft skills emphasized by the employer using bullet points.
32
 
33
+ **3. Suggested Mini Projects**
34
  Recommend mini projects or learning paths to strengthen the candidate’s profile, using bullet points.
35
 
36
+ **4. Resume Improvement Tips**
37
  Provide practical and specific tips to improve the candidate's resume, using bullet points.
38
 
39
  Use **bold headings** for each section and markdown bullet points (`- `). Write in a professional yet friendly tone. Be concise, clear, and focused on actionable advice.
40
 
41
+ Job Description:
42
  \"\"\"{job_description}\"\"\"
43
 
44
  """)
45
 
 
46
  chain = prompt | llm_model
47
 
 
48
  st.set_page_config(page_title="JD Analyzer AI")
49
  st.title("📄 JD Analyzer AI")
50
  st.markdown("Paste any job description below and get insights to improve your profile.")
 
52
  jd_input = st.text_area("Paste Job Description:", height=300)
53
 
54
  if st.button("Analyze"):
55
+ if not jd_input.strip():
56
+ st.warning("Please paste a job description to analyze.")
57
+ else:
58
+ try:
59
+ with st.spinner("Analyzing..."):
60
+ output = chain.invoke({"job_description": jd_input})
61
+ st.markdown("### 🔍 Output")
62
+ st.markdown(output)
63
+ except Exception as e:
64
+ st.error(f"Error: {e}")