Skip to main content

Take large input or read a file and send it in chunks to ChatGPT.

Project description

chatgptmax

PyPI Version Python Version License

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

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.

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 function to read and clean the text from this file:

from chatgptmax import clean_text_from_file

# 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.

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.

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

chatgptmax-1.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

chatgptmax-1.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file chatgptmax-1.0.1.tar.gz.

File metadata

  • Download URL: chatgptmax-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for chatgptmax-1.0.1.tar.gz
Algorithm Hash digest
SHA256 af2fae535b835c54f18456cc1966b8e17d5bdcdf8e99116d0a2b351d68d32229
MD5 c5603f730ab9ec756fcfd1465f66c999
BLAKE2b-256 21335e4cd41812ccd3b62aba9af7a6624cca6a5900f15d69b60d1d34d2061adc

See more details on using hashes here.

File details

Details for the file chatgptmax-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: chatgptmax-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for chatgptmax-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68c554ab09f9df40f451ebdb08cf74665fdd0bc57d8baf9daba593605a941928
MD5 dc11c50a62286a911848232021fc47b6
BLAKE2b-256 8fedb2422a33c799c36f8553594752eca78770c0f2aaee044303a0222eba655e

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