This script is a Reddit bot that uses the OpenAI API to generate responses to comments and submissions on Reddit. The bot will authenticate with both Reddit and OpenAI, and then ask the user if they want to reply to any comments or submissions that it comes across. If the user selects yes, the bot will generate a response using OpenAI and post it as a reply on Reddit.
- Python 3.7 or later
- Install requirements:
pip install -r requirements.txt
- Register for a Reddit account and create a Reddit app at https://www.reddit.com/prefs/apps
- Obtain your Reddit app's client ID and client secret, and set them as the values for the
PRAW_CLIENT_IDandPRAW_CLIENT_SECRETenvironment variables, respectively. - Set the value for the
PRAW_USER_AGENTenvironment variable to a string that describes your Reddit app. - Set the value for the
PRAW_USERNAMEenvironment variable to your Reddit username. - Set the value for the
PRAW_PASSWORDenvironment variable to your Reddit password. - Register for an OpenAI API key at https://beta.openai.com/signup/
- Set the value for the
OPENAI_API_KEYenvironment variable to your OpenAI API key. - Rename
copy.envto.env.
- Run the script using python reddit-sphinx.py
- The bot will authenticate with Reddit and OpenAI.
- The user will be prompted to choose which model to use from a list of options (davinci, curie, babbage, ada).
- The user will be prompted to enter a custom prompt for the model to respond to the comment or submission.
- The bot will begin searching for comments and submissions to reply to. When it finds a comment or submission, it will ask the user if they want to reply.
- If the user selects yes, the bot will generate a response using OpenAI and post it as a reply on Reddit.
- The bot will continue running until it is manually stopped with
ctrl+c.
The bot logs all actions to the bot.log file, including the time at which each action was taken, the name of the action, and any relevant messages. The log file is located in the same directory as the script.