Artounis-OpenAI-Client 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Artounis-OpenAI-Client --version 1.0.0
                    
NuGet\Install-Package Artounis-OpenAI-Client -Version 1.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="Artounis-OpenAI-Client" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Artounis-OpenAI-Client" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Artounis-OpenAI-Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Artounis-OpenAI-Client --version 1.0.0
                    
#r "nuget: Artounis-OpenAI-Client, 1.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.
#:package Artounis-OpenAI-Client@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Artounis-OpenAI-Client&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Artounis-OpenAI-Client&version=1.0.0
                    
Install as a Cake Tool

A C# client library for interacting with OpenAI's API, providing easy access to GPT-3, GPT-4, and other models for tasks like completions, embeddings, fine-tuning, and more.

Features

  • Access OpenAI models like GPT-3 and GPT-4.
  • Generate text completions, summaries, or responses based on prompts.
  • Work with embeddings for semantic search and similarity tasks.
  • Fine-tune models for custom applications.
  • Use moderation tools to filter unsafe content.
  • Support for batching requests and multilingual models.
  • Easy integration into any C# project.

Installation

You can install the OpenAI-Artounis library via NuGet.

Install-Package OpenAI-Artounis

Alternatively, you can clone the repository and build it from source:

git clone https://github.com/arashplus/OpenAI-Artounis.git
cd OpenAI-Artounis
dotnet build

Usage

Here’s a basic example of how to use OpenAI-Artounis to generate text completions using OpenAI’s models:

Initialize and Get a Completion

using OpenAIArtounis;

var config = new OpenAIConfig
{
    ApiKey = "your-api-key-here",
    DefaultModel = "text-davinci-003",
    Endpoint = "https://api.openai.com/v1"
};

var openAIClient = new OpenAIClient(config);
var completionService = new OpenAICompletion(openAIClient);

var result = await completionService.GetCompletionAsync("Once upon a time");
Console.WriteLine(result);

Generate Embeddings

var embeddingsService = new OpenAIEmbeddings(openAIClient);
var embeddings = await embeddingsService.GetEmbeddingsAsync("Hello, OpenAI!");
Console.WriteLine(embeddings);

Fine-Tune a Model

var fineTuningService = new OpenAIFineTuning(openAIClient);
var fineTuneId = await fineTuningService.FineTuneModelAsync("your-training-file-id");
Console.WriteLine(fineTuneId);

Perform Moderation Check

var moderationService = new OpenAIModeration(openAIClient);
var moderationResult = await moderationService.ModerationCheckAsync("Some sensitive content here");
Console.WriteLine(moderationResult);

Configuration

You can configure OpenAI-Artounis using the OpenAIConfig class. Below are the configuration options:

ApiKey: Your OpenAI API key (required). DefaultModel: The default model to use for completions (optional, default is "text-davinci-003"). Endpoint: The API endpoint to connect to (optional, default is "https://api.openai.com/v1"). Example:

var config = new OpenAIConfig
{
    ApiKey = "your-api-key-here",
    DefaultModel = "text-davinci-003",
    Endpoint = "https://api.openai.com/v1"
};

Contributing

We welcome contributions to OpenAI-Artounis! If you want to contribute, follow these steps:

Fork the repository. Clone your forked repository. Create a new branch for your feature or bug fix. Commit your changes and push to your fork. Open a pull request with a description of the changes.

Code of Conduct

Please follow our Code of Conduct when contributing.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

OpenAI for providing access to powerful models like GPT-3, GPT-4, and others. The open-source community for tools and libraries that helped in developing this project.

If you have any questions or need help, feel free to open an issue or contact us.

Key Sections Explained:

  1. Project Title and Description: This section gives a brief overview of the project and its functionality.

  2. Features: Lists the capabilities of your library, providing users with an idea of what they can do with it.

  3. Installation: Provides instructions on how to install the library, both via NuGet and by building from source.

  4. Usage: Shows example code snippets for common operations like generating text completions, embeddings, fine-tuning models, and performing moderation checks.

  5. Configuration: Describes how to set up and configure the library using the OpenAIConfig class. This section is important for users to understand how to provide their OpenAI API key and adjust the default settings.

  6. Contributing: Provides instructions for developers who want to contribute to the project, ensuring that the repository is open for improvements.

  7. License: Specifies the open-source license (MIT in this case), which is crucial for open-source projects.

  8. Acknowledgments: Thanks to the contributors and recognizes the libraries or APIs that your project depends on.

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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 117 1/27/2025
1.0.0 101 1/26/2025

Release Notes for Version 1.0.0 - 2025-01-25

Added:

Initial release of Artounis-OpenAI-Client.
A C# client library for interacting with OpenAI's API, supporting models like GPT-3, completions, embeddings, fine-tuning, and more.
Provides simple methods for making API calls to OpenAI.
Dependency: Added support for Newtonsoft.Json (>= 13.0.3).
NuGet Package:
Published as a stable version.
Supports netstandard2.0 and net9.0 frameworks.
Features:

Simplified interface for interacting with OpenAI’s GPT models.
Ability to generate text completions, embeddings, and more.
Support for OpenAI Fine-Tuning and Embeddings for similarity search.
Basic moderation tools to filter out unsafe content.
Documentation:

A README.md file has been added to the package for detailed usage instructions.
The LICENSE.txt file has been included with the MIT License.
Known Issues:

None reported as of version 1.0.0.