feat: PDF attachments as Anthropic document blocks
Reuses llm.ImageContent/session.ImageData with MimeType "application/pdf" rather than adding a new field: images already flow tool result -> session entry -> reload -> provider end to end, so a MIME check at the provider edge is the smallest change. - Anthropic provider emits a document block (source.type=base64, media_type=application/pdf) for a PDF attachment in a tool result or a user message; images are unaffected. Cache control now also applies to document blocks. - OpenAI provider replaces a PDF attachment with a text placeholder instead of an invalid image_url data URI; images still emitted. Gemini already accepts application/pdf inline and needs no change.
This commit is contained in:
1 parent
a1f34cce4c
commit
62f3424f30
6 files changed
+377
-3
No files matched your search
+7
-3
@@ -22,10 +22,14 @@ const (
|
||||
EventThinkingBlock
|
||||
)
|
||||
|
||||
// ImageContent holds image data for multimodal messages.
|
||||
// ImageContent holds image data for multimodal messages. MimeType
|
||||
// "application/pdf" is carried as a PDF document (not an image) by
|
||||
// providers that support it (e.g. Anthropic emits a `document` block);
|
||||
// providers without PDF support report a clear error or placeholder
|
||||
// instead of silently mishandling the bytes.
|
||||
type ImageContent struct {
|
||||
MimeType string // "image/jpeg", "image/png", etc.
|
||||
Data []byte // raw image bytes
|
||||
MimeType string // "image/jpeg", "image/png", "application/pdf", etc.
|
||||
Data []byte // raw bytes
|
||||
}
|
||||
|
||||
// Message represents a conversation message.
|
||||
|
||||
Reference in new issue
Block a user