使用 .NET 开始 OpenAI Completions

Using .NET to Start OpenAI Completions
This blog post is part of a series that explores OpenAI and .NET. In this article, we focus on completions - responses generated by models like GPT. Completions can take the form of text, code, images, and more.
To generate a completion, you need a model and a user input (prompt). The model is like a stateful function that recognizes patterns in data using algorithms. OpenAI models, like GPT, use a neural network algorithm called transformer.
The user input, or prompt, provides instructions on what output you want the model to produce. The prompt includes background information and a task/question.
The size of the prompt is measured in tokens, and each model has a token limit. To calculate the number of tokens in your prompt, you can use the Microsoft.ML.Tokenizers NuGet package.
To generate your own completion, you can register for or request access to OpenAI or Azure OpenAI services and try their .NET examples using your credentials.
In the next article, we will discuss prompt engineering, a process for optimizing prompts to produce more accurate results.
We appreciate your feedback on how you use AI in your applications. Take a few minutes to complete this survey and let us know what other topics you would like to learn more about.