An updated bot that posts to Tumblr, based on your very own blog!
Project description
tumblrbot
Description of original project:
4tv-tumblrbot was a collaborative project I embarked on with my close friend Dima, who goes by @smoqueen on Tumblr. The aim of this endeavor was straightforward yet silly: to develop a Tumblr bot powered by a machine-learning model. This bot would be specifically trained on the content from a particular Tumblr blog or a selected set of blogs, allowing it to mimic the style, tone, and thematic essence of the original posts.
This fork is largely a rewrite of the source code with similarities in its structure and process.
Features:
- An interactive console for all steps of generating posts for the blog:
- Asks for OpenAI and Tumblr tokens.
- Stores API tokens using keyring.
- Retrieves Tumblr OAuth tokens.
- Downloads posts from the configured blogs.
- Skips redownloading already downloaded posts.
- Shows progress and previews the current post.
- Creates examples to fine-tune the model from your posts.
- Filters out posts that contain more than just text data.
- Adds custom user messages and assistant responses to the dataset from the configured file.
- Filters out any posts flagged by the OpenAI Moderation API.
- Uploads examples to OpenAI and begins the fine-tuning process.
- Provides cost estimates if the currently saved examples are used to fine-tune the configured model.
- Resumes monitoring the same fine-tuning process when restarted.
- Deletes the uploaded examples file if fine-tuning does not succeed (optional).
- Stores the output model automatically when fine-tuning is completed.
- Generates and uploads posts to the configured blog using the configured fine-tuned model.
- Creates tags by extracting keywords at the configured frequency using the configured model.
- Uploads posts as drafts to the configured blog.
- Reblogs posts from the configured blogs at the configured frequency.
- Shows progress and previews the current post.
- Asks for OpenAI and Tumblr tokens.
- Colorful output, progress bars, and post previews using rich.
- Automatically keeps the config file up-to-date and recreates it if missing.
To-Do:
- Create training data from a sample of posts (possible).
- User-specified list of words that will filter out posts.
Known Issues:
- Sometimes, you will get an error about the training file not being found when starting fine-tuning. We do not currently have a fix or workaround for this. You should instead use the online portal for fine-tuning if this continues to happen. Read more in fine-tuning.
- Post counts are incorrect when downloading posts. We are not certain what the cause of this is, but our tests suggest this is a Tumblr API problem that is giving inaccurate numbers.
- During post downloading or post generation, you may receive a "Limit Exceeded" error message from the Tumblr API. This is caused by server-side rate-limiting by Tumblr. The only workaround is trying again or waiting for a period of time before retrying. In most cases, you either have to wait for a minute or an hour for the limits to reset. You can read more about the limits in the Tumblr API documentation on rate limits.
Please submit an issue or contact us for features you want added/reimplemented.
Installation
- Install the latest version of Python:
- Windows:
winget install python3 - Linux (apt):
apt install python-pip - Linux (pacman):
pacman install python-pip
- Windows:
- Install the pip package:
pip install tumblrbot- Alternatively, you can install from this repository:
pip install git+https://github.com/MaidThatPrograms/tumblrbot.git - On Linux, you will have to make a virtual environment or use the flag to install packages system-wide.
- See keyring for additional requirements if you are not on Windows.
- Alternatively, you can install from this repository:
Usage
Run tumblrbot from anywhere. Run tumblrbot --help for command-line options. Every command-line option corresponds to a value from the config.
Obtaining Tokens
OpenAI
API token can be created here: OpenAI Tokens.
- Leave everything at the defaults and set
ProjecttoDefault Project. - Press
Create secret key. - Press
Copyto copy the API token to your clipboard.
Tumblr
API tokens can be created here: Tumblr Tokens.
- Press
+ Register Application. - Enter anything for
Application NameandApplication Description. - Enter any URL for
Application WebsiteandDefault callback URL, likehttps://example.com. - Enter any email address for
Administrative contact email. It probably doesn't need to be one you have access to. - Press the checkbox next to
I'm not a robotand complete the CAPTCHA. - Press
Register. - You now have access to your
consumer keynext toOauth Consumer Key. - Press
Show secret keyto see yourConsumer Secret.
When running this program, you will be prompted to enter all of these tokens. The fields are password-protected, so there will be no output to the console. If something goes wrong while entering the tokens, you can always reset them by running the program again and answering y to the relevant prompt.
After inputting the Tumblr tokens, you will be given a URL that you need to open in your browser. Press Allow, then copy and paste the URL of the page you are redirected to into the console.
Configuration
All config options can be found in config.toml after running the program once. This will be kept up-to-date if there are changes to the config's format in a future update. This also means it may be worthwhile to double-check the config file after an update. Any changes to the config should be in the changelog for a given version.
All file options can include directories that will be created when the program is run.
All config options that involve blog identifiers expect any version of a blog URL, which is explained in more detail in the Tumblr API documentation on blog identifiers.
Specific Options:
-
custom_prompts_fileThis file should follow the following file format:{"user message 1": "assistant response 1"} {"user message 1": "assistant response 1"} {"user message 2": "assistant response 2", "user message 3": "assistant response 3"}
To be specific, it should follow the JSON Lines file format with one collection of name/value pairs (a dictionary) per line. You can validate your file using the JSON Lines Validator.
-
developer_message- This message is used in for fine-tuning the AI as well as generating prompts. If you change this, you will need to run the fine-tuning again with the new value before generating posts. -
user_message- This setting is used and works in the same way asdeveloper_message. -
expected_epochs- The default value here is the default number of epochs forbase_model. You may have to change this value if you changebase_model. After running fine-tuning once, you will see the number of epochs used in the fine-tuning portal under Hyperparameters. This value will also be updated automatically if you run fine-tuning through this program. -
token_price- The default value here is the default token price forbase_model. You can find the up-to-date value in OpenAI Pricing, in the Training column. -
job_id- If there is any value here, this program will resume monitoring the corresponding job, instead of starting a new one. This gets set when starting the fine-tuning and is cleared when it is completed. You can read more in fine-tuning. -
base_model- This value is used to choose the tokenizer for estimating fine-tuning costs. It is also the base model that will be fine-tuned and the model that is used to generate tags. You can find a list of options in the fine-tuning portal by pressing+ Createand opening the drop-down list forBase Model. Be sure to updatetoken_priceif you change this value. -
fine_tuned_model- Set automatically after monitoring fine-tuning if the job has succeeded. You can read more in fine-tuning. -
tags_chance- This should be between 0 and 1. Setting it to 0 corresponds to a 0% chance (never) to add tags to a post. 1 corresponds to a 100% chance (always) to add tags to a post. Adding tags incurs a very small token cost. -
reblog_chance- This setting works the same way astags_chance. -
reblog_user_message- This setting is a prefix that is directly prepended to the contents of the post being reblogged.
Manual Fine-Tuning
You can manually upload the examples file to OpenAI and start the fine-tuning here: fine-tuning portal.
- Press
+ Create. - Select the desired
Base Modelfrom the dropdown. This should ideally match the model set in the config. - Upload the generated examples file to the section under
Training data. You can find the path for this in the config. - Press
Create. - (Optional) Copy the value next to
Job IDand paste it into the config underjob_id. You can then run the program and monitor its progress as usual. - If you do not do the above, you will have to copy the value next to
Output modelonce the job is complete and paste it into the config underfine_tuned_model.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tumblrbot-1.7.0.tar.gz.
File metadata
- Download URL: tumblrbot-1.7.0.tar.gz
- Upload date:
- Size: 134.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83492426503872e89a59fec2e5c851999b7dad674b01be33ff408074c392afcd
|
|
| MD5 |
b90151c242c2848b36d7263cc42d7880
|
|
| BLAKE2b-256 |
4e0765c24cf13d16747130923e9c6ff3a9ed66e26f026f9ce003570f2428e795
|
File details
Details for the file tumblrbot-1.7.0-py3-none-any.whl.
File metadata
- Download URL: tumblrbot-1.7.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f23cc4e3aa82c83cd0cf56549690eef3d1bd1bc9128cb26c910a411d1e889a39
|
|
| MD5 |
3cbc05fbfebe0ea3236198969d030d59
|
|
| BLAKE2b-256 |
e2cc6801241d812ab7196f44eda25a7f72473f6ef20b0a94c3c2ff5ee8e96ed1
|