Conversational Chatbot + Speedy, (built-in) Reddit Media-Fetching
What it is and what it does:
- There are many separate tools, the chatbot, the reddit fetcher, the image generator, and the downloader, all in the progress of smoothly integrating into one simple "Siri on roids" that does what you need it to do, and is always a click away.
- Chatbot.py incorporates OpenAI's API, allowing access to different models, utilizing the combined power of ChatGPT's knowledge, DALL-E's image creation, reddit's existing content, and more, without the need for a browser, which in today's world, is increasingly vital for privacy from snooping third parties.
- The capabilities of Chatbot.py are blossoming fast, and presets for different use cases, as well as better integration with new tools are continuing to be worked on. I would love feedback on presets that are still in their infancy.
This work in progress is just for friends, but as it progresses, it's intended to be a versatile tool to harness the power of AI and design neat browserless strategies to complete all sorts of tasks! Whether you use it to engage in rich conversations shaping your life perspective, to goof off with fun presets, or even to task it with niche developer work that's historically human-only, the bounds truly are limited only by your imagination.
- My code is written with the end goal of being 100% friendly to investigate, tinker with, and even improve!
- Using this program in your CLI alongside a reliable VPN is leaps ahead of what most software could offer in terms of privacy.
- Browsers leak a lot of information that can be used to identify you.
- All tools in TanTan are pure Python, and run only where and when you call them.
- No third-parties (including me) are EVER contacted by your computer - Your device communicates with explicit calls:
- When sending a prompt in chatbot.py, generating a response makes an API call to an OpenAI endpoint.
- The command
-images
in chatbot.py and use of the image generator from image_generation.py makes an API call to an endpoint for Dall-E. - The command
-yt
in chatbot.py uses pytube to download a video from youtube. - reddit_fetcher.py uses the reddit API to fetch content from reddit (But does not make you subject to much of the tracking on a browser).
- The dev command -len (as well as prompt tokenizing more generally) is 100% offline and processed locally on your device
- All logfiles are stored in text files locally, only for you to reference.
- Go the the main github page @ github.com/TanGentleman/TanTan > Code > Download Zip
- Download TanTan-Main (Should be in ~/Downloads)
- Rename to TanTan and move the folder to the Desktop on your computer.
- This location is the filepath variable in config.py
- I'm working on instructions for Windows, but I need more time to test. I'll update this when I do.
OFFICIALLY OPTIONAL:
- Move chat.py to your home directory instead, and ensure the filepath matches in chat.py and config.py
- If you wish the install the repository anywhere else, just be sure to change it in these two files and you should be all good
- Allows running the terminal command
python3 chat.py
from the default home directory
Getting the Chatbot up and running from scratch (still in development):
- Download the latest python version from the official website: https://www.python.org/downloads/
- Type python3 in terminal
- Install required command line tools if needed
- Install pip (Python package manager)
To install pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
- If you get an error saying WARNING: The scripts pip... are installed in '<.../bin>' which is not on PATH, you have to add it to path
- For that, copy what was written in '<>', adding a /pip3 to it
- This will look something like 'Users/.../Library/Python/3.9/bin/pip3'
- Paste that instead of MUFFIN below
sudo set PATH=%PATH%'MUFFIN'
- install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- install python
brew install python
- You may need to follow the error message(s) and run the prompted commands (like chmod for file permissions)
If anything goes wrong before this point, and you are using the latest version of python/brew, please let me know. Should be smooth sailing after step 1.
Step 2: Install dependencies (Adjust python/python3 pip/pip3 depending on the flexibility of your setup)
- If on MacOS, try:
pip3 install gnureadline
- I don't officially support Windows, but I'll occasionally test the scripts on Windows 11 for core functionality
- Apply
python
andpip
accordingly with the below instructions.
- Apply
- Paste the following commands into terminal:
pip3 install openai
pip3 install clipboard
pip3 install requests
pip3 install pillow
pip3 install pytube
To troubleshoot, make sure packages are updated, specifically trying pip3 --upgrade openai
- Paste your secret openai key to mysecrets.py, and double
- Run
python3 chatbot.py
in terminal from the TanTan repository- Alternatively:
- check the filepath in config.py
- Run
python3 Desktop/TanTan/chatbot.py
from the home directory
- Alternatively:
After completing the prerequisites above, and moving chat.py to your home directory:
- You can run python3 chat.py
from your home directory in terminal
- You're in! Have fun feeling like a computer whiz with the world of knowledge at your fingertips.
To see the manual of commands and descriptions:
tan
ortanman
- FYI: You can follow
python3 chat.py
withconfig <engine> <max_tokens>
with optional-d
,-sp
,-st
,-a (soon)
flags - For instance
python3 chat.py config curie 30
for short, fast, simple responses with low latency. - Or even ...
config codex
for a simple, default-token value codex response generator (great for basic function-making, needs basic prompt engineering)
MacOS Shortcuts: Create a new shortcut with a name of your choice, 'Launch Chatbot' for instance. The body will only have one command.
- Run Shell script (replace Desktop/TanTan with path to repo if you've moved it):
osascript -e 'tell application "Terminal" to do script "python3 Desktop/TanTan/chatbot.py" activate'
- Please check out Chatbot/Chatbot_README.md for documentation and alternate setup environments. (I'll consolidate the info better as I figure out which workflow seems to work best)
Advisory: I recommend using a VPN, especially when connected to public networks
Note: The below is entirely optional and not needed for chatbot.py. It will soon be integrated for cleaner workflows.
- Ask for Text with "Format: {u/user or r/subreddit} {qty} {new/top} {all/year/month/week/day/hour}"
- Run Shell Script
python3 Desktop/TanTan/reddit_fetcher.py -s {PROVIDED_INPUT}
- Text = Shell Script Result
- If <shortcut_failure>
- Run this shortcut again (Link Grab + Download)
- Otherwise
- Show Alert "Would you like to Download?"
- Ask for Text with Folder Name:
- Run Shell Script
python3 Desktop/TanTan/Downloader.py {PROVIDED_INPUT}
- End If
(Pre-req: Create a reddit account)
Follow these steps to set up the Reddit Image Fetcher:
- Log in to your Reddit account and go to api prefs (https://www.reddit.com/prefs/apps).
- Scroll down and create a new app with a name of your choice - this will be used as the user agent when filling out mysecrets.py later on.
- Select 'script' as the type of app, then leave the 'about url' blank and set redirect to http://localhost - this is just a dummy URL for now so you can move on with setup.
- Locate the client id (string of characters written next to an icon under 'personal use script') and client secret (string of characters written next to 'secret'). Copy these into their respective fields in mysecrets.py file, then set token_needed to True. Leave reddit_token as None for now - that's what we're trying to get!
- Double check that all required fields are entered correctly, then run test_setup by entering
python3 Desktop/TanTan/test_setup
into your terminal window - if it doesn't work let me know so I can help you troubleshoot! Hint: Make sure your repository is in the correct place, and you are running this terminal command from your home directory. The printed outcome value is reddit_token, you should enter that as a string into mysecrets.py accordingly before running functions from reddit_fetcher.py
- Set the config.py variables filepath and reddit_folder_name
- Filepath is where you installed this repository.
- reddit_folder_name is a new folder that holds newly generated files
- The other variables in config.py can be used in lieu of additional arguments in the command line
- For now, please stick to subs/users with posts of standard image formats, not videos hosted elsewhere.
- Set the 5 query variables in config.py, or add the Magic String in the command line for step 3.
- [MAGIC STRING] = {u/user or r/subreddit} {qty} {new/top} {all/year/month/week/day/hour}
- Run either command in terminal from your home directory.
python3 Desktop/TanTan/reddit_fetcher.py
python3 Desktop/TanTan/reddit_fetcher.py r/houseplants 50 top year -d
- This should generate a contents.txt file in the {reddit_folder_name} directory (TanTan/{reddit_folder_name})
- The format in the file should be [Title + DELIMITER(something like '||' to separate them) + URL] for each entry
- The only argument following Downloader.py is the desired folder name.
- Run command in terminal from your home directory.
python3 Desktop/TanTan/Downloader.py Folder_For_Collected_Images
- The above example would save the images to TanTan/{reddit_folder_name}/Folder_For_Collected_Images