From f84bacb22d0adeb52e72ad81d7ce808937185a85 Mon Sep 17 00:00:00 2001 From: bghira Date: Sun, 26 May 2024 17:37:02 -0600 Subject: [PATCH] openai: fix text --- discord_tron_master/classes/openai/text.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/discord_tron_master/classes/openai/text.py b/discord_tron_master/classes/openai/text.py index 8a3ccc7..436ace6 100644 --- a/discord_tron_master/classes/openai/text.py +++ b/discord_tron_master/classes/openai/text.py @@ -6,16 +6,20 @@ logger = logging.getLogger(__name__) import openai +from openai import OpenAI openai.api_key = config.get_openai_api_key() class GPT: def __init__(self): - self.engine = "gpt-4-1106-preview" + self.engine = "gpt-4o" self.temperature = 0.9 self.max_tokens = 4096 self.discord_bot_role = "You are a Discord bot." self.concurrent_requests = config.get_concurrent_openai_requests() self.config = AppConfig() + self.client = OpenAI( + api_key=config.get_openai_api_key() + ) def set_values(self, **kwargs): for key, value in kwargs.items(): @@ -145,8 +149,8 @@ async def discord_bot_response(self, prompt, ctx = None): return await self.turbo_completion(user_role, prompt, temperature=user_temperature, max_tokens=4096) def send_request(self, message_log): - return openai.ChatCompletion.create( - model="gpt-4-1106-preview", + return self.client.chat.completions.create( + model="gpt-4o", messages=message_log, max_tokens=self.max_tokens, stop=None,