SemanticValidation 0.15.0-beta
dotnet add package SemanticValidation --version 0.15.0-beta
NuGet\Install-Package SemanticValidation -Version 0.15.0-beta
<PackageReference Include="SemanticValidation" Version="0.15.0-beta" />
paket add SemanticValidation --version 0.15.0-beta
#r "nuget: SemanticValidation, 0.15.0-beta"
// Install SemanticValidation as a Cake Addin #addin nuget:?package=SemanticValidation&version=0.15.0-beta&prerelease // Install SemanticValidation as a Cake Tool #tool nuget:?package=SemanticValidation&version=0.15.0-beta&prerelease
Semantic Validation
SemanticValidation is a library that integrates OpenAI’s powerful language models with validation systems. It allows you to perform semantic checks on your data and queries using natural language understanding.
It brings the power of OpenAI into the validation systems as easily as this:
var result = Semantic.AreSimilar("This automobile is red", "The car is red");
Console.WriteLine(result.IsValid);
// true
The interesting part is that: When it fails, it explains why! (thanks to OpenAI)
var result = Semantic.AreSimilar("This bicycle is red", "The car is red");
Console.WriteLine(result.IsValid);
// false
Console.WriteLine(result.Reason);
// The first text describes a red bicycle, while the second text describes a red car. They are not semantically equivalent.
Under the hood, it uses OpenAI and SemanticKernel to do all the semantic stuff.
There are other semantic methods available too. The HasConditoin
checks if a text
meets a special condition
. And again watch how
great it describes the reason for semantic validation failure.
var result = Semantic.HasCondition(
text: "This car is red",
condition: "It talks about trees"
Console.WriteLine(result.IsValid);
// false
Console.WriteLine(result.Reason);
// The input text does not talk about trees
Features
- Brings the power of OpenAI into the validation systems: You can use OpenAI's language models to perform semantic validation on your data and queries with a simple and intuitive syntax.
- Provides explanatory feedback: When a semantic check fails, it explains why, thanks to OpenAI's natural language generation capabilities.
- Uses OpenAI and SemanticKernel under the hood: Semantic Validation relies on OpenAI and SemanticKernel to do all the semantic stuff. SemanticKernel is a library that provides a unified interface to interact with OpenAI's language models.
Requirements
- .NET 8.0 or higher
- An OpenAI API key
Installation
Semantic Validation is available as a NuGet package that you can easily install in your project. To do so, run the following command in your terminal:
dotnet add package SemanticValidation
Next, you need to create an instance of the Semantic
class and pass your OpenAI subscription details as parameters:
var semantic = new Semantic(deployment, endpoint, apiKey);
That's it! You are ready to use Semantic Validation in your code. 😊
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Microsoft.Extensions.AI.OpenAI (>= 9.0.1-preview.1.24570.5)
- System.Text.Json (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SemanticValidation:
Package | Downloads |
---|---|
skUnit
A semantic unit testing engine for OpenAI and SemanticKernel plugins. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on SemanticValidation:
Repository | Stars |
---|---|
mehrandvd/skunit
skUnit is a testing tool for SemanticKernel units, such as plugin functions and kernels.
|
Version | Downloads | Last updated |
---|---|---|
0.15.0-beta | 22 | 11/25/2024 |
0.14.0-beta | 439 | 9/14/2024 |
0.12.0-beta | 1,953 | 12/28/2023 |
0.11.0-beta | 123 | 12/27/2023 |
0.10.0-beta | 84 | 12/26/2023 |
0.9.0-beta | 84 | 12/26/2023 |
0.8.0-beta | 132 | 12/25/2023 |
0.7.0-beta | 88 | 12/25/2023 |
0.6.0-beta | 123 | 12/24/2023 |
0.5.0-beta | 72 | 12/23/2023 |
0.4.0-beta | 71 | 12/22/2023 |
0.3.0-beta | 67 | 12/22/2023 |
0.2.0-beta | 73 | 12/22/2023 |