queryAsync method

Future<RAGResult> queryAsync(
  1. RAGQueryOptions options
)

Query the pipeline, running the blocking embed→retrieve→LLM-generate work in a short-lived worker isolate (Isolate.run) so the calling isolate — usually the Flutter UI isolate — stays responsive for the whole answer. rac_rag_query_proto runs the LLM generation inline (max_tokens/ temperature/system_prompt), so this is the heavy chat call. Same cross-isolate engine use as dart_bridge_llm.dart (see ingestDocumentAsync); the synchronous query is retained for callers that need it.

Implementation

Future<RAGResult> queryAsync(RAGQueryOptions options) async {
  final session = _requireSession();
  if (RacNative.bindings.rac_rag_query_proto == null) {
    throw UnsupportedError('rac_rag_query_proto is unavailable');
  }
  final sessionAddr = session.address;
  final requestBytes = options.writeToBuffer();
  final resultBytes =
      await Isolate.run(() => _ragQueryWorker(sessionAddr, requestBytes));
  return RAGResult.fromBuffer(resultBytes);
}