|
2 | 2 | package aichat
|
3 | 3 |
|
4 | 4 | import (
|
5 |
| - "fmt" |
6 | 5 | "math/rand"
|
7 | 6 | "strconv"
|
8 | 7 | "strings"
|
|
41 | 40 | "- 设置AI聊天(不)响应AT\n" +
|
42 | 41 | "- 设置AI聊天最大长度4096\n" +
|
43 | 42 | "- 设置AI聊天TopP 0.9\n" +
|
44 |
| - "- 查看AI聊天配置\n" + |
45 |
| - "- [启用|禁用]AI语音\n", |
| 43 | + "- 设置AI聊天(不)以AI语音输出\n" + |
| 44 | + "- 查看AI聊天配置\n", |
46 | 45 | PrivateDataFolder: "aichat",
|
47 | 46 | })
|
48 | 47 | )
|
|
53 | 52 | "OLLaMA": 1,
|
54 | 53 | "GenAI": 2,
|
55 | 54 | }
|
| 55 | + apilist = [3]string{"OpenAI", "OLLaMA", "GenAI"} |
56 | 56 | )
|
57 | 57 |
|
58 | 58 | func init() {
|
@@ -141,12 +141,25 @@ func init() {
|
141 | 141 | if t == "" {
|
142 | 142 | continue
|
143 | 143 | }
|
| 144 | + logrus.Infoln("[aichat] 回复内容:", t) |
144 | 145 | recCfg := airecord.GetRecordConfig()
|
145 |
| - fmt.Println(recCfg) |
146 |
| - if id != nil { |
147 |
| - id = ctx.SendChain(message.Reply(id), message.Text(t)) |
| 146 | + if !cfg.NoRecord { |
| 147 | + record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t).String() |
| 148 | + if record != "" { |
| 149 | + ctx.SendChain(message.Record(record)) |
| 150 | + } else { |
| 151 | + if id != nil { |
| 152 | + id = ctx.SendChain(message.Reply(id), message.Text(t)) |
| 153 | + } else { |
| 154 | + id = ctx.SendChain(message.Text(t)) |
| 155 | + } |
| 156 | + } |
148 | 157 | } else {
|
149 |
| - id = ctx.SendChain(message.Text(t)) |
| 158 | + if id != nil { |
| 159 | + id = ctx.SendChain(message.Reply(id), message.Text(t)) |
| 160 | + } else { |
| 161 | + id = ctx.SendChain(message.Text(t)) |
| 162 | + } |
150 | 163 | }
|
151 | 164 | process.SleepAbout1sTo2s()
|
152 | 165 | }
|
@@ -277,8 +290,24 @@ func init() {
|
277 | 290 | Handle(newextrasetuint(&cfg.MaxN))
|
278 | 291 | en.OnPrefix("设置AI聊天TopP", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
|
279 | 292 | Handle(newextrasetfloat32(&cfg.TopP))
|
| 293 | + en.OnRegex("^设置AI聊天(不)?以AI语音输出$", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true). |
| 294 | + Handle(newextrasetbool(&cfg.NoRecord)) |
280 | 295 | en.OnFullMatch("查看AI聊天配置", ensureconfig).SetBlock(true).
|
281 | 296 | Handle(func(ctx *zero.Ctx) {
|
282 |
| - ctx.SendChain(message.Text(printConfig(cfg))) |
| 297 | + c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) |
| 298 | + if !ok { |
| 299 | + ctx.SendChain(message.Text("ERROR: no such plugin")) |
| 300 | + return |
| 301 | + } |
| 302 | + gid := ctx.Event.GroupID |
| 303 | + rate := c.GetData(gid) & 0xff |
| 304 | + temp := (c.GetData(gid) >> 8) & 0xff |
| 305 | + if temp <= 0 { |
| 306 | + temp = 70 // default setting |
| 307 | + } |
| 308 | + if temp > 100 { |
| 309 | + temp = 100 |
| 310 | + } |
| 311 | + ctx.SendChain(message.Text(printConfig(rate, temp, cfg))) |
283 | 312 | })
|
284 | 313 | }
|
0 commit comments