Spaces:
Running
Running
| import gradio as gr | |
| from langchain.chains import LLMChain | |
| from langchain.prompts import PromptTemplate | |
| from langchain.chat_models import ChatOpenAI | |
| # Replace this with a CPU-compatible LLM for Hugging Face Spaces | |
| llm = ChatOpenAI(temperature=0.2, model="gpt-3.5-turbo") # Replace with HuggingFacePipeline if no OpenAI key | |
| prompt_template = PromptTemplate( | |
| template=""" | |
| You are a professional resume screener AI. | |
| Below is a resume and a job description. | |
| Evaluate how well the resume fits the job and provide a plain text output with: | |
| - Match Score (0-100) | |
| - Key Skills matched | |
| - Justification for the score | |
| Resume: | |
| {resume} | |
| Job Description: | |
| {job} | |
| Response: | |
| """, | |
| input_variables=["resume", "job"] | |
| ) | |
| chain = LLMChain(llm=llm, prompt=prompt_template) | |
| def screen_resume(resume, jd): | |
| try: | |
| response = chain.run(resume=resume, job=jd) | |
| return response | |
| except Exception as e: | |
| return f"Error: {str(e)}" | |
| iface = gr.Interface( | |
| fn=screen_resume, | |
| inputs=[ | |
| gr.Textbox(label="Paste Resume Text", lines=15, placeholder="Paste plain text from resume..."), | |
| gr.Textbox(label="Paste Job Description", lines=10, placeholder="Paste plain text from JD..."), | |
| ], | |
| outputs=gr.Textbox(label="Analysis Result"), | |
| title="Resume Screener Agent", | |
| description="Upload a resume and a job description. The AI will match and score them." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |