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)
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
Built Distribution
File details
Details for the file AI-Summarizer-1.0.3.tar.gz
.
File metadata
- Download URL: AI-Summarizer-1.0.3.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a46fcf4701087e6c9bfad6a0aa4c088dc6f5f64f59d10bdd9009c3552a9f22e5 |
|
MD5 | 2bf90147cd75d1aefb3fe18cd83d9b79 |
|
BLAKE2b-256 | eac9b23a530e739154faad10ffa0ce53ee8cd625a7eb81dcbf7fd637c699ef0b |
File details
Details for the file AI_Summarizer-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: AI_Summarizer-1.0.3-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c5e784a8ec08931c212334f4dc567802f5f00a6dc8b9130cd575d899919cd97 |
|
MD5 | 745bd201fc5a05fe9a3ea09363ec1dd0 |
|
BLAKE2b-256 | 1b5bf7b28fa4b05c8a4f87964717fbb686bf906e371abf1dc644e6a85f2bd93c |