Add env var for openai api endpoint

This commit is contained in:
2026-02-28 09:30:35 -05:00
parent f225eb2dc0
commit ddf5d02232
3 changed files with 23 additions and 4 deletions

View File

@@ -20,4 +20,4 @@ export DISCORD_TOKEN=$(cat .token)
podman run -e DISCORD_TOKEN localhost/vibe-bot:latest
```
## Deploy
## Deploy

10
main.py
View File

@@ -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

15
vibe-bot.container Normal file
View File

@@ -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