@lancedb/lancedb 0.4.3 → 0.4.13
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/dist/arrow.d.ts +189 -0
- package/dist/arrow.js +539 -0
- package/dist/connection.d.ts +97 -0
- package/dist/connection.js +126 -0
- package/dist/embedding/embedding_function.d.ts +45 -0
- package/dist/embedding/embedding_function.js +27 -0
- package/dist/embedding/index.d.ts +2 -0
- package/dist/embedding/index.js +7 -0
- package/dist/embedding/openai.d.ts +8 -0
- package/dist/embedding/openai.js +53 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +52 -0
- package/dist/indices.d.ts +165 -0
- package/dist/indices.js +71 -0
- package/dist/native.d.ts +147 -0
- package/dist/native.js +314 -0
- package/dist/query.d.ts +248 -0
- package/dist/query.js +346 -0
- package/dist/sanitize.d.ts +9 -0
- package/dist/sanitize.js +369 -0
- package/dist/table.d.ts +252 -0
- package/dist/table.js +298 -0
- package/nodejs-artifacts/arrow.d.ts +189 -0
- package/nodejs-artifacts/arrow.js +539 -0
- package/nodejs-artifacts/connection.d.ts +97 -0
- package/nodejs-artifacts/connection.js +126 -0
- package/nodejs-artifacts/embedding/embedding_function.d.ts +45 -0
- package/nodejs-artifacts/embedding/embedding_function.js +27 -0
- package/nodejs-artifacts/embedding/index.d.ts +2 -0
- package/nodejs-artifacts/embedding/index.js +7 -0
- package/nodejs-artifacts/embedding/openai.d.ts +8 -0
- package/nodejs-artifacts/embedding/openai.js +53 -0
- package/nodejs-artifacts/index.d.ts +22 -0
- package/nodejs-artifacts/index.js +52 -0
- package/nodejs-artifacts/indices.d.ts +165 -0
- package/nodejs-artifacts/indices.js +71 -0
- package/nodejs-artifacts/native.d.ts +147 -0
- package/nodejs-artifacts/native.js +314 -0
- package/nodejs-artifacts/query.d.ts +248 -0
- package/nodejs-artifacts/query.js +346 -0
- package/nodejs-artifacts/sanitize.d.ts +9 -0
- package/nodejs-artifacts/sanitize.js +369 -0
- package/nodejs-artifacts/table.d.ts +252 -0
- package/nodejs-artifacts/table.js +298 -0
- package/package.json +8 -10
- package/examples/js/index.mjs +0 -40
- package/examples/js/package.json +0 -14
- package/examples/js-openai/index.mjs +0 -43
- package/examples/js-openai/package-lock.json +0 -256
- package/examples/js-openai/package.json +0 -15
- package/examples/js-transformers/index.mjs +0 -65
- package/examples/js-transformers/package-lock.json +0 -1418
- package/examples/js-transformers/package.json +0 -15
- package/examples/js-youtube-transcripts/index.mjs +0 -135
- package/examples/js-youtube-transcripts/package.json +0 -15
- package/examples/ts/data/sample-lancedb/vectors.lance/_latest.manifest +0 -0
- package/examples/ts/data/sample-lancedb/vectors.lance/_transactions/0-adde4e05-fcfc-415c-86a6-5b252cb9e79a.txn +0 -0
- package/examples/ts/data/sample-lancedb/vectors.lance/_versions/1.manifest +0 -0
- package/examples/ts/data/sample-lancedb/vectors.lance/data/3618b33e-3eea-4b5e-a0fc-7d1f718d551e.lance +0 -0
- package/examples/ts/package-lock.json +0 -1340
- package/examples/ts/package.json +0 -22
- package/examples/ts/tsconfig.json +0 -10
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lancedb-example-js-openai",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.mjs",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"author": "Lance Devs",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@lancedb/lancedb": "file:../..",
|
|
13
|
-
"openai": "^3.2.1"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 Lance Developers.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
/* global console */
|
|
18
|
-
|
|
19
|
-
import * as lancedb from "@lancedb/lancedb";
|
|
20
|
-
|
|
21
|
-
async function example() {
|
|
22
|
-
// Import transformers and the all-MiniLM-L6-v2 model (https://huggingface.co/Xenova/all-MiniLM-L6-v2)
|
|
23
|
-
const { pipeline } = await import("@xenova/transformers");
|
|
24
|
-
const pipe = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2");
|
|
25
|
-
|
|
26
|
-
// Create embedding function from pipeline which returns a list of vectors from batch
|
|
27
|
-
// sourceColumn is the name of the column in the data to be embedded
|
|
28
|
-
//
|
|
29
|
-
// Output of pipe is a Tensor { data: Float32Array(384) }, so filter for the vector
|
|
30
|
-
const embedFun = {};
|
|
31
|
-
embedFun.sourceColumn = "text";
|
|
32
|
-
embedFun.embed = async function (batch) {
|
|
33
|
-
let result = [];
|
|
34
|
-
for (let text of batch) {
|
|
35
|
-
const res = await pipe(text, { pooling: "mean", normalize: true });
|
|
36
|
-
result.push(Array.from(res["data"]));
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Link a folder and create a table with data
|
|
42
|
-
const db = await lancedb.connect("data/sample-lancedb");
|
|
43
|
-
|
|
44
|
-
const data = [
|
|
45
|
-
{ id: 1, text: "Cherry", type: "fruit" },
|
|
46
|
-
{ id: 2, text: "Carrot", type: "vegetable" },
|
|
47
|
-
{ id: 3, text: "Potato", type: "vegetable" },
|
|
48
|
-
{ id: 4, text: "Apple", type: "fruit" },
|
|
49
|
-
{ id: 5, text: "Banana", type: "fruit" },
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const table = await db.createTable("food_table", data, embedFun);
|
|
53
|
-
|
|
54
|
-
// Query the table
|
|
55
|
-
const results = await table
|
|
56
|
-
.search("a sweet fruit to eat")
|
|
57
|
-
.metricType("cosine")
|
|
58
|
-
.limit(2)
|
|
59
|
-
.execute();
|
|
60
|
-
console.log(results.map((r) => r.text));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
example()
|
|
64
|
-
.then(() => console.log("All done!"))
|
|
65
|
-
.catch(console.error);
|