krishbakshi commited on
Commit
5c65e46
·
verified ·
1 Parent(s): 5a44ddf

Create config.py

Browse files
Files changed (1) hide show
  1. config.py +34 -0
config.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from docx import Document
2
+ from docx.shared import Pt
3
+ from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
4
+ import os
5
+
6
+
7
+ def write_email(name, company, ai_email):
8
+ output_folder = "./output"
9
+ # Create a new Word document
10
+ doc = Document()
11
+
12
+ # Add AI-generated text to the document
13
+ paragraph = doc.add_paragraph()
14
+ run = paragraph.add_run(ai_email)
15
+
16
+ # Formatting the text
17
+ run.font.name = "Trebuchet MS"
18
+ run.font.size = Pt(10)
19
+
20
+ # # Justify the paragraph
21
+ # paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.JUSTIFY
22
+
23
+ # Set vertical spacing (before and after paragraph)
24
+ paragraph.paragraph_format.space_before = Pt(10) # 10pt space before paragraph
25
+ paragraph.paragraph_format.space_after = Pt(10) # 10pt space after paragraph
26
+ paragraph.paragraph_format.line_spacing = 1.0 # 1.5 line spacing
27
+
28
+ # Save the document
29
+ if not os.path.exists(output_folder):
30
+ os.makedirs(output_folder)
31
+
32
+ doc.save(os.path.join(output_folder, f"{name}, {company}.docx"))
33
+
34
+ return f"Email for {name}, {company} has been saved as a Word document."