Skip to content

Python: implement KernelContent and all related classes#4491

Merged
moonbox3 merged 39 commits intomicrosoft:mainfrom
eavanvalkenburg:response_object
Jan 30, 2024
Merged

Python: implement KernelContent and all related classes#4491
moonbox3 merged 39 commits intomicrosoft:mainfrom
eavanvalkenburg:response_object

Conversation

@eavanvalkenburg
Copy link
Member

@eavanvalkenburg eavanvalkenburg commented Jan 5, 2024

Motivation and Context

As we are preparing to move towards v1 where the context no longer is used, we need a better way of handling the responses from models and capture them in a more structured way, also in preparation of multi-modal models and the like.

Closes #4598

Description

Added KernelContent and StreamingKernelContent base classs, consistent with the dotnet versions of those.
Subclasses of this class for specific services, for instance, the OpenAI class has parsing for the content, function_calls, tool_calls in it, and the Azure OpenAI one has parsing for the context in it.

Contribution Checklist

@eavanvalkenburg eavanvalkenburg requested a review from a team as a code owner January 5, 2024 15:42
@eavanvalkenburg eavanvalkenburg marked this pull request as draft January 5, 2024 15:42
@shawncal shawncal added the python Pull requests for the Python Semantic Kernel label Jan 5, 2024
@eavanvalkenburg eavanvalkenburg force-pushed the response_object branch 3 times, most recently from 981a886 to edb8885 Compare January 11, 2024 13:13
@shawncal shawncal added the .NET Issue or Pull requests regarding .NET code label Jan 13, 2024
@github-actions github-actions bot changed the title Python: WIP for a new AIResponse setup .Net: Python: WIP for a new AIResponse setup Jan 13, 2024
@eavanvalkenburg eavanvalkenburg changed the title .Net: Python: WIP for a new AIResponse setup .Net: Python: WIP for a new KernelContent setup Jan 15, 2024
@eavanvalkenburg eavanvalkenburg marked this pull request as ready for review January 16, 2024 18:10
@eavanvalkenburg eavanvalkenburg requested a review from a team as a code owner January 16, 2024 18:10
Copy link
Collaborator

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

Really nice work on all of this.

@markwallace-microsoft markwallace-microsoft removed the .NET Issue or Pull requests regarding .NET code label Jan 18, 2024
@juliomenendez juliomenendez changed the title .Net: Python: WIP for a new KernelContent setup Python: WIP for a new KernelContent setup Jan 18, 2024
@eavanvalkenburg eavanvalkenburg force-pushed the response_object branch 5 times, most recently from 9941cd5 to 8852b0b Compare January 23, 2024 21:01
Copy link
Collaborator

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

I don't see anything major right now. It's all looking good!

@eavanvalkenburg eavanvalkenburg changed the title Python: WIP for a new KernelContent setup Python: implement KernelContent and all related classes Jan 24, 2024
Copy link
Contributor

@juliomenendez juliomenendez left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple comments

@moonbox3 moonbox3 added this pull request to the merge queue Jan 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2024
@moonbox3 moonbox3 added this pull request to the merge queue Jan 30, 2024
Merged via the queue into microsoft:main with commit 11cf8ea Jan 30, 2024
@eavanvalkenburg eavanvalkenburg deleted the response_object branch January 31, 2024 10:24
Bryan-Roe pushed a commit to Bryan-Roe-ai/semantic-kernel that referenced this pull request Oct 6, 2024
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
As we are preparing to move towards v1 where the context no longer is
used, we need a better way of handling the responses from models and
capture them in a more structured way, also in preparation of
multi-modal models and the like.

Closes microsoft#4598 

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Added KernelContent and StreamingKernelContent base classs, consistent
with the dotnet versions of those.
Subclasses of this class for specific services, for instance, the OpenAI
class has parsing for the content, function_calls, tool_calls in it, and
the Azure OpenAI one has parsing for the context in it.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Align AI Response with KernelContent in .NET

6 participants