Themis.Inference.Remote.Grpc
4.7.1
See the version list below for details.
dotnet add package Themis.Inference.Remote.Grpc --version 4.7.1
NuGet\Install-Package Themis.Inference.Remote.Grpc -Version 4.7.1
<PackageReference Include="Themis.Inference.Remote.Grpc" Version="4.7.1" />
<PackageVersion Include="Themis.Inference.Remote.Grpc" Version="4.7.1" />
<PackageReference Include="Themis.Inference.Remote.Grpc" />
paket add Themis.Inference.Remote.Grpc --version 4.7.1
#r "nuget: Themis.Inference.Remote.Grpc, 4.7.1"
#:package Themis.Inference.Remote.Grpc@4.7.1
#addin nuget:?package=Themis.Inference.Remote.Grpc&version=4.7.1
#tool nuget:?package=Themis.Inference.Remote.Grpc&version=4.7.1
Themis.Inference.Remote.Grpc
Themis.Inference.Remote.Grpc provides a default gRPC wire contract for
Themis decision inference. It is built on Themis.Inference.Remote.Rpc:
GrpcDecisionRpcProtocol implements IRemoteDecisionRpcProtocol, while the
RPC package supplies the shared provider lifecycle, cancellation forwarding,
latency measurement, and logging.
The package includes the versioned themis.inference.v1 protobuf contract,
generated client and server stubs, and a server service that delegates to a
ThemisDecisionRouter. It provides non-routed Infer and routed InferRouted
operations. The contract maps decision state, questions, extras, typed answers,
usage, and routing metadata. JSON-valued fields travel as JSON text to preserve
their values exactly.
Client
Register the generated client and Themis remote provider. Options can be
configured directly, with DI-aware callbacks, or by returning options from a
Func<IServiceProvider, GrpcClientFactoryOptions>. The returned
IHttpClientBuilder supports channel settings, interceptors, and handler
pipelines:
using Microsoft.Extensions.DependencyInjection;
using Grpc.Net.ClientFactory;
using Themis.Core;
using Themis.Core.Extensions;
using Themis.Inference.Remote.Grpc;
services.AddThemisRemoteGrpcDecisionInference(options =>
options.Address = new Uri("https://inference.example/"))
.ConfigureChannel(options =>
{
options.MaxReceiveMessageSize = 4 * 1024 * 1024;
});
services.AddThemisDecisionRouter(new DecisionRouterOptions("model-v1")
{
RouteUnspecifiedRequestsToDefaultModel = true
});
Use the keyed overload to register multiple remote gRPC services:
services.AddThemisRemoteGrpcDecisionInference(
"secondary",
options => options.Address = new Uri("https://secondary.example/"));
The Func-based overload can build its options from host services:
services.AddThemisRemoteGrpcDecisionInference(provider =>
new GrpcClientFactoryOptions
{
Address = provider.GetRequiredService<InferenceEndpoint>().Address
});
Use the generated client directly when making an explicitly routed call. An absent provider key selects the unkeyed provider on the server:
var response = await client.InferRoutedAsync(new RoutedDecisionInferenceRequest
{
Request = request,
ProviderKey = "secondary"
});
Authentication, TLS, retry policy, deadlines, and interceptors remain host configuration. The default protocol forwards the caller cancellation token and lets gRPC transport exceptions propagate unchanged.
Server
The server project references Grpc.AspNetCore and
Themis.Inference.Remote.Grpc. The package registers the service and its router
dependencies; the host still adds gRPC transport services and maps the
endpoint:
using Microsoft.Extensions.DependencyInjection;
using Themis.Core;
using Themis.Core.Interfaces;
using Themis;
using Themis.Inference.Remote.Grpc;
builder.Services.AddGrpc();
builder.Services.AddThemis(options =>
options.ModelBundleDirectory = @"C:\models\support-triage");
builder.Services.AddThemisRemoteGrpcDecisionInferenceServer();
var app = builder.Build();
app.MapGrpcService<ThemisDecisionInferenceGrpcService>();
app.Run();
The server registration can instead create an unkeyed or keyed provider, or create a custom router from DI:
builder.Services.AddThemisRemoteGrpcDecisionInferenceServer(
provider => provider.GetRequiredService<MyDecisionInferenceProvider>());
builder.Services.AddThemisRemoteGrpcDecisionInferenceServer(
"secondary",
provider => provider.GetRequiredService<SecondaryDecisionInferenceProvider>());
builder.Services.AddThemisRemoteGrpcDecisionInferenceServer(
provider => new ThemisDecisionRouter(
provider.GetRequiredService<IDecisionInferenceProvider>(),
new DecisionRouterOptions("model-v1")));
Register the referenced provider types in DI before using the provider factory
overloads. The unkeyed provider serves Infer; a keyed provider is selected by
InferRouted using its provider key. The Func-based router overload lets the
host build a custom router from its own services.
Infer invokes ThemisDecisionRouter.PredictAsync; InferRouted invokes
PredictRoutedAsync and can select a keyed provider. Server authentication,
authorization, message-size limits, and transport policy are configured by the
host. The host can replace the service implementation or use the generated
ThemisDecisionInference service base for custom behavior.
The protobuf source is included in the NuGet package under protos/ for
non-.NET clients and server implementations. The package does not reference
Grpc.AspNetCore; server hosts add that dependency themselves.
| Product | Versions 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. |
-
net10.0
- Google.Protobuf (>= 3.36.2)
- Grpc.Core.Api (>= 2.85.0)
- Grpc.Net.ClientFactory (>= 2.85.0)
- Themis.Common (>= 4.7.1)
- Themis.Core (>= 4.7.1)
- Themis.Inference.Remote.Rpc (>= 4.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.