search method
Retrieve the chunks closest to query without generating an answer.
Uses the commons retrieval-only ABI (rac_rag_search_proto); no LLM
generation is started.
Throws SDKException when the session is closed, the native search symbol is unavailable, or retrieval fails.
Implementation
Future<List<Match>> search(String query, {int? topK}) async {
_requireLive();
if (!DartBridgeRAG.shared.isSearchAvailable) {
throw SDKException.featureNotAvailable(
'rag.search (rac_rag_search_proto)',
);
}
final response = await DartBridgeRAG.shared.searchAsync(
_searchRequest(query, topK: topK),
);
if (response.hasError()) {
throw SDKException.processingFailed(response.error.message);
}
return List<Match>.unmodifiable(
response.chunks.map(Match.fromProto),
);
}