You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.9 KiB
41 lines
1.9 KiB
package memory
|
|
|
|
import (
|
|
"yunyan/pb"
|
|
)
|
|
|
|
// IModel 模型组件接口
|
|
type IModel interface {
|
|
// 记忆项
|
|
addItem(item *pb.DBMemoryItem) error
|
|
findItemByClientKey(uid, clientKey string) (*pb.DBMemoryItem, error)
|
|
getItem(uid string, id uint64) (*pb.DBMemoryItem, error)
|
|
saveItem(item *pb.DBMemoryItem) error
|
|
listItems(q *itemQuery) ([]*pb.DBMemoryItem, int64, error)
|
|
delItems(uid string, ids []uint64) (int64, error)
|
|
completeItems(uid string, ids []uint64, done bool) (int64, error)
|
|
delMeetingItems(sourceID string, genRound int32) (int64, error)
|
|
delMeetingItemsBySource(uid string, sourceIDs []string) (int64, error)
|
|
|
|
// 周期报告
|
|
upsertReport(rec *pb.DBMemoryReport) error
|
|
saveReport(rec *pb.DBMemoryReport) error
|
|
getReport(id uint64) (*pb.DBMemoryReport, error)
|
|
getReportByPeriod(uid, ptype, pkey string) (*pb.DBMemoryReport, error)
|
|
latestUnconfirmedReport(uid string) (*pb.DBMemoryReport, error)
|
|
listReports(uid, ptype string, page, size int32) ([]*pb.DBMemoryReport, int64, error)
|
|
uidsWithItemsBetween(start, end string, minItems int) ([]string, error)
|
|
countItemsBetween(uid, start, end string) (int64, error)
|
|
}
|
|
|
|
// Redis 队列键后缀(实际使用时还会经 service.GetTag() 与 redissys.RKey 加应用前缀,
|
|
// 测试机上多个应用共用一个 Redis,不加前缀会串号)
|
|
const (
|
|
QueueReportAwait = "memory:report:await" //报告生成等待队列
|
|
LockReportPrefix = "memory:report:lock" //cron 抢锁前缀,后面拼 <period_type>:<period_key>
|
|
// 单份报告的生成锁,后面拼 report id。与上面那把不是一回事:
|
|
// 上面那把按周期抢,管的是「这一轮 cron 由谁来建单」;这把按报告抢,
|
|
// 管的是「这一份报告由哪个 worker 真的去跑 LLM」——cron 与 ensureRecent
|
|
// 两条路都能把同一份报告送进队列,没有它就会跑两遍、计两次费。
|
|
LockReportProcPrefix = "memory:report:proc"
|
|
)
|
|
|