Skip to main content

chatgptmax

PyPI Version Python Version License

A Python package for sending long input text to OpenAI's GPT models using message chunking.

Read the blog post that inspired this project.

Installation

You can install chatgptmax using pip:

pip install chatgptmax

Usage

Here's are basic usage examples of the chatgptmax module. This assumes you have an OpenAI API key set up as an environment variable, OPENAI_API_KEY.

You can also try out chatgptmax using the Jupyter notebook provided here.

Clean text with preprocessing

Suppose you have a file named sample.txt with the following content:

This is a sample text. It contains some stop words that should be removed. We will use the chatgptmax module to clean and process this text.

You can use the clean.text_from_file method to read and clean the text from this file:

from chatgptmax import clean

# Specify the path to your file
file_path = "sample.txt"

# Clean and process the text from the file
cleaned_text = clean.text_from_file(file_path)

# Print the cleaned text
print(cleaned_text)

This code will read the content of sample.txt, remove common stopwords, and print the cleaned text:

This sample text contains stop words removed. We chatgptmax module clean process text.

Send lots of text to ChatGPT

You can use the send function to send a prompt along with a large amount of text data from a file to ChatGPT:

from chatgptmax import send, read_data

# Define the path to your text file
file_path = "path_to_your_file.txt"

# Read the text data from the file
text_data = read_data(file_path)

# Define your prompt
prompt_text = "Summarize the following text for me:"

# Send the text data to ChatGPT for summarization
responses = send(prompt=prompt_text, text_data=text_data)

# Print ChatGPT's responses
for response in responses:
    print(response)

This code will send the cleaned text as text data to ChatGPT along with the prompt. ChatGPT will provide responses based on your prompt and text data.

Please make sure you have your OpenAI API key properly set up as an environment variable or using a secret management service for this example to work.

For more examples and instructions, read the documentation

Documentation

For more information on how to use chatgptmax, please refer to the official documentation.

Contributing

If you'd like to contribute to this project, please read our Contribution Guide for details on how to get started.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Release files for chatgptmax 2.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chatgptmax 2.3.5
File Size Uploaded
chatgptmax-2.3.5.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chatgptmax 2.3.5
File Interpreter ABI Platform
chatgptmax-2.3.5-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / chatgptmax-2.3.5.tar.gz

Download URL chatgptmax-2.3.5.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b7194f38987225670527db483e8f0ced6ddba052790460c6653eccd40adb6617
BLAKE2b-256 checksum
How to use checksums
4d45318b1101fa67bda52e2e94b5f7e1747e0095d7ee1d398243e2a0cc9a06d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / chatgptmax-2.3.5-py3-none-any.whl

Download URL chatgptmax-2.3.5-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
197e226dee075bbbf7cf75325aa83f602b84ab429a872fe6144eab67763a3d79
BLAKE2b-256 checksum
How to use checksums
e394c1146a4f83b686ec420ae32f75aed0f1d3915895d1563aeb4c48d6163762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release history Release notifications | RSS feed

This release

2.3.5 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page