Interface IKnowledgeRetriever
A source of passages an agent or a conversation can ground its answers in.
public interface IKnowledgeRetriever
Examples
public sealed class HelpCenterRetriever : IKnowledgeRetriever
{
public async Task<IReadOnlyList<KnowledgeEvidence>> RetrieveAsync(
KnowledgeQuery query, CancellationToken cancellationToken = default)
{
var hits = await MySearch.FindAsync(query.Text, query.MaxResults, cancellationToken);
return hits.Select(h => new KnowledgeEvidence("help-center", h.Body, h.Score) { Title = h.Title, Uri = h.Url }).ToList();
}
}
Remarks
Implement this interface to connect any search backend: the SDK's own RagEngineKnowledgeRetriever (a RagEngine or a DocumentRag), a vector database, a search service, an enterprise index. The retriever is the authorization boundary: it must return only passages the current caller is allowed to read.
Return the best passages first. An empty list means nothing matched; the conversation then applies WhenNoEvidence.
Methods
- RetrieveAsync(KnowledgeQuery, CancellationToken)
Returns the passages that best match
query, best first.