CanDoItAll.AgentFramework.SemanticCompletion.Onnx
0.1.18
dotnet add package CanDoItAll.AgentFramework.SemanticCompletion.Onnx --version 0.1.18
NuGet\Install-Package CanDoItAll.AgentFramework.SemanticCompletion.Onnx -Version 0.1.18
<PackageReference Include="CanDoItAll.AgentFramework.SemanticCompletion.Onnx" Version="0.1.18" />
<PackageVersion Include="CanDoItAll.AgentFramework.SemanticCompletion.Onnx" Version="0.1.18" />
<PackageReference Include="CanDoItAll.AgentFramework.SemanticCompletion.Onnx" />
paket add CanDoItAll.AgentFramework.SemanticCompletion.Onnx --version 0.1.18
#r "nuget: CanDoItAll.AgentFramework.SemanticCompletion.Onnx, 0.1.18"
#:package CanDoItAll.AgentFramework.SemanticCompletion.Onnx@0.1.18
#addin nuget:?package=CanDoItAll.AgentFramework.SemanticCompletion.Onnx&version=0.1.18
#tool nuget:?package=CanDoItAll.AgentFramework.SemanticCompletion.Onnx&version=0.1.18
CanDoItAll Agent Framework Semantic Completion — ONNX
Optional local ONNX Runtime embeddings for
CanDoItAll.AgentFramework.SemanticCompletion.Driver, targeting .NET 10.
This package contains the ONNX adapter, BERT WordPiece tokenizer, and explicit
Hugging Face model acquisition helper. It depends on the Driver contracts; the
Driver does not depend on this package.
No model binaries are bundled.
Install
dotnet add package CanDoItAll.AgentFramework.SemanticCompletion.Onnx
Create and own a provider directly
using CanDoItAll.AgentFramework.SemanticCompletion.Onnx;
using var embeddings = new OnnxAgentTextEmbeddingGenerator(
new OnnxAgentTextEmbeddingOptions
{
ModelDirectory = ".models/Xenova/all-MiniLM-L6-v2",
ModelFileName = "onnx/model.onnx",
VocabularyFileName = "vocab.txt",
MaxTokenCount = 128,
NormalizeOutput = true,
});
OnnxAgentTextEmbeddingGenerator owns an ONNX InferenceSession and implements
IDisposable. Reuse one instance rather than creating a session per request.
Dispose directly constructed instances. When the DI container constructs the
singleton, dispose the service provider/host so the session is released.
Use with the Driver DI extension
Register ONNX before the Driver. The Driver uses TryAdd, so the custom
provider remains selected:
using CanDoItAll.AgentFramework.SemanticCompletion.Driver.DependencyInjection;
using CanDoItAll.AgentFramework.SemanticCompletion.Driver.Embeddings;
using CanDoItAll.AgentFramework.SemanticCompletion.Onnx;
using Microsoft.Extensions.DependencyInjection;
services.Configure<OnnxAgentTextEmbeddingOptions>(options =>
{
options.ModelDirectory = ".models/Xenova/all-MiniLM-L6-v2";
options.MaxTokenCount = 128;
});
services.AddSingleton<IAgentTextEmbeddingGenerator, OnnxAgentTextEmbeddingGenerator>();
services.AddAgentSemanticCompletionDriver();
The singleton can receive concurrent GenerateAsync calls after the Driver's
one-time intent initialization. Validate concurrency and native-runtime
settings for the host's workload. The Driver checks that every candidate and
query uses the same profile ID and dimension, and always computes bounded full
cosine similarity. NormalizeOutput defaults to true, but correctness does
not rely on that declaration.
Acquire model assets explicitly
The defaults expect the Hugging Face repository
Xenova/all-MiniLM-L6-v2, files onnx/model.onnx and vocab.txt, under
.models/Xenova/all-MiniLM-L6-v2.
using var httpClient = new HttpClient();
var downloader = new HuggingFaceModelDownloader(httpClient);
var token = Environment.GetEnvironmentVariable("HF_TOKEN")
?? Environment.GetEnvironmentVariable("HUGGINGFACE_TOKEN")
?? Environment.GetEnvironmentVariable("HUGGING_FACE_HUB_TOKEN");
await downloader.DownloadAsync(
new HuggingFaceModelDownloadOptions
{
RepositoryId = "Xenova/all-MiniLM-L6-v2",
Revision = "main",
OutputDirectory = ".models/Xenova/all-MiniLM-L6-v2",
},
token);
Keep access tokens in the host environment or secret store; do not put them in source, options files, logs, or package content. The downloader sends a bearer token only when one is supplied, creates missing directories, and reuses existing non-empty files. Pin a reviewed model revision for reproducible production deployments.
Licensing and trust
This NuGet package does not redistribute Hugging Face model weights. Model selection, download authorization, integrity/provenance checks, storage, and compliance with the selected model's license are the consuming application's responsibility. Microsoft ONNX Runtime and other transitive dependencies retain their own licenses. Review the package dependency list and the model repository before distribution.
Neural similarity remains fallback evidence; it is not authoritative workflow completion, authorization, or proof.
Project links
| 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
- CanDoItAll.AgentFramework.SemanticCompletion.Driver (>= 0.1.18)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.ML.OnnxRuntime (>= 1.25.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.