feat(llm): add document_base64() and PDF support for Claude and Bedrock mappers#64
Merged
msmakouz merged 1 commit intoJun 15, 2026
Conversation
wolfy-j
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
src/llm/src/prompt.luaprompt.CONTENT_TYPEconstantsprompt.document_base64(mime_type, data) constructowhich mirrors the existing image_base64() pattern, producing an internal document content part with a base64 sourcesrc/llm/src/claude/mapper.luaconvert_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.luaconvert_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 subtypemap_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