OpenAi_Fetcher 0.1.4
See the version list below for details.
dotnet add package OpenAi_Fetcher --version 0.1.4
NuGet\Install-Package OpenAi_Fetcher -Version 0.1.4
<PackageReference Include="OpenAi_Fetcher" Version="0.1.4" />
paket add OpenAi_Fetcher --version 0.1.4
#r "nuget: OpenAi_Fetcher, 0.1.4"
// Install OpenAi_Fetcher as a Cake Addin
#addin nuget:?package=OpenAi_Fetcher&version=0.1.4
// Install OpenAi_Fetcher as a Cake Tool
#tool nuget:?package=OpenAi_Fetcher&version=0.1.4
OpenAI Fetcher
Class library to incorporate OpenAI in your .NET application.
Changelog
0.1.4 - Adjustment to readme
0.1.3 - More options
Added
- More options: Other settings
- Changed default model to gpt-3.5-turbo-1106
Use
Fetch data
Replace ’apiKey’ with your OpenAI API key. Replace 'instruction' and 'input' with your specific requirements.
var fetcher = new OpenAi.OpenAiApiFetcher(apiKey, "Return the 3 biggest cities of the country", "Sweden");
Change default model
Default setting is GPT-3.5-turbo. But you can select GPT-4 or GPT-4-1106-preview.
fetcher.Model = GptModels.Gpt4
Custom model
fetcher.Model = GptModels.Custom = "custom-model";
Other settings
You can also change Temprature, JsonMode* and token size.
Temp
Temp can be set between 0 and 1, where 0 will give little/none variation in the response, and 1 give more variation. Between 0.6 - 0.9 is recommended for creative tasks.
fetcher.Temp = 0.7
JsonMode
Json mode is available with GPT-3.5-turbo-1106 and gpt-4-1106-preview (Gpt35T and Gpt4T)
fetcher.JsonMode = true
Token Size
Max size for context window. (Read OpenAi docs for limitations)
fetcher.TokenSize = 1000
Default settings
- Model: gpt-3.5-turbo-1106
- Temp: 0
- JsonMode: false
- TokenSize: 500
Results
You can get results returned as a JSON string or strongly-typed as GptResponse
Strongly-typed
GptResponse response = await fetcher.FetchCompletionsAsync();
var gptChoises = response.Choices[0];
Result
gptChoises.Message.Content:
1. Stockholm - The capital and largest city of Sweden, with a population of approximately 975,000 people.
2. Gothenburg - The second-largest city in Sweden, with a population of around 590,000 people.
3. Malmö - The third-largest city in Sweden, with a population of about 320,000 people.
JSON string
string result = await fetcher.FetchCompletionsAsync();
Result
{
"id": "chatcmpl-8Ig99G1IFcO0JIU77OOL7g15vgD7D",
"object": "chat.completion",
"created": 1699462607,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The three biggest cities in Sweden are:\n\n1. Stockholm - The capital and largest city of Sweden, with a population of approximately 975,000 people.\n2. Gothenburg - The second-largest city in Sweden, with a population of around 590,000 people.\n3. Malmö - The third-largest city in Sweden, with a population of about 320,000 people."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 21,
"completion_tokens": 78,
"total_tokens": 99
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Small adjustment to readme