Skip to content

Commit 512561d

Browse files
committed
feat: add set sep
1 parent f73bf5a commit 512561d

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,7 @@ print("run[CQ:image,file="+j["img"]+"]")
15471547
- [x] 设置AI聊天密钥xxx
15481548
- [x] 设置AI聊天模型名xxx
15491549
- [x] 设置AI聊天系统提示词xxx
1550+
- [x] 设置AI聊天分隔符`</think>`
15501551

15511552
</details>
15521553
<details>

plugin/aichat/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (l *list) add(grp int64, txt string) {
4141
}
4242

4343
func (l *list) body(mn, sysp string, temp float32, grp int64) deepinfra.Model {
44-
m := model.NewCustom(mn, "", temp, 0.9, 1024).System(sysp)
44+
m := model.NewCustom(mn, sepstr, temp, 0.9, 1024).System(sysp)
4545
l.mu.RLock()
4646
defer l.mu.RUnlock()
4747
for _, msg := range l.m[grp] {

plugin/aichat/main.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ var (
2727
DisableOnDefault: false,
2828
Extra: control.ExtraFromString("aichat"),
2929
Brief: "OpenAI聊天",
30-
Help: "- 设置AI聊天触发概率10\n- 设置AI聊天温度80\n- 设置AI聊天密钥xxx\n- 设置AI聊天模型名xxx\n- 设置AI聊天系统提示词xxx",
30+
Help: "- 设置AI聊天触发概率10\n- 设置AI聊天温度80\n- 设置AI聊天密钥xxx\n- 设置AI聊天模型名xxx\n- 设置AI聊天系统提示词xxx\n- 设置AI聊天分隔符</think>",
3131
PrivateDataFolder: "aichat",
3232
})
3333
lst = newlist()
3434
)
3535

3636
var (
3737
modelname = "deepseek-ai/DeepSeek-R1"
38-
systemprompt = "你正在QQ群与用户聊天,用户发送了消息。按自己的心情简短思考后,条理清晰地回应**一句话**,禁止回应多句。"
38+
systemprompt = "你正在QQ群与用户聊天,用户发送了消息。按自己的心情简短思考后条理清晰地回复。"
39+
sepstr = ""
3940
)
4041

4142
func init() {
4243
mf := en.DataFolder() + "model.txt"
4344
sf := en.DataFolder() + "system.txt"
45+
pf := en.DataFolder() + "sep.txt"
4446
if file.IsExist(mf) {
4547
data, err := os.ReadFile(mf)
4648
if err != nil {
@@ -57,6 +59,14 @@ func init() {
5759
systemprompt = string(data)
5860
}
5961
}
62+
if file.IsExist(pf) {
63+
data, err := os.ReadFile(pf)
64+
if err != nil {
65+
logrus.Warnln("read sep", err)
66+
} else {
67+
sepstr = string(data)
68+
}
69+
}
6070

6171
en.OnMessage(func(ctx *zero.Ctx) bool {
6272
txt := ctx.ExtractPlainText()
@@ -242,4 +252,18 @@ func init() {
242252
}
243253
ctx.SendChain(message.Text("成功"))
244254
})
255+
en.OnPrefix("设置AI聊天分隔符", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
256+
args := strings.TrimSpace(ctx.State["args"].(string))
257+
if args == "" {
258+
ctx.SendChain(message.Text("ERROR: empty args"))
259+
return
260+
}
261+
sepstr = args
262+
err := os.WriteFile(pf, []byte(args), 0644)
263+
if err != nil {
264+
ctx.SendChain(message.Text("ERROR: ", err))
265+
return
266+
}
267+
ctx.SendChain(message.Text("成功"))
268+
})
245269
}

0 commit comments

Comments
 (0)