Skip to content

Commit

Permalink
feat(chat): new template
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Feb 22, 2025
1 parent 26d1b9f commit 5d403aa
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 75 deletions.
12 changes: 12 additions & 0 deletions chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 任务
在QQ群与用户聊天,按自己的心情简短思考后条理清晰地回复。

## 输入
你将收到不同用户发送的一至多条消息。

- 如果消息是@你发送的,会以`>>`起始;
- 接下来是以【】包裹的用户名;
- 随后是消息内容。

## 输出
不带任何格式的消息内容,纯文本。
18 changes: 14 additions & 4 deletions chat/init.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package chat

Check failure on line 1 in chat/init.go

View workflow job for this annotation

GitHub Actions / lint

package-comments: should have a package comment (revive)

import (
_ "embed"

"github.com/fumiama/deepinfra"
"github.com/fumiama/deepinfra/chat"
"github.com/fumiama/deepinfra/model"

zero "github.com/wdvxdr1123/ZeroBot"
)

var lst = newlist()
//go:embed README.md
var SystemPrompt string

Check failure on line 14 in chat/init.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported var SystemPrompt should have comment or be unexported (revive)

var lst = chat.NewLog(8, "\n\n", "自己随机开启新话题", "【", "】", ">>")

func init() {
zero.OnMessage(func(ctx *zero.Ctx) bool {
Expand All @@ -19,14 +25,18 @@ func init() {
if gid == 0 {
gid = -ctx.Event.UserID
}
lst.add(gid, ctx.Event.Sender.Name(), ctx.State["__zbputil_chat_txt__"].(string), false)
lst.Add(
gid, ctx.Event.Sender.Name(),
ctx.State["__zbputil_chat_txt__"].(string),
false, ctx.Event.IsToMe,
)
})
}

func Reply(grp int64, txt string) {

Check failure on line 36 in chat/init.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function Reply should have comment or be unexported (revive)
lst.add(grp, "", txt, true)
lst.Add(grp, "", txt, true, false)
}

func Ask(p model.Protocol, grp int64, sysp string) deepinfra.Model {

Check failure on line 40 in chat/init.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function Ask should have comment or be unexported (revive)
return lst.modelize(p, grp, sysp)
return lst.Modelize(p, grp, sysp)
}
68 changes: 0 additions & 68 deletions chat/list.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
github.com/fumiama/cron v1.3.0
github.com/fumiama/deepinfra v0.0.0-20250221160812-ed1290950d32
github.com/fumiama/deepinfra v0.0.0-20250222055014-e969fc5b4ccf
github.com/fumiama/go-base16384 v1.7.0
github.com/gin-gonic/gin v1.8.2
github.com/go-playground/assert/v2 v2.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 h1:BBade+Jl
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4/go.mod h1:H7chHJglrhPPzetLdzBleF8d22WYOv7UM/lEKYiwlKM=
github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
github.com/fumiama/deepinfra v0.0.0-20250221160812-ed1290950d32 h1:loqzJ8AK5R/ayUoFbiVr02rvwqIhcwgeKSvOuv20Q1U=
github.com/fumiama/deepinfra v0.0.0-20250221160812-ed1290950d32/go.mod h1:wW05PQSn8mo1mZIoa6LBUE+3xIBjkoONvnfPTV5ZOhY=
github.com/fumiama/deepinfra v0.0.0-20250222055014-e969fc5b4ccf h1:xi3K9hukyF34JTLZTNCwM42gxcWKGJXSVou/U0pTYKg=
github.com/fumiama/deepinfra v0.0.0-20250222055014-e969fc5b4ccf/go.mod h1:wW05PQSn8mo1mZIoa6LBUE+3xIBjkoONvnfPTV5ZOhY=
github.com/fumiama/go-base16384 v1.7.0 h1:6fep7XPQWxRlh4Hu+KsdH+6+YdUp+w6CwRXtMWSsXCA=
github.com/fumiama/go-base16384 v1.7.0/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
github.com/fumiama/go-registry v0.2.7 h1:tLEqgEpsiybQMqBv0dLHm5leia/z1DhajMupwnOHeNs=
Expand Down

0 comments on commit 5d403aa

Please sign in to comment.