This file contains hidden or 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
| from reportlab.pdfbase import pdfmetrics | |
| from reportlab.pdfbase.ttfonts import TTFont | |
| from reportlab.lib.pagesizes import A4 | |
| from reportlab.lib.units import inch | |
| from reportlab.pdfgen import canvas | |
| def split_text_into_chunks(text, num_chunks): | |
| """Split the text into specified number of chunks.""" | |
| lines_per_chunk = len(text) // num_chunks | |
| return [text[i * lines_per_chunk:(i + 1) * lines_per_chunk] for i in range(num_chunks - 1)] + [text[(num_chunks - 1) * lines_per_chunk:]] |
This file contains hidden or 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
| # coding: utf-8 | |
| # !pip install -U openai | |
| import time | |
| from copy import deepcopy | |
| import openai | |
| from openai._types import NOT_GIVEN | |
| openai.api_key = '<YOUR_API_KEY>' |