processing.text
Text processing functions
split_text
def split_text(text: str,
               max_length: int = 8192) -> Generator[str, None, None]
Split text into chunks of a maximum length
Arguments:
- textstr - The text to split
- max_lengthint, optional - The maximum length of each chunk. Defaults to 8192.
Yields:
- str- The next chunk of text
Raises:
- ValueError- If the text is longer than the maximum length
summarize_text
def summarize_text(url: str,
                   text: str,
                   question: str,
                   driver: Optional[WebDriver] = None) -> str
Summarize text using the OpenAI API
Arguments:
- urlstr - The url of the text
- textstr - The text to summarize
- questionstr - The question to ask the model
- driverWebDriver - The webdriver to use to scroll the page
Returns:
- str- The summary of the text
scroll_to_percentage
def scroll_to_percentage(driver: WebDriver, ratio: float) -> None
Scroll to a percentage of the page
Arguments:
- driverWebDriver - The webdriver to use
- ratiofloat - The percentage to scroll to
Raises:
- ValueError- If the ratio is not between 0 and 1
create_message
def create_message(chunk: str, question: str) -> Dict[str, str]
Create a message for the chat completion
Arguments:
- chunkstr - The chunk of text to summarize
- questionstr - The question to answer
Returns:
Dict[str, str]: The message to send to the chat completion
write_to_file
def write_to_file(filename: str, text: str) -> None
Write text to a file
Arguments:
- textstr - The text to write
- filenamestr - The filename to write to