taha454 commited on
Commit
e846143
·
verified ·
1 Parent(s): 1f81514

Upload 2 files

Browse files
Files changed (2) hide show
  1. agent/tools/PDF.py +36 -36
  2. agent/tools/email.py +39 -39
agent/tools/PDF.py CHANGED
@@ -1,36 +1,36 @@
1
- from markdown_pdf import MarkdownPdf, Section
2
- import os
3
-
4
- #### For this version the nodes used directly not by graph
5
-
6
- format_css = """
7
- body {
8
- font-family: 'Amiri', 'Arial', sans-serif; /* خط يدعم عربي وانجليزي */
9
- font-size: 12pt;
10
- line-height: 1.6;
11
- direction: rtl; /* لجعل النص من اليمين لليسار */
12
- margin: 20px;
13
- }
14
- h1, h2, h3 {
15
- color: #2E86C1;
16
- margin-bottom: 10px;
17
- }
18
- table {
19
- border-collapse: collapse;
20
- width: 100%;
21
- margin-bottom: 10px;
22
- }
23
- table, th, td {
24
- border: 1px solid #555;
25
- padding: 6px;
26
- }
27
- th {
28
- background-color: #f0f0f0;
29
- }
30
- """
31
-
32
- def PDF_generator_Node(text_md,text_title,path_pdf):
33
- pdf = MarkdownPdf(toc_level=2)
34
- pdf.add_section(Section("# "+text_title), user_css=format_css)
35
- pdf.add_section(Section(text_md), user_css=format_css)
36
- pdf.save(path_pdf)
 
1
+ from markdown_pdf import MarkdownPdf, Section
2
+ import os
3
+
4
+ #### For this version the nodes used directly not by graph
5
+
6
+ format_css = """
7
+ body {
8
+ font-family: 'Amiri', 'Arial', sans-serif; /* خط يدعم عربي وانجليزي */
9
+ font-size: 12pt;
10
+ line-height: 1.6;
11
+ direction: rtl; /* لجعل النص من اليمين لليسار */
12
+ margin: 20px;
13
+ }
14
+ h1, h2, h3 {
15
+ color: #2E86C1;
16
+ margin-bottom: 10px;
17
+ }
18
+ table {
19
+ border-collapse: collapse;
20
+ width: 100%;
21
+ margin-bottom: 10px;
22
+ }
23
+ table, th, td {
24
+ border: 1px solid #555;
25
+ padding: 6px;
26
+ }
27
+ th {
28
+ background-color: #f0f0f0;
29
+ }
30
+ """
31
+
32
+ def PDF_generator_Node(text_md,text_title,path_pdf):
33
+ pdf = MarkdownPdf(toc_level=2)
34
+ pdf.add_section(Section("# "+text_title), user_css=format_css)
35
+ pdf.add_section(Section(text_md), user_css=format_css)
36
+ pdf.save(path_pdf)
agent/tools/email.py CHANGED
@@ -1,39 +1,39 @@
1
- import smtplib
2
- from email.message import EmailMessage
3
- import os
4
-
5
- #### For this version the nodes used directly not by graph
6
-
7
-
8
- smtp_server = "smtp.gmail.com" # SMTP is protcol for sending mail, use this server
9
- smtp_port = 587
10
- # for large scale / send many message you should use other server
11
-
12
- def EMAIL_sender_Node(user_email,email_txt,subject,path_pdf):
13
- APP_email = os.environ["APP_email"]
14
- APP_password = os.environ["APP_password"]
15
-
16
- msg = EmailMessage()
17
- msg["Subject"] = subject
18
- msg["From"] = APP_email
19
- msg["To"] = user_email
20
-
21
- msg.set_content(email_txt)
22
-
23
- with open(path_pdf, "rb") as f:
24
- file_data = f.read()
25
- msg.add_attachment(file_data,
26
- maintype="application",
27
- subtype="pdf",
28
- filename=path_pdf)
29
-
30
-
31
- with smtplib.SMTP(smtp_server, smtp_port) as server:
32
- server.ehlo() # know server / get info
33
- server.starttls() # start the tls (securing protocol)
34
- server.ehlo()
35
- server.login(APP_email, APP_password)
36
- server.send_message(msg)
37
- print("Email sent!")
38
-
39
-
 
1
+ import smtplib
2
+ from email.message import EmailMessage
3
+ import os
4
+
5
+ #### For this version the nodes used directly not by graph
6
+
7
+
8
+ smtp_server = "smtp.gmail.com" # SMTP is protcol for sending mail, use this server
9
+ smtp_port = 587
10
+ # for large scale / send many message you should use other server
11
+
12
+ def EMAIL_sender_Node(user_email,email_txt,subject,path_pdf):
13
+ APP_email = os.environ["APP_email"]
14
+ APP_password = os.environ["APP_password"]
15
+
16
+ msg = EmailMessage()
17
+ msg["Subject"] = subject
18
+ msg["From"] = APP_email
19
+ msg["To"] = user_email
20
+
21
+ msg.set_content(email_txt)
22
+
23
+ with open(path_pdf, "rb") as f:
24
+ file_data = f.read()
25
+ msg.add_attachment(file_data,
26
+ maintype="application",
27
+ subtype="pdf",
28
+ filename=path_pdf)
29
+
30
+
31
+ with smtplib.SMTP(smtp_server, smtp_port) as server:
32
+ server.ehlo() # know server / get info
33
+ server.starttls() # start the tls (securing protocol)
34
+ server.ehlo()
35
+ server.login(APP_email, APP_password)
36
+ server.send_message(msg)
37
+ print("Email sent!")
38
+
39
+