Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
from
|
4 |
-
from
|
5 |
-
from
|
6 |
-
|
|
|
7 |
from sendgrid import SendGridAPIClient
|
8 |
from sendgrid.helpers.mail import Mail
|
9 |
import json
|
@@ -121,12 +122,13 @@ class EmailGenie:
|
|
121 |
return self.current_profile is not None
|
122 |
|
123 |
def structure_info(self, info: str) -> str:
|
124 |
-
|
125 |
-
"
|
|
|
126 |
)
|
127 |
-
chain =
|
128 |
-
return chain.
|
129 |
-
|
130 |
def generate_email(self, template_name: str, context: Dict) -> str:
|
131 |
if not self.current_profile:
|
132 |
return "Please set up your profile first."
|
@@ -134,8 +136,9 @@ class EmailGenie:
|
|
134 |
template = self.email_template.get_template(template_name)
|
135 |
structured_info = self.structure_info(context.get('recipient_info', ''))
|
136 |
|
137 |
-
email_prompt = PromptTemplate
|
138 |
-
"""
|
|
|
139 |
Using the following template and information, create a personalized email:
|
140 |
Template: {template}
|
141 |
Sender: {sender_name} ({sender_industry})
|
@@ -146,17 +149,17 @@ class EmailGenie:
|
|
146 |
"""
|
147 |
)
|
148 |
|
149 |
-
chain =
|
150 |
-
return chain.
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
def preview_email(self, email_content: str) -> str:
|
161 |
if not self.current_profile:
|
162 |
return "Please set up your profile first."
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from langchain.llms import Groq
|
4 |
+
from langchain.prompts import PromptTemplate
|
5 |
+
from langchain.chains import LLMChain
|
6 |
+
import pandas as pd
|
7 |
+
from datetime import datetime
|
8 |
from sendgrid import SendGridAPIClient
|
9 |
from sendgrid.helpers.mail import Mail
|
10 |
import json
|
|
|
122 |
return self.current_profile is not None
|
123 |
|
124 |
def structure_info(self, info: str) -> str:
|
125 |
+
prompt = PromptTemplate(
|
126 |
+
input_variables=["info"],
|
127 |
+
template="Please structure and summarize the following information about a person or company: {info}"
|
128 |
)
|
129 |
+
chain = LLMChain(llm=self.llm, prompt=prompt)
|
130 |
+
return chain.run(info=info)
|
131 |
+
|
132 |
def generate_email(self, template_name: str, context: Dict) -> str:
|
133 |
if not self.current_profile:
|
134 |
return "Please set up your profile first."
|
|
|
136 |
template = self.email_template.get_template(template_name)
|
137 |
structured_info = self.structure_info(context.get('recipient_info', ''))
|
138 |
|
139 |
+
email_prompt = PromptTemplate(
|
140 |
+
input_variables=["template", "sender_name", "sender_industry", "sender_background", "recipient", "subject", "structured_info"],
|
141 |
+
template="""
|
142 |
Using the following template and information, create a personalized email:
|
143 |
Template: {template}
|
144 |
Sender: {sender_name} ({sender_industry})
|
|
|
149 |
"""
|
150 |
)
|
151 |
|
152 |
+
chain = LLMChain(llm=self.llm, prompt=email_prompt)
|
153 |
+
return chain.run(
|
154 |
+
template=template,
|
155 |
+
sender_name=self.current_profile['name'],
|
156 |
+
sender_industry=self.current_profile['industry'],
|
157 |
+
sender_background=self.current_profile['background'],
|
158 |
+
recipient=context['recipient'],
|
159 |
+
subject=context['email_subject'],
|
160 |
+
structured_info=structured_info
|
161 |
+
)
|
162 |
+
|
163 |
def preview_email(self, email_content: str) -> str:
|
164 |
if not self.current_profile:
|
165 |
return "Please set up your profile first."
|