RAGResult.fromBridge constructor

RAGResult.fromBridge(
  1. RAGBridgeResult bridge
)

Create from a bridge result.

Converts the bridge's RAGBridgeResult to public RAGResult, mapping each chunk through RAGSearchResult.fromBridge. Empty contextUsed strings are converted to null.

Implementation

factory RAGResult.fromBridge(RAGBridgeResult bridge) {
  return RAGResult(
    answer: bridge.answer,
    retrievedChunks: bridge.retrievedChunks
        .map(RAGSearchResult.fromBridge)
        .toList(growable: false),
    contextUsed: bridge.contextUsed.isEmpty ? null : bridge.contextUsed,
    retrievalTimeMs: bridge.retrievalTimeMs,
    generationTimeMs: bridge.generationTimeMs,
    totalTimeMs: bridge.totalTimeMs,
  );
}