Documentation
¶
Overview ¶
Package attachment provides MIME-aware routing for document attachments.
It defines how a chat.Document should be sent to a model: either dropped (unsupported), wrapped in a plain-text envelope (StrategyTXT), or encoded as inline base64 data (StrategyB64).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TXTEnvelope ¶
TXTEnvelope wraps text content in a unique XML-like tag derived from the document name and MIME type. The tag name is a slug of both, making accidental tag break-out in the content practically impossible without escaping the body.
Example: a document named "report.md" with MIME "text/markdown" produces:
<document-report-md-text-markdown> …body… </document-report-md-text-markdown>
Types ¶
type Strategy ¶
type Strategy int
Strategy describes how an attachment should be handled before sending to the provider.
const ( // StrategyDrop means the attachment is not supported by the model or has no // inline content, and should be silently skipped (with a log warning). StrategyDrop Strategy = iota // StrategyTXT means the attachment should be wrapped in a TXTEnvelope and // sent as plain text. Used for text/* MIME types whose content is already // in Source.InlineText. StrategyTXT // StrategyB64 means the attachment content (Source.InlineData) should be // base64-encoded and sent as a native provider image/document block. StrategyB64 )
func Decide ¶
Decide returns the routing Strategy for a document given the current model's capabilities.
Algorithm:
- If the model does not support the document's MIME type → (Drop, reason).
- If Source.InlineData is non-empty → (B64, "").
- If Source.InlineText is non-empty → (TXT, "").
- Otherwise → (Drop, "no inline content").