Enable ChatGPT API-powered translation on your Mastodon instance!
A lightweight scirpt that act as LibreTranslate service but chat with GPT to get translation done.
Recommand to run with uv. If you want other tools or run it manually, see pyproject.toml for package dependencies.
export OPENAI_API_KEY=sk-xxxxxxxxxx
uv run chatlibre.pyUpdate Mastodon environment variables:
LIBRE_TRANSLATE_ENDPOINT=http://localhost:8080
LIBRE_TRANSLATE_API_KEY=whatever
(We don't check LibreTranslate API key, so this value doesn't matter)
Then restart your Mastodon web server.
Clone this repo into /opt/chatlibre, then
cd /opt/chatlibre
cp systemd/* /etc/systemd/system/
echo sk-xxxxxxxxxx > openai_key
chmod og-r openai_keyEdit chatlibre.service if you use path other than /opt/chatlibre.
Edit chatlibre.socket to change listen address and port number.
systemctl daemon-reload
systemctl enable --now chatlibre.socket