From 02bf308452aa127e9f3d2ce5b4821ba426c4c94a Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sun, 7 Dec 2025 14:17:33 +0300 Subject: Enha: address template issues --- models/models.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'models') 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 { -- cgit v1.2.3