| |
| export interface Document { |
| id: string; |
| title: string; |
| body: string; |
| filepath: string; |
| } |
|
|
| |
| export interface Chunk { |
| docId: string; |
| chunkIndex: number; |
| text: string; |
| startChar: number; |
| title: string; |
| } |
|
|
| |
| export interface EmbeddedChunk extends Chunk { |
| embedding: Float32Array; |
| } |
|
|
| |
| export interface ScoredChunk { |
| chunk: Chunk; |
| score: number; |
| source: "bm25" | "vector"; |
| } |
|
|
| |
| export interface RRFResult { |
| docId: string; |
| filepath: string; |
| title: string; |
| bestChunk: string; |
| score: number; |
| contributions: RRFContribution[]; |
| } |
|
|
| export interface RRFContribution { |
| source: "bm25" | "vector"; |
| queryType: "original" | "lex" | "vec" | "hyde"; |
| query: string; |
| rank: number; |
| weight: number; |
| rrfContribution: number; |
| } |
|
|
| |
| export interface RerankedResult extends RRFResult { |
| rerankScore: number; |
| blendedScore: number; |
| } |
|
|
| |
| export interface FinalResult { |
| filepath: string; |
| title: string; |
| bestChunk: string; |
| score: number; |
| docId: string; |
| } |
|
|
| |
| export interface ExpandedQuery { |
| hyde: string; |
| vec: string[]; |
| lex: string; |
| source?: "model" | "fallback" | "strong-signal"; |
| note?: string; |
| } |
|
|
| |
| export type PipelineStage = "expansion" | "search" | "rrf" | "rerank" | "blend"; |
| export type PipelineStatus = "idle" | "running" | "done" | "error"; |
|
|
| export type PipelineEvent = |
| | { stage: "expansion"; status: "running" } |
| | { stage: "expansion"; status: "done"; data: ExpandedQuery } |
| | { stage: "expansion"; status: "error"; error: string } |
| | { stage: "search"; status: "running" } |
| | { |
| stage: "search"; |
| status: "done"; |
| data: { bm25Hits: ScoredChunk[]; vectorHits: ScoredChunk[] }; |
| } |
| | { stage: "rrf"; status: "done"; data: { merged: RRFResult[] } } |
| | { stage: "rerank"; status: "running" } |
| | { |
| stage: "rerank"; |
| status: "done"; |
| data: { before: RRFResult[]; after: RerankedResult[] }; |
| } |
| | { stage: "blend"; status: "done"; data: { finalResults: FinalResult[] } }; |
|
|
| |
| export interface ModelState { |
| name: string; |
| status: "pending" | "downloading" | "loading" | "ready" | "error"; |
| progress: number; |
| error?: string; |
| } |
|
|