From 71ec2f7c085e232d74f1ca60d85f5517f71cf71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 30 Mar 2025 21:51:28 +0900 Subject: [PATCH] feat(chat): add param isusersystem to Modelize --- chat/chat.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/chat/chat.go b/chat/chat.go index aafb128..60ece4f 100644 --- a/chat/chat.go +++ b/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] } -func (l *Log) Modelize(p model.Protocol, grp int64, sysp string) deepinfra.Model { - m := p.System(sysp) +func (l *Log) Modelize(p model.Protocol, grp int64, sysp string, isusersystem bool) deepinfra.Model { + m := p + if sysp != "" && !isusersystem { + m.System(sysp) + } l.mu.RLock() defer l.mu.RUnlock() 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] { if i%2 == 0 { // is user + if i == 0 && isusersystem { + _ = m.User(sysp + "\n\n" + msg.String()) + continue + } _ = m.User(msg.String()) - } else { - _ = m.Assistant(msg.String()) + continue } + _ = m.Assistant(msg.String()) } return m }