Aiursoft.GptClient.Abstractions 9.0.10

Aiursoft GptClient

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

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

How to install

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

dotnet add package Aiursoft.GptClient

Exposed API in ChatClient:

public Task<CompletionData> AskModel(OpenAiModel model);
public Task<CompletionData> AskString(string gptModelType, params string[] content);

Required IConfiguration keys:

{
    "OpenAI:Token": "YourOpenAIKey",
    "OpenAI:CompletionApiUrl": "https://api.openai.com/v1/engines/davinci/completions"
}

For example, you can use the following code to create a simple ChatGpt client:

var inMemorySettings = new Dictionary<string, string>
{
    { "OpenAI:Token", apiKey },
    { "OpenAI:CompletionApiUrl", endpoint }
};
var model = GptModel.DeepseekR170B;
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
{
    Model = modelName
};
while (true)
{
    var nextQuestion = AskUser("USER:", null);
    history.Messages.Add(new MessagesItem
    {
        Role = "user",
        Content = nextQuestion
    });

    var result = await chatClient.AskModel(history);
    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.

Showing the top 20 packages that depend on Aiursoft.GptClient.Abstractions.

Packages
Aiursoft.GptClient
Automatic dependencies management system which powers Aiursoft

.NET 9.0

  • No dependencies.

Version Last updated
9.0.20 03/31/2025
9.0.19 03/31/2025
9.0.18 03/31/2025
9.0.17 03/31/2025
9.0.16 03/31/2025
9.0.11 03/31/2025
9.0.10 03/31/2025
9.0.9 03/31/2025
9.0.7 03/12/2025
9.0.0 02/02/2025