refactor: make ParameterMapper generic on Content type#189
Merged
Kamilbenkirane merged 4 commits intomainfrom Feb 25, 2026
Merged
refactor: make ParameterMapper generic on Content type#189Kamilbenkirane merged 4 commits intomainfrom
Kamilbenkirane merged 4 commits intomainfrom
Conversation
Replace Any with a Content type parameter on parse_output() using PEP 695 syntax. Update parameter_mappers() return type on ModalityClient to propagate the generic through _transform_output().
Add Content type parameter to all provider-level and protocol-level ParameterMapper/FieldMapper subclasses. Shared mappers in generate_content are generic [Content]; single-modality mappers are specialized directly (TextContent, ImageContent, etc.).
…lients Specialize parent generic mappers with modality content types and update all parameter_mappers() return types and mapper list annotations across text, images, videos, audio, and embeddings modalities.
Update test mappers and template scaffolding to use parameterized ParameterMapper[Content] and FieldMapper[Content] types.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
3 tasks
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
Closes #186.
ParameterMapper[Content]andFieldMapper[Content]generic using PEP 695 syntax, replacing theAnytype onparse_output()introduced in Move _transform_output from provider _parse_content to base _predict pipeline #142Contenttype parameter through the full mapper hierarchy: provider-level → protocol-level → modality-level → client filesparameter_mappers()return type onModalityClienttolist[ParameterMapper[Content]], restoring end-to-end type safety through_transform_output()Approach
Three categories of mapper changes:
generate_content/parameters.py): Made generic[Content]so modality-level subclasses can specializeTextContent,ImageContent,VideoContent,AudioContent,EmbeddingsContent)Test plan
uv run pytest tests/unit_tests/ -v— 478 tests passuv run mypy src/— no type errors_transform_outputtype chain:mapper.parse_output(content, value)returnsContentnotAny