Aiursoft.GptClient.Abstractions 9.0.0

dotnet add package Aiursoft.GptClient.Abstractions --version 9.0.0                
NuGet\Install-Package Aiursoft.GptClient.Abstractions -Version 9.0.0                
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="Aiursoft.GptClient.Abstractions" Version="9.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aiursoft.GptClient.Abstractions --version 9.0.0                
#r "nuget: Aiursoft.GptClient.Abstractions, 9.0.0"                
#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 Aiursoft.GptClient.Abstractions as a Cake Addin
#addin nuget:?package=Aiursoft.GptClient.Abstractions&version=9.0.0

// Install Aiursoft.GptClient.Abstractions as a Cake Tool
#tool nuget:?package=Aiursoft.GptClient.Abstractions&version=9.0.0                

Aiursoft GptClient

MIT licensed Pipeline stat Test Coverage NuGet version (Aiursoft.GptClient) ManHours

The SDK for ChatGpt. Simple implementation and easy to use.

How to use Aiursoft.GptClient.ChatConsole as a CLI

Before starting, it's suggested to install ollama first for local testing.

curl -fsSL https://ollama.com/install.sh | sh

This project uses deepseek-r1:32b as the default model. Pull it first.

ollama pull deepseek-r1:32b

To use Aiursoft.GptClient.ChatConsole as a CLI, you can install it as a global tool:

dotnet tool install --global Aiursoft.GptClient.ChatConsole

Then you can use the tool like this:

chat-console

That's it! You can now chat with GPT in your terminal.

How to use Aiursoft.GptClient as a Library

First, install Aiursoft.GptClient to your ASP.NET Core project from nuget.org:

dotnet add package Aiursoft.GptClient

Then you can use the client like this:

var inMemorySettings = new Dictionary<string, string>
{
    { "OpenAI:Token", apiKey },
    { "OpenAI:CompletionApiUrl", endpoint }
};
var configuration = new ConfigurationBuilder()
    .AddInMemoryCollection(inMemorySettings!)
    .Build();

var services = new ServiceCollection();
services.AddSingleton<IConfiguration>(configuration);
services.AddHttpClient();
services.AddLogging(logging =>
{
    logging.SetMinimumLevel(LogLevel.Warning);
});
services.AddGptClient();
var serviceProvider = services.BuildServiceProvider();
var chatClient = serviceProvider.GetRequiredService<ChatClient>();

var history = new OpenAiModel();
while (true)
{
    var nextQuestion = AskUser("USER:", null);
    history.Messages.Add(new MessagesItem
    {
        Role = "user",
        Content = nextQuestion
    });

    var result = await chatClient.AskModel(history, model);
    Console.WriteLine("AI:");
    Console.WriteLine(result.GetAnswerPart());
    
    history.Messages.Add(new MessagesItem
    {
        Role = "assistant",
        Content = result.GetAnswerPart()
    });
}

Now you have built a simple ChatGpt client.

How to contribute

There are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.

Even if you with push rights on the repository, you should create a personal fork and create feature branches there when you need them. This keeps the main repository clean and your workflow cruft out of sight.

We're also interested in your feedback on the future of this project. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aiursoft.GptClient.Abstractions:

Package Downloads
Aiursoft.GptClient

Automatic dependencies management system which powers Aiursoft

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.0 40 2/2/2025