-
Notifications
You must be signed in to change notification settings - Fork 839
Add ChatResponseFormat.ForJsonSchema<T> #6786
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR exposes the JSON schema formatting functionality as a public API by adding a new ChatResponseFormat.ForJsonSchema<T>
method, making the schema generation logic directly accessible to users who want the formatting capabilities without using the generic GetResponseAsync<T>
method.
- Moves schema creation logic from
ChatClientStructuredOutputExtensions
toChatResponseFormat
as a new public method - Refactors
GetResponseAsync<T>
to use the newForJsonSchema<T>
method internally - Adds comprehensive test coverage for the new API
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs |
Adds the new ForJsonSchema<T> method and moves shared constants and helper methods |
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatClientStructuredOutputExtensions.cs |
Refactors to use the new ForJsonSchema<T> method and removes duplicated code |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/ChatCompletion/ChatResponseFormatTests.cs |
Adds comprehensive test coverage for the new API |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/TestJsonSerializerContext.cs |
Adds serialization support for test types |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.json |
Documents the new public API surface |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatClientStructuredOutputExtensions.cs
Show resolved
Hide resolved
Moves the implementation used by `GetResponseAsync<T>` to be exposed as its own helper that can be used directly, for cases where folks want the formatting but don't want to use the generic `GetResponseAsync<T>`.
7386635
to
b630759
Compare
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
Outdated
Show resolved
Hide resolved
7f6f73f
to
ff2e1be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Moves the implementation used by
GetResponseAsync<T>
to be exposed as its own helper that can be used directly, for cases where folks want the formatting but don't want to use the genericGetResponseAsync<T>
.Fixes #6179
Microsoft Reviewers: Open in CodeFlow