Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net Kernel and ISKFunction Streaming Option #1 (Phase 1) #3496

Merged

Conversation

RogerBarreto
Copy link
Member

Context and Problem Statement

Resolves #1649
Resolves #1298

It is quite common in co-pilot implementations to have a streamlined output of messages from the LLM (large language models) and currently that is not possible while using ISKFunctions.InvokeAsync or Kernel.RunAsync methods, which enforces users to work around the Kernel and Functions to use ITextCompletion and IChatCompletion services directly as the only interfaces that currently support streaming.

Currently streaming is a capability that not all providers do support and this as part of our design we try to ensure the services will have the proper abstractions to support streaming not only of text but be open to other types of data like images, audio, video, etc.

Needs to be clear for the sk developer when he is attempting to get streaming data.

Decision Drivers

  1. The sk developer should be able to get streaming data from the Kernel and Functions using Kernel.RunAsync or ISKFunctions.InvokeAsync methods

  2. The sk developer should be able to get the data in a generic way, so the Kernel and Functions can be able to stream data of any type, not limited to text.

  3. The sk developer when using streaming from a model that does not support streaming should still be able to use it with only one streaming update representing the whole data.

User Experience Goal

//(providing the type at as generic parameter)

// Getting a Raw Streaming data from Kernel
await foreach(string update in kernel.StreamingRunAsync<byte[]>(function, variables))

// Getting a String as Streaming data from Kernel
await foreach(string update in kernel.StreamingRunAsync<string>(function, variables))

// Getting a StreamingResultUpdate as Streaming data from Kernel
await foreach(StreamingResultUpdate update in kernel.StreamingRunAsync<StreamingResultUpdate>(variables, function))
// OR
await foreach(StreamingResultUpdate update in kernel.StreamingRunAsync(function, variables)) // defaults to Generic above)
{
    Console.WriteLine(update);
}

Out of Scope

  • Streaming with plans will not be supported in this phase. Attempting to do so will throw an exception.
  • Kernel streaming will not support multiple functions (pipeline).

Contribution Checklist

@RogerBarreto RogerBarreto added docs and tests Improvements or additions to documentation enhancement PR: in progress Under development and/or addressing feedback .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel PR: breaking change Pull requests that introduce breaking changes labels Nov 14, 2023
@RogerBarreto RogerBarreto added this to the v1.0.0 milestone Nov 14, 2023
@RogerBarreto RogerBarreto self-assigned this Nov 14, 2023
@RogerBarreto RogerBarreto requested a review from a team as a code owner November 14, 2023 19:46
@RogerBarreto RogerBarreto added PR: ready for review All feedback addressed, ready for reviews and removed PR: in progress Under development and/or addressing feedback labels Nov 23, 2023
@RogerBarreto RogerBarreto removed the PR: breaking change Pull requests that introduce breaking changes label Nov 23, 2023
Copy link
Member

@markwallace-microsoft markwallace-microsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the plan to add unit and integration tests for this?

@RogerBarreto RogerBarreto added the PR: ready to merge PR has been approved by all reviewers, and is ready to merge. label Nov 24, 2023
@RogerBarreto RogerBarreto added this pull request to the merge queue Nov 24, 2023
Merged via the queue into microsoft:main with commit b9c742d Nov 24, 2023
19 checks passed
@RogerBarreto RogerBarreto deleted the feaures/kernel-streaming-option1 branch November 24, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs and tests Improvements or additions to documentation kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code PR: ready for review All feedback addressed, ready for reviews PR: ready to merge PR has been approved by all reviewers, and is ready to merge.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

.Net: Streaming support for semantic functions on IKernel .NET Allow ISKFunction to return IAsyncEnumerable
4 participants