Skip to main content

AI Summarizer is a Python package that uses OpenAI's GPT-3.5 to summarize any given text.

Project description

AI Summarizer

AI Summarizer is a Python package that uses OpenAI's GPT-3.5 to summarize any given text. You can input some text describing what kind of information you are interested in. When the text is too long it splits it logically into different sections, to make it simpler to summarise

Installation

You can install AI-Summarizer using pip:

pip install AI-Summarizer

You also need to set up your OpenAI API key, which can be obtained from the OpenAI website. Once you have your API key, create a .env file in the root directory of your project and add the following line:

OPENAI_API_KEY=<your-api-key>

Make sure to replace with your actual API key.

Usage

Here's a simple example of how to use AI Summarizer. It has been developed to create short summaries that the AI can digest. It should work with any page, but so far it has been only tested with wikipedia pages

from ai_summarizer import summarize_text

text = <insert long wikipedia page text here>

filter = "technological breakthrough"

summary_length = 500

model = "gpt-3.5-turbo"

summary = summarize_text(text, filter=filter, summary_length=summary_length, model=model, max_number_tokens=4096)

print(summary)

This example summarizes a text from wikipedia using the summarize_text() function from the AI Summarizer library. The filter parameter is used to specify the keywords to include in the summary, the summary_length parameter is used to specify the maximum length of the summary, and the model parameter is used to specify the GPT-3 model to use.

This will output a summary of (about) the correct length of the given text.

The library includes also a number of other functions that were necessary for it to function, and could be of great utility for others as well.

def split_text_logically(A: str) --> A_part_1, A_part_2

takes some text in markdown format and splits it into two parts. The usual way to do this is to split it half way, just keeping some text in common. I abhore this practice, as I would abhore reading a book from half a word. Instead it tries to split it using sections, and if this is not possible sub-sections, and if this is not possible...

This is useful to analyse the text to summarise easily. But it could be useful for a lot of other reasons too.

def get_number_of_tokens(text,model="gpt-3.5-turbo")

this will give you an approximation of how many tokens would this text be, if you need to send it to openai. Although if you need this function, you are probably better off just using directly tiktoken and not this which is just a wrap.

def html_to_markdown(html_content,ignore_links=True)

This will transform the html text into markdown text. We do this because it is much easier to handle and underastand markdown text for an AI than html which includes a lot of elements unnecessary.

License AI Summarizer is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AI-Summarizer-1.0.4.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

AI_Summarizer-1.0.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file AI-Summarizer-1.0.4.tar.gz.

File metadata

  • Download URL: AI-Summarizer-1.0.4.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for AI-Summarizer-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e6b661c27e0ed0cd89aff491916dda4b1590e5855743d1e363b012231b5ff373
MD5 3ccf7a21260a125d9d4b2b4efb512272
BLAKE2b-256 7ec05919e119e794873212f5800ed88922d5672fa9edb29393b56a6cf02f1020

See more details on using hashes here.

File details

Details for the file AI_Summarizer-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for AI_Summarizer-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 892fd81e6b808d3496ce87db3bafe73c7a9f707d3e40f482a145c548d1732092
MD5 fa751f299fcba0037f34c7fd74da788e
BLAKE2b-256 4ac89ea1938350fb9787142cf375d0e8985ec435622ad620ee01049cb353f3e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page