-
Notifications
You must be signed in to change notification settings - Fork 342
Add JsonPatch support for Chat, Responses, and Embeddings #736
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d66058c
Add dynamicModel decorator
ShivangiReja c0db273
Fix custom code
ShivangiReja 6fcfedb
Merge branch 'main' of https://github.com/openai/openai-dotnet into s…
ShivangiReja 95f6e01
Update generated code
ShivangiReja a632294
Merge branch 'main' of https://github.com/openai/openai-dotnet into s…
ShivangiReja 1e8cd92
Add a sample
ShivangiReja 08c4123
Add samples
ShivangiReja a1132b6
Add more samples
ShivangiReja 2b83621
Merge branch 'main' of https://github.com/openai/openai-dotnet into s…
ShivangiReja e992611
Update generated code
ShivangiReja 0af181b
Add missed recordings
ShivangiReja a6a4dfe
Merge branch 'main' of https://github.com/openai/openai-dotnet into s…
jorgerangel-msft 1deb7ab
fix: update visitors to account for jsonpatch changes
jorgerangel-msft f1fdd73
Add missed recordings
ShivangiReja 4d10d21
Feedback
ShivangiReja 8518ee1
Revert [Test]
ShivangiReja 1a565f5
Add tests
ShivangiReja 164ac0b
add test infra & visitor tests
jorgerangel-msft 833212a
revert main.yaml. Move to codegen pipeline
jorgerangel-msft 1dd0134
cleanup
jorgerangel-msft b08cc8b
Add a sample
ShivangiReja 982086b
Merge branch 'main' of https://github.com/openai/openai-dotnet into s…
ShivangiReja 489ce5f
fb
ShivangiReja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using NUnit.Framework; | ||
| using OpenAI.Chat; | ||
| using System; | ||
|
|
||
| namespace OpenAI.Examples; | ||
|
|
||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. | ||
|
|
||
| public partial class ChatExamples | ||
| { | ||
| [Test] | ||
| public void Example10_AdditionalProperties() | ||
| { | ||
| ChatClient client = new(model: "gpt-5", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); | ||
|
|
||
| // You can use the Patch property to set additional properties in the request | ||
| ChatCompletionOptions options = new(); | ||
| options.Patch.Set("$.reasoning_effort"u8, "minimal"); | ||
|
|
||
| ChatCompletion completion = client.CompleteChat([new UserChatMessage("Say 'this is a test.'")], options); | ||
|
|
||
| Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}"); | ||
|
|
||
| // You can also read additional properties back from the response | ||
ShivangiReja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var serviceTier = completion.Patch.GetString("$.service_tier"u8); | ||
| Console.WriteLine($"service_tier={serviceTier}"); | ||
| } | ||
| } | ||
|
|
||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| using NUnit.Framework; | ||
| using OpenAI.Chat; | ||
| using System; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace OpenAI.Examples; | ||
|
|
||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. | ||
|
|
||
| public partial class ChatExamples | ||
| { | ||
| [Test] | ||
| public async Task Example10_AdditionalPropertiesAsync() | ||
| { | ||
| ChatClient client = new(model: "gpt-5", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); | ||
|
|
||
| // You can use the Patch property to set additional properties in the request | ||
| ChatCompletionOptions options = new(); | ||
| options.Patch.Set("$.reasoning_effort"u8, "minimal"); | ||
|
|
||
| ChatCompletion completion = await client.CompleteChatAsync([new UserChatMessage("Say 'this is a test.'")], options); | ||
|
|
||
| Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}"); | ||
|
|
||
| // You can also read additional properties back from the response | ||
| var serviceTier = completion.Patch.GetString("$.service_tier"u8); | ||
| Console.WriteLine($"service_tier={serviceTier}"); | ||
| } | ||
| } | ||
|
|
||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.