inboundImageToModels converts a hydrated gateway image attachment into the provider-agnostic models.ImageContent carried on a user turn. It returns a 0- or 1-element slice (downstream callers carry a slice): an attachment without bytes or with an unsupported media type yields none.
(im *gateway.InboundImage)
| 623 | // 0- or 1-element slice (downstream callers carry a slice): an attachment |
| 624 | // without bytes or with an unsupported media type yields none. |
| 625 | func inboundImageToModels(im *gateway.InboundImage) []models.ImageContent { |
| 626 | if im == nil || len(im.Data) == 0 { |
| 627 | return nil |
| 628 | } |
| 629 | mime := im.MimeType |
| 630 | if _, ok := models.NormalizeImageMediaType(mime); !ok { |
| 631 | // Fall back to sniffing when the platform sent no/!supported MIME. |
| 632 | if sniffed, ok2 := models.DetectImageMediaType(im.Data); ok2 { |
| 633 | mime = sniffed |
| 634 | } else { |
| 635 | return nil |
| 636 | } |
| 637 | } |
| 638 | return []models.ImageContent{{ |
| 639 | MediaType: mime, |
| 640 | Data: im.Data, |
| 641 | FileName: im.FileName, |
| 642 | }} |
| 643 | } |
| 644 | |
| 645 | // transcribeInbound converts a voice message to text. It returns handled=true |
| 646 | // with a user-facing reply when transcription is unavailable, fails, or yields |
no test coverage detected