Simplify multimodal content handling; pass parts through to providers#94
Merged
Merged
Conversation
* testing image format fix * review fixes * lint fix
# Conflicts: # tee_gateway/controllers/chat_controller.py # tee_gateway/llm_backend.py # tee_gateway/test/test_tee_core.py
Revert the bespoke image-conversion path in convert_messages to main's raw pass-through (text/image parts already convert correctly to every provider's native API, so images keep working untouched). Only file/PDF parts are rewritten to LangChain standard file blocks, since Anthropic needs a 'document' block and rejects OpenAI's raw file shape. Capability gating, the per-request size cap, and request-hash canonicalization are retained. Drop the design doc.
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.
Summary
Refactor multimodal user message content handling to pass OpenAI-style content parts through to LangChain and providers largely unchanged, rather than converting them to LangChain standard blocks. This simplifies the enclave code path while preserving native multimodal support on the OHTTP route.
Changes
Remove design document: Delete
docs/native-attachments-design.md(the design phase is complete; implementation details now live in code and tests)Simplify content normalization (
tee_gateway/llm_backend.py):_convert_user_content()with_normalize_user_content_parts()that passes text and image parts through as-is in their OpenAI formfile/input_fileparts into LangChain standard file blocks (required for Anthropic compatibility)Fix content handling edge cases (
tee_gateway/llm_backend.py):Nonecontent values before applyingor ""coercion, preserving empty lists and falsy valuesUpdate tests (
tee_gateway/test/test_tee_core.py):test_user_content_text_only_parts_collapse_to_string→test_user_content_text_parts_passthroughand verify parts stay as a listtest_empty_user_content_list_is_preservedto ensure empty multimodal lists are not coerced to stringsimage_urlformat (passed through unchanged) instead of LangChain standard blocksAdd multimodal serialization test (
tests/test_structured_outputs.py):test_hash_dict_preserves_multimodal_user_contentverifies that multimodal content lists serialize consistently for request hashingImplementation Details
langchain-*versions already handle OpenAI-styleimage_urlandfileparts correctly at send time, so no PCR impactdocument, OpenAIfile_data, etc.) automaticallyhttps://claude.ai/code/session_01QjmXmpuiSCYrr9Lq5AYUve