mirror of
https://github.com/fumiama/deepinfra.git
synced 2026-06-05 00:32:46 +08:00
feat(chat): add param isusersystem to Modelize
This commit is contained in:
17
chat/chat.go
17
chat/chat.go
@@ -72,8 +72,11 @@ func (l *Log) Add(grp int64, usr, txt string, isbot, isatme bool) {
|
|||||||
l.m[grp] = msgs[:len(msgs)-1]
|
l.m[grp] = msgs[:len(msgs)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Log) Modelize(p model.Protocol, grp int64, sysp string) deepinfra.Model {
|
func (l *Log) Modelize(p model.Protocol, grp int64, sysp string, isusersystem bool) deepinfra.Model {
|
||||||
m := p.System(sysp)
|
m := p
|
||||||
|
if sysp != "" && !isusersystem {
|
||||||
|
m.System(sysp)
|
||||||
|
}
|
||||||
l.mu.RLock()
|
l.mu.RLock()
|
||||||
defer l.mu.RUnlock()
|
defer l.mu.RUnlock()
|
||||||
sz := len(l.m[grp])
|
sz := len(l.m[grp])
|
||||||
@@ -82,10 +85,14 @@ func (l *Log) Modelize(p model.Protocol, grp int64, sysp string) deepinfra.Model
|
|||||||
}
|
}
|
||||||
for i, msg := range l.m[grp] {
|
for i, msg := range l.m[grp] {
|
||||||
if i%2 == 0 { // is user
|
if i%2 == 0 { // is user
|
||||||
_ = m.User(msg.String())
|
if i == 0 && isusersystem {
|
||||||
} else {
|
_ = m.User(sysp + "\n\n" + msg.String())
|
||||||
_ = m.Assistant(msg.String())
|
continue
|
||||||
}
|
}
|
||||||
|
_ = m.User(msg.String())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
_ = m.Assistant(msg.String())
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user