mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-25 12:31:07 -05:00
ChatGPT: Update README, $botnick prompt replace
This commit is contained in:
parent
585ef8f2de
commit
66d60de97c
@ -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 <text>
|
||||
|
||||
^^ 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
|
||||
|
@ -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",
|
||||
|
@ -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},
|
||||
|
Loading…
x
Reference in New Issue
Block a user