-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdraft_mail.py
More file actions
39 lines (30 loc) · 1.24 KB
/
draft_mail.py
File metadata and controls
39 lines (30 loc) · 1.24 KB
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
import os
import json
from langchain.chains import LLMChain
from langchain_groq import ChatGroq
from langchain.prompts import PromptTemplate
from langchain.chains import SequentialChain, LLMChain
from prompts import mail_prompt, sample_reco
os.environ["GROQ_API_KEY"] = "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"
class DraftMail:
def __init__(self):
self.llm = ChatGroq(
model="llama3-70b-8192",
temperature=1,
max_tokens=400,
)
self.prompt = mail_prompt
self.customer_dataset = json.load(open("data/customer_profile.json"))
self.product_dataset = json.load(open("data/products.json"))
def setup_chain(self):
prompt = PromptTemplate(input_variables=["product_recommendation"], template=self.prompt)
self.llmchain = LLMChain(llm=self.llm, prompt=prompt, output_key="mail", verbose=True)
def get_content(self, recommendation: str):
email = "xyz@dfgh.com"
product_recommendation = recommendation
result = self.llmchain({"product_recommendation": product_recommendation})
return {"mail": result["mail"]}
# obj = DraftMail()
# obj.setup_chain()
# mail_content = obj.get_content(sample_reco)
# print(mail_content)