-
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 1 commit
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,32 @@ | ||
| using NUnit.Framework; | ||
| using OpenAI.Responses; | ||
| using System; | ||
|
|
||
| namespace OpenAI.Examples; | ||
|
|
||
| // This example uses experimental APIs which are subject to change. To use experimental APIs, | ||
| // please acknowledge their experimental status by suppressing the corresponding warning. | ||
| #pragma warning disable OPENAI001 | ||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. | ||
|
|
||
| public partial class ResponseExamples | ||
| { | ||
| [Test] | ||
| public void Example09_ModelOverridePerRequest() | ||
| { | ||
| OpenAIResponseClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); | ||
|
|
||
| // Add extra request fields using Patch. | ||
| // Patch lets you set fields like `model` that aren't exposed on ResponseCreationOptions. | ||
| // See the API docs https://platform.openai.com/docs/api-reference/responses/create for supported additional fields. | ||
| ResponseCreationOptions options = new(); | ||
| options.Patch.Set("$.model"u8, "gpt-5"); | ||
|
|
||
| OpenAIResponse response = client.CreateResponse("Say 'this is a test.", options); | ||
|
|
||
| Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}, [Mode]: {response.Model}"); | ||
| } | ||
| } | ||
|
|
||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. | ||
| #pragma warning restore OPENAI001 | ||
33 changes: 33 additions & 0 deletions
33
examples/Responses/Example09_ModelOverridePerRequestAsync.cs
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,33 @@ | ||
| using NUnit.Framework; | ||
| using OpenAI.Responses; | ||
| using System; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace OpenAI.Examples; | ||
|
|
||
| // This example uses experimental APIs which are subject to change. To use experimental APIs, | ||
| // please acknowledge their experimental status by suppressing the corresponding warning. | ||
| #pragma warning disable OPENAI001 | ||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. | ||
|
|
||
| public partial class ResponseExamples | ||
| { | ||
| [Test] | ||
| public async Task Example09_ModelOverridePerRequestAsync() | ||
| { | ||
| OpenAIResponseClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); | ||
|
|
||
| // Add extra request fields using Patch. | ||
| // Patch lets you set fields like `model` that aren't exposed on ResponseCreationOptions. | ||
| // See the API docs https://platform.openai.com/docs/api-reference/responses/create for supported additional fields. | ||
| ResponseCreationOptions options = new(); | ||
| options.Patch.Set("$.model"u8, "gpt-5"); | ||
|
|
||
| OpenAIResponse response = await client.CreateResponseAsync("Say 'this is a test.", options); | ||
|
|
||
| Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}, [Mode]: {response.Model}"); | ||
| } | ||
| } | ||
|
|
||
| #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. | ||
| #pragma warning restore OPENAI001 |
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.