This module provides tools for cleaning text, removing stopwords, reading text from files, and sending text data to ChatGPT via the OpenAI API.
Before using the chatgptmax
module, make sure you have the necessary dependencies installed, including OpenAI's Python library and tiktoken
. You will also need to set up your OpenAI API key. Follow the instructions in the OpenAI API documentation for more information on setting up your API key.
You can install the required dependencies using pip
:
pip install -r requirements.txt
If you plan to contribute, please also install and use black
to format the files:
pip install --upgrade black
To use the chatgptmax
module, follow these steps:
- Sign up for ChatGPT and create a secret API key. More information here: https://platform.openai.com/docs/quickstart/step-2-setup-your-api-key
- Ensure your key is present in the environment variable
OPENAI_API_KEY
. For instructions, read Set up your OpenAI API key - Import and use
chatgptmax
as shown in the examples below.
The clean.text
method can be used to clean text by removing URLs, email addresses, non-letter characters, and extra whitespace.
from chatgptmax.clean import text
# Clean the input text
just_letters = text("Your input text goes here.")
# Print the cleaned text
print(just_letters)
The clean.stopwords
method removes common stopwords from the provided text.
from chatgptmax.clean import stopwords
# Remove stopwords from the input text
text_without_stopwords = stopwords("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.")
The read_data
method reads the content of a file and returns it as a string.
from chatgptmax import read_data
# Specify the path to your file
file_path = "path_to_your_file.txt"
# Read the content of the file
file_content = read_data(file_path)
The send
method sends text data to ChatGPT for processing. It can handle large text by splitting it into chunks.
from chatgptmax import send
# Define your prompt and text data
prompt_text = "Summarize the following text for me:"
text_data = cleaned_text # Use the cleaned text
# 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)
If you would like to contribute to the chatgptmax
module, please follow these steps:
- Fork the repository to your GitHub account.
- Create a new branch for your contributions.
- Make your changes and improvements.
- Commit your changes with clear and concise commit messages.
- Push your changes to your forked repository.
- Open a pull request against the
master
branch of the original repository.
For more details, see CONTRIBUTING.md.
We welcome contributions and suggestions to improve this module.
Happy coding!