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 | 60 | 9/6/2024 | |
3.3.0-alpha.4 | 55 | 9/6/2024 | |
3.3.0-alpha.3 | 94 | 8/16/2024 | |
3.3.0-alpha.2 | 77 | 8/16/2024 | |
3.3.0-alpha.1 | 69 | 8/9/2024 | |
3.2.2 | 107 | 9/13/2024 | |
3.2.1 | 94 | 9/13/2024 | |
3.2.0 | 120 | 7/24/2024 | |
3.2.0-alpha.11 | 66 | 7/17/2024 | |
3.2.0-alpha.10 | 44 | 7/17/2024 | |
3.2.0-alpha.9 | 56 | 7/17/2024 | |
3.2.0-alpha.8 | 55 | 7/16/2024 | |
3.2.0-alpha.7 | 51 | 7/12/2024 | |
3.2.0-alpha.5 | 59 | 7/10/2024 | |
3.1.0-alpha.22 | 51 | 7/10/2024 | |
3.0.8 | 123 | 7/4/2024 | |
3.0.7 | 120 | 7/2/2024 | |
3.0.6 | 121 | 6/29/2024 | |
3.0.5 | 111 | 6/26/2024 | |
3.0.4 | 107 | 6/25/2024 | |
3.0.3 | 104 | 6/24/2024 | |
3.0.2 | 122 | 6/23/2024 | |
3.0.1 | 133 | 6/21/2024 | |
3.0.0 | 129 | 6/14/2024 | |
2.0.17 | 119 | 6/14/2024 | |
2.0.16 | 109 | 6/3/2024 | |
2.0.15 | 156 | 5/31/2024 | |
2.0.14 | 114 | 5/29/2024 | |
2.0.13 | 131 | 5/15/2024 | |
2.0.12 | 109 | 5/15/2024 | |
2.0.11 | 134 | 5/8/2024 | |
2.0.10 | 103 | 5/2/2024 | |
2.0.9 | 138 | 4/27/2024 | |
2.0.8 | 127 | 4/27/2024 | |
2.0.7 | 125 | 4/26/2024 | |
2.0.6 | 146 | 4/24/2024 | |
2.0.5 | 154 | 4/21/2024 | |
2.0.4 | 132 | 4/21/2024 | |
2.0.3 | 147 | 4/21/2024 | |
2.0.2 | 150 | 4/20/2024 | |
2.0.1 | 147 | 4/20/2024 | |
2.0.0 | 139 | 4/20/2024 | |
1.0.0 | 153 | 4/12/2024 | |
0.1.0 | 136 | 4/12/2024 |