-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(assistants): Add PDF generation functionality and nice emails
- Loading branch information
1 parent
ed814de
commit cb0051f
Showing
10 changed files
with
564 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
|
||
from fpdf import FPDF | ||
from pydantic import BaseModel | ||
|
||
|
||
class PDFModel(BaseModel): | ||
title: str | ||
content: str | ||
|
||
|
||
class PDFGenerator(FPDF): | ||
def __init__(self, pdf_model: PDFModel, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.pdf_model = pdf_model | ||
|
||
def header(self): | ||
# Logo | ||
logo_path = os.path.join(os.path.dirname(__file__), "logo.png") | ||
self.image(logo_path, 10, 10, 20) # Adjust size as needed | ||
|
||
# Move cursor to right of image | ||
self.set_xy(20, 15) | ||
|
||
# Title | ||
self.set_font("Arial", "B", 12) | ||
self.multi_cell(0, 10, self.pdf_model.title, align="C") | ||
self.ln(5) # Padding after title | ||
|
||
def footer(self): | ||
self.set_y(-15) | ||
self.set_font("helvetica", "I", 8) | ||
self.set_text_color(169, 169, 169) | ||
self.cell(80, 10, "Generated by Quivr", 0, 0, "C") | ||
self.set_font("helvetica", "U", 8) | ||
self.set_text_color(0, 0, 255) | ||
self.cell(30, 10, "quivr.app", 0, 0, "C", link="https://quivr.app") | ||
self.cell(0, 10, "Github", 0, 1, "C", link="https://github.com/quivrhq/quivr") | ||
|
||
def chapter_body(self): | ||
self.set_font("Arial", "", 12) | ||
self.multi_cell(0, 10, self.pdf_model.content, markdown=True) | ||
self.ln() | ||
|
||
def print_pdf(self): | ||
self.add_page() | ||
self.chapter_body() | ||
|
||
|
||
if __name__ == "__main__": | ||
pdf_model = PDFModel( | ||
title="Summary of Legal Services Rendered by Orrick", | ||
content=""" | ||
**Summary:** | ||
The document is an invoice from Quivr Technologies, Inc. for legal services provided to client YC W24, related to initial corporate work. The total fees and disbursements amount to $8,345.00 for services rendered through February 29, 2024. The invoice includes specific instructions for payment remittance and contact information for inquiries. Online payment through e-billexpress.com is also an option. | ||
**Key Points:** | ||
- Quivr Technologies, Inc., based in France and represented by Stanislas Girard, provided legal services to client YC W24. | ||
- Services included preparing and completing forms, drafting instructions, reviewing and responding to emails, filing 83(b) elections, and finalizing documents for submission to YC. | ||
- The timekeepers involved in providing these services were Julien Barbey, Maria T. Coladonato, Michael LaBlanc, Jessy K. Parker, Marisol Sandoval Villasenor, Alexis A. Smith, and Serena Tibrewala. | ||
- The total hours billed for the services provided was 16.20, with a total cost of $8,345.00. | ||
- Instructions for payment remittance, contact information, and online payment options through e-billex | ||
""", | ||
) | ||
pdf = PDFGenerator(pdf_model) | ||
pdf.print_pdf() | ||
pdf.output("simple.pdf") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters