File size: 2,180 Bytes
8bc7dc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

class email_writing:

    def __init__(self, llm):
        self.llm = llm

    def email_gen(self, recipient, recipient_position, sender_name, position_sender, desc):
        
        email_prompt = f"Write a professional and well organized Email on {desc}.\nThe name of the Recipient is {recipient} and the recipient position is {recipient_position}.\nMy Name is {sender_name} and my Position is {position_sender}."
            
        email_promptTemp = PromptTemplate(
        input_variables=["text_input"],
        template="You are a professional email writer:\n{text_input}\nEmail:")
    
        email_extraction_chain = LLMChain(llm=self.llm, prompt=email_promptTemp)
        email = email_extraction_chain.run(email_prompt)
        
        return email

    def email_subject_gen(self, email):

        email_subject_prompt = f"Generate a subject for the following email:\n{email}\n"
            
        email_subject_promptTemp = PromptTemplate(
        input_variables=["text_input"],
        template="You are a professional email writer:\n{text_input}\nEmail Subject:")
    
        email_subject_extraction_chain = LLMChain(llm=self.llm, prompt=email_subject_promptTemp)
        email_subject = email_subject_extraction_chain.run(email_subject_prompt)
        
        return email_subject
    
    def email_marketing_campaigns_gen(self, product_name, product_description, target_audience, goal):
    
        email_prompt = f"Generate a high-converting email marketing campaign for {product_name}. {product_name} is {product_description}. that is targeted at {target_audience} and has the goal of {goal}. The campaign should include a welcome email, a nurture sequence, and a promotional email."
            
        email_promptTemp = PromptTemplate(
        input_variables=["text_input"],
        template="You are a Professional Email Marketing Copywriter:\n{text_input}\nEmail Marketing Campaign:")
    
        email_extraction_chain = LLMChain(llm=self.llm, prompt=email_promptTemp)
        email = email_extraction_chain.run(email_prompt)
        
        return email