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

ITextCompletion Multiple Results (Incl. Streaming) #952

Merged
merged 31 commits into from
May 17, 2023

Conversation

RogerBarreto
Copy link
Member

@RogerBarreto RogerBarreto commented May 11, 2023

Motivation and Context

Potential to get multiple results for the same prompt with and without streaming support.

Resolves #526
Closes #526

MultiChatCompletionStream2

Description

This PR introduces abstractions and the capability to get multiple results for the same prompt using the same request including streaming support.

Proposed:

  • Added 2 result abstractions ITextCompletionResult and ITextCompletionStreamingResult
  • Changed current base ITextCompletion interface with the multiple results abstraction capability
  • Added 2 extensions methods to ITextCompletion to keep it retro compatible / avoid major breaking changes
  • Added concrete implementation to: Azure OpenAI / Open AI / Hugging Face completion impl.
  • Added Samples (with and without streaming) how to use multiple results

Breaking potential:

  • Any custom completion implementation will need to implement the new methods in ITextCompletion interface with the ITextCompletionResult/ITextCompletionStreamingResult abstractions. Pretty straightforward and example was added in CustomLLM sample.

Contribution Checklist

@github-actions github-actions bot added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core labels May 11, 2023
@RogerBarreto RogerBarreto marked this pull request as ready for review May 12, 2023 17:51
@RogerBarreto RogerBarreto changed the title DRAFT - ITextCompletion Multiple Results (Incl. Streaming) ITextCompletion Multiple Results (Incl. Streaming) May 12, 2023
@RogerBarreto RogerBarreto self-assigned this May 12, 2023
@RogerBarreto RogerBarreto added the PR: ready for review All feedback addressed, ready for reviews label May 12, 2023
dluc
dluc previously approved these changes May 12, 2023
@shawncal shawncal force-pushed the features/itextcompletion-multi branch from 78fd561 to 4222bbb Compare May 13, 2023 02:33
@RogerBarreto RogerBarreto added 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. and removed PR: in progress Under development and/or addressing feedback labels May 16, 2023
stephentoub
stephentoub previously approved these changes May 16, 2023
@RogerBarreto RogerBarreto removed the PR: ready for review All feedback addressed, ready for reviews label May 16, 2023
@shawncal shawncal merged commit d6edd3e into microsoft:main May 17, 2023
shawncal added a commit to johnoliver/semantic-kernel that referenced this pull request May 19, 2023
### Motivation and Context

Potential to get multiple results for the same prompt with and without
streaming support.

Resolves microsoft#526 
Closes microsoft#526 


![MultiChatCompletionStream2](https://github.com/microsoft/semantic-kernel/assets/19890735/fb37d37c-e915-4a2e-92c8-662cb26f1e89)


### Description

This PR introduces abstractions and the capability to get multiple
results for the same prompt using the same request including streaming
support.

Proposed:

- Added 2 result abstractions `ITextCompletionResult` and
`ITextCompletionStreamingResult`
- Changed current base `ITextCompletion` interface with the multiple
results abstraction capability
- Added 2 extensions methods to `ITextCompletion` to keep it retro
compatible / avoid major breaking changes
- Added concrete implementation to: Azure OpenAI / Open AI / Hugging
Face completion impl.
- Added Samples (with and without streaming) how to use multiple results

Breaking potential:
- Any custom completion implementation will need to implement the new
methods in `ITextCompletion` interface with the
`ITextCompletionResult`/`ITextCompletionStreamingResult` abstractions.
Pretty straightforward and example was added in `CustomLLM` sample.


Co-authored-by: Lee Miller <[email protected]>
Co-authored-by: Shawn Callegari <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
@RogerBarreto RogerBarreto deleted the features/itextcompletion-multi branch December 5, 2023 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code PR: ready to merge PR has been approved by all reviewers, and is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for chat completion choices parameter
6 participants