Repository navigation
FIX Include the template parameters in the LLMGenericTextConverter identifier - #3387
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Conversation
…entifier LLMGenericTextConverter renders its extra keyword arguments into both prompt templates, but its identifier recorded only the template hashes, so converters built from one template with different parameters (for example language="French" and language="Spanish") shared a hash and default registry name. Fixes microsoft#3385. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Description
Fixes #3385.
LLMGenericTextConverterforwards its extra keyword arguments (**kwargs, stored as_prompt_kwargs) to both the system prompt and the user prompt templates when it renders them, but_build_identifier()recorded only hashes of the unrendered templates. Converters built from one template with different parameters sent different prompts but had the same hash and default registry name:language="French"andlanguage="Spanish"collided, and registering the second raisedValueError: Instance 'LLMGenericTextConverter::ddb4af05' already exists.Changes:
template_parameters, the keyword arguments the templates are rendered with. It isNonewhen there are none.default=str), so tuples become lists and other objects such as paths are stored as their string form, which keeps the params valid JSON values.Conversion behavior is unchanged.
Noneparams are not hashed, so converters without template parameters keep their hash, includingMaliciousQuestionGeneratorConverter,MathPromptConverter,ToxicSentenceGeneratorConverter,VariationConverter,ScientificTranslationConverterandDenylistConverter. Subclasses that pass a template parameter and already list it themselves (ToneConverter,TenseConverter,NoiseConverter,TranslationConverter,IPAConverter) now also carry it undertemplate_parameters, so their hash changes once.ImagePromptStyleConverterandPersuasionConverterbuild their own identifier and are unchanged here.Tests and Documentation
tests/unit/converter/test_generic_llm_converter.py: different template parameters get different hashes, equal ones get the same hash, the parameters appear in the params, a converter without them has notemplate_parameters, and tuple andPathvalues are stored as JSON values.mainboth new tests fail. With this change they pass.pytest tests/unit/converter -n 4: 2792 passed, 44 skipped.pytest tests/unit/registry tests/unit/backend tests/unit/models/identifiers tests/unit/docs tests/unit/scenario -n 4: 6013 passed, 7 skipped.ruff checkandruff formatpass on the changed files, andty checkreports nothing new compared tomain.git diff --checkis clean.🤖 Generated with Claude Code