Add env var for openai api endpoint
This commit is contained in:
10
main.py
10
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
|
||||
|
||||
15
vibe-bot.container
Normal file
15
vibe-bot.container
Normal 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
|
||||
Reference in New Issue
Block a user