File size: 1,535 Bytes
fdc0d68
 
 
 
4b41cfa
fdc0d68
4b41cfa
 
 
 
 
6d9b2de
 
03c9778
 
6d9b2de
 
 
 
03c9778
6d9b2de
 
 
 
 
 
 
 
 
 
fdc0d68
 
 
 
 
 
 
 
 
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
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 provide insights about the candidate . 
    If and only if asked about reliability , 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
    
    \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']