soulshack
v0.74
// ____ _ ____ _ _
// / ___| ___ _ _ | | / ___| | |__ __ _ ___ | | __
// ___ / _ | | | | | | ___ | '_ / _` | / __| | |/ /
// ___) | | (_) | | |_| | | | ___) | | | | | | (_| | | (__ | <
// |____/ ___/ __,_| |_| |____/ |_| |_| __,_| ___| |_|_
// . . . because real people are overrated
Soulshack 是一个 IRC 聊天机器人,它利用 openai api 端点来生成类似人类的响应。
go build .
docker build . -t soulshack:dev
soulshack --nick chatbot --server irc.freenode.net --port 6697 --channel ' #soulshack ' --ssl --apikey ****************
Soulshack 可以使用命令行标志、环境变量或配置文件进行配置。
Usage:
soulshack --channel <channel> [--nick <nickname>] [--server <server>] [--port <port>] [--tls] [--apikey <key>] [flags]
Examples:
soulshack --nick chatbot --server irc.freenode.net --port 6697 --channel '#soulshack' --tls --apikey ****************
Flags:
-a, --addressed require bot be addressed by nick for response (default true)
-A, --admins strings comma-separated list of allowed hostmasks (e.g. alex!~alex@localhost, josh!~josh@localhost).
-t, --apitimeout duration timeout for each completion request (default 5m0s)
-c, --channel string irc channel to join
-C, --chunkdelay duration after this delay, bot will look to split the incoming buffer on sentence boundaries (default 15s)
-m, --chunkmax int maximum number of characters to send as a single message (default 350)
-b, --config string use the named configuration file
--greeting string prompt to be used when the bot joins the channel (default "hello.")
-h, --help help for soulshack
--maxtokens int maximum number of tokens to generate (default 512)
--model string model to be used for responses (default "gpt-4o")
-n, --nick string bot's nickname on the irc server (default "soulshack")
--apikey string openai api key
--apiurl string alternative base url to use instead of openai
-p, --port int irc server port (default 6667)
--prompt string initial system prompt (default "you are a helpful chatbot. do not use caps. do not use emoji.")
--saslnick string nick used for SASL
--saslpass string password for SASL plain
-s, --server string irc server address (default "localhost")
-S, --sessionduration duration duration for the chat session; message context will be cleared after this time (default 3m0s)
-H, --sessionhistory int maximum number of lines of context to keep per session (default 50)
--temperature float32 temperature for the completion (default 0.7)
-e, --tls enable TLS for the IRC connection
--tlsinsecure skip TLS certificate verification
--tools enable tool use (default false)
--toolsdir directory to load tools from (default "examples/tools")
--top_p float32 top P value for the completion (default 1)
-v, --verbose enable verbose logging of sessions and configuration
--version version for soulshack
所有标志也可以通过带有前缀soulshack_
环境变量来设置。例如, soulshack_server
代表--server
标志。
配置文件使用yaml格式。可以使用--config
标志加载它们。配置文件可以包含可以通过标志设置的任何设置。
要使用创建新的配置文件,请按照下列步骤操作:
marvin.yml
)。 nick : marvin
greeting : " explain the size of your brain compared to common household objects. "
prompt : " you are marvin the paranoid android. respond with a short text message: "
channel : " #marvinshouse "
server : localhost
soulshack --config /path/to/marvin.yml
/set
:设置配置参数(例如/set nick newnick
)/get
:获取配置参数的当前值(例如/get nick
)/leave
: 让机器人离开频道并退出/help
: 显示可用命令的帮助将可执行文件或脚本放入您的 tooldir 位置。为了注册它必须响应以下命令:
尝试确保 llm 无法在执行 json 中注入一些会毁掉你生活的东西。因为你不能信任机器人或使用它们的人。
老实说,你不应该对 shell 脚本执行此操作,这有点像雷区。所以这是一个 shell 脚本
set -e
# Check if --schema argument is provided
if [[ " $1 " == " --schema " ]] ; then
# Output a JSON schema to describe the tool
# shellcheck disable=SC2016
cat << EOF
{
"name": "get_current_date_with_format",
"description": "provides the current time and date in the specified unix date command format",
"type": "object",
"properties": {
"format": {
"type": "string",
"description": "The format for the date. use unix date command format (e.g., +%Y-%m-%d %H:%M:%S). always include the leading + sign."
}
},
"required": ["format"],
"additionalProperties": false
}
EOF
exit 0
fi
if [[ " $1 " == " --execute " ]] ; then
# Ensure jq is available
if ! command -v jq & > /dev/null ; then
echo " Error: jq is not installed. " >&2
exit 1
fi
# Extract format field from JSON
format= $( jq -r ' .format ' <<< " $2 " )
# Sanitize the format string
if [[ " $format " =~ [^a-zA-Z0-9%+:/ - ] ]] ; then
echo " Error: Invalid characters in format string. " >&2
exit 1
fi
# Use -- to prevent option parsing
date_output= $( date -- " $format " )
echo " $date_output "
exit 0
fi
# if no arguments, show usage
# shellcheck disable=SC2140
echo " Usage: currentdate.sh [--schema | --execute '{ " format " : " +%Y-%m-%d %H:%M:%S " }'] "