feat: add as_generic_chat_history function to convert any Context to …#1007
Open
akihikokuroda wants to merge 3 commits intogenerative-computing:mainfrom
Open
feat: add as_generic_chat_history function to convert any Context to …#1007akihikokuroda wants to merge 3 commits intogenerative-computing:mainfrom
akihikokuroda wants to merge 3 commits intogenerative-computing:mainfrom
Conversation
…Message Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
Contributor
|
The PR description has been updated. Please fill out the template for your PR to be reviewed. |
psschwei
reviewed
May 5, 2026
| return c.parsed_repr | ||
| # Use value if parsed_repr is None or not a Message | ||
| content = ( | ||
| str(c.value) if c.parsed_repr is None else formatter(c.parsed_repr) |
Member
There was a problem hiding this comment.
I think we also need to consider the case if c.parsed_repr is a string (I believe that's what a MOT will return after a completed CBlock action (?) )
quick way to test:
mot = ModelOutputThunk(value='reply text')
mot.parsed_repr = 'reply text'
as_generic_chat_history(ChatContext().add(Message('user','hi')).add(mot))
# → WARNING: Unknown component type str ...
Member
Author
There was a problem hiding this comment.
Yes, it was an issue. I fix it. Thanks!
Member
There was a problem hiding this comment.
should we add a test case for it too?
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
Member
|
there's a typo in the PR title: |
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
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.
Misc PR
Type of PR
Description
Add as_generic_chat_history() function to handle heterogeneous contexts with
configurable formatter. Unlike as_chat_history(), this gracefully handles
arbitrary component types by converting them to strings, with optional logging
for unknown types.
Testing
Attribution