EchoCoders.AIServiceWrapper.DependencyInjection
1.0.3
dotnet add package EchoCoders.AIServiceWrapper.DependencyInjection --version 1.0.3
NuGet\Install-Package EchoCoders.AIServiceWrapper.DependencyInjection -Version 1.0.3
<PackageReference Include="EchoCoders.AIServiceWrapper.DependencyInjection" Version="1.0.3" />
<PackageVersion Include="EchoCoders.AIServiceWrapper.DependencyInjection" Version="1.0.3" />
<PackageReference Include="EchoCoders.AIServiceWrapper.DependencyInjection" />
paket add EchoCoders.AIServiceWrapper.DependencyInjection --version 1.0.3
#r "nuget: EchoCoders.AIServiceWrapper.DependencyInjection, 1.0.3"
#:package EchoCoders.AIServiceWrapper.DependencyInjection@1.0.3
#addin nuget:?package=EchoCoders.AIServiceWrapper.DependencyInjection&version=1.0.3
#tool nuget:?package=EchoCoders.AIServiceWrapper.DependencyInjection&version=1.0.3
EchoCoders.AIServiceWrapper.DependencyInjection
This package provides a simple way to integrate OpenAI services into your .NET applications using dependency injection.
Installation
You can install the package via NuGet Package Manager:
Usage
Follow these steps to configure and use the OpenAI service in your application:
Add the OpenAI service to the IServiceCollection:
In your
Startup.csorProgram.csor wherever you configure your services, use theAddOpenAIServiceextension method to add the OpenAI service to theIServiceCollection.Inject and use the IAIService in your application:
Once the service is registered, you can inject
IAIServiceinto your classes and use it.
Configuration
The AddOpenAIService method allows you to configure the OpenAIOptions using a configuration action. Here are some of the properties you can configure:
ApiKey: The API key for accessing OpenAI services.URL: The base URL for the OpenAI API (optional, defaults to the official OpenAI API URL).Model: The model name to use for the OpenAI service (optional, defaults to the default model).`
Register OpenAI service
services.AddOpenAIService(options =>
{
options.APIKey = "your-api-key";
options.URL = "api-url";//optional
options.Model= "your-model-name";//optional
});
Example:
HttpClient Configuration
The AddOpenAIService method also adds an HttpClient to the service collection. You can configure this HttpClient as needed.
Example:
License
This project is licensed under the MIT License.
Supported .NET versions
.NET 8 and upper
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- EchoCoders.AIServiceWrapper (>= 1.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.