1
0
mirror of https://github.com/fumiama/go-onebot-agent.git synced 2026-06-05 18:20:24 +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
imgpcache *ttl.Cache[uint64, string]
mem MemoryStorage
manualaddreq bool
manualaddmem bool
hasimageapi bool
}
@@ -59,13 +60,13 @@ type Agent struct {
func NewAgent(
id int64, batchcap, itemscap int, imgpcachettl time.Duration,
nickname, sex, characteristics, defaultprompt string, mem MemoryStorage,
manualaddmem bool,
manualaddreq, manualaddmem bool,
) (ag Agent) {
ag = Agent{
id: id, nickname: nickname, sex: sex, chars: characteristics,
imgpcache: ttl.NewCache[uint64, string](imgpcachettl),
log: chat.NewLog[fmt.Stringer](batchcap, itemscap, "\n", defaultprompt),
mem: mem, manualaddmem: manualaddmem,
mem: mem, manualaddreq: manualaddreq, manualaddmem: manualaddmem,
}
_ = ag.LoadPermTable()
return
@@ -255,7 +256,9 @@ func (ag *Agent) GetAction(api deepinfra.API, p model.Protocol, grp int64, role
err = errors.Wrap(ErrPermissionDenied, r.Action)
return
default:
ag.AddRequest(grp, &r)
if !ag.manualaddreq {
ag.AddRequest(grp, &r)
}
if !ag.manualaddmem && r.Action == SVM {
txt, err := extractMemory(&r)
if err != nil {

View File

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