CSharpToJsonSchema 3.9.2-dev.3
See the version list below for details.
dotnet add package CSharpToJsonSchema --version 3.9.2-dev.3
NuGet\Install-Package CSharpToJsonSchema -Version 3.9.2-dev.3
<PackageReference Include="CSharpToJsonSchema" Version="3.9.2-dev.3" />
paket add CSharpToJsonSchema --version 3.9.2-dev.3
#r "nuget: CSharpToJsonSchema, 3.9.2-dev.3"
// Install CSharpToJsonSchema as a Cake Addin #addin nuget:?package=CSharpToJsonSchema&version=3.9.2-dev.3&prerelease // Install CSharpToJsonSchema as a Cake Tool #tool nuget:?package=CSharpToJsonSchema&version=3.9.2-dev.3&prerelease
CSharpToJsonSchema
Features 🔥
- Source generator to define functions natively through C# interfaces
- Doesn't use Reflection
- All modern .NET features - nullability, trimming, NativeAOT, etc.
- Tested for compatibility with OpenAI/Ollama/Anthropic/LangChain/Gemini
Usage
using CSharpToJsonSchema;
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;
}
[GenerateJsonSchema(Strict = true)] // false by default. You can't use parameters with default values in Strict mode.
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,
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 tools = service.AsTools();
Support
Priority place for bugs: https://github.com/tryAGI/CSharpToJsonSchema/issues
Priority place for ideas and general questions: https://github.com/tryAGI/CSharpToJsonSchema/discussions
Discord: https://discord.gg/Ca2xhfBf3v
Acknowledgments
This project is supported by JetBrains through the Open Source Support Program.
This project is supported by CodeRabbit through the Open Source Support Program.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 is compatible. 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. |
.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 (>= 9.0.0-rc.1.24431.7)
-
.NETStandard 2.0
- System.Text.Json (>= 9.0.0-rc.1.24431.7)
-
net8.0
- System.Text.Json (>= 9.0.0-rc.1.24431.7)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on CSharpToJsonSchema:
Package | Downloads |
---|---|
tryAGI.OpenAI
Generated C# SDK based on official OpenAI OpenAPI specification. 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 |
|
LangChain.Providers.Abstractions
LangChain Providers abstractions. |
|
Anthropic
Generated C# SDK based on official Anthropic OpenAPI specification. |
|
Ollama
Generated C# SDK based on Ollama OpenAPI specification. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.10.1 | 246 | 11/13/2024 |
3.9.2-dev.3 | 56 | 11/2/2024 |
3.9.2-dev.2 | 33 | 11/2/2024 |
3.9.1 | 8,191 | 10/18/2024 |
3.9.0 | 784 | 10/18/2024 |
3.8.2-dev.13 | 71 | 10/14/2024 |
3.8.2-dev.10 | 45 | 10/13/2024 |
3.8.2-dev.9 | 51 | 10/13/2024 |
0.0.0-dev.1 | 89 | 10/18/2024 |