How to change content in ChatMessageContent in a safe way #13426
DmitryLukyanov
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a chatbot implemented using
Semantic Kernelthat retrieves responses viaIChatCompletionService.In certain scenarios, the model’s output needs to be post-processed: the original text is validated and, if necessary, replaced with a rephrased version generated by a separate
LLMcall that is not part of the same conversational context.Currently, this is handled by creating a new
ChatMessageContentinstance with the updated text:and adding it to the chat history. However, this approach discards metadata from the original response (such as ModelId, InnerContent, and related fields).
Retaining the original metadata while modifying the text also seems problematic, as it could introduce inconsistencies between the content and the associated model details.
Is creating a new ChatMessageContent the correct approach in this situation, or is there a more appropriate pattern for handling post-processed model responses in Semantic Kernel?
Beta Was this translation helpful? Give feedback.
All reactions