Aiursoft.GptClient 9.0.20
Aiursoft GptClient
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 model = GptModel.DeepseekR170B;
var services = new ServiceCollection();
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, endpoint, apiKey);
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.
No packages depend on Aiursoft.GptClient.
.NET 9.0
- Aiursoft.GptClient.Abstractions (>= 9.0.20)
- Aiursoft.CSTools (>= 9.0.2)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.3)
Version | Last updated |
---|---|
9.0.24 | 04/09/2025 |
9.0.23 | 04/08/2025 |
9.0.22 | 04/07/2025 |
9.0.21 | 04/07/2025 |
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.15 | 03/31/2025 |
9.0.14 | 03/31/2025 |
9.0.13 | 03/31/2025 |
9.0.12 | 03/31/2025 |
9.0.11 | 03/31/2025 |
9.0.10 | 03/31/2025 |
9.0.9 | 03/31/2025 |
9.0.8 | 03/12/2025 |
9.0.7 | 03/12/2025 |
9.0.6 | 03/03/2025 |
9.0.5 | 02/23/2025 |
9.0.4 | 02/12/2025 |
9.0.3 | 02/02/2025 |
9.0.0 | 02/02/2025 |