diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-02-03 16:56:31 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-02-03 16:56:31 +0300 |
| commit | 76f14ce4a376bbbb99c79cc2090c067b5ba28484 (patch) | |
| tree | 6922620541ece02f849d6f50a4f371720f2ce298 /models | |
| parent | 0f5bbaa94390cd4d11facc8b2e7fb825b128ef31 (diff) | |
Enha: detailed error
Diffstat (limited to 'models')
| -rw-r--r-- | models/models.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/models/models.go b/models/models.go index 76ef183..340cb42 100644 --- a/models/models.go +++ b/models/models.go @@ -369,14 +369,22 @@ func (cb *ChatBody) ListRoles() []string { } func (cb *ChatBody) MakeStopSlice() []string { - namesMap := make(map[string]struct{}) - for _, m := range cb.Messages { - namesMap[m.Role] = struct{}{} - } - ss := make([]string, 0, 1+len(namesMap)) - ss = append(ss, "<|im_end|>") - for k := range namesMap { - ss = append(ss, k+":\n") + return cb.MakeStopSliceExcluding("", cb.ListRoles()) +} + +func (cb *ChatBody) MakeStopSliceExcluding( + excludeRole string, roleList []string, +) []string { + ss := []string{} + for _, role := range roleList { + // Skip the excluded role (typically the current speaker) + if role == excludeRole { + continue + } + // Add multiple variations to catch different formatting + ss = append(ss, role+":\n") // Most common: role with newline + ss = append(ss, role+":") // Role with colon but no newline + ss = append(ss, role+": ") // Role with colon and space } return ss } |
