import streamlit as st import os from langchain_core.prompts import ChatPromptTemplate from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace from langchain_core.messages import AIMessage, HumanMessage, SystemMessage os.environ["HUGGINGFACEHUB_API_KEY"] = os.getenv("HF") os.environ["HF_TOKEN"] = os.getenv("HF") model = HuggingFaceEndpoint( repo_id="meta-llama/Llama-3.2-3B-Instruct", provider="novita", temperature=0.6, max_new_tokens=300, task="conversational" ) llama_model = ChatHuggingFace( llm=model, repo_id="meta-llama/Llama-3.2-3B-Instruct", provider="novita", temperature=0.6, max_new_tokens=300, task="conversational" ) # session message history if "message_history" not in st.session_state: st.session_state.message_history = [ SystemMessage(content=""" 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. Given a Job Description, extract and present the following sections using markdown formatting: **1. Key Technical Skills** List the main technical skills required using bullet points. **2. Important Soft Skills** List the soft skills emphasized by the employer using bullet points. **3. Suggested Mini Projects** Recommend mini projects or learning paths to strengthen the candidate’s profile, using bullet points. **4. Resume Improvement Tips** Provide practical and specific tips to improve the candidate's resume, using bullet points. 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. """) ] st.set_page_config(page_title="Smart JD Analyzer", page_icon="🧠", layout="wide") st.markdown(""" """, unsafe_allow_html=True) st.markdown('
🧠 Smart JD Analyzer
', unsafe_allow_html=True) st.markdown('
Paste a job description to get technical skills, soft skills, mini-project ideas, and resume tips instantly!
', unsafe_allow_html=True) jd_input = st.text_area("📄 Paste Job Description Below:", height=300, placeholder="Paste the full job description here...", key="jd_input", help="Paste any software/data-related JD here to analyze it.", label_visibility="visible") analyze = st.button("🔍 Analyze JD", use_container_width=True) # --- RESPONSE --- if analyze: if jd_input.strip(): with st.spinner("Analyzing job description..."): st.session_state.message_history.append(HumanMessage(content=jd_input)) try: response = llama_model.invoke(st.session_state.message_history) # st.session_state.message_history.append(AIMessage(content=response.content)) with st.container(): st.markdown('
', unsafe_allow_html=True) st.markdown("### 📝 **Analysis Output**") st.markdown(response.content, unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) except Exception as e: st.error(f"❌ Error occurred: {e}") else: st.warning("⚠️ Please enter a valid job description before analyzing.")