OP 12 February, 2023 - 06:38 AM
UsageTo use the library, first create an instance of the
Code:
Client
var endpoint = "https://api.openai.com/v1/";
var client = new Client(apiKey, endpoint);You can now use the Client instance to call the various methods available in the library. For example, to generate text, you would call the GenerateText method:
var model = "text-davinci-002";
var prompt = "The future is bright.";
var length = 100;
var nopunct = false;
var stop = false;
var temperature = 0.5;
var result = client.GenerateText(model, prompt, length, nopunct, stop, temperature);The library also provides methods for summarizing text, completing code, analyzing sentiment, recognizing named entities, classifying text, translating text, and recognizing emotions in text or speech.
For more information on how to use each method, see the API reference section below.
API ReferenceGenerateTextGenerates text using the OpenAI API.
public string GenerateText(string model, string prompt, int length, bool nopunct, bool stop, int temperature)Parameters
Code:
model
Code:
prompt
Code:
length
Code:
nopunct
Code:
stop
Code:
temperature
SummarizeTextSummarizes text using the OpenAI API.
public string SummarizeText(string text, int length)Parameters
Code:
text
Code:
length
#CompleteCode Completes code using the OpenAI API.
public string CompleteCode(string model, string prompt, int maxTokens, int n)Parameters
Code:
model
Code:
prompt
Code:
maxTokens
Code:
n
#AnalyzeSentiment Analyzes the sentiment of text using the OpenAI API.
public string AnalyzeSentiment(string text)Parameters
Code:
text
#RecognizeEntities Recognizes named entities in text using the OpenAI API.
public string RecognizeEntities(string text)Parameters
Code:
text
#ClassifyText Classifies text into categories using the OpenAI API.
public string ClassifyText(string text)Parameters
Code:
text
#TranslateText Translates text from one language to another using the OpenAI API.
public string TranslateText(string text, string from, string to)Parameters
Code:
text
Code:
from
Code:
to
#RecognizeEmotion Recognizes emotions in text or speech (Coming Soon) using the OpenAI API.
public string RecognizeEmotion(string text)Parameters
Code:
text