diff --git a/ChatGPT/README.md b/ChatGPT/README.md index 7915ba8..ca30ce9 100644 --- a/ChatGPT/README.md +++ b/ChatGPT/README.md @@ -6,4 +6,14 @@ Get an API key from https://platform.openai.com/account/api-keys (free) @config plugins.chatgpt.api_key YOUR_KEY_HERE +@config plugins.chatgpt.prompt "You are $botnick the IRC bot. Be brief, helpful" +^^ Configurable per channel, etc. get creative + +@chat + +^^ Command to send text to the chatgpt API + +@messageparser add "(?i)(.*BOT_NICK_HERE.*)" "chat $1" + +^^ replace BOT_NICK_HERE with your bot nick and add automatic replies to nick mentions diff --git a/ChatGPT/config.py b/ChatGPT/config.py index aa57571..f64a289 100644 --- a/ChatGPT/config.py +++ b/ChatGPT/config.py @@ -68,7 +68,7 @@ conf.registerChannelValue( ChatGPT, "prompt", registry.String( - "You are a helpful IRC bot that responds in 400 characters or less", + "You are $botnick the IRC bot. Be brief, helpful", _( """ The prompt defining your bot's personality. @@ -77,6 +77,19 @@ conf.registerChannelValue( ), ) +conf.registerChannelValue( + ChatGPT, + "model", + registry.String( + "gpt-3.5-turbo", + _( + """ + OpenAI endpoint model, default: "gpt-3.5-turbo" + """ + ), + ), +) + conf.registerChannelValue( ChatGPT, "reply_intact", diff --git a/ChatGPT/plugin.py b/ChatGPT/plugin.py index e0d82c3..3d2c5a8 100644 --- a/ChatGPT/plugin.py +++ b/ChatGPT/plugin.py @@ -45,9 +45,9 @@ class ChatGPT(callbacks.Plugin): def chat(self, irc, msg, args, text): """Manual Call to the ChatGPT API""" openai.api_key = self.registryValue("api_key") - prompt = self.registryValue("prompt", msg.channel) + prompt = self.registryValue("prompt", msg.channel).replace("$botnick", irc.nick) completion = openai.ChatCompletion.create( - model="gpt-3.5-turbo", + model=self.registryValue("model", msg.channel), messages=[ {"role": "system", "content": prompt}, {"role": "user", "content": text},