AIHelperLibrary 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package AIHelperLibrary --version 1.0.1
                    
NuGet\Install-Package AIHelperLibrary -Version 1.0.1
                    
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="AIHelperLibrary" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AIHelperLibrary" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AIHelperLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AIHelperLibrary --version 1.0.1
                    
#r "nuget: AIHelperLibrary, 1.0.1"
                    
#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.
#addin nuget:?package=AIHelperLibrary&version=1.0.1
                    
Install AIHelperLibrary as a Cake Addin
#tool nuget:?package=AIHelperLibrary&version=1.0.1
                    
Install AIHelperLibrary as a Cake Tool

AIHelperLibrary

Overview

The AIHelperLibrary is a modular and reusable .NET library for integrating with OpenAI's API. Designed for flexibility and efficiency, it supports creating dynamic prompts, managing chatbot sessions, and generating AI-driven responses with ease. Whether you're building simple AI integrations or complex, context-aware chatbot systems, this library provides the tools to streamline development.


Features

Core Functionality

  • OpenAI Client:

    • Supports models like GPT-3.5-Turbo, GPT-4, GPT-4o, GPT-4o-Mini, GPT-o1, and GPT-o1-Mini.
    • Configurable retry logic, proxy support, and error handling.
  • Dynamic Prompt Management:

    • Define, store, and reuse custom prompts programmatically.
    • Contextual system prompts to customize AI behavior.
  • Chatbot Session Management:

    • Maintain multi-turn conversations with persistent context.
    • Configurable chat history size for memory management.
  • Advanced Configuration:

    • Fine-tune responses using temperature, token limits, and sampling parameters.
    • Proxy support for restricted environments.

Additional Features

  • Built-in Retry Logic: Robust retry mechanism with configurable delay.
  • Logging Support: Optional logging of requests and responses for debugging.

Installation

Install the package via NuGet:

Install-Package AIHelperLibrary -Version 1.0.1

Or via the .NET CLI:

dotnet add package AIHelperLibrary --version 1.0.1

Getting Started

Configuration Example

Define your preferences using AIExtensionHelperConfiguration:

using AIHelperLibrary.Configurations;
using AIHelperLibrary.Services;

var config = new AIExtensionHelperConfiguration
{
    DefaultModel = AIModel.GPT_4,
    MaxTokens = 200,
    Temperature = 0.7,
    TopP = 1.0,
    RequestTimeoutMs = 10000,
    EnableLogging = true
};

var client = new OpenAIClient("your-api-key", config);

Generate AI Responses

Custom Prompt

Send a freeform prompt to the AI:

var response = await client.GenerateTextAsync("Explain the difference between AI and machine learning.");
Console.WriteLine(response);
Predefined Prompts

Use built-in templates for common tasks:

var predefinedPrompt = PromptManager.GetPrompt(PromptType.Summarize);
var summary = await client.GenerateTextWithPredefinedPromptAsync(predefinedPrompt, "Artificial intelligence is transforming the world...");
Console.WriteLine(summary);
Dynamic Prompts

Define and reuse custom prompts programmatically:

var promptManager = new DynamicPromptManager();
promptManager.AddPrompt("Greeting", "Greet the user warmly and politely.");

var response = await client.GenerateTextWithDynamicPromptAsync(promptManager, "Greeting", "Hi there!");
Console.WriteLine(response);

Chatbot Sessions

Maintain multi-turn conversations with persistent context:

var chatResponse = await client.GenerateChatResponseAsync(
    "CustomerSupportBot",
    "What are your working hours?",
    "You are a polite and helpful customer support assistant."
);
Console.WriteLine(chatResponse);

Supported Models

Model Name Description
GPT-3.5-Turbo Standard model optimized for cost and speed.
GPT-3.5-Turbo-16k Higher context window for larger inputs.
GPT-3.5-Turbo-0125 Slightly improved instruction-following capabilities.
GPT-3.5-Turbo-Instruct Enhanced for instructional and fine-grained tasks.
GPT-3.5-Turbo-1106 Latest refined variant of GPT-3.5.
GPT-4 Advanced model for complex tasks.
GPT-4-Turbo Faster variant of GPT-4 optimized for efficiency.
GPT-4o Optimized variant of GPT-4 for specific tasks.
GPT-4o-Mini Lightweight and fast version of GPT-4o.
GPT-4o-RealTime-Preview Experimental real-time optimized version of GPT-4o.
ChatGPT-4o-Latest Latest optimized model variant used in ChatGPT.
o1 Optimized variant from the o1 series for improved performance.
o1-mini Lightweight mini variant from the o1 series for efficient usage.
o1-preview Preview variant from the o1 series with early access features.
o3-mini Next-generation mini variant from the o3 series offering high efficiency.
GPT-4o-Mini-RealTime-Preview Mini real-time preview variant of GPT-4o.
GPT-4o-Audio-Preview Audio-optimized preview variant of GPT-4o.

Contribution

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request.

License

This library is open-source and licensed under the MIT License.


Contact

For support or inquiries, reach out via GitHub or email at ns.dev.contact@gmail.com.

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.  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. 
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
1.1.0 137 4/27/2025
1.0.1 113 2/2/2025
1.0.0 89 1/19/2025
0.0.1 82 1/17/2025