Add parse_response to Processor, make it a bit more official#45143
Merged
Rocketknight1 merged 3 commits intomainfrom Mar 31, 2026
Merged
Add parse_response to Processor, make it a bit more official#45143Rocketknight1 merged 3 commits intomainfrom
Rocketknight1 merged 3 commits intomainfrom
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
zucchini-nlp
approved these changes
Mar 31, 2026
Member
zucchini-nlp
left a comment
There was a problem hiding this comment.
Nice, can you add in any to any as well and we can merge
Comment on lines
-440
to
+443
| generated_text = list(prompt_text.messages) + [ | ||
| {"role": "assistant", "content": generated_text} | ||
| ] | ||
| if getattr(self.tokenizer, "response_schema", False): | ||
| assistant_message = self.tokenizer.parse_response(generated_text) | ||
| else: | ||
| assistant_message = {"role": "assistant", "content": generated_text} |
Member
There was a problem hiding this comment.
can we do same in any-to-any pipe?
Member
Author
There was a problem hiding this comment.
Done! Just copied things over there
| generated_text = list(prompt_text.messages) + [ | ||
| {"role": "assistant", "content": generated_text} | ||
| ] | ||
| if getattr(self.tokenizer, "response_schema", False): |
Member
There was a problem hiding this comment.
do we always load a tokenizer on these pipes, or should just if processor.tokenizer.response_schema: processor.parse_response
Member
Author
There was a problem hiding this comment.
I think we always load a tokenizer, but I want to be safe just in case response_schema is undefined for whatever reason!
SangbumChoi
pushed a commit
to SangbumChoi/transformers
that referenced
this pull request
Apr 4, 2026
…face#45143) * Add parse_response to Processor, make it a bit more official * Make the parse_response annotation a string to avoid torch import issues * Add the same logic to any-to-any
sirzechs66
pushed a commit
to sirzechs66/transformers
that referenced
this pull request
Apr 18, 2026
…face#45143) * Add parse_response to Processor, make it a bit more official * Make the parse_response annotation a string to avoid torch import issues * Add the same logic to any-to-any
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.
This PR adds
parse_responseto Processor classes by wrapping theTokenizermethod!cc @zucchini-nlp