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 " }'] "