@zukhruf/retrieval 0.8.77 → 0.8.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/distribution-based-score-fusion.d.ts +10 -0
- package/dist/distribution-based-score-fusion.d.ts.map +1 -0
- package/dist/distribution-based-score-fusion.js +21 -0
- package/dist/distribution-based-score-fusion.js.map +1 -0
- package/dist/fusion-retriever.d.ts +26 -0
- package/dist/fusion-retriever.d.ts.map +1 -0
- package/dist/fusion-retriever.js +30 -0
- package/dist/fusion-retriever.js.map +1 -0
- package/dist/hyde-retriever.d.ts +20 -0
- package/dist/hyde-retriever.d.ts.map +1 -0
- package/dist/hyde-retriever.js +29 -0
- package/dist/hyde-retriever.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/model-identity.d.ts +26 -0
- package/dist/model-identity.d.ts.map +1 -0
- package/dist/model-identity.js +31 -0
- package/dist/model-identity.js.map +1 -0
- package/dist/model-mismatch-error.d.ts +9 -12
- package/dist/model-mismatch-error.d.ts.map +1 -1
- package/dist/model-mismatch-error.js +6 -6
- package/dist/model-mismatch-error.js.map +1 -1
- package/dist/multi-query-retriever.d.ts +28 -0
- package/dist/multi-query-retriever.d.ts.map +1 -0
- package/dist/multi-query-retriever.js +95 -0
- package/dist/multi-query-retriever.js.map +1 -0
- package/dist/reciprocal-rank-fusion.d.ts +11 -0
- package/dist/reciprocal-rank-fusion.d.ts.map +1 -0
- package/dist/reciprocal-rank-fusion.js +13 -0
- package/dist/reciprocal-rank-fusion.js.map +1 -0
- package/dist/relative-score-fusion.d.ts +10 -0
- package/dist/relative-score-fusion.d.ts.map +1 -0
- package/dist/relative-score-fusion.js +18 -0
- package/dist/relative-score-fusion.js.map +1 -0
- package/dist/sqlite/identifier.d.ts +3 -0
- package/dist/sqlite/identifier.d.ts.map +1 -0
- package/dist/sqlite/identifier.js +3 -0
- package/dist/sqlite/identifier.js.map +1 -0
- package/dist/sqlite/passage-rows.d.ts +13 -0
- package/dist/sqlite/passage-rows.d.ts.map +1 -0
- package/dist/sqlite/passage-rows.js +44 -0
- package/dist/sqlite/passage-rows.js.map +1 -0
- package/dist/sqlite/sqlite-bm25-retriever.d.ts +21 -0
- package/dist/sqlite/sqlite-bm25-retriever.d.ts.map +1 -0
- package/dist/sqlite/sqlite-bm25-retriever.js +48 -0
- package/dist/sqlite/sqlite-bm25-retriever.js.map +1 -0
- package/dist/sqlite/sqlite-embedding-retriever.d.ts +23 -0
- package/dist/sqlite/sqlite-embedding-retriever.d.ts.map +1 -0
- package/dist/sqlite/sqlite-embedding-retriever.js +125 -0
- package/dist/sqlite/sqlite-embedding-retriever.js.map +1 -0
- package/dist/sqlite/sqlite-passage-store.d.ts +23 -0
- package/dist/sqlite/sqlite-passage-store.d.ts.map +1 -0
- package/dist/sqlite/sqlite-passage-store.js +32 -0
- package/dist/sqlite/sqlite-passage-store.js.map +1 -0
- package/dist/sqlite/where.d.ts +13 -0
- package/dist/sqlite/where.d.ts.map +1 -0
- package/dist/sqlite/where.js +62 -0
- package/dist/sqlite/where.js.map +1 -0
- package/dist/sqlite.d.ts +4 -0
- package/dist/sqlite.d.ts.map +1 -0
- package/dist/sqlite.js +4 -0
- package/dist/sqlite.js.map +1 -0
- package/dist/sum-on-id.d.ts +14 -0
- package/dist/sum-on-id.d.ts.map +1 -0
- package/dist/sum-on-id.js +36 -0
- package/dist/sum-on-id.js.map +1 -0
- package/package.json +15 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SQLInputValue, SQLOutputValue, StatementSync } from 'node:sqlite';
|
|
2
|
+
import type { Passage } from '../passage.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Runs a statement whose result ends with `p.*`, the columns of the passages,
|
|
5
|
+
* and gives the cells before them and the passage of each row. A metadata
|
|
6
|
+
* column is any other column of the passages, under its own name, even when
|
|
7
|
+
* it has the name of a cell before it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function passageRows(statement: StatementSync, cellsBefore: number, parameters: readonly SQLInputValue[]): {
|
|
10
|
+
readonly cells: readonly SQLOutputValue[];
|
|
11
|
+
readonly passage: Passage;
|
|
12
|
+
}[];
|
|
13
|
+
//# sourceMappingURL=passage-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passage-rows.d.ts","sourceRoot":"","sources":["../../src/sqlite/passage-rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAc7C;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,aAAa,EACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,SAAS,aAAa,EAAE,GACnC;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EAAE,CA6B5E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// `rowid` is the integer key that the keyword index joins on (ADR 0004): a
|
|
2
|
+
// view of the passages exposes it as a column, and it is not metadata.
|
|
3
|
+
const passageColumns = new Set([
|
|
4
|
+
'rowid',
|
|
5
|
+
'id',
|
|
6
|
+
'source',
|
|
7
|
+
'seq',
|
|
8
|
+
'start',
|
|
9
|
+
'end',
|
|
10
|
+
'text',
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Runs a statement whose result ends with `p.*`, the columns of the passages,
|
|
14
|
+
* and gives the cells before them and the passage of each row. A metadata
|
|
15
|
+
* column is any other column of the passages, under its own name, even when
|
|
16
|
+
* it has the name of a cell before it.
|
|
17
|
+
*/
|
|
18
|
+
export function passageRows(statement, cellsBefore, parameters) {
|
|
19
|
+
statement.setReturnArrays(true);
|
|
20
|
+
const names = statement
|
|
21
|
+
.columns()
|
|
22
|
+
.slice(cellsBefore)
|
|
23
|
+
.map(({ name }) => name);
|
|
24
|
+
// node:sqlite types each row as a record; with return arrays it is an
|
|
25
|
+
// array, whose values are the cells in the order of the columns.
|
|
26
|
+
return statement.all(...parameters).map((record) => {
|
|
27
|
+
const row = Object.values(record);
|
|
28
|
+
const values = row.slice(cellsBefore);
|
|
29
|
+
const cell = (name) => values[names.indexOf(name)];
|
|
30
|
+
return {
|
|
31
|
+
cells: row.slice(0, cellsBefore),
|
|
32
|
+
passage: {
|
|
33
|
+
id: String(cell('id')),
|
|
34
|
+
text: String(cell('text')),
|
|
35
|
+
source: String(cell('source')),
|
|
36
|
+
seq: Number(cell('seq')),
|
|
37
|
+
start: Number(cell('start')),
|
|
38
|
+
end: Number(cell('end')),
|
|
39
|
+
metadata: Object.fromEntries(names.flatMap((name, index) => passageColumns.has(name) ? [] : [[name, values[index]]])),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=passage-rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passage-rows.js","sourceRoot":"","sources":["../../src/sqlite/passage-rows.ts"],"names":[],"mappings":"AAIA,2EAA2E;AAC3E,uEAAuE;AACvE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,OAAO;IACP,IAAI;IACJ,QAAQ;IACR,KAAK;IACL,OAAO;IACP,KAAK;IACL,MAAM;CACP,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,SAAwB,EACxB,WAAmB,EACnB,UAAoC;IAEpC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,SAAS;SACpB,OAAO,EAAE;SACT,KAAK,CAAC,WAAW,CAAC;SAClB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE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} from 'node:sqlite';
|
|
2
|
+
import type { RetrieveOptions } from '../retrieve-options.ts';
|
|
3
|
+
import type { Retriever } from '../retriever.ts';
|
|
4
|
+
import type { ScoredPassage } from '../scored-passage.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Ranks the passages by FTS5 `bm25()` over the keyword index that elt writes:
|
|
7
|
+
* an FTS5 table with the passages as its external content (ADR 0004). The
|
|
8
|
+
* score is `-bm25()`, so a better match has a higher score (ADR 0005).
|
|
9
|
+
*/
|
|
10
|
+
export declare class SqliteBM25Retriever implements Retriever {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(options: {
|
|
13
|
+
readonly database: DatabaseSync;
|
|
14
|
+
readonly passages: string;
|
|
15
|
+
readonly index: string;
|
|
16
|
+
/** How the words of the query join: 'AND', the implicit operator of FTS5, when absent. */
|
|
17
|
+
readonly operator?: 'AND' | 'OR';
|
|
18
|
+
});
|
|
19
|
+
retrieve(query: string, options?: RetrieveOptions): Promise<ScoredPassage[]>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=sqlite-bm25-retriever.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-bm25-retriever.d.ts","sourceRoot":"","sources":["../../src/sqlite/sqlite-bm25-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,SAAS;;IAMnD,YAAY,OAAO,EAAE;QACnB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;QAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,0FAA0F;QAC1F,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;KAClC,EAKA;IAEK,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,aAAa,EAAE,CAAC,CAmB1B;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { identifier } from './identifier.js';
|
|
2
|
+
import { passageRows } from './passage-rows.js';
|
|
3
|
+
import { where } from './where.js';
|
|
4
|
+
/**
|
|
5
|
+
* Ranks the passages by FTS5 `bm25()` over the keyword index that elt writes:
|
|
6
|
+
* an FTS5 table with the passages as its external content (ADR 0004). The
|
|
7
|
+
* score is `-bm25()`, so a better match has a higher score (ADR 0005).
|
|
8
|
+
*/
|
|
9
|
+
export class SqliteBM25Retriever {
|
|
10
|
+
#database;
|
|
11
|
+
#passages;
|
|
12
|
+
#index;
|
|
13
|
+
#operator;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.#database = options.database;
|
|
16
|
+
this.#passages = identifier(options.passages);
|
|
17
|
+
this.#index = identifier(options.index);
|
|
18
|
+
this.#operator = options.operator ?? 'AND';
|
|
19
|
+
}
|
|
20
|
+
async retrieve(query, options = {}) {
|
|
21
|
+
options.abortSignal?.throwIfAborted();
|
|
22
|
+
const words = query.split(/\s+/).filter((word) => word !== '');
|
|
23
|
+
if (words.length === 0)
|
|
24
|
+
return [];
|
|
25
|
+
const filter = where(options.filter);
|
|
26
|
+
const statement = this.#database.prepare(`
|
|
27
|
+
SELECT -bm25(${this.#index}) AS "score", p.*
|
|
28
|
+
FROM ${this.#index} JOIN ${this.#passages} p ON p.rowid = ${this.#index}.rowid
|
|
29
|
+
WHERE ${this.#index} MATCH ? AND ${filter.sql}
|
|
30
|
+
ORDER BY bm25(${this.#index}), p."id"
|
|
31
|
+
LIMIT ?`);
|
|
32
|
+
return passageRows(statement, 1, [
|
|
33
|
+
ftsQuery(words, this.#operator),
|
|
34
|
+
...filter.parameters,
|
|
35
|
+
options.topK ?? 10,
|
|
36
|
+
]).map(({ cells: [score], passage }) => ({
|
|
37
|
+
passage,
|
|
38
|
+
score: Number(score),
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Each word as an FTS5 phrase, with a `"` in it doubled, so no word of the
|
|
44
|
+
* query is FTS5 syntax: `-`, `:`, `*`, `NEAR` and `OR` stay words
|
|
45
|
+
* (sqlite.org/fts5.html §3), as text2sql's `toFtsQuery` quotes them (#5410).
|
|
46
|
+
*/
|
|
47
|
+
const ftsQuery = (words, operator) => words.map((word) => `"${word.replaceAll('"', '""')}"`).join(` ${operator} `);
|
|
48
|
+
//# sourceMappingURL=sqlite-bm25-retriever.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-bm25-retriever.js","sourceRoot":"","sources":["../../src/sqlite/sqlite-bm25-retriever.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IACrB,SAAS,CAAe;IACxB,SAAS,CAAS;IAClB,MAAM,CAAS;IACf,SAAS,CAAe;IAEjC,YAAY,OAMX;QACC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,KAAa,EACb,O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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { type EmbeddingModel } from 'ai';
|
|
3
|
+
import type { BatchRetriever } from '../batch-retriever.ts';
|
|
4
|
+
import type { RetrieveOptions } from '../retrieve-options.ts';
|
|
5
|
+
import type { ScoredPassage } from '../scored-passage.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Ranks the passages by the cosine similarity of their vectors to the query,
|
|
8
|
+
* with `vec_distance_cosine` in the SQL of SQLite (ADR 0003). The host
|
|
9
|
+
* registers that function: it loads sqlite-vec, or calls `install()` of
|
|
10
|
+
* `@zukhruf/vectors/sqlite`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SqliteEmbeddingRetriever implements BatchRetriever {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(options: {
|
|
15
|
+
readonly database: DatabaseSync;
|
|
16
|
+
readonly passages: string;
|
|
17
|
+
readonly vectors: string;
|
|
18
|
+
readonly model: EmbeddingModel;
|
|
19
|
+
});
|
|
20
|
+
retrieve(query: string, options?: RetrieveOptions): Promise<ScoredPassage[]>;
|
|
21
|
+
retrieveMany(queries: readonly string[], options?: RetrieveOptions): Promise<ScoredPassage[][]>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=sqlite-embedding-retriever.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-embedding-retriever.d.ts","sourceRoot":"","sources":["../../src/sqlite/sqlite-embedding-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,IAAI,CAAC;AAK3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAQ5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,cAAc;;IAM7D,YAAY,OAAO,EAAE;QACnB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;QAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;KAChC,EAKA;IAEK,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,aAAa,EAAE,CAAC,CAU1B;IAEK,YAAY,CAChB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAU5B;CA6FF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { embed, embedMany } from 'ai';
|
|
2
|
+
import { DimensionMismatchError, Vector } from '@zukhruf/vectors';
|
|
3
|
+
import { fromSql, toSql } from '@zukhruf/vectors/sqlite';
|
|
4
|
+
import { describe, modelName, parseModelIdentity, } from '../model-identity.js';
|
|
5
|
+
import { ModelMismatchError } from '../model-mismatch-error.js';
|
|
6
|
+
import { identifier } from './identifier.js';
|
|
7
|
+
import { passageRows } from './passage-rows.js';
|
|
8
|
+
import { where } from './where.js';
|
|
9
|
+
/**
|
|
10
|
+
* Ranks the passages by the cosine similarity of their vectors to the query,
|
|
11
|
+
* with `vec_distance_cosine` in the SQL of SQLite (ADR 0003). The host
|
|
12
|
+
* registers that function: it loads sqlite-vec, or calls `install()` of
|
|
13
|
+
* `@zukhruf/vectors/sqlite`.
|
|
14
|
+
*/
|
|
15
|
+
export class SqliteEmbeddingRetriever {
|
|
16
|
+
#database;
|
|
17
|
+
#passages;
|
|
18
|
+
#vectors;
|
|
19
|
+
#model;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.#database = options.database;
|
|
22
|
+
this.#passages = identifier(options.passages);
|
|
23
|
+
this.#vectors = identifier(options.vectors);
|
|
24
|
+
this.#model = options.model;
|
|
25
|
+
}
|
|
26
|
+
async retrieve(query, options = {}) {
|
|
27
|
+
const [passages] = await this.#retrieve(1, options, async (abortSignal) => {
|
|
28
|
+
const { embedding } = await embed({
|
|
29
|
+
model: this.#model,
|
|
30
|
+
value: query,
|
|
31
|
+
...(abortSignal === undefined ? {} : { abortSignal }),
|
|
32
|
+
});
|
|
33
|
+
return [embedding];
|
|
34
|
+
});
|
|
35
|
+
return passages ?? [];
|
|
36
|
+
}
|
|
37
|
+
async retrieveMany(queries, options = {}) {
|
|
38
|
+
if (queries.length === 0)
|
|
39
|
+
return [];
|
|
40
|
+
return this.#retrieve(queries.length, options, async (abortSignal) => {
|
|
41
|
+
const { embeddings } = await embedMany({
|
|
42
|
+
model: this.#model,
|
|
43
|
+
values: [...queries],
|
|
44
|
+
...(abortSignal === undefined ? {} : { abortSignal }),
|
|
45
|
+
});
|
|
46
|
+
return embeddings;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async #retrieve(count, options, embedQueries) {
|
|
50
|
+
options.abortSignal?.throwIfAborted();
|
|
51
|
+
const query = modelName(this.#model);
|
|
52
|
+
const stored = this.#storedIdentities();
|
|
53
|
+
const [first] = stored;
|
|
54
|
+
if (first === undefined)
|
|
55
|
+
return Array.from({ length: count }, () => []);
|
|
56
|
+
const sameModel = stored.filter(({ provider, modelId }) => provider === query.provider && modelId === query.modelId);
|
|
57
|
+
const [nearest] = sameModel;
|
|
58
|
+
if (nearest === undefined) {
|
|
59
|
+
throw new ModelMismatchError({ provider: first.provider, modelId: first.modelId }, query);
|
|
60
|
+
}
|
|
61
|
+
const vectors = await embedQueries(options.abortSignal);
|
|
62
|
+
options.abortSignal?.throwIfAborted();
|
|
63
|
+
const dimensions = vectors[0]?.length ?? 0;
|
|
64
|
+
const identity = sameModel.find((candidate) => candidate.dimensions === dimensions);
|
|
65
|
+
if (identity === undefined) {
|
|
66
|
+
throw new DimensionMismatchError(nearest.dimensions, dimensions);
|
|
67
|
+
}
|
|
68
|
+
return this.#search(vectors, identity, options);
|
|
69
|
+
}
|
|
70
|
+
/** The identities of the stored vectors, in the order of their text. */
|
|
71
|
+
#storedIdentities() {
|
|
72
|
+
return this.#database
|
|
73
|
+
.prepare(`SELECT DISTINCT "model" FROM ${this.#vectors} ORDER BY "model"`)
|
|
74
|
+
.all()
|
|
75
|
+
.map(({ model }) => parseModelIdentity(String(model)));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* One SQL query for every query vector. It compares a query only with the
|
|
79
|
+
* vectors of its own model identity, and breaks a tie of distance by the
|
|
80
|
+
* passage id, as `VectorSearch` of `@zukhruf/embeddings` does.
|
|
81
|
+
*/
|
|
82
|
+
#search(vectors, identity, options) {
|
|
83
|
+
const filter = where(options.filter);
|
|
84
|
+
const statement = this.#database.prepare(`
|
|
85
|
+
WITH "queries" ("query", "vector") AS (VALUES ${vectors.map(() => '(?, ?)').join(', ')}),
|
|
86
|
+
"scored" AS (
|
|
87
|
+
SELECT q."query", v."id", v."vector", vec_distance_cosine(v."vector", q."vector") AS "distance"
|
|
88
|
+
FROM "queries" q CROSS JOIN ${this.#vectors} v JOIN ${this.#passages} p ON p."id" = v."id"
|
|
89
|
+
WHERE v."model" = ? AND ${filter.sql}
|
|
90
|
+
),
|
|
91
|
+
"ranked" AS (
|
|
92
|
+
SELECT *, ROW_NUMBER() OVER (PARTITION BY "query" ORDER BY "distance", "id") AS "rank" FROM "scored"
|
|
93
|
+
)
|
|
94
|
+
SELECT r."query", r."distance", r."vector", p.*
|
|
95
|
+
FROM "ranked" r JOIN ${this.#passages} p ON p."id" = r."id"
|
|
96
|
+
WHERE r."rank" <= ?
|
|
97
|
+
ORDER BY r."query", r."rank"`);
|
|
98
|
+
const rows = passageRows(statement, 3, [
|
|
99
|
+
...vectors.flatMap((vector, index) => [
|
|
100
|
+
index,
|
|
101
|
+
toSql(Vector.from(vector)),
|
|
102
|
+
]),
|
|
103
|
+
describe(identity),
|
|
104
|
+
...filter.parameters,
|
|
105
|
+
options.topK ?? 10,
|
|
106
|
+
]);
|
|
107
|
+
const lists = vectors.map(() => []);
|
|
108
|
+
for (const { cells: [query, distance, vector], passage, } of rows) {
|
|
109
|
+
lists[Number(query)]?.push({
|
|
110
|
+
passage,
|
|
111
|
+
score: 1 - Number(distance),
|
|
112
|
+
...(options.includeVectors === true
|
|
113
|
+
? { vector: Array.from(fromSql(Vector, blob(vector)).values) }
|
|
114
|
+
: {}),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return lists;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function blob(value) {
|
|
121
|
+
if (value instanceof Uint8Array)
|
|
122
|
+
return value;
|
|
123
|
+
throw new TypeError(`A stored vector is a BLOB of float32 values, not ${String(value)}`);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=sqlite-embedding-retriever.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-embedding-retriever.js","sourceRoot":"","sources":["../../src/sqlite/sqlite-embedding-retriever.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,EAEL,QAAQ,EACR,SAAS,EACT,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,OAAO,wB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CAAC,MAAM,CAAC,CAAC;aAC3B,CAAC;YACF,QAAQ,CAAC,QAAQ,CAAC;YAClB,GAAG,MAAM,CAAC,UAAU;YACpB,OAAO,CAAC,IAAI,IAAI,EAAE;SACnB,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAoB,EAAE,CAAC,EAAE,CAAC,CAAC;QACrD,KAAK,MAAM,EACT,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAChC,OAAO,GACR,IAAI,IAAI,EAAE,CAAC;YACV,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;gBACzB,OAAO;gBACP,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;gBAC3B,GAAG,CAAC,OAAO,CAAC,cAAc,KAAK,IAAI;oBACjC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;oBAC9D,CAAC,CAAC,EAAE,CAAC;aACR,CAAC,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,KAAK,CAAC;IAC9C,MAAM,IAAI,SAAS,CACjB,oDAAoD,MAAM,CAAC,KAAK,CAAC,EAAE,CACpE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import type { PassageStore } from '../passage-store.ts';
|
|
3
|
+
import type { Passage } from '../passage.ts';
|
|
4
|
+
/** Reads the passages of the passage contract in SQLite by id, and the neighbours of a passage in its source. */
|
|
5
|
+
export declare class SqlitePassageStore implements PassageStore {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(options: {
|
|
8
|
+
readonly database: DatabaseSync;
|
|
9
|
+
readonly passages: string;
|
|
10
|
+
});
|
|
11
|
+
get(ids: readonly string[]): Promise<ReadonlyMap<string, Passage>>;
|
|
12
|
+
/**
|
|
13
|
+
* The passages of the source from `seq - windowSize` to `seq + windowSize`,
|
|
14
|
+
* the passage itself among them, in the order of `seq`, as Haystack's
|
|
15
|
+
* `SentenceWindowRetriever` reads its window.
|
|
16
|
+
*/
|
|
17
|
+
neighbours(options: {
|
|
18
|
+
readonly source: string;
|
|
19
|
+
readonly seq: number;
|
|
20
|
+
readonly windowSize: number;
|
|
21
|
+
}): Promise<Passage[]>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=sqlite-passage-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-passage-store.d.ts","sourceRoot":"","sources":["../../src/sqlite/sqlite-passage-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C,iHAAiH;AACjH,qBAAa,kBAAmB,YAAW,YAAY;;IAIrD,YAAY,OAAO,EAAE;QACnB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;QAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC3B,EAGA;IAEK,GAAG,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAUvE;IAED;;;;OAIG;IACG,UAAU,CAAC,OAAO,EAAE;QACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;KAC7B,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CASrB;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { identifier } from './identifier.js';
|
|
2
|
+
import { passageRows } from './passage-rows.js';
|
|
3
|
+
/** Reads the passages of the passage contract in SQLite by id, and the neighbours of a passage in its source. */
|
|
4
|
+
export class SqlitePassageStore {
|
|
5
|
+
#database;
|
|
6
|
+
#passages;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.#database = options.database;
|
|
9
|
+
this.#passages = identifier(options.passages);
|
|
10
|
+
}
|
|
11
|
+
async get(ids) {
|
|
12
|
+
const statement = this.#database.prepare(`SELECT p.* FROM ${this.#passages} p WHERE p."id" IN (SELECT "value" FROM json_each(?))`);
|
|
13
|
+
return new Map(passageRows(statement, 0, [JSON.stringify(ids)]).map(({ passage }) => [
|
|
14
|
+
passage.id,
|
|
15
|
+
passage,
|
|
16
|
+
]));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The passages of the source from `seq - windowSize` to `seq + windowSize`,
|
|
20
|
+
* the passage itself among them, in the order of `seq`, as Haystack's
|
|
21
|
+
* `SentenceWindowRetriever` reads its window.
|
|
22
|
+
*/
|
|
23
|
+
async neighbours(options) {
|
|
24
|
+
const statement = this.#database.prepare(`SELECT p.* FROM ${this.#passages} p WHERE p."source" = ? AND p."seq" BETWEEN ? AND ? ORDER BY p."seq", p."id"`);
|
|
25
|
+
return passageRows(statement, 0, [
|
|
26
|
+
options.source,
|
|
27
|
+
options.seq - options.windowSize,
|
|
28
|
+
options.seq + options.windowSize,
|
|
29
|
+
]).map(({ passage }) => passage);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=sqlite-passage-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-passage-store.js","sourceRoot":"","sources":["../../src/sqlite/sqlite-passage-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CA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
|
4
|
+
* The filter as a SQL condition on the passages, aliased `p`, with each value
|
|
5
|
+
* a parameter (ADR 0009). `==` and `!=` compare NULL as a value, and `not in`
|
|
6
|
+
* keeps a NULL, as Haystack's pgvector store does (`IS DISTINCT FROM`,
|
|
7
|
+
* `IS NULL OR != ALL`).
|
|
8
|
+
*/
|
|
9
|
+
export declare function where(filter: Filter | undefined): {
|
|
10
|
+
readonly sql: string;
|
|
11
|
+
readonly parameters: readonly SQLInputValue[];
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=where.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.d.ts","sourceRoot":"","sources":["../../src/sqlite/where.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAM3C;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C,CAIA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { identifier } from './identifier.js';
|
|
2
|
+
const passageFields = new Set(['source', 'seq', 'start', 'end']);
|
|
3
|
+
const metadata = 'metadata.';
|
|
4
|
+
/**
|
|
5
|
+
* The filter as a SQL condition on the passages, aliased `p`, with each value
|
|
6
|
+
* a parameter (ADR 0009). `==` and `!=` compare NULL as a value, and `not in`
|
|
7
|
+
* keeps a NULL, as Haystack's pgvector store does (`IS DISTINCT FROM`,
|
|
8
|
+
* `IS NULL OR != ALL`).
|
|
9
|
+
*/
|
|
10
|
+
export function where(filter) {
|
|
11
|
+
const parameters = [];
|
|
12
|
+
const sql = filter === undefined ? '1' : condition(filter, parameters);
|
|
13
|
+
return { sql, parameters };
|
|
14
|
+
}
|
|
15
|
+
function condition(filter, parameters) {
|
|
16
|
+
if ('conditions' in filter) {
|
|
17
|
+
const parts = filter.conditions.map((part) => condition(part, parameters));
|
|
18
|
+
if (filter.operator === 'OR')
|
|
19
|
+
return parts.length === 0 ? '0' : `(${parts.join(' OR ')})`;
|
|
20
|
+
const all = parts.length === 0 ? '1' : `(${parts.join(' AND ')})`;
|
|
21
|
+
return filter.operator === 'NOT' ? `(NOT ${all})` : all;
|
|
22
|
+
}
|
|
23
|
+
const field = column(filter.field);
|
|
24
|
+
const { operator, value } = filter;
|
|
25
|
+
if (operator === 'in' || operator === 'not in') {
|
|
26
|
+
if (!Array.isArray(value)) {
|
|
27
|
+
throw new TypeError(`The value of an ${JSON.stringify(operator)} filter on ${filter.field} is an array, not ${JSON.stringify(value)}`);
|
|
28
|
+
}
|
|
29
|
+
parameters.push(...value.map(parameter));
|
|
30
|
+
const list = `(${value.map(() => '?').join(', ')})`;
|
|
31
|
+
return operator === 'in'
|
|
32
|
+
? `${field} IN ${list}`
|
|
33
|
+
: `(${field} IS NULL OR ${field} NOT IN ${list})`;
|
|
34
|
+
}
|
|
35
|
+
parameters.push(parameter(value));
|
|
36
|
+
if (operator === '==')
|
|
37
|
+
return `${field} IS ?`;
|
|
38
|
+
if (operator === '!=')
|
|
39
|
+
return `${field} IS NOT ?`;
|
|
40
|
+
return `${field} ${operator} ?`;
|
|
41
|
+
}
|
|
42
|
+
function column(field) {
|
|
43
|
+
if (passageFields.has(field))
|
|
44
|
+
return `p.${identifier(field)}`;
|
|
45
|
+
if (field.startsWith(metadata))
|
|
46
|
+
return `p.${identifier(field.slice(metadata.length))}`;
|
|
47
|
+
throw new TypeError(`The filter field ${JSON.stringify(field)} is not source, seq, start, end or metadata.<column>`);
|
|
48
|
+
}
|
|
49
|
+
// SQLite has no boolean: TRUE is 1 and FALSE is 0.
|
|
50
|
+
function parameter(value) {
|
|
51
|
+
if (typeof value === 'boolean')
|
|
52
|
+
return Number(value);
|
|
53
|
+
if (value === null ||
|
|
54
|
+
typeof value === 'string' ||
|
|
55
|
+
typeof value === 'number' ||
|
|
56
|
+
typeof value === 'bigint' ||
|
|
57
|
+
value instanceof Uint8Array) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
throw new TypeError(`A filter value is a string, a number, a bigint, a boolean, null or a Uint8Array, not ${String(value)}`);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=where.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.js","sourceRoot":"","sources":["../../src/sqlite/where.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACjE,MAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,MAA0B;IAI9C,MAAM,UAAU,GAAoB,EAAE,CAAC;IACvC,MAAM,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;AAC7B,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,UAA2B;IAC5D,IAAI,YAAY,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI;YAC1B,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAA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.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../src/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ScoredPassage } from './scored-passage.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The part that the three fusions share: each list's scores become new
|
|
4
|
+
* scores by the fusion's own rule, each new score is multiplied by the weight
|
|
5
|
+
* of its list, and the products of one `Passage.id` are added, best first. A
|
|
6
|
+
* passage that a list does not hold adds nothing from that list (ADR 0007,
|
|
7
|
+
* amendment 2026-11-23).
|
|
8
|
+
*
|
|
9
|
+
* The passage is the one of the first list that holds the id, its vector the
|
|
10
|
+
* first that a list gives, and equal fused scores keep the order in which
|
|
11
|
+
* their ids first appear (`toSorted` is stable).
|
|
12
|
+
*/
|
|
13
|
+
export declare function sumOnId(lists: readonly (readonly ScoredPassage[])[], weights: readonly number[], rescale: (scores: readonly number[]) => readonly number[]): ScoredPassage[];
|
|
14
|
+
//# sourceMappingURL=sum-on-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sum-on-id.d.ts","sourceRoot":"","sources":["../src/sum-on-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,EAAE,EAC5C,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,EAAE,GACxD,aAAa,EAAE,CA0BjB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part that the three fusions share: each list's scores become new
|
|
3
|
+
* scores by the fusion's own rule, each new score is multiplied by the weight
|
|
4
|
+
* of its list, and the products of one `Passage.id` are added, best first. A
|
|
5
|
+
* passage that a list does not hold adds nothing from that list (ADR 0007,
|
|
6
|
+
* amendment 2026-11-23).
|
|
7
|
+
*
|
|
8
|
+
* The passage is the one of the first list that holds the id, its vector the
|
|
9
|
+
* first that a list gives, and equal fused scores keep the order in which
|
|
10
|
+
* their ids first appear (`toSorted` is stable).
|
|
11
|
+
*/
|
|
12
|
+
export function sumOnId(lists, weights, rescale) {
|
|
13
|
+
if (weights.length !== lists.length) {
|
|
14
|
+
throw new RangeError(`A fusion takes one weight for each list: got ${weights.length} weights for ${lists.length} lists`);
|
|
15
|
+
}
|
|
16
|
+
const fused = new Map();
|
|
17
|
+
for (const [index, list] of lists.entries()) {
|
|
18
|
+
const weight = weights[index] ?? 1;
|
|
19
|
+
const scores = rescale(list.map(({ score }) => score));
|
|
20
|
+
for (const [position, { passage, vector }] of list.entries()) {
|
|
21
|
+
const score = weight * (scores[position] ?? 0);
|
|
22
|
+
const entry = fused.get(passage.id);
|
|
23
|
+
if (entry === undefined) {
|
|
24
|
+
fused.set(passage.id, { passage, score, vector });
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
entry.score += score;
|
|
28
|
+
entry.vector ??= vector;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return [...fused.values()]
|
|
33
|
+
.map(({ passage, score, vector }) => vector === undefined ? { passage, score } : { passage, score, vector })
|
|
34
|
+
.toSorted((a, b) => b.score - a.score);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=sum-on-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sum-on-id.js","sourceRoot":"","sources":["../src/sum-on-id.ts"],"names":[],"mappings":"AAEA;;;;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vB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAClC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CACvE;SACA,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/retrieval",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.79",
|
|
4
4
|
"description": "The query side of RAG: retrievers that search a passage table by meaning or keywords in SQLite, Postgres or SQL Server, fuse lists, rerank and post-process, and give the best passages first with a score that is higher for a better passage.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,12 @@
|
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
34
|
"import": "./dist/index.js",
|
|
35
35
|
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./sqlite": {
|
|
38
|
+
"@zukhruf/source": "./src/sqlite.ts",
|
|
39
|
+
"types": "./dist/sqlite.d.ts",
|
|
40
|
+
"import": "./dist/sqlite.js",
|
|
41
|
+
"default": "./dist/sqlite.js"
|
|
36
42
|
}
|
|
37
43
|
},
|
|
38
44
|
"files": [
|
|
@@ -43,5 +49,13 @@
|
|
|
43
49
|
],
|
|
44
50
|
"publishConfig": {
|
|
45
51
|
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@zukhruf/statistics": "^0.8.79",
|
|
55
|
+
"@zukhruf/vectors": "^0.8.79",
|
|
56
|
+
"ai": "^7.0.179"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@zukhruf/sqlite-open": "^0.8.79"
|
|
46
60
|
}
|
|
47
61
|
}
|