WK.OpenAiWrapper
2.0.5
See the version list below for details.
dotnet add package WK.OpenAiWrapper --version 2.0.5
NuGet\Install-Package WK.OpenAiWrapper -Version 2.0.5
<PackageReference Include="WK.OpenAiWrapper" Version="2.0.5" />
paket add WK.OpenAiWrapper --version 2.0.5
#r "nuget: WK.OpenAiWrapper, 2.0.5"
// Install WK.OpenAiWrapper as a Cake Addin #addin nuget:?package=WK.OpenAiWrapper&version=2.0.5 // Install WK.OpenAiWrapper as a Cake Tool #tool nuget:?package=WK.OpenAiWrapper&version=2.0.5
OpenAiWrapper - A .NET Library for OpenAI API Integration
OpenAiWrapper is a user-friendly .NET library designed to simplify the integration and utilization of the OpenAI API in .NET applications. This library acts as a wrapper around the OpenAI-DotNet
package by RageAgainstThePixel, streamlining API interactions and enhancing usability, particularly for managing AI workflows and threads.
Features
- ๐ Easy Configuration: Simplify the setup process with extension methods for IServiceCollection.
- ๐ค Enhanced AI Operations: Utilize various OpenAI models efficiently within your .NET applications.
- ๐งต Thread Management: Manage threads for continuous conversations or data tracking.
- ๐ Advanced Pilot Management: Configure and use different pilots with specific capabilities and tools.
- ๐ Support for Multiple AI Features: Get text, image, and audio responses easily.
Installation
To start using OpenAiWrapper, add the package to your .NET project using NuGet:
dotnet add package OpenAiWrapper
Configuration
Setup in Startup.cs
or Program.cs
public void ConfigureServices(IServiceCollection services)
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
// Register OpenAI services with API key and optional pilots
services.RegisterOpenAi("your_openai_api_key_here", new Pilot("default", "Default Pilot Instructions"));
}
Usage Examples
Getting AI Responses
public async Task<string> GetResponseFromOpenAi(string userInput)
{
var client = serviceProvider.GetService<IOpenAiClient>();
var response = await client.GetOpenAiResponseWithNewThread(userInput, "default", "user1");
if (response.IsSuccess)
{
return response.Value.Answer;
}
else
{
throw new Exception("Failed to get response from OpenAI");
}
}
Working with Images
public async Task<string> GetImageUrlFromOpenAi(string prompt)
{
var client = serviceProvider.GetService<IOpenAiClient>();
var response = await client.GetOpenAiImageResponse(prompt);
if (response.IsSuccess)
{
return response.Value.Url;
}
else
{
throw new Exception("Failed to generate image from OpenAI");
}
}
Advanced Configuration
Defining Pilots
Pilots can be defined with specific tools and models to tailor the AI responses according to the application's needs.
var advancedPilot = new Pilot("advanced", "Provide detailed analysis", "gpt-4-turbo")
{
Tools = new List<Tool>
{
new Tool("AnalysisTool", "Detailed Analysis")
}
};
services.RegisterOpenAi("your_openai_api_key_here", advancedPilot);
Contribution
Contributions are welcome! If you would like to improve the OpenAiWrapper, feel free to fork the repository and submit a pull request.
About Us
Werbas continues to innovate and improve upon tools and technologies that enhance your experience with artificial intelligence. Visit us at www.werbas.com to learn more about our contributions to the tech community and how we can help you achieve your business goals.
License
OpenAiWrapper is released under the MIT License. See the LICENSE
file for more information.
Enjoy building with OpenAiWrapper, and unleash the power of AI in your .NET applications seamlessly! ๐โจ
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. |
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- morelinq (>= 4.2.0)
- OpenAI-DotNet (>= 7.7.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.3.0-alpha.5 | 56 | 9/6/2024 | |
3.3.0-alpha.4 | 50 | 9/6/2024 | |
3.3.0-alpha.3 | 87 | 8/16/2024 | |
3.3.0-alpha.2 | 72 | 8/16/2024 | |
3.3.0-alpha.1 | 60 | 8/9/2024 | |
3.2.2 | 94 | 9/13/2024 | |
3.2.1 | 83 | 9/13/2024 | |
3.2.0 | 110 | 7/24/2024 | |
3.2.0-alpha.11 | 61 | 7/17/2024 | |
3.2.0-alpha.10 | 39 | 7/17/2024 | |
3.2.0-alpha.9 | 49 | 7/17/2024 | |
3.2.0-alpha.8 | 48 | 7/16/2024 | |
3.2.0-alpha.7 | 43 | 7/12/2024 | |
3.2.0-alpha.5 | 52 | 7/10/2024 | |
3.1.0-alpha.22 | 44 | 7/10/2024 | |
3.0.8 | 113 | 7/4/2024 | |
3.0.7 | 111 | 7/2/2024 | |
3.0.6 | 112 | 6/29/2024 | |
3.0.5 | 102 | 6/26/2024 | |
3.0.4 | 99 | 6/25/2024 | |
3.0.3 | 93 | 6/24/2024 | |
3.0.2 | 108 | 6/23/2024 | |
3.0.1 | 122 | 6/21/2024 | |
3.0.0 | 120 | 6/14/2024 | |
2.0.17 | 110 | 6/14/2024 | |
2.0.16 | 98 | 6/3/2024 | |
2.0.15 | 147 | 5/31/2024 | |
2.0.14 | 105 | 5/29/2024 | |
2.0.13 | 122 | 5/15/2024 | |
2.0.12 | 100 | 5/15/2024 | |
2.0.11 | 124 | 5/8/2024 | |
2.0.10 | 92 | 5/2/2024 | |
2.0.9 | 129 | 4/27/2024 | |
2.0.8 | 118 | 4/27/2024 | |
2.0.7 | 116 | 4/26/2024 | |
2.0.6 | 137 | 4/24/2024 | |
2.0.5 | 145 | 4/21/2024 | |
2.0.4 | 124 | 4/21/2024 | |
2.0.3 | 139 | 4/21/2024 | |
2.0.2 | 141 | 4/20/2024 | |
2.0.1 | 141 | 4/20/2024 | |
2.0.0 | 131 | 4/20/2024 | |
1.0.0 | 147 | 4/12/2024 | |
0.1.0 | 127 | 4/12/2024 |