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 (4)
Showing the top 4 NuGet packages that depend on tryAGI.OpenAI:
| Package | Downloads |
|---|---|
|
LangChain.Providers.OpenAI
OpenAI API LLM and Chat model provider. |
|
|
LangChain
LangChain meta-package with the most used things. |
|
|
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.216 | 0 | 3/30/2026 |
| 4.2.1-dev.215 | 0 | 3/29/2026 |
| 4.2.1-dev.214 | 0 | 3/29/2026 |
| 4.2.1-dev.211 | 23 | 3/29/2026 |
| 4.2.1-dev.203 | 35 | 3/28/2026 |
| 4.2.1-dev.202 | 33 | 3/28/2026 |
| 4.2.1-dev.201 | 31 | 3/28/2026 |
| 4.2.1-dev.199 | 32 | 3/27/2026 |
| 4.2.1-dev.185 | 56 | 3/21/2026 |
| 4.2.1-dev.181 | 35 | 3/20/2026 |
| 4.2.1-dev.180 | 38 | 3/20/2026 |
| 4.2.1-dev.179 | 40 | 3/20/2026 |
| 4.2.1-dev.176 | 38 | 3/20/2026 |
| 4.2.1-dev.175 | 34 | 3/20/2026 |
| 4.2.1-dev.174 | 40 | 3/19/2026 |
| 4.2.1-dev.172 | 37 | 3/19/2026 |
| 4.2.1-dev.170 | 42 | 3/19/2026 |
| 4.2.1-dev.169 | 33 | 3/19/2026 |
| 4.2.0 | 53,975 | 2/11/2025 |
| 1.1.1 | 58,392 | 6/30/2023 |