VoyageAI.AgentFramework
1.0.1
dotnet add package VoyageAI.AgentFramework --version 1.0.1
NuGet\Install-Package VoyageAI.AgentFramework -Version 1.0.1
<PackageReference Include="VoyageAI.AgentFramework" Version="1.0.1" />
<PackageVersion Include="VoyageAI.AgentFramework" Version="1.0.1" />
<PackageReference Include="VoyageAI.AgentFramework" />
paket add VoyageAI.AgentFramework --version 1.0.1
#r "nuget: VoyageAI.AgentFramework, 1.0.1"
#:package VoyageAI.AgentFramework@1.0.1
#addin nuget:?package=VoyageAI.AgentFramework&version=1.0.1
#tool nuget:?package=VoyageAI.AgentFramework&version=1.0.1
VoyageAI.AgentFramework
Microsoft Agent Framework integration for the Voyage AI .NET SDK.
Composes a search stage (IVoyageRagSearcher<T>) with the Voyage reranker
(IVoyageReranker) and hands the result to the Agent Framework's TextSearchProvider, so
you get two-stage retrieval (vector search → rerank) on any agent with a few lines of wiring.
Why
The Agent Framework's TextSearchProvider is sealed and takes a single
Func<string, CancellationToken, Task<IEnumerable<TextSearchResult>>> delegate in its
constructor. Building that delegate by hand — embed the query, run a vector search, score
candidates with the reranker, map indices back to records, project to TextSearchResult —
is ~80 lines of orchestration that gets copy-pasted into every RAG sample.
This package factors that into a search/rerank split: you implement only the transport-specific search (MongoDB, pgvector, Redis, Qdrant, …), and the package handles the rerank composition and the three framework wiring paths.
Install
dotnet add package VoyageAI.AgentFramework
References VoyageAI.Sdk, Microsoft.Agents.AI, and Microsoft.Agents.AI.Abstractions
(1.10.0).
Quick start
using VoyageAI;
// 1. Implement the search stage (transport-specific — this one knows about MongoDB).
// Lives in your app, not in this package.
public sealed class MongoSearcher : IVoyageRagSearcher<KBDocument> { ... }
var searcher = new MongoSearcher(mongoCollection, queryEmbedder, limit: 10);
// 2. Build a reranker from the Voyage SDK client.
var reranker = new VoyageReranker(rerankClient, new VoyageRerankerOptions { TopK = 3 });
// 3. Wire RAG into your agent — pick one of the three paths:
ChatClientAgentOptions (mutator)
AIAgent agent = chatClient.AsAIAgent(new ChatClientAgentOptions
{
ChatOptions = new() { Instructions = "Answer using the provided context; cite sources." }
}.UseVoyageRag(searcher, reranker, o => o.RerankerOptions.TopK = 3));
AIAgentBuilder (pipeline)
AIAgent agent = chatClient.AsAIAgent()
.UseVoyageRag(searcher, reranker, o => o.RerankerOptions.TopK = 3);
ChatClientBuilder (MEAI pipeline)
ChatClientBuilder builder = new(openAiClient)
.UseVoyageRag(searcher, reranker);
Dependency injection
// Registers IVoyageReranker as a singleton. AddVoyageAI must already be registered so
// IRerankClient can be resolved.
builder.Services.AddVoyageAI(o => o.ApiKey = apiKey);
builder.Services.AddVoyageReranker(o => o.Model = VoyageAIModels.Rerank2);
Skipping reranking
Pass reranker: null to use the searcher's ordering as-is (single-stage retrieval):
chatClient.AsAIAgent().UseVoyageRag(searcher, reranker: null);
Result mapping
By default the provider builds TextSearchResult entries with Text always set, plus
SourceName/SourceLink populated if your record type implements
IVoyageSearchResultMetadata, and RawRepresentation set to the record.
For record types that don't fit that shape, supply a custom mapper. The mapper receives a strongly-typed candidate — no cast, no per-candidate wrapper allocation:
.UseVoyageRag(searcher, reranker, o => o.ResultMapper = c => new()
{
Text = c.Text,
SourceName = c.Record.Title
});
Or skip a searcher class entirely with the ad-hoc delegate factory:
var provider = VoyageRagContextProvider.Create<KBDocument>(
(query, ct) => SearchAsync(query, ct),
reranker);
Design notes
- Does not subclass
TextSearchProvider— it's sealed; we compose with it. - No transport dependency — the package references only the Voyage SDK and Agent Framework abstractions. MongoDB/pgvector/Redis live in your app.
- Reranking is optional —
reranker: nullpreserves the searcher's order. RerankerOptionsis non-nullable — defaults tonew()so consumers never need!.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. 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 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
- Microsoft.Agents.AI (>= 1.10.0)
- Microsoft.Agents.AI.Abstractions (>= 1.10.0)
- Microsoft.Extensions.AI (>= 10.7.0)
- Microsoft.Extensions.AI.Abstractions (>= 10.7.0)
- Microsoft.Extensions.Configuration (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.9)
- VoyageAI.Sdk (>= 1.0.1)
-
net8.0
- Microsoft.Agents.AI (>= 1.10.0)
- Microsoft.Agents.AI.Abstractions (>= 1.10.0)
- Microsoft.Extensions.AI (>= 10.7.0)
- Microsoft.Extensions.AI.Abstractions (>= 10.7.0)
- Microsoft.Extensions.Configuration (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.9)
- System.Text.Json (>= 10.0.9)
- VoyageAI.Sdk (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.