SemanticValidation 0.10.0-beta

This is a prerelease version of SemanticValidation.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package SemanticValidation --version 0.10.0-beta                
NuGet\Install-Package SemanticValidation -Version 0.10.0-beta                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SemanticValidation" Version="0.10.0-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SemanticValidation --version 0.10.0-beta                
#r "nuget: SemanticValidation, 0.10.0-beta"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SemanticValidation as a Cake Addin
#addin nuget:?package=SemanticValidation&version=0.10.0-beta&prerelease

// Install SemanticValidation as a Cake Tool
#tool nuget:?package=SemanticValidation&version=0.10.0-beta&prerelease                

Semantic Validation

Build and Deploy NuGet version (SemanticValidation) NuGet downloads

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 42 11/25/2024
0.14.0-beta 466 9/14/2024
0.12.0-beta 1,964 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