Spaces:
Sleeping
Sleeping
import os | |
import time | |
from langchain_openai import ChatOpenAI | |
from langchain.prompts import PromptTemplate | |
from langchain.agents import initialize_agent, AgentType | |
from langchain.tools import Tool | |
from langchain.agents import Tool | |
from dotenv import load_dotenv | |
from langchain_core.messages import HumanMessage | |
# Load environment variables | |
load_dotenv() | |
# Set environment variables for model API key and model type | |
os.environ.setdefault("DSP_CACHEBOOL", "false") | |
# Get API key | |
api_key = os.getenv("OPENAI_API_KEY") | |
if not api_key: | |
raise ValueError("OPENAI_API_KEY environment variable is not set") | |
# Initialize the chat model | |
model = ChatOpenAI( | |
model=os.getenv("MODEL", "gpt-4o-mini"), | |
openai_api_key=api_key, | |
temperature=0.0, | |
max_tokens=4000 | |
) | |
# Define your tool to process the job description | |
class JobDescriptionProcessor(Tool): | |
def __init__(self, name: str, description: str, func): | |
super().__init__(name=name, func=func, description=description) | |
def _run(self, job_description: str): | |
return self.func(job_description) | |
# Define a function to generate aspects based on job description | |
def generate_aspects(job_description: str) -> str: | |
# Create a prompt for the model | |
prompt = f""" | |
You are an expert recruiter specialized in analyzing resumes against job descriptions (JDs). Your task is to formulate checkpoints that focus on verifying criteria that are explicitly mentioned as must-have in the JD. These checkpoints will help generate insightful responses in the next step, ensuring the resume is analyzed against the critical, non-negotiable requirements, if any, outlined in the JD. | |
**Input**: The input for this task will be the job description (JD). | |
**Output**: Formulate 2 to 3 evaluation checkpoints/criteria focused solely on the must-have requirements. These checkpoints/criteria will serve as evaluation criteria for the next stage, where the candidate's resume will be checked for evidence and reasoning. | |
### Steps: | |
1) Understand the JD and determine the number of checkpoints (between 2-3) required depending on the specifications from the JD and the context of the role. For freshers/career beginners, the number of checkpoints could be less in number. | |
2) With a holistic and pragmatic approach, formulate the checkpoints that cover the verifiable aspects usually available from resumes. Note that the cultural aspects or thinking process or future plans of the candidate should not be part of this exercise. | |
**Guidelines**: | |
1. Identify parameters explicitly marked as must-have in the JD. | |
a. Consider the context and include aspects labeled as “required,” “mandatory,” “essential,” “prerequisite,” or similar if appropriate to be considered as must-have. | |
b. Focus only on very critical criteria that, if missing, should lead to disqualification of the candidate. | |
2. Clearly differentiate between must-haves and good-to-haves/preferences. | |
a. Exclude any parameters described as “preferred,” “nice-to-have,” or optional. | |
3. If specific education, certification, or experience is not explicitly mentioned as a must-have, do not include it in this section. | |
**Output Format:** | |
Checkpoint 1: [Description of checkpoint] | |
Checkpoint 2: [Description of checkpoint]""" | |
# Get response from the model | |
response = model.invoke([HumanMessage(content=prompt)]) | |
return response.content | |
# Define the agent tools | |
tools = [ | |
JobDescriptionProcessor( | |
name="JobDescriptionProcessor", | |
description="Process job descriptions and generate aspects", | |
func=generate_aspects, | |
), | |
] | |
# Initialize the LangChain agent | |
agent = initialize_agent( | |
tools, model, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True | |
) | |
# Main logic to execute the agent with job description input | |
if __name__ == "__main__": | |
good_jd = """ | |
Job Description | |
Workday FIN Consultant | |
Sentient Solutions is a rapidly growing accounting outsourcing firm with clients across the United States. Sentient's highly experienced team of experts based in the US, India, and Mexico offer fully customized solutions to suit the specific business needs of CPA Firms. With AI, process automation, and a suite of scalable services, we promise success to CPA firms. | |
Location: Jubilee Hills, Hyderabad | |
Experience: 3 to 7 years | |
Website: https://sentientsolutions.io/ | |
Job Summary : | |
1. Ensure a smooth transition and onboarding of new partner firms and tuck-ins into our Workday Financials landscape. | |
Ensure newly acquired firms and tuck-ins are live on Workday financials on Day 1 of deal closure | |
Demonstrate strong service orientation, change management skills, and overall dedication to stakeholder success at our Partner Firms | |
Seek to drive process and automation-based improvements to minimize the time to delivery for onboarding and the resources required to onboard new acquisitions. | |
Participate in overall partner firm integration and lead the conversations around financials integration. Maintain an updated playbook for all requirements to onboard an acquisition effectively. | |
2. Demonstrate strong knowledge in multiple Workday Financials areas to include core financials, suppliers, accounts payable, expenses, payroll, banking, assets, report writing. | |
Perform as a subject matter expert in the aforementioned Workday areas. | |
Act as the first point of service for Workday Financials related support questions | |
Escalate as necessary, to our external partners, manage the use of the external partnership to support workday Financials. | |
3. Monitor and maintain all Workday financials integrations and workflows. | |
Proactively resolve errors in integration and workflows | |
Provide suggestions to the change committee for improving integration and workflows to maximize efficiency and reduce opportunities for error. | |
4. Achieve an NPS score > 70 by the end of the first year for Partner Firm Experience with Workday onboarding | |
Maximize the Partner Firm experience by embodying our values and committing to excellent customer service. | |
5. VALUES & CULTURE: Uphold and embody Ascend values | |
Own it. We seize growth opportunities with the passion, speed and accountability of an entrepreneur. | |
Serve whole-heartedly. We love our people and serve them with positivity and kindness. | |
Be excellent. We set a high bar because our mission matters. | |
Win together. We stay in sync, achieve as a team and celebrate each other. | |
Bring the sunshine. We have fun and bring enthusiasm to make the journey joyful. | |
""" | |
# Run the LangChain agent to get the results | |
ans = agent.run(job_description=good_jd) | |
print("\n\ncriteria : \n", ans) | |