Spaces:
Build error
Build error
File size: 1,501 Bytes
62d3b3c 9956d52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain_core.messages import SystemMessage
from langchain_core.output_parsers import JsonOutputParser
import os
from dotenv import load_dotenv
# load the environment variables
load_dotenv()
# Define the google api key
os.environ['GOOGLE_API_KEY'] = os.getenv('GOOGLE_API_KEY')
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
# define the parser object
parser = JsonOutputParser()
def jobdes2text(jobdes):
# setup the gemini pro
llm = ChatGoogleGenerativeAI(model="gemini-pro", temperature=0.3, convert_system_message_to_human=True, api_key=GOOGLE_API_KEY)
# create the prompt template
finnal_jd_chat_template = ChatPromptTemplate.from_messages(
[
SystemMessage(
content=(
"""Return Job title, level(Fresher, Junior, Senior, ...) and Brief summary of required skills about 20 words from the job description. Use the following format: Job Title is {job title}, Level is {level}, and Brief summary of required skills is {brief summary of required skills}."""
)
),
HumanMessagePromptTemplate.from_template("{text}"),
]
)
# create the chat message
chat_message = finnal_jd_chat_template.format_messages(text=jobdes)
# create a chain
chain = llm
result = chain.invoke(chat_message)
return result.content |