From 73dffac2907a369202d3cdf6f874c3bc6d3f0fbe Mon Sep 17 00:00:00 2001 From: Gordon Shumway Date: Wed, 29 May 2024 04:39:14 -0400 Subject: [PATCH] Update plugin.py Simplify/modernize/fix? --- ChatGPT/plugin.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ChatGPT/plugin.py b/ChatGPT/plugin.py index 1dadd71..8e5e852 100644 --- a/ChatGPT/plugin.py +++ b/ChatGPT/plugin.py @@ -31,7 +31,7 @@ from supybot import utils, plugins, ircutils, callbacks from supybot.commands import * from supybot.i18n import PluginInternationalization -from openai import OpenAI +import openai _ = PluginInternationalization("ChatGPT") @@ -44,9 +44,9 @@ class ChatGPT(callbacks.Plugin): def chat(self, irc, msg, args, text): """Manual Call to the ChatGPT API""" - client = OpenAI(api_key=self.registryValue("api_key")) + openai.api_key = self.registryValue("api_key") prompt = self.registryValue("prompt", msg.channel).replace("$botnick", irc.nick) - completion = client.chat.completions.create( + completion = openai.chat.completions.create( model=self.registryValue("model", msg.channel), messages=[ {"role": "system", "content": prompt}, @@ -70,8 +70,6 @@ class ChatGPT(callbacks.Plugin): chat = wrap(chat, ["text"]) - Class = ChatGPT - # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: