1
0
mirror of https://github.com/fumiama/deepinfra.git synced 2026-06-16 09:00:25 +08:00

feat(model): add item pre/post modelize hook

This commit is contained in:
源文雨
2025-09-24 21:41:53 +08:00
parent 8c92983b13
commit 348633b5c6
2 changed files with 22 additions and 2 deletions

View File

@@ -22,9 +22,16 @@ func (l *Log[T]) newbatch(sz int) *batch[T] {
func (cl *batch[T]) String() string {
sb := strings.Builder{}
for _, item := range cl.items {
for i := range cl.items {
pre, post := cl.lst.preM, cl.lst.postM
if pre != nil {
pre(&cl.items[i])
}
sb.WriteString(cl.lst.itemsep)
sb.WriteString(item.String())
sb.WriteString(cl.items[i].String())
if post != nil {
post(&cl.items[i])
}
}
return sb.String()[len(cl.lst.itemsep):]
}