MCPcopy Create free account
hub / github.com/diillson/chatcli / inboundImageToModels

Function inboundImageToModels

cli/gateway_command.go:625–643  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

623// 0- or 1-element slice (downstream callers carry a slice): an attachment
624// without bytes or with an unsupported media type yields none.
625func 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

Callers 1

gatewayAgentFuncMethod · 0.85

Calls 2

NormalizeImageMediaTypeFunction · 0.92
DetectImageMediaTypeFunction · 0.92

Tested by

no test coverage detected