tryAGI.OpenAI
1.1.1
Prefix Reserved
See the version list below for details.
dotnet add package tryAGI.OpenAI --version 1.1.1
NuGet\Install-Package tryAGI.OpenAI -Version 1.1.1
<PackageReference Include="tryAGI.OpenAI" Version="1.1.1" />
<PackageVersion Include="tryAGI.OpenAI" Version="1.1.1" />
<PackageReference Include="tryAGI.OpenAI" />
paket add tryAGI.OpenAI --version 1.1.1
#r "nuget: tryAGI.OpenAI, 1.1.1"
#:package tryAGI.OpenAI@1.1.1
#addin nuget:?package=tryAGI.OpenAI&version=1.1.1
#tool nuget:?package=tryAGI.OpenAI&version=1.1.1
OpenAI
Generated C# SDK based on official OpenAI OpenAPI specification using NSwag
This package includes C# Source Generator which allows you to define functions natively through a C# interface,
and also provides extensions that make it easier to call this interface later.
In addition to easy function implementation and readability,
it generates Args classes, extension methods to easily pass a functions to API,
and extension methods to simply call a function via json and return json.
Currently only System.Text.Json is supported.
Usage
using tryAGI.OpenAI;
public enum Unit
{
Celsius,
Fahrenheit,
}
public class Weather
{
public string Location { get; set; } = string.Empty;
public double Temperature { get; set; }
public Unit Unit { get; set; }
public string Description { get; set; } = string.Empty;
}
[OpenAiFunctions]
public interface IWeatherFunctions
{
[Description("Get the current weather in a given location")]
public Task<Weather> GetCurrentWeatherAsync(
[Description("The city and state, e.g. San Francisco, CA")] string location,
Unit unit = Unit.Celsius,
CancellationToken cancellationToken = default);
}
public class WeatherService : IWeatherFunctions
{
public Task<Weather> GetCurrentWeatherAsync(string location, Unit unit = Unit.Celsius, CancellationToken cancellationToken = default)
{
return Task.FromResult(new Weather
{
Location = location,
Temperature = 22.0,
Unit = unit,
Description = "Sunny",
});
}
}
var service = new WeatherService();
using var httpClient = new HttpClient();
var api = new OpenAiApi(apiKey, httpClient);
var result = await api.CreateChatCompletionAsync(new CreateChatCompletionRequest
{
Messages = new List<ChatCompletionRequestMessage>
{
"You are a helpful weather assistant.".AsSystemMessage(),
"What's the weather like today?".AsUserMessage(),
},
Functions = service.AsFunctions(),
Function_call = Function_call4.Auto,
Model = "gpt-3.5-turbo-0613",
});
// ...
var resultMessage = result.GetFirstChoiceMessage();
var functionArgumentsJson = resultMessage.Function_call?.Arguments ?? string.Empty;
var json = await service.CallGetCurrentWeatherAsync(functionArgumentsJson);
// or just get arguments
var args = service.AsGetCurrentWeatherAsyncArgs(functionArgumentsJson);
Support
Priority place for bugs: https://github.com/tryAGI/OpenAI/issues
Priority place for ideas and general questions: https://github.com/tryAGI/OpenAI/discussions
Discord: https://discord.gg/Ca2xhfBf3v
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. 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 is compatible. 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. net9.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Text.Json (>= 7.0.3)
- Tiktoken (>= 1.1.0)
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 7.0.3)
- Tiktoken (>= 1.1.0)
-
net6.0
- Tiktoken (>= 1.1.0)
-
net7.0
- Tiktoken (>= 1.1.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on tryAGI.OpenAI:
| Package | Downloads |
|---|---|
|
LangChain.Providers.OpenAI
OpenAI API LLM and Chat model provider. |
|
|
Anyscale
SDK for Anyscale Endpoint that makes it easy and cheap to use LLama 2 |
|
|
LangChain.Serve.OpenAI
LangChain Serve as OpenAI sdk compatible API |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on tryAGI.OpenAI:
| Repository | Stars |
|---|---|
|
tryAGI/LangChain
C# implementation of LangChain. We try to be as close to the original as possible in terms of abstractions, but are open to new entities.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.1-dev.6 | 2,594 | 3/9/2025 |
| 4.2.1-dev.3 | 132 | 2/27/2025 |
| 4.2.0 | 18,174 | 2/11/2025 |
| 4.1.0 | 626 | 2/3/2025 |
| 4.0.0 | 34,270 | 1/27/2025 |
| 3.9.3-dev.40 | 187 | 1/7/2025 |
| 3.9.3-dev.38 | 105 | 1/7/2025 |
| 3.9.3-dev.37 | 123 | 1/7/2025 |
| 3.9.3-dev.36 | 290 | 1/7/2025 |
| 3.9.3-dev.35 | 122 | 1/7/2025 |
| 3.9.3-dev.31 | 151 | 12/19/2024 |
| 3.9.3-dev.14 | 130 | 11/15/2024 |
| 3.9.3-dev.13 | 127 | 11/15/2024 |
| 3.9.3-dev.1 | 121 | 10/26/2024 |
| 3.9.2 | 3,509 | 10/26/2024 |
| 3.9.2-dev.7 | 3,650 | 10/25/2024 |
| 3.9.2-dev.6 | 114 | 10/25/2024 |
| 3.9.2-dev.4 | 107 | 10/25/2024 |
| 3.9.2-dev.1 | 219 | 10/24/2024 |
| 3.9.1 | 182 | 10/24/2024 |
| 3.8.2-dev.13 | 138 | 10/14/2024 |
| 3.8.2-dev.10 | 120 | 10/13/2024 |
| 3.8.2-dev.9 | 120 | 10/13/2024 |
| 3.8.1 | 1,061 | 10/9/2024 |
| 3.8.1-dev.14 | 127 | 10/2/2024 |
| 3.8.1-dev.13 | 115 | 10/2/2024 |
| 3.8.1-dev.6 | 99 | 9/28/2024 |
| 3.8.1-dev.3 | 103 | 9/28/2024 |
| 3.8.1-dev.2 | 105 | 9/26/2024 |
| 3.8.0 | 1,140 | 9/26/2024 |
| 3.7.1-dev.14 | 111 | 9/24/2024 |
| 3.7.1-dev.12 | 125 | 9/23/2024 |
| 3.7.1-dev.5 | 152 | 9/16/2024 |
| 3.7.1-dev.3 | 30,061 | 9/15/2024 |
| 3.7.0 | 465 | 9/14/2024 |
| 3.6.4-dev.10 | 113 | 9/14/2024 |
| 3.6.4-dev.9 | 108 | 9/14/2024 |
| 3.6.4-dev.7 | 115 | 9/13/2024 |
| 3.6.4-dev.5 | 119 | 9/9/2024 |
| 3.6.3 | 747 | 9/2/2024 |
| 3.6.2 | 229 | 9/1/2024 |
| 3.6.1 | 245 | 9/1/2024 |
| 3.5.2-dev.24 | 136 | 8/31/2024 |
| 3.5.2-dev.22 | 112 | 8/31/2024 |
| 3.5.2-dev.21 | 127 | 8/31/2024 |
| 3.5.2-dev.14 | 112 | 8/29/2024 |
| 3.5.2-dev.10 | 140 | 8/24/2024 |
| 3.5.2-dev.9 | 142 | 8/21/2024 |
| 3.5.2-dev.7 | 142 | 8/19/2024 |
| 3.5.2-dev.6 | 112 | 8/19/2024 |
| 3.5.2-dev.5 | 134 | 8/19/2024 |
| 3.5.2-dev.2 | 146 | 8/18/2024 |
| 3.5.1 | 955 | 8/18/2024 |
| 3.5.1-dev.4 | 136 | 8/18/2024 |
| 3.5.1-dev.3 | 143 | 8/18/2024 |
| 3.5.0 | 241 | 8/17/2024 |
| 3.4.2-dev.5 | 136 | 8/17/2024 |
| 3.4.2-dev.1 | 132 | 8/17/2024 |
| 3.4.1 | 335 | 8/16/2024 |
| 3.4.0 | 252 | 8/16/2024 |
| 3.3.1-dev.17 | 140 | 8/15/2024 |
| 3.3.1-dev.16 | 120 | 8/15/2024 |
| 3.3.1-dev.14 | 124 | 8/15/2024 |
| 3.3.1-dev.12 | 153 | 8/13/2024 |
| 3.3.1-dev.11 | 143 | 8/13/2024 |
| 3.3.1-dev.8 | 121 | 8/12/2024 |
| 3.3.1-dev.7 | 130 | 8/12/2024 |
| 3.3.1-dev.1 | 96 | 8/6/2024 |
| 3.3.0 | 430 | 8/6/2024 |
| 3.2.2-dev.3 | 91 | 8/6/2024 |
| 3.2.1 | 1,175 | 8/6/2024 |
| 3.2.1-dev.2 | 102 | 8/6/2024 |
| 3.2.1-dev.1 | 90 | 8/5/2024 |
| 3.2.0 | 203 | 8/5/2024 |
| 3.1.1-dev.1 | 103 | 8/4/2024 |
| 3.1.0 | 266 | 8/1/2024 |
| 3.0.4-dev.11 | 107 | 8/1/2024 |
| 3.0.4-dev.9 | 714 | 7/24/2024 |
| 3.0.4-dev.8 | 164 | 7/23/2024 |
| 3.0.4-dev.6 | 224 | 7/20/2024 |
| 3.0.4-dev.5 | 95 | 7/20/2024 |
| 3.0.4-dev.4 | 107 | 7/20/2024 |
| 3.0.4-dev.3 | 97 | 7/20/2024 |
| 3.0.4-dev.2 | 119 | 7/19/2024 |
| 3.0.4-dev.1 | 118 | 7/18/2024 |
| 3.0.3 | 260 | 7/18/2024 |
| 3.0.3-dev.1 | 103 | 7/18/2024 |
| 3.0.1 | 207 | 7/13/2024 |
| 3.0.0 | 223 | 7/11/2024 |
| 3.0.0-alpha.3 | 107 | 7/7/2024 |
| 3.0.0-alpha.2 | 106 | 7/6/2024 |
| 2.0.9 | 44,343 | 5/14/2024 |
| 2.0.8 | 241 | 4/29/2024 |
| 2.0.7 | 220 | 4/29/2024 |
| 2.0.6 | 10,618 | 4/22/2024 |
| 2.0.5 | 729 | 4/10/2024 |
| 2.0.4 | 602 | 4/4/2024 |
| 2.0.3 | 223 | 4/3/2024 |
| 2.0.2 | 298 | 4/3/2024 |
| 2.0.1 | 232 | 4/2/2024 |
| 2.0.0 | 399 | 3/22/2024 |
| 2.0.0-alpha.10 | 3,868 | 2/23/2024 |
| 2.0.0-alpha.9 | 43,932 | 1/27/2024 |
| 2.0.0-alpha.8 | 110 | 1/27/2024 |
| 2.0.0-alpha.7 | 146 | 1/20/2024 |
| 2.0.0-alpha.5 | 559 | 12/5/2023 |
| 2.0.0-alpha.4 | 247 | 11/16/2023 |
| 2.0.0-alpha.3 | 155 | 11/16/2023 |
| 2.0.0-alpha.2 | 119 | 11/16/2023 |
| 2.0.0-alpha.1 | 118 | 11/15/2023 |
| 2.0.0-alpha.0 | 118 | 11/15/2023 |
| 1.8.2 | 162,485 | 10/13/2023 |
| 1.8.1 | 616 | 10/11/2023 |
| 1.8.0 | 363 | 9/29/2023 |
| 1.7.2 | 1,995 | 8/15/2023 |
| 1.7.1 | 266 | 8/15/2023 |
| 1.7.0 | 428 | 8/15/2023 |
| 1.6.3 | 2,496 | 7/29/2023 |
| 1.6.1 | 257 | 7/29/2023 |
| 1.6.0 | 447 | 7/29/2023 |
| 1.5.0 | 789 | 7/13/2023 |
| 1.4.1 | 273 | 7/12/2023 |
| 1.4.0 | 280 | 7/12/2023 |
| 1.3.0 | 267 | 7/12/2023 |
| 1.2.0 | 761 | 7/5/2023 |
| 1.1.2 | 504 | 6/30/2023 |
| 1.1.1 | 248 | 6/30/2023 |
| 1.1.0 | 272 | 6/29/2023 |
| 1.0.0 | 281 | 6/28/2023 |
| 0.9.0 | 330 | 6/24/2023 |
| 0.0.0-dev.150 | 119 | 7/18/2024 |
| 0.0.0-dev | 177 | 9/14/2024 |