diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-02-16 16:35:06 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-02-16 16:35:06 +0300 |
| commit | 1b36ef938e1fb1bda040cbbe1c1e0886af7e140e (patch) | |
| tree | 99b8409ea4668fe6efb8e036810881a3651c551b /models/models.go | |
| parent | 987d5842a430842e1408e94b7646f59fd3a3cc88 (diff) | |
Fix: parsing of content parts
Diffstat (limited to 'models/models.go')
| -rw-r--r-- | models/models.go | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/models/models.go b/models/models.go index d15e0d1..9f41803 100644 --- a/models/models.go +++ b/models/models.go @@ -175,9 +175,16 @@ func (m *RoleMsg) ToText(i int) string { // For structured content, just take the text parts var textParts []string for _, part := range m.ContentParts { - if partMap, ok := part.(map[string]any); ok { - if partType, exists := partMap["type"]; exists && partType == "text" { - if textVal, textExists := partMap["text"]; textExists { + switch p := part.(type) { + case TextContentPart: + if p.Type == "text" { + textParts = append(textParts, p.Text) + } + case ImageContentPart: + // skip images for text display + case map[string]any: + if partType, exists := p["type"]; exists && partType == "text" { + if textVal, textExists := p["text"]; textExists { if textStr, isStr := textVal.(string); isStr { textParts = append(textParts, textStr) } @@ -206,9 +213,16 @@ func (m *RoleMsg) ToPrompt() string { // For structured content, just take the text parts var textParts []string for _, part := range m.ContentParts { - if partMap, ok := part.(map[string]any); ok { - if partType, exists := partMap["type"]; exists && partType == "text" { - if textVal, textExists := partMap["text"]; textExists { + switch p := part.(type) { + case TextContentPart: + if p.Type == "text" { + textParts = append(textParts, p.Text) + } + case ImageContentPart: + // skip images for text display + case map[string]any: + if partType, exists := p["type"]; exists && partType == "text" { + if textVal, textExists := p["text"]; textExists { if textStr, isStr := textVal.(string); isStr { textParts = append(textParts, textStr) } |
