WK.OpenAiWrapper 2.0.5

There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WK.OpenAiWrapper" Version="2.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WK.OpenAiWrapper --version 2.0.5                
#r "nuget: WK.OpenAiWrapper, 2.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.10 is deprecated because it is no longer maintained.
2.0.9 129 4/27/2024 2.0.9 is deprecated because it is no longer maintained.
2.0.8 118 4/27/2024 2.0.8 is deprecated because it is no longer maintained.
2.0.7 116 4/26/2024 2.0.7 is deprecated because it is no longer maintained.
2.0.6 137 4/24/2024 2.0.6 is deprecated because it is no longer maintained.
2.0.5 145 4/21/2024 2.0.5 is deprecated because it is no longer maintained.
2.0.4 124 4/21/2024 2.0.4 is deprecated because it is no longer maintained.
2.0.3 139 4/21/2024 2.0.3 is deprecated because it is no longer maintained.
2.0.2 141 4/20/2024 2.0.2 is deprecated because it is no longer maintained.
2.0.1 141 4/20/2024 2.0.1 is deprecated because it is no longer maintained and has critical bugs.
2.0.0 131 4/20/2024 2.0.0 is deprecated because it is no longer maintained and has critical bugs.
1.0.0 147 4/12/2024 1.0.0 is deprecated because it is no longer maintained and has critical bugs.
0.1.0 127 4/12/2024 0.1.0 is deprecated because it is no longer maintained and has critical bugs.