You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our existing AddMessages/AddMessagesAsync extension methods don't help because they only work on they complete set of output, whereas for an interactive UI app it's necessary to process the updates as they arrive incrementally. This results in undesired boilerplate code in chat applications.
We could improve MEAI to make this nicer, especially given how it would need to be more complex still if they wanted to receive other content types or to retain other information from the updates, such as AuthorName, AdditionalProperties, RawRepresentation).
One option would be adding to MEAI's ChatResponseExtensions another extension method like this:
This is more general since it works with any content type and preserves the other metadata properties.
Then in application code, the call to AddNonTextContentToConversation would be replaced by a one-liner inside the await foreach above:
messages.AddMessages(update,filter: u =>uis not TextContent);
@MackinnonBuck If you think this is better, would you be interested in adding this extension method to MEAI as part of this change? It's quite nice that the template code can now directly use MEAI updates in the same PR!
@stephentoub Do you have any opinions on this proposed extension method? If you have concerns like "it's too specific to this one scenario" please say so. In my view it is pretty specific to this one scenario, but also, UI applications are a critical scenario we need to have clean patterns for.
Our existing
AddMessages
/AddMessagesAsync
extension methods don't help because they only work on they complete set of output, whereas for an interactive UI app it's necessary to process the updates as they arrive incrementally. This results in undesired boilerplate code in chat applications.We could improve MEAI to make this nicer, especially given how it would need to be more complex still if they wanted to receive other content types or to retain other information from the updates, such as
AuthorName
,AdditionalProperties
,RawRepresentation
).One option would be adding to MEAI's
ChatResponseExtensions
another extension method like this:This is more general since it works with any content type and preserves the other metadata properties.
Then in application code, the call to
AddNonTextContentToConversation
would be replaced by a one-liner inside theawait foreach
above:Originally posted by @SteveSandersonMS in #6096 (comment)
The text was updated successfully, but these errors were encountered: