searchHybridWithContext method
Hybrid search with context assembly for LLM.
adjacentChunks - Include N chunks before/after matches (default: 0).
singleSourceMode - Only include chunks from most relevant source.
Implementation
Future<RagSearchResult> searchHybridWithContext(
String query, {
int topK = 10,
int tokenBudget = 2000,
ContextStrategy strategy = ContextStrategy.relevanceFirst,
double vectorWeight = 0.2,
double bm25Weight = 0.8,
List<int>? sourceIds,
int adjacentChunks = 0,
bool singleSourceMode = false,
String? collectionId,
}) async {
final service = await _serviceForCollection(collectionId);
await _flushIndex(
collectionId: collectionId,
); // Ensure index is up-to-date before searching
return service.searchHybridWithContext(
query,
topK: topK,
tokenBudget: tokenBudget,
strategy: strategy,
vectorWeight: vectorWeight,
bm25Weight: bm25Weight,
sourceIds: sourceIds,
adjacentChunks: adjacentChunks,
singleSourceMode: singleSourceMode,
);
}