Compare commits

..

No commits in common. "daa69445f1287115f9a79ecec5d7ab57d0d0c712" and "18b0e79fb92d46a63ef258a136c428db7c1b3441" have entirely different histories.

3
bot.py
View File

@ -8,7 +8,6 @@ from dotenv import load_dotenv
load_dotenv() load_dotenv()
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN') DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
MAX_TOKENS = int(os.getenv('MAX_TOKENS'))
aclient = AsyncOpenAI(api_key=OPENAI_API_KEY) aclient = AsyncOpenAI(api_key=OPENAI_API_KEY)
# Initialize OpenAI API # Initialize OpenAI API
@ -35,7 +34,7 @@ async def on_message(message):
async def ask_gpt(ctx, *, question: str): async def ask_gpt(ctx, *, question: str):
try: try:
# Send the question to GPT-4o using the new OpenAI API # Send the question to GPT-4o using the new OpenAI API
response = await aclient.chat.completions.create(model="gpt-4o", max_tokens=MAX_TOKENS, response = await aclient.chat.completions.create(model="gpt-4o",
messages=[ 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": "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} {"role": "user", "content": question}