Class RAGOperationHandle

Fluent handle for a single in-flight RAG operation. Call .complete(resultsCount) to finalize timing and add it to the collector.

Constructors

Methods

  • Parameters

    • method: undefined | {
          strategy: "hybrid" | "similarity" | "mmr";
          hybridAlpha?: number;
          topK?: number;
          mmrLambda?: number;
      }

    Returns this

  • Parameters

    • chunks: {
          id?: string;
          chunkId?: string;
          originalDocumentId?: string;
          documentId?: string;
          content?: string;
          contentSnippet?: string;
          relevanceScore?: number;
          dataSourceId?: string;
          source?: string;
          metadata?: Record<string, unknown>;
      }[]

    Returns this

  • Parameters

    • usage: {
          embeddingTokens: number;
          llmPromptTokens: number;
          llmCompletionTokens: number;
          totalTokens: number;
      }
      • embeddingTokens: number
      • llmPromptTokens: number
      • llmCompletionTokens: number
      • totalTokens: number

    Returns this

  • Parameters

    • details: {
          entitiesMatched: number;
          communitiesSearched: number;
          traversalTimeMs: number;
      }
      • entitiesMatched: number
      • communitiesSearched: number
      • traversalTimeMs: number

    Returns this

  • Parameters

    • details: {
          providerId: string;
          modelId: string;
          documentsReranked: number;
      }
      • providerId: string
      • modelId: string
      • documentsReranked: number

    Returns this

  • Attach HyDE-specific metadata to this audit operation.

    Parameters

    • details: {
          hypothesis: string;
          effectiveThreshold: number;
          thresholdSteps: number;
      }

      Hypothesis text, effective threshold, and step count.

      • hypothesis: string

        The generated hypothetical answer used for embedding.

      • effectiveThreshold: number

        Final similarity threshold after adaptive stepping.

      • thresholdSteps: number

        Number of adaptive threshold steps taken.

    Returns this

    this for fluent chaining.

  • Finalizes the operation, records duration, computes relevance score stats, and adds the entry to the parent collector.

    Parameters

    • resultsCount: number

      Number of results this operation produced.

    • Optional overrideDurationMs: number

      Optional override for duration (when timing is measured externally).

    Returns RAGOperationEntry