Compare commits
3 Commits
18b0e79fb9
...
master
Author | SHA1 | Date | |
---|---|---|---|
1891fe5d57 | |||
daa69445f1 | |||
358a423c6b |
3
bot.py
3
bot.py
@@ -8,6 +8,7 @@ from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
|
||||
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
||||
MAX_TOKENS = int(os.getenv('MAX_TOKENS'))
|
||||
aclient = AsyncOpenAI(api_key=OPENAI_API_KEY)
|
||||
# Initialize OpenAI API
|
||||
|
||||
@@ -34,7 +35,7 @@ async def on_message(message):
|
||||
async def ask_gpt(ctx, *, question: str):
|
||||
try:
|
||||
# Send the question to GPT-4o using the new OpenAI API
|
||||
response = await aclient.chat.completions.create(model="gpt-4o",
|
||||
response = await aclient.chat.completions.create(model="gpt-4o", max_tokens=MAX_TOKENS,
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant. You exist inside a discord server. There is a character limit so please keep responses brief if possible."},
|
||||
{"role": "user", "content": question}
|
||||
|
@@ -3,6 +3,7 @@ version: '3.8'
|
||||
services:
|
||||
discord-bot:
|
||||
network_mode: bridge
|
||||
restart: always
|
||||
build: .
|
||||
container_name: discord-bot
|
||||
env_file:
|
||||
|
Reference in New Issue
Block a user