chat/config.py

128 lines
4.1 KiB
Python

###
# Copyright (c) 2023, John Burwell
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the author of this software nor the name of
# contributors to this software may be used to endorse or promote products
# derived from this software without specific prior written consent.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
###
from supybot import conf, registry
try:
from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('Chat')
except:
# Placeholder that allows to run the plugin on a bot
# without the i18n module
_ = lambda x: x
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
# a bool that specifies whether the user identified themself as an advanced
# user or not. You should effect your configuration by manipulating the
# registry as appropriate.
from supybot.questions import expect, anything, something, yn
conf.registerPlugin('Chat', True)
Chat = conf.registerPlugin('Chat')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(Chat, 'someConfigVariableName',
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
# API key
conf.registerGlobalValue(
Chat,
"api_key",
registry.String(
"",
_("""Your ChatGPT API key"""),
private=True,
)
)
# Model
conf.registerChannelValue(
Chat,
"model",
registry.String(
"gpt-3.5-turbo",
_("""The language model to use"""),
),
)
# System prompt
conf.registerChannelValue(
Chat,
"system_prompt",
registry.String(
"I am an IRC bot named $bot_name, in an IRC channel called $channel_name. I will not remind users that I am an AI or what my limitations are; I will just respond. I will not prefix my own response with any user's name. The following is a transcript of the conversation in the channel.",
_("""The 'system' prompt first given to ChatGPT"""),
),
)
# What to do with multi-line replies
conf.registerChannelValue(
Chat,
"join_multiple_lines",
registry.Boolean(
True,
_("""Combine multiple lines in the response into one string. If false, reply line by line"""),
),
)
# What to use to join multiple lines
conf.registerChannelValue(
Chat,
"join_string",
registry.String(
" / ",
_("""When joining lines, what string to use between each line"""),
),
)
# How much scrollback to include in the prompt
conf.registerChannelValue(
Chat,
"scrollback_lines",
registry.Integer(
30,
_("""How many lines of scrollback history to include in the prompt"""),
),
)
# Maximum tokens to use
conf.registerChannelValue(
Chat,
"max_tokens",
registry.Integer(
1000,
_("""Maximum token count for combined query/reply"""),
),
)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: