SemanticValidation 0.12.0-beta

This is a prerelease version of SemanticValidation.
dotnet add package SemanticValidation --version 0.12.0-beta
NuGet\Install-Package SemanticValidation -Version 0.12.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.12.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SemanticValidation --version 0.12.0-beta
#r "nuget: SemanticValidation, 0.12.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.12.0-beta&prerelease

// Install SemanticValidation as a Cake Tool
#tool nuget:?package=SemanticValidation&version=0.12.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 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. 
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

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.12.0-beta 354 12/28/2023
0.11.0-beta 111 12/27/2023
0.10.0-beta 71 12/26/2023
0.9.0-beta 71 12/26/2023
0.8.0-beta 118 12/25/2023
0.7.0-beta 74 12/25/2023
0.6.0-beta 106 12/24/2023
0.5.0-beta 59 12/23/2023
0.4.0-beta 58 12/22/2023
0.3.0-beta 54 12/22/2023
0.2.0-beta 61 12/22/2023