IChatCompletion Multiple Results / New Interfaces
Motivation and Context
Add potential for IChatCompletion with multiple results per prompt.
Description
- Adds new Interfaces/Abstractions for Chat Results:
IChatResult,IChatStreamingResult,IChatMessage - Adds new
IChatCompletioninterface methods for Streaming and Non-Streaming results - Moves old
IChatCompletioninterface methodsIAsyncEnumerable<string> GenerateMessageStreamAsyncandTask<string> GenerateMessageAsyncas extensions for retro compatibility - Changed
ChatAsTextto use the new multiple results implementations - Makes
ChatHistory.ChatMessage&ChatHistory.AuthorsRoletypes obsolete (discouraging usage of those implementation in favor of newIChatMessage ChatHistoryabstraction now extends fromList<IChatMessage>- Updates all Samples using the new interfaces.
Paves the way to ... (Futures)
- Remove
ChatHistory.ChatMessageinner class - Remove
ChatHistory.AuthorsRoleenums - Make
ChatHistoryan abstract class or anIChatHistoryinterface. - Rename
ITextCompletionResulttoITextResult - Rename
ITextCompletionStreamingResulttoITextStreamingResult
Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [x] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with
dotnet format - [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
Moves old IChatCompletion interface methods IAsyncEnumerable
GenerateMessageStreamAsync and Task GenerateMessageAsync as extensions for retro compatibility
What's our plan for tracking / removing such temporary measures? Do we actually need them?
What's our plan for tracking / removing such temporary measures? Do we actually need them?
@stephentoub The plan here is to keep those as extensions while we still use it as part of the SK internal implementations.
Once we moved all the SK implementations to use the Result approach those extension methods will be moved to another package/namespace Extensions or flagged as Obsolete.