diff --git a/README.md b/README.md index 30ec9fc..a9ff40c 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,4 @@ export DISCORD_TOKEN=$(cat .token) podman run -e DISCORD_TOKEN localhost/vibe-bot:latest ``` -## Deploy \ No newline at end of file +## Deploy diff --git a/main.py b/main.py index e141758..e8f41d8 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +from re import escape import discord from discord.ext import commands import requests @@ -6,21 +7,24 @@ import json DISCORD_TOKEN = os.getenv("DISCORD_TOKEN", "placeholder") +OPENAI_API_ENDPOINT = os.getenv("OPENAI_API_ENDPOINT") + +if not OPENAI_API_ENDPOINT: + raise Exception("OPENAI_API_ENDPOINT required.") + # Set your OpenAI API key as an environment variable # You can also pass it directly but environment variables are safer OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "placeholder") KEEP_MESSAGE_HISTORY = 5 -QUEUE = [] - # Initialize the bot intents = discord.Intents.default() intents.message_content = True bot = commands.Bot(command_prefix="!", intents=intents) # OpenAI Completions API endpoint -OPENAI_COMPLETIONS_URL = "https://llama-cpp.reeselink.com/chat/completions" +OPENAI_COMPLETIONS_URL = f"{OPENAI_API_ENDPOINT}/chat/completions" @bot.event diff --git a/vibe-bot.container b/vibe-bot.container new file mode 100644 index 0000000..19eddb5 --- /dev/null +++ b/vibe-bot.container @@ -0,0 +1,15 @@ +[Unit] +Description=Discord Bot Container +After=network.target + +[Container] +Image=localhost/vibe-bot:latest +Environment=DISCORD_TOKEN=your_token_here +Environment=OPENAI_API_ENDPOINT=http://host.containers.internal:8000 + +[Service] +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target default.target \ No newline at end of file