mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-18 20:50:12 +08:00
feat: add set sep
This commit is contained in:
parent
f73bf5a270
commit
512561d8fd
@ -1547,6 +1547,7 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
- [x] 设置AI聊天密钥xxx
|
||||
- [x] 设置AI聊天模型名xxx
|
||||
- [x] 设置AI聊天系统提示词xxx
|
||||
- [x] 设置AI聊天分隔符`</think>`
|
||||
|
||||
</details>
|
||||
<details>
|
||||
|
||||
@ -41,7 +41,7 @@ func (l *list) add(grp int64, txt string) {
|
||||
}
|
||||
|
||||
func (l *list) body(mn, sysp string, temp float32, grp int64) deepinfra.Model {
|
||||
m := model.NewCustom(mn, "", temp, 0.9, 1024).System(sysp)
|
||||
m := model.NewCustom(mn, sepstr, temp, 0.9, 1024).System(sysp)
|
||||
l.mu.RLock()
|
||||
defer l.mu.RUnlock()
|
||||
for _, msg := range l.m[grp] {
|
||||
|
||||
@ -27,7 +27,7 @@ var (
|
||||
DisableOnDefault: false,
|
||||
Extra: control.ExtraFromString("aichat"),
|
||||
Brief: "OpenAI聊天",
|
||||
Help: "- 设置AI聊天触发概率10\n- 设置AI聊天温度80\n- 设置AI聊天密钥xxx\n- 设置AI聊天模型名xxx\n- 设置AI聊天系统提示词xxx",
|
||||
Help: "- 设置AI聊天触发概率10\n- 设置AI聊天温度80\n- 设置AI聊天密钥xxx\n- 设置AI聊天模型名xxx\n- 设置AI聊天系统提示词xxx\n- 设置AI聊天分隔符</think>",
|
||||
PrivateDataFolder: "aichat",
|
||||
})
|
||||
lst = newlist()
|
||||
@ -35,12 +35,14 @@ var (
|
||||
|
||||
var (
|
||||
modelname = "deepseek-ai/DeepSeek-R1"
|
||||
systemprompt = "你正在QQ群与用户聊天,用户发送了消息。按自己的心情简短思考后,条理清晰地回应**一句话**,禁止回应多句。"
|
||||
systemprompt = "你正在QQ群与用户聊天,用户发送了消息。按自己的心情简短思考后条理清晰地回复。"
|
||||
sepstr = ""
|
||||
)
|
||||
|
||||
func init() {
|
||||
mf := en.DataFolder() + "model.txt"
|
||||
sf := en.DataFolder() + "system.txt"
|
||||
pf := en.DataFolder() + "sep.txt"
|
||||
if file.IsExist(mf) {
|
||||
data, err := os.ReadFile(mf)
|
||||
if err != nil {
|
||||
@ -57,6 +59,14 @@ func init() {
|
||||
systemprompt = string(data)
|
||||
}
|
||||
}
|
||||
if file.IsExist(pf) {
|
||||
data, err := os.ReadFile(pf)
|
||||
if err != nil {
|
||||
logrus.Warnln("read sep", err)
|
||||
} else {
|
||||
sepstr = string(data)
|
||||
}
|
||||
}
|
||||
|
||||
en.OnMessage(func(ctx *zero.Ctx) bool {
|
||||
txt := ctx.ExtractPlainText()
|
||||
@ -242,4 +252,18 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Text("成功"))
|
||||
})
|
||||
en.OnPrefix("设置AI聊天分隔符", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
args := strings.TrimSpace(ctx.State["args"].(string))
|
||||
if args == "" {
|
||||
ctx.SendChain(message.Text("ERROR: empty args"))
|
||||
return
|
||||
}
|
||||
sepstr = args
|
||||
err := os.WriteFile(pf, []byte(args), 0644)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功"))
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user