Skip to content

feat(llm): add document_base64() and PDF support for Claude and Bedrock mappers#64

Merged
msmakouz merged 1 commit into
wippyai:masterfrom
VladKhomich:feature/document-pdf-support
Jun 15, 2026
Merged

feat(llm): add document_base64() and PDF support for Claude and Bedrock mappers#64
msmakouz merged 1 commit into
wippyai:masterfrom
VladKhomich:feature/document-pdf-support

Conversation

@VladKhomich

Copy link
Copy Markdown
Contributor

What was changed

src/llm/src/prompt.lua

  • Added DOCUMENT to prompt.CONTENT_TYPE constants
  • Added prompt.document_base64(mime_type, data) constructo which mirrors the existing image_base64() pattern, producing an internal document content part with a base64 source

src/llm/src/claude/mapper.lua

  • Extended convert_image_content() to handle document content parts, translating the internal format to the Anthropic wire format (type: "document", source.media_type, source.data)

src/llm/src/bedrock/mapper.lua

  • Added convert_document_to_converse() that maps internal document parts to the Bedrock Converse API document block format (document.format, document.name, document.source.bytes), extracting the format string from the MIME subtype
  • Wired convert_document_to_converse() into both the user and assistant message branches of map_messages()

Unit tests added for all three files covering: constructor output, content type constant, user/assistant message mapping on both providers, MIME subtype extraction, and missing MIME fallback to "pdf".

Why?

Wippy's prompt module supported text and image content parts but had no equivalent for document content (PDFs and other file types). This meant applications that needed to send documents to LLMs had to bypass the wippy/llm abstraction entirely by making direct HTTP calls with provider-specific auth, serialization, and response parsing. That approach breaks as soon as the provider changes.

Both the Anthropic direct API and the Bedrock Converse API support native document processing, but with different wire formats. This change adds first-class document support at the prompt and mapper layers so application code can use prompt.document_base64() provider-agnostically, with each provider mapper handling the translation. No anthropic-beta headers are required because document support is GA on both providers.

Checklist

  • Closes #
  • Tested
    • Tested manually
    • Unit tests added

@msmakouz msmakouz merged commit 4cdc2a0 into wippyai:master Jun 15, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants