WK.OpenAiWrapper 2.0.11

There is a newer version of this package available.
See the version list below for details.
dotnet add package WK.OpenAiWrapper --version 2.0.11                
NuGet\Install-Package WK.OpenAiWrapper -Version 2.0.11                
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.11" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WK.OpenAiWrapper --version 2.0.11                
#r "nuget: WK.OpenAiWrapper, 2.0.11"                
#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.11

// Install WK.OpenAiWrapper as a Cake Tool
#tool nuget:?package=WK.OpenAiWrapper&version=2.0.11                

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 59 9/6/2024
3.3.0-alpha.4 54 9/6/2024
3.3.0-alpha.3 93 8/16/2024
3.3.0-alpha.2 76 8/16/2024
3.3.0-alpha.1 68 8/9/2024
3.2.2 106 9/13/2024
3.2.1 93 9/13/2024
3.2.0 119 7/24/2024
3.2.0-alpha.11 65 7/17/2024
3.2.0-alpha.10 43 7/17/2024
3.2.0-alpha.9 55 7/17/2024
3.2.0-alpha.8 54 7/16/2024
3.2.0-alpha.7 50 7/12/2024
3.2.0-alpha.5 58 7/10/2024
3.1.0-alpha.22 50 7/10/2024
3.0.8 122 7/4/2024
3.0.7 119 7/2/2024
3.0.6 120 6/29/2024
3.0.5 110 6/26/2024
3.0.4 106 6/25/2024
3.0.3 103 6/24/2024
3.0.2 121 6/23/2024
3.0.1 132 6/21/2024
3.0.0 128 6/14/2024
2.0.17 118 6/14/2024
2.0.16 108 6/3/2024
2.0.15 155 5/31/2024
2.0.14 113 5/29/2024
2.0.13 130 5/15/2024
2.0.12 108 5/15/2024
2.0.11 133 5/8/2024
2.0.10 102 5/2/2024 2.0.10 is deprecated because it is no longer maintained.
2.0.9 137 4/27/2024 2.0.9 is deprecated because it is no longer maintained.
2.0.8 126 4/27/2024 2.0.8 is deprecated because it is no longer maintained.
2.0.7 124 4/26/2024 2.0.7 is deprecated because it is no longer maintained.
2.0.6 145 4/24/2024 2.0.6 is deprecated because it is no longer maintained.
2.0.5 153 4/21/2024 2.0.5 is deprecated because it is no longer maintained.
2.0.4 131 4/21/2024 2.0.4 is deprecated because it is no longer maintained.
2.0.3 146 4/21/2024 2.0.3 is deprecated because it is no longer maintained.
2.0.2 149 4/20/2024 2.0.2 is deprecated because it is no longer maintained.
2.0.1 146 4/20/2024 2.0.1 is deprecated because it is no longer maintained and has critical bugs.
2.0.0 138 4/20/2024 2.0.0 is deprecated because it is no longer maintained and has critical bugs.
1.0.0 152 4/12/2024 1.0.0 is deprecated because it is no longer maintained and has critical bugs.
0.1.0 135 4/12/2024 0.1.0 is deprecated because it is no longer maintained and has critical bugs.