Skip to content

Commit

Permalink
openai: fix text
Browse files Browse the repository at this point in the history
  • Loading branch information
bghira committed May 26, 2024
1 parent 085fef9 commit f84bacb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions discord_tron_master/classes/openai/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f84bacb

Please sign in to comment.