Spaces:
Sleeping
Sleeping
from langchain.chains.combine_documents import create_stuff_documents_chain | |
from langchain_core.prompts import ChatPromptTemplate | |
from langchain.chains import create_retrieval_chain | |
#from Api_Key import google_plam | |
from langchain_groq import ChatGroq | |
import os | |
from dotenv import load_dotenv | |
load_dotenv() | |
def prompt_template_to_analyze_resume(): | |
template = """ | |
You are provided with the Resume of the Candidate in the context below . As an Talent Aquistion bot , your task is to analyze that candidate is | |
is reliable or not. To find out reliability parameter check , How frequently the candidate has switched from one company to another. | |
Grade him on the given basis: | |
If less than 2 Year - very less Reliable | |
if more than 2 years but less than 5 years - Reliable | |
if more than 5 Years - Highly Reliable | |
Finally Generate a one line Response and small reason for it . | |
\n\n:{context} | |
""" | |
prompt = ChatPromptTemplate.from_messages( | |
[ | |
('system',template), | |
('human','input'), | |
] | |
) | |
return prompt | |
def Q_A(vectorstore,question,API_KEY): | |
os.environ["GROQ_API_KEY"] = API_KEY | |
llm_groq = ChatGroq(model="llama3-8b-8192") | |
# Create a retriever | |
retriever = vectorstore.as_retriever(search_type = 'similarity',search_kwargs = {'k':2},) | |
question_answer_chain = create_stuff_documents_chain(llm_groq, prompt_template_to_analyze_resume()) | |
chain = create_retrieval_chain(retriever, question_answer_chain) | |
result = chain.invoke({'input':question}) | |
return result['answer'] |