1
0
mirror of https://github.com/fumiama/go-onebot-agent.git synced 2026-06-10 13:00:44 +08:00

feat:add manualaddreq option

This commit is contained in:
源文雨
2026-01-06 20:39:31 +08:00
parent d291584892
commit a0c81601f2
2 changed files with 7 additions and 4 deletions

View File

@@ -46,6 +46,7 @@ type Agent struct {
perm *Perm perm *Perm
imgpcache *ttl.Cache[uint64, string] imgpcache *ttl.Cache[uint64, string]
mem MemoryStorage mem MemoryStorage
manualaddreq bool
manualaddmem bool manualaddmem bool
hasimageapi bool hasimageapi bool
} }
@@ -59,13 +60,13 @@ type Agent struct {
func NewAgent( func NewAgent(
id int64, batchcap, itemscap int, imgpcachettl time.Duration, id int64, batchcap, itemscap int, imgpcachettl time.Duration,
nickname, sex, characteristics, defaultprompt string, mem MemoryStorage, nickname, sex, characteristics, defaultprompt string, mem MemoryStorage,
manualaddmem bool, manualaddreq, manualaddmem bool,
) (ag Agent) { ) (ag Agent) {
ag = Agent{ ag = Agent{
id: id, nickname: nickname, sex: sex, chars: characteristics, id: id, nickname: nickname, sex: sex, chars: characteristics,
imgpcache: ttl.NewCache[uint64, string](imgpcachettl), imgpcache: ttl.NewCache[uint64, string](imgpcachettl),
log: chat.NewLog[fmt.Stringer](batchcap, itemscap, "\n", defaultprompt), log: chat.NewLog[fmt.Stringer](batchcap, itemscap, "\n", defaultprompt),
mem: mem, manualaddmem: manualaddmem, mem: mem, manualaddreq: manualaddreq, manualaddmem: manualaddmem,
} }
_ = ag.LoadPermTable() _ = ag.LoadPermTable()
return return
@@ -255,7 +256,9 @@ func (ag *Agent) GetAction(api deepinfra.API, p model.Protocol, grp int64, role
err = errors.Wrap(ErrPermissionDenied, r.Action) err = errors.Wrap(ErrPermissionDenied, r.Action)
return return
default: default:
ag.AddRequest(grp, &r) if !ag.manualaddreq {
ag.AddRequest(grp, &r)
}
if !ag.manualaddmem && r.Action == SVM { if !ag.manualaddmem && r.Action == SVM {
txt, err := extractMemory(&r) txt, err := extractMemory(&r)
if err != nil { if err != nil {

View File

@@ -463,7 +463,7 @@ func (fakemem) Load(grp int64) []string {
func TestAgent_system(t *testing.T) { func TestAgent_system(t *testing.T) {
ag := NewAgent( ag := NewAgent(
12345, 10, 10, time.Minute, "testname", "testsex", "testchar", 12345, 10, 10, time.Minute, "testname", "testsex", "testchar",
"testd", &fakemem{}, false, "testd", &fakemem{}, false, false,
) )
p, err := ag.system(PermRoleAdmin, 123) p, err := ag.system(PermRoleAdmin, 123)
if err != nil { if err != nil {