-
Notifications
You must be signed in to change notification settings - Fork 364
Add comprehensive dependency injection support with IServiceCollection extension methods #696
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
Open
mokarchi
wants to merge
14
commits into
openai:main
Choose a base branch
from
mokarchi:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a5b0ea1
Add dependency injection support for OpenAI clients
mokarchi 04eb997
Merge branch 'main' into main
mokarchi 4a9b117
Refactor: Remove advanced service collection extensions and related t…
mokarchi 0189432
rm doc
mokarchi 0c03ce7
Implement per-specialized-client settings and ctors per feedback from…
mokarchi 8e6a5d9
direct inheritance, Options binding in OpenAIClientOptions ctor, simp…
mokarchi 3baa593
Updated the internal ctor
mokarchi 3616d92
Refactor: Update client constructors to include argument validation a…
mokarchi 8fd3384
chore: Add missing using directive for System.Linq in ChatClient.cs
mokarchi 9c45186
fix: Remove unnecessary blank line in ResponsesClient.cs
mokarchi e427ecb
test: Add unit tests for OpenAIHostBuilderExtensions methods
mokarchi a94299b
Merge branch 'openai:main' into main
mokarchi 26965f0
run ./scripts/Export-Api.ps1
645a8f4
Merge branch 'openai:main' into main
mokarchi 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
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,20 @@ | ||
| using Microsoft.Extensions.Configuration; | ||
| using System.ClientModel.Primitives; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Assistants; | ||
|
|
||
| [Experimental("SCME0002")] | ||
| public sealed class AssistantClientSettings : ClientSettings | ||
| { | ||
| public OpenAIClientOptions Options { get; set; } | ||
|
|
||
| protected override void BindCore(IConfigurationSection section) | ||
| { | ||
| var optionsSection = section.GetSection("Options"); | ||
| if (optionsSection.Exists()) | ||
| { | ||
| Options ??= new OpenAIClientOptions(optionsSection); | ||
| } | ||
| } | ||
| } |
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,24 @@ | ||
| using Microsoft.Extensions.Configuration; | ||
| using System.ClientModel.Primitives; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Audio; | ||
|
|
||
| [Experimental("SCME0002")] | ||
| public sealed class AudioClientSettings : ClientSettings | ||
| { | ||
| public string Model { get; set; } | ||
|
|
||
| public OpenAIClientOptions Options { get; set; } | ||
|
|
||
| protected override void BindCore(IConfigurationSection section) | ||
| { | ||
| Model = section["Model"]; | ||
|
|
||
| var optionsSection = section.GetSection("Options"); | ||
| if (optionsSection.Exists()) | ||
| { | ||
| Options ??= new OpenAIClientOptions(optionsSection); | ||
| } | ||
| } | ||
| } |
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,20 @@ | ||
| using Microsoft.Extensions.Configuration; | ||
| using System.ClientModel.Primitives; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Batch; | ||
|
|
||
| [Experimental("SCME0002")] | ||
| public sealed class BatchClientSettings : ClientSettings | ||
| { | ||
| public OpenAIClientOptions Options { get; set; } | ||
|
|
||
| protected override void BindCore(IConfigurationSection section) | ||
| { | ||
| var optionsSection = section.GetSection("Options"); | ||
| if (optionsSection.Exists()) | ||
| { | ||
| Options ??= new OpenAIClientOptions(optionsSection); | ||
| } | ||
| } | ||
| } |
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,24 @@ | ||
| using Microsoft.Extensions.Configuration; | ||
| using System.ClientModel.Primitives; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Chat; | ||
|
|
||
| [Experimental("SCME0002")] | ||
| public sealed class ChatClientSettings : ClientSettings | ||
| { | ||
| public string Model { get; set; } | ||
|
|
||
| public OpenAIClientOptions Options { get; set; } | ||
|
|
||
| protected override void BindCore(IConfigurationSection section) | ||
| { | ||
| Model = section["Model"]; | ||
|
|
||
| var optionsSection = section.GetSection("Options"); | ||
| if (optionsSection.Exists()) | ||
| { | ||
| Options ??= new OpenAIClientOptions(optionsSection); | ||
| } | ||
| } | ||
| } |
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,20 @@ | ||
| using Microsoft.Extensions.Configuration; | ||
| using System.ClientModel.Primitives; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Containers; | ||
|
|
||
| [Experimental("SCME0002")] | ||
| public sealed class ContainerClientSettings : ClientSettings | ||
| { | ||
| public OpenAIClientOptions Options { get; set; } | ||
|
|
||
| protected override void BindCore(IConfigurationSection section) | ||
| { | ||
| var optionsSection = section.GetSection("Options"); | ||
| if (optionsSection.Exists()) | ||
| { | ||
| Options ??= new OpenAIClientOptions(optionsSection); | ||
| } | ||
| } | ||
| } |
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,20 @@ | ||
| using Microsoft.Extensions.Configuration; | ||
| using System.ClientModel.Primitives; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Conversations; | ||
|
|
||
| [Experimental("SCME0002")] | ||
| public sealed class ConversationClientSettings : ClientSettings | ||
| { | ||
| public OpenAIClientOptions Options { get; set; } | ||
|
|
||
| protected override void BindCore(IConfigurationSection section) | ||
| { | ||
| var optionsSection = section.GetSection("Options"); | ||
| if (optionsSection.Exists()) | ||
| { | ||
| Options ??= new OpenAIClientOptions(optionsSection); | ||
| } | ||
| } | ||
| } |
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.