diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-12-07 14:17:33 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-12-07 14:17:33 +0300 |
| commit | 02bf308452aa127e9f3d2ce5b4821ba426c4c94a (patch) | |
| tree | f11158f283b1eacf061f4f869e8d42b5f47cc2bb /models | |
| parent | 4d18d6e7308ebc3741abf0b933841600a7f1e5bb (diff) | |
Enha: address template issues
Diffstat (limited to 'models')
| -rw-r--r-- | models/models.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/models/models.go b/models/models.go index 798ea35..b4e7113 100644 --- a/models/models.go +++ b/models/models.go @@ -230,6 +230,38 @@ func NewMultimodalMsg(role string, contentParts []interface{}) RoleMsg { } } +// HasContent returns true if the message has either string content or structured content parts +func (m RoleMsg) HasContent() bool { + if m.Content != "" { + return true + } + if m.hasContentParts && len(m.ContentParts) > 0 { + return true + } + return false +} + +// IsContentParts returns true if the message uses structured content parts +func (m RoleMsg) IsContentParts() bool { + return m.hasContentParts +} + +// GetContentParts returns the content parts of the message +func (m RoleMsg) GetContentParts() []interface{} { + return m.ContentParts +} + +// Copy creates a copy of the RoleMsg with all fields +func (m RoleMsg) Copy() RoleMsg { + return RoleMsg{ + Role: m.Role, + Content: m.Content, + ContentParts: m.ContentParts, + ToolCallID: m.ToolCallID, + hasContentParts: m.hasContentParts, + } +} + // AddTextPart adds a text content part to the message func (m *RoleMsg) AddTextPart(text string) { if !m.hasContentParts { |
