File size: 2,748 Bytes
6f27a32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from langchain.llms import OpenAI, GooglePalm
from Api_Key import openapi_key,google_plam
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
import PromptHelper

google_llm = GooglePalm(google_api_key=google_plam,temperature=0.1)

def Book_Name1(main_cat):

    """
    Prompt P1
    Return only Education Related
    """
    prompt_template_name = PromptTemplate(
        input_variables=['main_cat'],
        template=PromptHelper.P1
    )
    chain = LLMChain(llm=google_llm, prompt=prompt_template_name)
    response = chain.run(main_cat=main_cat)
    return response


def Book_Name1_1(main_cat):
    """
    Prompt P1_1
    Return only Education Related for given year
    """
    prompt_template_name = PromptTemplate(
        input_variables=['main_cat'],
        template=PromptHelper.P1_1
    )
    chain = LLMChain(llm=google_llm, prompt=prompt_template_name)
    response = chain.run(main_cat=main_cat)
    return response

def Book_Name2(main_cat,topic):
    """
    Prompt P2
    Return only Education Related for ant specific topic
    """
    prompt_template_name = PromptTemplate(
        input_variables=['main_cat', 'topic'],
        template=PromptHelper.P2
    )
    chain = LLMChain(llm=google_llm, prompt=prompt_template_name)
    response = chain.run(main_cat=main_cat,topic=topic)
    return response

def Book_Name3(main_cat,topic,p_year):
    """
    Prompt P3
    Return only Education Related for ant specific topic for given year
    """
    prompt_template_name = PromptTemplate(
        input_variables=['main_cat', 'topic', 'p_year'],
        template=PromptHelper.P3
    )
    chain = LLMChain(llm=google_llm, prompt=prompt_template_name)
    response = chain.run(main_cat=main_cat,topic=topic,p_year=p_year)
    return response

def Book_Name4(main_cat,genres):
    """
    Prompt P4
    Return only Non Education Related for any specific list of genres
    """
    prompt_template_name = PromptTemplate(
        input_variables=['main_cat', 'genres'],
        template=PromptHelper.P4
    )
    chain = LLMChain(llm=google_llm, prompt=prompt_template_name)
    response = chain.run(main_cat=main_cat,genres=genres)
    return response

def Book_Name5(main_cat,genres,p_year):
    """
    Prompt P5
    Return only Non Education Related for any specific list of genres for given year
    """
    prompt_template_name = PromptTemplate(
        input_variables=['main_cat', 'list_sub_cat', 'p_year'],
        template=PromptHelper.P5
    )
    chain = LLMChain(llm=google_llm, prompt=prompt_template_name)
    response = chain.run(main_cat=main_cat,genres=genres,p_year=p_year)
    return response

if __name__ == "__main__":
    print(Book_Name5('Non Education', 'Horror', '2002'))