TruthVouch.SemanticKernel
1.0.1
dotnet add package TruthVouch.SemanticKernel --version 1.0.1
NuGet\Install-Package TruthVouch.SemanticKernel -Version 1.0.1
<PackageReference Include="TruthVouch.SemanticKernel" Version="1.0.1" />
<PackageVersion Include="TruthVouch.SemanticKernel" Version="1.0.1" />
<PackageReference Include="TruthVouch.SemanticKernel" />
paket add TruthVouch.SemanticKernel --version 1.0.1
#r "nuget: TruthVouch.SemanticKernel, 1.0.1"
#:package TruthVouch.SemanticKernel@1.0.1
#addin nuget:?package=TruthVouch.SemanticKernel&version=1.0.1
#tool nuget:?package=TruthVouch.SemanticKernel&version=1.0.1
TruthVouch.SemanticKernel
Semantic Kernel integration for TruthVouch — verify LLM outputs for factual accuracy and attach trust scores to kernel function results.
Installation
dotnet add package TruthVouch.SemanticKernel
Quick Start
Register TruthVouch directly on your IKernelBuilder. This wires in both the function invocation filter and the prompt render filter automatically:
using TruthVouch.SemanticKernel;
var kernel = Kernel.CreateBuilder()
.AddOpenAIChatCompletion("gpt-4o", openAiApiKey)
.AddTruthVouch(o =>
{
o.ApiKey = "your-truthvouch-api-key";
o.TrustThreshold = 0.75;
o.ThrowOnLowTrust = true;
})
.Build();
If you use a plain IServiceCollection (e.g., ASP.NET Core), call the IServiceCollection overload instead:
builder.Services.AddTruthVouch(o =>
{
o.ApiKey = "your-truthvouch-api-key";
o.TrustThreshold = 0.8;
});
Components
TruthVouchPlugin
A Semantic Kernel plugin that exposes fact-verification as a first-class kernel function (verify_content). The function accepts a text string and an optional verification mode, calls the TruthVouch Trust API, and returns a structured VerifyResponse containing the trust score and per-claim verdicts.
Add the plugin to your kernel to let the AI planner invoke it on demand:
kernel.Plugins.AddFromObject(kernel.Services.GetRequiredService<TruthVouchPlugin>(), "TruthVouch");
TruthVouchFilter
Implements IFunctionInvocationFilter. After every kernel function call that returns a string, this filter automatically sends the output to the Trust API and:
- Attaches
truthvouch_trust_scoreandtruthvouch_verification_idto theFunctionResultmetadata on every call. - When the score falls below
TrustThresholdandThrowOnLowTrustisfalse, logs a warning and adds atruthvouch_warningkey to the result metadata. - When
ThrowOnLowTrustistrue, throws aTrustVerificationException.
Functions decorated with [SkipTruthVerification] are bypassed entirely.
TruthVouchPromptFilter
Implements IPromptRenderFilter. When VerifyInputPrompts is true, this filter verifies the fully rendered prompt text before it is sent to the LLM. The trust score and verification ID are attached to the prompt context arguments (truthvouch_prompt_trust_score, truthvouch_prompt_verification_id) so downstream filters can inspect them without a second API call.
Both filters are registered automatically when you call AddTruthVouch on an IKernelBuilder.
Configuration
All options are set via the TruthVouchOptions delegate passed to AddTruthVouch.
| Property | Type | Default | Description |
|---|---|---|---|
ApiKey |
string |
"" |
Bearer token sent with every Trust API request. |
BaseUrl |
string |
http://localhost:5004/api/v1/trust |
Base URL of the TruthVouch Trust API. |
TrustThreshold |
double |
0.8 |
Minimum acceptable trust score (0.0–1.0). Scores below this trigger a warning or exception. |
DefaultMode |
string |
spot_check |
Default verification mode when none is specified. Valid values: spot_check, standard, full. |
ThrowOnLowTrust |
bool |
false |
When true, TruthVouchFilter throws a TrustVerificationException instead of logging a warning on low-trust results. |
VerifyInputPrompts |
bool |
false |
When true, TruthVouchPromptFilter verifies rendered prompts before they are sent to the LLM. |
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- Microsoft.SemanticKernel (>= 1.34.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.0.1: Added package README, LICENSE, tags and metadata. No code changes from v1.0.0.