Skip to content

Latest commit

 

History

History
105 lines (85 loc) · 3.48 KB

README.md

File metadata and controls

105 lines (85 loc) · 3.48 KB

AI Toolbox

License NuGet

AI Toolbox is a .NET SDK that provides an extensible toolset for .NET developers to build AI driven applications. It elevates the power of Semantic Kernel by using a configuration driven approach, which allows adding AI capabilities to .NET applications in no time.

Features:

Planned Features:

  • Kernel Memory support
  • Token calculation
  • EF Core data storage connector
  • ASP.NET WebApi service
  • Docker images
  • and much more ...

Documentation

Example

using var host = Host.CreateDefaultBuilder(args)
    .ConfigureServices((_, services) =>
    {
        services
            .AddAIToolbox()
            .AddConnectors()
            .IncludeOllamaConnector(options => options.Endpoint = "http://localhost:11434")
            .AddKernel(options =>
            {
                options.Ollama = new OllamaOptions
                {
                    ChatCompletion = new OllamaChatCompletionOptions { ModelId = "llama3" }
                };
            })
            .AddMemory(options =>
            {
                options.TextEmbeddingGeneration = new TextEmbeddingGenerationOptions
                {
                    Ollama = new OllamaTextEmbeddingGenerationMemoryOptions
                    {
                        ModelId = "llama3"
                    }
                };
            })
            .IncludeSimpleMemoryStore(options =>
            {
                options.Directory = "tmp-sk-memory";
                options.StorageType = StorageType.Persistent;
            })
            .AddAgents()
            .IncludeChatCompletionAgent()
            .WithSemanticTextMemoryRetriever();
    })
    .Build();

var agent = host.Services.GetRequiredService<IChatAgent>();

Console.WriteLine();
Console.WriteLine("Chat agent");
Console.WriteLine("-----------------------");
Console.WriteLine("Press Ctrl+C to quit the conversation");
Console.WriteLine();

while (true)
{
    Console.Write("User > ");

    var message = Console.ReadLine()!;
    var first = true;

    await foreach (var response in agent.SendMessageAsStreamAsync(message))
    {
        if (first)
        {
            Console.Write("Assistant > ");
            first = false;
        }

        Console.Write(response.Content);
    }

    Console.WriteLine();
    Console.WriteLine();
}

await host.RunAsync();

Credits

Icon by Freepik