Themis.Core 4.5.0

dotnet add package Themis.Core --version 4.5.0
                    
NuGet\Install-Package Themis.Core -Version 4.5.0
                    
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="Themis.Core" Version="4.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Themis.Core" Version="4.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Themis.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Themis.Core --version 4.5.0
                    
#r "nuget: Themis.Core, 4.5.0"
                    
#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.
#:package Themis.Core@4.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Themis.Core&version=4.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Themis.Core&version=4.5.0
                    
Install as a Cake Tool

Themis.Core

Themis.Core provides provider and runtime-initialization contracts, model routing, and the keyed model-packing registry used by Themis.

The package targets .NET 10 and depends on Themis.Common. Add Themis.Inference for the built-in ONNX provider and packer.

Hand-written typed decision schemas

For fixed question sets, implement IDecisionSchema<TSelf, TInput> with a central question, question definitions, and a response mapper. The generic input is serialized by Themis at the router boundary; application code does not need to construct a JsonElement. Dynamic callers can continue using DecisionRequest directly.

public sealed record TicketState(string Message);

public sealed record TicketTriage(string Department)
    : IDecisionSchema<TicketTriage, TicketState>
{
    public static string CentralQuestion => "How should this ticket be routed?";

    public static IReadOnlyDictionary<string, QuestionDefinition> Questions { get; } =
        new Dictionary<string, QuestionDefinition>
        {
            ["department"] = new(QuestionType.Choice, "Choose the owning team.")
        };

    public static TicketTriage MapResponse(DecisionResponse response) =>
        new(response.GetRequiredAnswer<ChoiceAnswer>("department").Choice);
}

var result = await router.PredictSchemaAsync<TicketTriage, TicketState>(
    new(new TicketState("The invoice appears duplicated."), Model: "triage-model"));

DecisionSchemaContext<TInput> also accepts provider key, task, language, and object-valued extras. Missing answers and answer-kind mismatches reported by GetRequiredAnswer<TAnswer> use ThemisMappingException; custom mapping exceptions propagate unchanged.

PredictSchemaAsync uses web JSON defaults for state and extras. Set its jsonSerializerDefaults parameter to JsonSerializerDefaults.General or .Web, or pass an IJsonWrapper through jsonWrapper for host-specific settings; an explicit wrapper takes precedence. QuestionDefinition.FromCriteria and DecisionEvaluationCase.Create<TState> accept the same defaults and wrapper options, so criteria, evaluation state, and inference state can use consistent serialization rules.

The router keeps route selection behind an internal resolver and exposes Route/RouteRouted for inspecting the selected model and provider. Callers can explicitly select a model or keyed provider with the existing request contracts. There is not yet a public custom-route-selector API; the internal resolver can evolve without freezing an unsupported routing extension contract.

Optional confidence escalation

Register the primary and escalation providers under keys, then register a composed key with AddThemisConfidenceEscalationProvider. Select that key through DecisionSchemaContext<TInput>.ProviderKey or RouteRequest. The internal provider forwards the same request to the primary provider and invokes the escalation provider only when a configured answer succeeds but falls below its measured per-question threshold. There are no default thresholds. Concurrency, timeout, and optional per-minute escalation limits are configured through ConfidenceEscalationOptions. Provider failures, invalid/missing answers, and cancellation are not treated as uncertainty; human review remains an application outcome.

Local-provider lifecycle

Register a lifecycle-controlled default provider with AddThemisDecisionProviderLifecycle, or a keyed one with AddThemisKeyedDecisionProviderLifecycle. The host supplies a factory that creates a provider instance owned exclusively by the lifecycle; do not return another container-owned singleton. Use the default lifecycle registration in place of other default IDecisionInferenceProvider registrations. Resolve the public IDecisionProviderLifecycle to control it. FirstUse is the default mode; Startup requires the host to call StartAsync before serving traffic; Explicit requires InitializeAsync. WarmupAsync can initialize and run a host-owned warmup request. RetireAsync rejects new calls, drains active inference, disposes owned resources, and releases the underlying provider reference. A retired first-use provider may initialize again on its next call; startup/explicit modes require another explicit initialization.

services.AddThemisDecisionProviderLifecycle(
    (serviceProvider, cancellationToken) => CreateLocalProviderAsync(serviceProvider, cancellationToken),
    DecisionProviderActivationMode.Startup);
services.AddThemisDecisionRouter();

var lifecycle = app.Services.GetRequiredService<IDecisionProviderLifecycle>();
await lifecycle.StartAsync(hostStoppingToken);
// Stop accepting new work before retiring during host shutdown.
await lifecycle.RetireAsync(hostStoppingToken);

Disposal does not guarantee that the runtime immediately returns native model memory to the operating system. The router may continue to hold its lifecycle wrapper; retirement releases the owned provider/session reference behind that explicit boundary.

Provider telemetry

Provider calls through ThemisDecisionAgent are instrumented automatically. The Themis.DecisionInference activity source traces routing, provider calls, batches, and lifecycle operations. The meter records provider-call outcomes. Telemetry does not include request state, question keys, answer content, model IDs, provider registration keys, or credentials. Hosts configure exporters.

License

Themis.Core is licensed under MIT. The package includes the Themis license text; its dependency has its own package metadata and terms.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (20)

Showing the top 5 NuGet packages that depend on Themis.Core:

Package Downloads
Themis.Inference.Ollama

Ollama System One decision inference without ONNX runtime dependencies.

Themis.Inference

Prepared ONNX inference, bundle validation, and model packing for Themis.

Themis

Typed model decisions for .NET apps, with dependency-injection registration and a default ONNX runtime.

Themis.Maf

Expose typed Themis decision inference through Microsoft.Extensions.AI.

Themis.Inference.WinML

Optional Windows ML execution-provider integration for Themis ONNX inference.

GitHub repositories

This package is not used by any popular GitHub repositories.