OpenAi.Api.Abstractions 1.0.1

dotnet tool install --global OpenAi.Api.Abstractions --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local OpenAi.Api.Abstractions --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=OpenAi.Api.Abstractions&version=1.0.1
nuke :add-package OpenAi.Api.Abstractions --version 1.0.1

OpenAi.Api

The OpenAiProvider class is a provider for interacting with the OpenAI API. It allows you to generate completions and retrieve information about specific models.

Public Constructors

OpenAiProvider(HttpClient httpClient)

Initializes a new instance of the OpenAiProvider class with the specified HttpClient object used for making HTTP requests to the OpenAI API.

  • httpClient: The HttpClient object to use for making HTTP requests.

Public Methods

Task<string?> GenerateCompletionAsync(CompletionRequest completionRequest)

Asynchronously generates a completion based on the provided CompletionRequest.

  • completionRequest: The completion request object.
  • Returns: A Task<string> representing the asynchronous operation. The task result contains the generated completion as a JSON string, or null if an error occurs.

Task<Model?> GetModelAsync(string modelName)

Asynchronously retrieves information about a specific model by its name.

  • modelName: The name of the model.
  • Returns: A Task<Model> representing the asynchronous operation. The task result contains the retrieved model information as a Model object, or null if an error occurs.

Usage

To use the OpenAiProvider class, you need to instantiate it with an HttpClient object and then call the desired methods. Here's an example:

HttpClient httpClient = new HttpClient();
OpenAiProvider openAiProvider = new OpenAiProvider(httpClient);

// Generate completion
CompletionRequest completionRequest = new CompletionRequest(model, prompt);
string? completion = await openAiProvider.GenerateCompletionAsync(completionRequest);

// Get model information
string modelName = "davinci-codex";
Model? model = await openAiProvider.GetModelAsync(modelName);
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.1 190 6/19/2023
1.0.0 158 6/18/2023