1: Install Zenity and jq
Zenity usually comes with LXDE. If it's not there, install it with:
Code: Select all
slapt-mod -m zenityCode: Select all
slapt-mod -m jqCode: Select all
mv /tmp/zenity-*.xzm /mnt/sdaX/porteus/modules/
mv /tmp/jq-*.xzm /mnt/sdaX/porteus/modules/If slapt-mod throws the Failed to open package_data error, fix the path with:
Code: Select all
sed -i 's|/var/cache/slapt-get|/var/slapt-get|g' /etc/slapt-get/slapt-getrc
slapt-mod -uThis tutorial uses Public AI (https://platform.publicai.co/) because it's free and compatible with the OpenAI format. Any similar API will work.
Sign up on the platform.
Create an API Key.
Copy the key.
3: Create the bot script
Create the chat_bot.sh file in your home folder:
Code: Select all
cat > /home/guest/chat_bot.sh << 'SCRIPT_END'
#!/bin/bash
API_KEY="YOUR_KEY_HERE"
API_URL="https://api.publicai.co/v1/chat/completions"
MODEL="swiss-ai/apertus-v1.5-8b"
while true; do
msg=$(zenity --entry --title="Chat" --text="Type your message:" --width=400)
[ -z "$msg" ] && break
response=$(curl -s "$API_URL" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-H "User-Agent: MiBot/1.0" \
-d "{\"model\":\"$MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"$msg\"}]}" \
| jq -r '.choices[0].message.content')
zenity --info --title="Bot" --text="$response" --width=400
done
SCRIPT_END
chmod +x /home/guest/chat_bot.sh4: Test it from the terminal
Code: Select all
/home/guest/chat_bot.sh5: Create a desktop icon
Create the launcher:
Code: Select all
cat > /home/guest/Desktop/ChatBot.desktop << 'DESKTOP_END'
[Desktop Entry]
Type=Application
Name=My AI Chat Bot
Comment=Launcher for the AI Chat Bot
Exec=/home/guest/chat_bot.sh
Icon=utilities-terminal
Terminal=false
DESKTOP_END
chmod +x /home/guest/Desktop/ChatBot.desktopNotes and limitations
Zenity is not a real chat app. Every message opens a new window. For a Telegram-like experience you'd need yad or a more complete graphical toolkit.
The API Key is stored inside the script. On a shared machine, it's better to move it to a separate file.
The bot has no memory. Each message is sent as if it were the first one. To add memory, you'd need to accumulate messages in an array and send them all together.
Porteus doesn't save changes by default. You need persistence enabled (save.dat or similar) so the script and the icon survive a reboot.
see the video for this: https://i.imgur.com/5VWCZhQ.mp4
Input message in the Chat Bot

and Output







