CommonSDK 1.0.7

dotnet add package CommonSDK --version 1.0.7
                    
NuGet\Install-Package CommonSDK -Version 1.0.7
                    
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="CommonSDK" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommonSDK" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="CommonSDK" />
                    
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 CommonSDK --version 1.0.7
                    
#r "nuget: CommonSDK, 1.0.7"
                    
#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 CommonSDK@1.0.7
                    
#: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=CommonSDK&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=CommonSDK&version=1.0.7
                    
Install as a Cake Tool

Goal: Write a universal development toolkit

Includes the following directory:
  • CommonSDK
    • AI
      • Enum
        • AIPlatform
      • Interface
        • IChatService<T>
        • ICommandService
      • Ollama
        • OllamaService
        • OllamaCommandService
      • ChatClient
        • IChatClient
        • OllamaChatClient
    • EventBus
      • Interface
      • Model
      • Service
    • README.md
  1. The AI module only supports Ollama and provides the IChatService<T> interface and the OllamaService class. The IChatService<T> interface defines the basic operations of the chat service, including methods for sending messages, receiving messages, and retrieving chat history. The OllamaService class implements the IChatService<T> interface and provides the specific interaction logic with the Ollama chat model.

  2. The event bus provides a communication method between modules, offering the BaseEventSource<T> class and the EventBusService class. The BaseEventSource<T> class defines the basic operations of the event source, including methods for registering, unregistering, and triggering events. The EventBusService class implements the BaseEventSource<T> interface and provides the specific interaction logic with the event bus.

  3. Has stopped using Microsoft.Extensions.AI and Microsoft.Extensions.AI.Ollama, now rewrite the logical interface request, to provide the reference Ollama API documentation. ChatStreamAsync、ChatAsync、GetLocalModelsAsync、GetModelInfoAsync calls are currently supported, and implementation of streams is in progress. ollama chat API interface, providing large model question-answering capabilities. It takes a long time to request the interface without streaming, and the average time is 20 ~ 30ms

  4. It is now possible to request a question and answer as an OllamaService or OllamaChatClient, and OllamaService supports running the model through code

  5. The full source code for this project is available at https://github.com/WenElevating/CommonSDK

  6. Support to load a local JSON configuration file is supported now. Here is an example:

{
    "ModelId": "llama3.2",
    "Endpoint": "http://localhost:8000",
    "ExectuePath":  "D://example"
}
The following is an example usage of the ollama service: (based on the WPF framework)
        public partial class MainWindow : Window
    {
        private readonly OllamaService service = new("D:\\RiderProject\\CommonSDK\\CommonSDK.Application\\OllamaConfiguration.json");

        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
            Closed += MainWindow_Closed;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
            {
                // use on service
                //await service.RunAsync();

                //AI.ChatClient.ChatResponse response = await service.ChatAsync("Recommend a few must-read books for programmers.");

                //ChatTextBlock.Text += response.Data.Message.Content;

                //await service.ChatStreamAsync("Recommend a few must-read books for programmers.", (message) =>
                //{
                //    ChatTextBlock.Text += message;
                //});

                // use on client
                IChatClient client = new OllamaChatClient("http://localhost:8000", "llama3.2");
                CancellationTokenSource tokenSource = new();
                await foreach (var item in client.ChatStreamAsync("Recommend a few must-read books for programmers.", tokenSource.Token))
                {
                    if (item.Code == ChatResultCode.Success)
                    {
                        ChatTextBlock.Text += item.Data.Message.Content;
                    }
                }
            });
        }

        private async void MainWindow_Closed(object? sender, EventArgs e)
        {
            await service.DisposeAsync();
        }
    }
Provide a running screenshot:

Run TextBlock Sample
Run Markdown Sample

Product 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.

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.0.7 191 5/28/2025
1.0.6 172 5/25/2025
1.0.5 125 5/25/2025
1.0.4 100 5/24/2025
1.0.3 254 5/13/2025
1.0.2 256 5/12/2025
1.0.1 251 5/12/2025
1.0.0 193 4/27/2025