AI.Dev.OpenAI.GPT 1.0.2

dotnet add package AI.Dev.OpenAI.GPT --version 1.0.2
NuGet\Install-Package AI.Dev.OpenAI.GPT -Version 1.0.2
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="AI.Dev.OpenAI.GPT" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AI.Dev.OpenAI.GPT --version 1.0.2
#r "nuget: AI.Dev.OpenAI.GPT, 1.0.2"
#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.
// Install AI.Dev.OpenAI.GPT as a Cake Addin
#addin nuget:?package=AI.Dev.OpenAI.GPT&version=1.0.2

// Install AI.Dev.OpenAI.GPT as a Cake Tool
#tool nuget:?package=AI.Dev.OpenAI.GPT&version=1.0.2

GPT Tokenizer

.NET / C#

When using OpenAI GPT, you may need to know how many tokens your code is using for various purposes, such as estimating costs and improving results.

The GPT3Tokenizer C# class can help you count tokens in your prompts and in the responses received.

using AI.Dev.OpenAI.GPT;

string text = "January 1st, 2000";

// 5 tokens => [21339, 352, 301, 11, 4751]
List<int> tokens = GPT3Tokenizer.Encode(text);

The tokenizer uses a byte-pair encoding (BPE) algorithm to split words into subwords based on frequency and merges rules. It can handle out-of-vocabulary words, punctuation, and special tokens.

The result of this library is compatible with OpenAI GPT tokenizer that you can also test here.

Installation

Install AI.Dev.OpenAI.GPT NuGet package from nuget.org, e.g.:

dotnet add package AI.Dev.OpenAI.GPT --version 1.0.2

or

NuGet\Install-Package AI.Dev.OpenAI.GPT -Version 1.0.2

Python and Node.js

If you are looking for an equivalent solution in other languages:

Licensing

This library is licensed CC0, in the public domain. You can use it for any application, you can modify the code, and you can redistribute any part of it.

I am not affiliated with OpenAI and this library is not endorsed by them. I just work with several AI solutions and I share this code hoping to make technology more accessible and easier to work with.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on AI.Dev.OpenAI.GPT:

Package Downloads
AllInAI.Sharp.API

AllInAI.Sharp.API is an SDK that calls language models from various platforms, and it helps users quickly integrate with major models. It has integrated OpenAI, chatGLM, Wenxin Qianfan, Synonymous Qianwen, stable-diffusion,pinecone,pgvector etc. It supports setting reverse proxies and streaming interfaces. The AllInAI SDK integrates unified input and output parameters in the chat and image interfaces, making it easy to call. Now, the SDK supports vector library extension, enabling fast implementation of local or cloud-based knowledge base functionality. AllInAI.Sharp.API一款调用各大平台语言模型的SDK,能帮助使用者快速对接各大模型和向量数据库。已整合OpenAI,chatGLM,文心千帆,同义千问,stable-diffusion,pinecone,pgvector 等 支持设置反向代理,支持流式接口 AllInAI SDK 在聊天和图片接口中整合统一的入参和出参。方便调用。 现在,SDK支持向量库扩展,可以快速实现本地或云端知识库功能。

SyNemo.OpenAI

目前包含 ChatGPT, 1.1.x增加GPT3.5

Perplex.AI.Assistant

Provides ChatGPT integrations for Umbraco

DotnetPrompt.LLM.OpenAI

A clients for OpenAI and Azure OpenAI for DotnetPrompt. DotnetPrompt is a dotnet library that provides a set of tools for working with Large Language Models (LLMs) combined in chains.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on AI.Dev.OpenAI.GPT:

Repository Stars
microsoft/conversational-speaker
Version Downloads Last updated
1.0.2 85,695 10/20/2022
1.0.1 497 10/20/2022