TextGen / email_writer.py
abdullah10's picture
Upload 35 files
8bc7dc5
raw
history blame
2.18 kB
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