Betalgo.OpenAI.GPT3
0.0.3
PackageId is updated to Betalgo.OpenAI, Please use the new packageId(Betalgo.OpenAI) to get the latest updates.
See the version list below for details.
dotnet add package Betalgo.OpenAI.GPT3 --version 0.0.3
NuGet\Install-Package Betalgo.OpenAI.GPT3 -Version 0.0.3
<PackageReference Include="Betalgo.OpenAI.GPT3" Version="0.0.3" />
paket add Betalgo.OpenAI.GPT3 --version 0.0.3
#r "nuget: Betalgo.OpenAI.GPT3, 0.0.3"
// Install Betalgo.OpenAI.GPT3 as a Cake Addin #addin nuget:?package=Betalgo.OpenAI.GPT3&version=0.0.3 // Install Betalgo.OpenAI.GPT3 as a Cake Tool #tool nuget:?package=Betalgo.OpenAI.GPT3&version=0.0.3
Dotnet SDK for OpenAI GTP-3 (Unofficial)
Install-Package Betalgo.OpenAI.GPT3
I was building an SDK for myself then I decide to share it, I hope it will be useful for you. I haven't maintained any open source projects before. Any help would be much appreciated. I am open to suggestions If you would like to contribute somehow.
I will be using the latest libraries all the time (including dotnet 6). Also, next releasing will include breaking changes frequently (as I mentioned before I was building the SDK for myself. Unfortunately I do not have time to plan these changes and support lower version apps). So please be aware of that before starting to use the library.
As you can guess I do not accept any damage caused by use of the library. You are always free to use other libraries or OpenAI Web-API.
Sample Usages
The repository includes one sample project already "OpenAI.Playground" You can check playground project to see how I was testing it while I was developing the library. Be carefull while playing with it. Some test methods will delete your files or fine tunings. I would suggest to use different account than your main account while you use playground.
Using dependcy injection:
secrets.json:
*(How to use user secret? ⇒ right click your project name in "solution explorer" then click "Manage User Secret", it is a good way to keep your api keys) *
"OpenAIServiceOptions": {
//"ApiKey":"Your api key goes here"
//,"Organization": "Your Organization Id goes here (optional)"
},
Program.cs
serviceCollection.AddOpenAIService();
or use it like below but do NOT put your API key directly to your source code, you may expose your API key, which will cost you $$.
Program.cs
serviceCollection.AddOpenAIService(settings => { settings.ApiKey = "TEST"; });
After injecting your service you will be able to get it from service provider
var openAiService = serviceProvider.GetRequiredService<IOpenAIService>();
Without dependcy injection:
var openAiService = new OpenAIService(new OpenAiOptions()
{
ApiKey = "MY_API_KEY"
});
You can set default engine(optional):
openAiService.SetDefaultEngineId(Engines.Davinci);
Completions Sample
var completionResult = await openAiService.Completions.Create(new CompletionCreateRequest()
{
Prompt = "Once upon a time",
MaxTokens = 5
}, Engines.Engine.Davinci);
if (completionResult.Successful)
{
Console.WriteLine(completionResult.Choices.FirstOrDefault());
}
else
{
if (completionResult.Error == null)
{
throw new Exception("Unknown Error");
}
Console.WriteLine($"{completionResult.Error.Code}: {completionResult.Error.Message}");
}
Notes: I couldn't find enough time to test all the methods or improve the documentation. My main target was to make fine-tuning available. If you hit any issue please report it or pull request always appreciated.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.AspNet.WebApi.Client (>= 5.2.7)
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Betalgo.OpenAI.GPT3:
Package | Downloads |
---|---|
BootstrapBlazor.OpenAI.GPT3
Bootstrap UI OpenAI GPT3 components experience |
|
Witrics.AI.Activities
UiPath AI activities for working with ChatGPT |
|
Senparc.Xncf.OpenAI
OpenAI 和 ChatGPT 接口 |
|
Luga
A Generative AI Agent Management framework for .NET. |
|
YKT.ChatGPT.AI
访问OpenAI ChatGPT模型api的库,OpenAI, ChatGPT |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
6.8.4 | 90,096 | 4/19/2023 | |
6.8.3 | 70,051 | 3/28/2023 | |
6.8.1 | 20,662 | 3/20/2023 | |
6.8.0 | 26,048 | 3/14/2023 | |
6.7.3 | 10,379 | 3/10/2023 | |
6.7.2 | 18,002 | 3/5/2023 | |
6.7.1 | 2,818 | 3/4/2023 | |
6.7.0 | 4,749 | 3/2/2023 | |
6.6.8 | 2,279 | 2/28/2023 | |
6.6.7 | 12,288 | 2/8/2023 | |
6.6.6 | 8,353 | 1/19/2023 | |
6.6.5 | 2,017 | 1/16/2023 | |
6.6.4 | 3,516 | 1/11/2023 | |
6.6.3 | 2,401 | 1/5/2023 | |
6.6.2 | 2,325 | 1/1/2023 | |
6.6.0 | 3,585 | 12/2/2022 | |
6.5.0 | 664 | 11/4/2022 | |
6.4.1 | 490 | 11/1/2022 | |
6.4.0 | 696 | 9/26/2022 | |
6.3.0 | 560 | 9/20/2022 | |
6.2.0 | 678 | 8/10/2022 | |
6.1.0 | 686 | 6/9/2022 | |
6.0.0 | 800 | 3/12/2022 | |
0.0.3 | 458 | 1/7/2022 | |
0.0.2 | 550 | 1/7/2022 | |
0.0.1 | 495 | 12/28/2021 |