AiAssistant 0.0.3
dotnet add package AiAssistant --version 0.0.3
NuGet\Install-Package AiAssistant -Version 0.0.3
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="AiAssistant" Version="0.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AiAssistant" Version="0.0.3" />
<PackageReference Include="AiAssistant" />
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 AiAssistant --version 0.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AiAssistant, 0.0.3"
#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.
#:package AiAssistant@0.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AiAssistant&version=0.0.3
#tool nuget:?package=AiAssistant&version=0.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AiAssistant
AiAssistant — This is a lightweight and extensible library for integrating AI assistants into .NET applications. The library allows you to process user requests, register commands, work with various AI engines (Groq, OpenAI), and centrally generate prompts.
Features
- Registration of user commands and handling of their execution via delegates.
- Support for multiple AI engines:
- Groq API
- OpenAI GPT
- Prompt generation with centralized logic via
IPromptBuilder. - Extensions for convenient command parameter extraction.
- Full support for asynchronous interaction.
- Easy integration via Dependency Injection (
Microsoft.Extensions.DependencyInjection).
Installation
Install via NuGet:
dotnet add package AiAssistant --version 0.0.3
Usage
- Register the service in your DI container
using Microsoft.Extensions.DependencyInjection; using AiAssistant.DependencyInjection; var services = new ServiceCollection(); // Register AI Assistant services in DI container services.AddAiAssistant(); var serviceProvider = services.BuildServiceProvider(); - How to use
using AiAssistant.Core; var assistantService = provider.GetRequiredService<IAiAssistantService>(); // Select the desired engine and submit the API key assistantService.UseGroqEngine(groqApiKey); // Or assistantService.UseOpenAIEngine(openAI-ApiKey); // Example of command registration // Registration of the “openpage” command with action _assistantService.RegisterCommand("openpage", async cmd => { Console.WriteLine($"Opening page: {cmd.Target}"); return await Task.FromResult(true); }); // Provide additional prompt instructions for the "openpage" command _assistantService.AddCommandPrompt("openpage", "Available pages: Print - PrintPage, Home - HomePage"); // Registration of the “find” command with action _assistantService.RegisterCommand("find", async cmd => { Console.WriteLine($"Searching for: {cmd.Parameters}"); return true; }); // Registration of the “exit” command with action _assistantService.RegisterCommand("exit", async cmd => { Environment.Exit(0); return true; }); // Call Console.Write("Enter a message for the AI Assistant (or 'exit' to quit): "); var msg = Console.ReadLine(); // Process the input using the AI Assistant service var response = await _assistantService!.ProcessAsync(msg!);
API
IAiAssistantService
Main library interface:
- RegisterCommand(string commandName, CommandDelegate action) — command registration.
- AddCommandPrompt(string commandName, string prompt) — adding additional instructions for a command.
- ProcessAsync(string query) — processing a user request.
- GetAvailableCommands() — getting a list of available commands.
- UseGroqEngine(string apiKey) — connecting the Groq AI engine.
- UseOpenAIEngine(string apiKey) — connecting OpenAI GPT.
AssistantCommandExtensions Extensions for conveniently obtaining command parameters:
var value = command.GetParameter<int>("count", 0);
Supported Platforms
- .NET 9.0
License
MIT License. See LICENSE for details.
Contributors
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- GroqApiLibrary (>= 1.0.9)
- Microsoft.Extensions.DependencyInjection (>= 9.0.10)
- Microsoft.Extensions.Logging (>= 9.0.10)
- OpenAI (>= 2.6.0)
- System.Text.Json (>= 9.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.