presubmit 0.1.0
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/LICENSE +202 -0
- package/README.md +51 -0
- package/THIRD_PARTY_NOTICES.md +24 -0
- package/apps/web/dist/assets/FileCode-CZZH52o7.js +5 -0
- package/apps/web/dist/assets/FileCode-DovDO7Jh.css +1 -0
- package/apps/web/dist/assets/SettingsPage-CRvOwdjt.js +4 -0
- package/apps/web/dist/assets/SettingsPage-UbYSCwJj.css +1 -0
- package/apps/web/dist/assets/TerminalPanel-0sw-J6YS.css +1 -0
- package/apps/web/dist/assets/TerminalPanel-BqUjPWav.js +16 -0
- package/apps/web/dist/assets/index-BhqNNFja.js +54 -0
- package/apps/web/dist/assets/index-DD8VXy8H.css +1 -0
- package/apps/web/dist/assets/presubmit-mark-BBQ19Fmr.svg +7 -0
- package/apps/web/dist/assets/presubmit-mark-busy-CwBC-7on.svg +8 -0
- package/apps/web/dist/assets/react-vendor-wiHys0m2.js +9 -0
- package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/apps/web/dist/index.html +6 -0
- package/apps/web/dist/service-worker.js +11 -0
- package/dist/apps/server/src/agent-builder.js +204 -0
- package/dist/apps/server/src/attach.js +163 -0
- package/dist/apps/server/src/attachments.js +86 -0
- package/dist/apps/server/src/browser-access.js +131 -0
- package/dist/apps/server/src/check-provenance.js +95 -0
- package/dist/apps/server/src/check-supervisor.js +112 -0
- package/dist/apps/server/src/checks.js +402 -0
- package/dist/apps/server/src/child-collaboration-guidance.js +2 -0
- package/dist/apps/server/src/child-sessions.js +191 -0
- package/dist/apps/server/src/cli.js +162 -0
- package/dist/apps/server/src/conversation-search.js +12 -0
- package/dist/apps/server/src/coordinator-messages.js +72 -0
- package/dist/apps/server/src/dev-auth.js +54 -0
- package/dist/apps/server/src/dev-server.js +201 -0
- package/dist/apps/server/src/dev-worker.js +48 -0
- package/dist/apps/server/src/diagnostics.js +105 -0
- package/dist/apps/server/src/fast-mode.js +8 -0
- package/dist/apps/server/src/folder-picker.js +54 -0
- package/dist/apps/server/src/git-blobs.js +62 -0
- package/dist/apps/server/src/git-handoff.js +127 -0
- package/dist/apps/server/src/history-sources.js +59 -0
- package/dist/apps/server/src/hub.js +159 -0
- package/dist/apps/server/src/internal-transport.js +38 -0
- package/dist/apps/server/src/local-embeddings.js +70 -0
- package/dist/apps/server/src/ollama-setup.js +56 -0
- package/dist/apps/server/src/planning.js +30 -0
- package/dist/apps/server/src/project-agents.js +276 -0
- package/dist/apps/server/src/project-memory.js +94 -0
- package/dist/apps/server/src/projects.js +106 -0
- package/dist/apps/server/src/queued-launch.js +13 -0
- package/dist/apps/server/src/reply-search.js +172 -0
- package/dist/apps/server/src/review-context.js +60 -0
- package/dist/apps/server/src/review-refresh.js +14 -0
- package/dist/apps/server/src/reviewers.js +75 -0
- package/dist/apps/server/src/search-settings.js +22 -0
- package/dist/apps/server/src/semantic-history.js +186 -0
- package/dist/apps/server/src/server.js +4338 -0
- package/dist/apps/server/src/session-changes.js +181 -0
- package/dist/apps/server/src/session-router-settings.js +198 -0
- package/dist/apps/server/src/session-workspaces.js +135 -0
- package/dist/apps/server/src/sessions.js +579 -0
- package/dist/apps/server/src/shared-auth.js +70 -0
- package/dist/apps/server/src/shell-evaluator-settings.js +53 -0
- package/dist/apps/server/src/store.js +203 -0
- package/dist/apps/server/src/tailscale-process.js +115 -0
- package/dist/apps/server/src/tailscale-serve-worker.js +33 -0
- package/dist/apps/server/src/tailscale-serve.js +276 -0
- package/dist/apps/server/src/task-capacity.js +92 -0
- package/dist/apps/server/src/task-graph.js +190 -0
- package/dist/apps/server/src/task-logs.js +74 -0
- package/dist/apps/server/src/task-numbers.js +25 -0
- package/dist/apps/server/src/task-orchestrator.js +1088 -0
- package/dist/apps/server/src/terminal.js +182 -0
- package/dist/apps/server/src/terminals.js +80 -0
- package/dist/apps/server/src/tool-safety.js +2 -0
- package/dist/apps/server/src/workspace-lock.js +140 -0
- package/dist/apps/server/src/workspace-watcher.js +65 -0
- package/dist/apps/server/src/workspace.js +517 -0
- package/dist/packages/agent-pi/src/agent-builder-tool.js +32 -0
- package/dist/packages/agent-pi/src/agent-capabilities.js +44 -0
- package/dist/packages/agent-pi/src/ask-user.js +86 -0
- package/dist/packages/agent-pi/src/auth.js +510 -0
- package/dist/packages/agent-pi/src/check-tools.js +72 -0
- package/dist/packages/agent-pi/src/command-policy.js +246 -0
- package/dist/packages/agent-pi/src/coordinator-tools.js +122 -0
- package/dist/packages/agent-pi/src/fast-mode.js +67 -0
- package/dist/packages/agent-pi/src/file-tools.js +163 -0
- package/dist/packages/agent-pi/src/history-tool.js +40 -0
- package/dist/packages/agent-pi/src/history.js +34 -0
- package/dist/packages/agent-pi/src/index.js +177 -0
- package/dist/packages/agent-pi/src/ipc.js +314 -0
- package/dist/packages/agent-pi/src/jev-session-router.js +408 -0
- package/dist/packages/agent-pi/src/jev-tools.js +71 -0
- package/dist/packages/agent-pi/src/local-model.js +277 -0
- package/dist/packages/agent-pi/src/memory-tools.js +119 -0
- package/dist/packages/agent-pi/src/model.js +25 -0
- package/dist/packages/agent-pi/src/planning.js +206 -0
- package/dist/packages/agent-pi/src/resource-loader.js +23 -0
- package/dist/packages/agent-pi/src/review-tools.js +158 -0
- package/dist/packages/agent-pi/src/review-transition.js +73 -0
- package/dist/packages/agent-pi/src/review.js +40 -0
- package/dist/packages/agent-pi/src/routing.js +27 -0
- package/dist/packages/agent-pi/src/session-setup.js +118 -0
- package/dist/packages/agent-pi/src/shell-context.js +51 -0
- package/dist/packages/agent-pi/src/shell-policy.js +281 -0
- package/dist/packages/agent-pi/src/shell-safety.js +205 -0
- package/dist/packages/agent-pi/src/shell.js +121 -0
- package/dist/packages/agent-pi/src/snapshot-permissions.js +12 -0
- package/dist/packages/agent-pi/src/spike.js +41 -0
- package/dist/packages/agent-pi/src/task-tools.js +53 -0
- package/dist/packages/agent-pi/src/types.js +1 -0
- package/dist/packages/agent-pi/src/usage.js +30 -0
- package/dist/packages/agent-pi/src/worker.js +602 -0
- package/dist/packages/protocol/src/activity-summary.js +77 -0
- package/dist/packages/protocol/src/agents.js +301 -0
- package/dist/packages/protocol/src/browser-access.js +1 -0
- package/dist/packages/protocol/src/checks.js +40 -0
- package/dist/packages/protocol/src/child-sessions.js +28 -0
- package/dist/packages/protocol/src/command-policy.js +3 -0
- package/dist/packages/protocol/src/coordinator.js +135 -0
- package/dist/packages/protocol/src/delegation.js +40 -0
- package/dist/packages/protocol/src/git-diff.js +71 -0
- package/dist/packages/protocol/src/git-handoff.js +1 -0
- package/dist/packages/protocol/src/index.js +1 -0
- package/dist/packages/protocol/src/memory.js +46 -0
- package/dist/packages/protocol/src/metrics.js +70 -0
- package/dist/packages/protocol/src/planning.js +138 -0
- package/dist/packages/protocol/src/retrieval.js +36 -0
- package/dist/packages/protocol/src/reviewers.js +17 -0
- package/dist/packages/protocol/src/search.js +16 -0
- package/dist/packages/protocol/src/session-changes.js +29 -0
- package/dist/packages/protocol/src/session-router.js +123 -0
- package/dist/packages/protocol/src/shell-evaluator.js +43 -0
- package/dist/packages/protocol/src/task-graph.js +1 -0
- package/dist/packages/protocol/src/token-usage.js +17 -0
- package/dist/packages/protocol/src/user-questions.js +106 -0
- package/package.json +71 -0
- package/vendor/lancedb/NODEJS_THIRD_PARTY_LICENSES.md +668 -0
- package/vendor/lancedb/RUST_THIRD_PARTY_LICENSES.html +14607 -0
- package/vendor/lancedb/dist/arrow.d.ts +296 -0
- package/vendor/lancedb/dist/arrow.js +1145 -0
- package/vendor/lancedb/dist/arrow_type.d.ts +9 -0
- package/vendor/lancedb/dist/arrow_type.js +29 -0
- package/vendor/lancedb/dist/connection.d.ts +508 -0
- package/vendor/lancedb/dist/connection.js +298 -0
- package/vendor/lancedb/dist/embedding/embedding_function.d.ts +103 -0
- package/vendor/lancedb/dist/embedding/embedding_function.js +192 -0
- package/vendor/lancedb/dist/embedding/index.d.ts +37 -0
- package/vendor/lancedb/dist/embedding/index.js +108 -0
- package/vendor/lancedb/dist/embedding/openai.d.ts +16 -0
- package/vendor/lancedb/dist/embedding/openai.js +81 -0
- package/vendor/lancedb/dist/embedding/registry.d.ts +94 -0
- package/vendor/lancedb/dist/embedding/registry.js +221 -0
- package/vendor/lancedb/dist/embedding/transformers.d.ts +36 -0
- package/vendor/lancedb/dist/embedding/transformers.js +110 -0
- package/vendor/lancedb/dist/header.d.ts +162 -0
- package/vendor/lancedb/dist/header.js +217 -0
- package/vendor/lancedb/dist/index.d.ts +246 -0
- package/vendor/lancedb/dist/index.js +176 -0
- package/vendor/lancedb/dist/indices.d.ts +721 -0
- package/vendor/lancedb/dist/indices.js +166 -0
- package/vendor/lancedb/dist/materialized_view.d.ts +69 -0
- package/vendor/lancedb/dist/materialized_view.js +112 -0
- package/vendor/lancedb/dist/merge.d.ts +104 -0
- package/vendor/lancedb/dist/merge.js +120 -0
- package/vendor/lancedb/dist/native.d.ts +1193 -0
- package/vendor/lancedb/dist/native.js +688 -0
- package/vendor/lancedb/dist/oauth.d.ts +66 -0
- package/vendor/lancedb/dist/oauth.js +15 -0
- package/vendor/lancedb/dist/otel.d.ts +26 -0
- package/vendor/lancedb/dist/otel.js +114 -0
- package/vendor/lancedb/dist/permutation.d.ts +143 -0
- package/vendor/lancedb/dist/permutation.js +184 -0
- package/vendor/lancedb/dist/query.d.ts +663 -0
- package/vendor/lancedb/dist/query.js +966 -0
- package/vendor/lancedb/dist/rerankers/index.d.ts +5 -0
- package/vendor/lancedb/dist/rerankers/index.js +19 -0
- package/vendor/lancedb/dist/rerankers/rrf.d.ts +14 -0
- package/vendor/lancedb/dist/rerankers/rrf.js +28 -0
- package/vendor/lancedb/dist/sanitize.d.ts +32 -0
- package/vendor/lancedb/dist/sanitize.js +544 -0
- package/vendor/lancedb/dist/scannable.d.ts +92 -0
- package/vendor/lancedb/dist/scannable.js +200 -0
- package/vendor/lancedb/dist/schema.d.ts +16 -0
- package/vendor/lancedb/dist/schema.js +387 -0
- package/vendor/lancedb/dist/table.d.ts +1069 -0
- package/vendor/lancedb/dist/table.js +498 -0
- package/vendor/lancedb/dist/util.d.ts +14 -0
- package/vendor/lancedb/dist/util.js +77 -0
- package/vendor/lancedb/license_header.txt +2 -0
- package/vendor/lancedb/package.json +56 -0
- package/vendor/transformers/LICENSE +202 -0
- package/vendor/transformers/dist/transformers.cjs +30844 -0
- package/vendor/transformers/dist/transformers.mjs +31404 -0
- package/vendor/transformers/package.json +55 -0
- package/vendor/transformers/types/backends/onnx.d.ts +30 -0
- package/vendor/transformers/types/configs.d.ts +85 -0
- package/vendor/transformers/types/env.d.ts +110 -0
- package/vendor/transformers/types/generation/configuration_utils.d.ts +320 -0
- package/vendor/transformers/types/generation/logits_process.d.ts +354 -0
- package/vendor/transformers/types/generation/logits_sampler.d.ts +51 -0
- package/vendor/transformers/types/generation/parameters.d.ts +47 -0
- package/vendor/transformers/types/generation/stopping_criteria.d.ts +81 -0
- package/vendor/transformers/types/generation/streamers.d.ts +81 -0
- package/vendor/transformers/types/models/whisper/common_whisper.d.ts +8 -0
- package/vendor/transformers/types/models/whisper/generation_whisper.d.ts +76 -0
- package/vendor/transformers/types/models.d.ts +3684 -0
- package/vendor/transformers/types/ops/registry.d.ts +11 -0
- package/vendor/transformers/types/pipelines.d.ts +2402 -0
- package/vendor/transformers/types/processors.d.ts +924 -0
- package/vendor/transformers/types/tokenizers.d.ts +990 -0
- package/vendor/transformers/types/transformers.d.ts +13 -0
- package/vendor/transformers/types/utils/audio.d.ts +130 -0
- package/vendor/transformers/types/utils/constants.d.ts +2 -0
- package/vendor/transformers/types/utils/core.d.ts +98 -0
- package/vendor/transformers/types/utils/data-structures.d.ts +236 -0
- package/vendor/transformers/types/utils/devices.d.ts +18 -0
- package/vendor/transformers/types/utils/dtypes.d.ts +19 -0
- package/vendor/transformers/types/utils/generic.d.ts +11 -0
- package/vendor/transformers/types/utils/hub.d.ts +152 -0
- package/vendor/transformers/types/utils/image.d.ts +119 -0
- package/vendor/transformers/types/utils/maths.d.ts +280 -0
- package/vendor/transformers/types/utils/tensor.d.ts +418 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.LocalConnection = exports.Connection = void 0;
|
|
6
|
+
exports.cleanseStorageOptions = cleanseStorageOptions;
|
|
7
|
+
const apache_arrow_1 = require("apache-arrow");
|
|
8
|
+
const arrow_1 = require("./arrow");
|
|
9
|
+
const arrow_2 = require("./arrow");
|
|
10
|
+
const registry_1 = require("./embedding/registry");
|
|
11
|
+
const materialized_view_1 = require("./materialized_view");
|
|
12
|
+
const sanitize_1 = require("./sanitize");
|
|
13
|
+
const table_1 = require("./table");
|
|
14
|
+
/**
|
|
15
|
+
* A LanceDB Connection that allows you to open tables and create new ones.
|
|
16
|
+
*
|
|
17
|
+
* Connection could be local against filesystem or remote against a server.
|
|
18
|
+
*
|
|
19
|
+
* A Connection is intended to be a long lived object and may hold open
|
|
20
|
+
* resources such as HTTP connection pools. This is generally fine and
|
|
21
|
+
* a single connection should be shared if it is going to be used many
|
|
22
|
+
* times. However, if you are finished with a connection, you may call
|
|
23
|
+
* close to eagerly free these resources. Any call to a Connection
|
|
24
|
+
* method after it has been closed will result in an error.
|
|
25
|
+
*
|
|
26
|
+
* Closing a connection is optional. Connections will automatically
|
|
27
|
+
* be closed when they are garbage collected.
|
|
28
|
+
*
|
|
29
|
+
* Any created tables are independent and will continue to work even if
|
|
30
|
+
* the underlying connection has been closed.
|
|
31
|
+
* @hideconstructor
|
|
32
|
+
*/
|
|
33
|
+
class Connection {
|
|
34
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
35
|
+
return this.display();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Connection = Connection;
|
|
39
|
+
/** @hideconstructor */
|
|
40
|
+
class LocalConnection extends Connection {
|
|
41
|
+
inner;
|
|
42
|
+
/** @hidden */
|
|
43
|
+
constructor(inner) {
|
|
44
|
+
super();
|
|
45
|
+
this.inner = inner;
|
|
46
|
+
}
|
|
47
|
+
isOpen() {
|
|
48
|
+
return this.inner.isOpen();
|
|
49
|
+
}
|
|
50
|
+
close() {
|
|
51
|
+
this.inner.close();
|
|
52
|
+
}
|
|
53
|
+
display() {
|
|
54
|
+
return this.inner.display();
|
|
55
|
+
}
|
|
56
|
+
async tableNames(namespacePathOrOptions, options) {
|
|
57
|
+
// Detect if first argument is namespacePath array or options object
|
|
58
|
+
let namespacePath;
|
|
59
|
+
let tableNamesOptions;
|
|
60
|
+
if (Array.isArray(namespacePathOrOptions)) {
|
|
61
|
+
// First argument is namespacePath array
|
|
62
|
+
namespacePath = namespacePathOrOptions;
|
|
63
|
+
tableNamesOptions = options;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// First argument is options object (backwards compatibility)
|
|
67
|
+
namespacePath = undefined;
|
|
68
|
+
tableNamesOptions = namespacePathOrOptions;
|
|
69
|
+
}
|
|
70
|
+
return this.inner.tableNames(namespacePath ?? [], tableNamesOptions?.startAfter, tableNamesOptions?.limit);
|
|
71
|
+
}
|
|
72
|
+
async createMaterializedView(name, source, options) {
|
|
73
|
+
(0, materialized_view_1.validateNonNegativeInteger)(options?.limit, "limit");
|
|
74
|
+
const innerTable = await this.inner.createMaterializedView(name, source, (0, materialized_view_1.normalizeSelect)(options?.select), options?.where, options?.limit);
|
|
75
|
+
return new materialized_view_1.MaterializedView(new table_1.LocalTable(innerTable));
|
|
76
|
+
}
|
|
77
|
+
async openMaterializedView(name) {
|
|
78
|
+
const innerTable = await this.inner.openMaterializedView(name);
|
|
79
|
+
return new materialized_view_1.MaterializedView(new table_1.LocalTable(innerTable));
|
|
80
|
+
}
|
|
81
|
+
async listMaterializedViews() {
|
|
82
|
+
return await this.inner.listMaterializedViews();
|
|
83
|
+
}
|
|
84
|
+
async listTables(namespacePathOrOptions, options) {
|
|
85
|
+
// Detect if first argument is namespacePath array or options object
|
|
86
|
+
const namespacePath = Array.isArray(namespacePathOrOptions)
|
|
87
|
+
? namespacePathOrOptions
|
|
88
|
+
: undefined;
|
|
89
|
+
const listTablesOptions = Array.isArray(namespacePathOrOptions)
|
|
90
|
+
? options
|
|
91
|
+
: namespacePathOrOptions;
|
|
92
|
+
return this.inner.listTables(namespacePath ?? [], listTablesOptions?.pageToken, listTablesOptions?.limit);
|
|
93
|
+
}
|
|
94
|
+
async openTable(name, namespacePath, options) {
|
|
95
|
+
const innerTable = await this.inner.openTable(name, namespacePath ?? [], cleanseStorageOptions(options?.storageOptions), options?.indexCacheSize);
|
|
96
|
+
let table = new table_1.LocalTable(innerTable);
|
|
97
|
+
// "main" is the default branch, so treat it as no branch. On a real branch,
|
|
98
|
+
// scope and pin in one step (yielding "version V of branch B"); otherwise
|
|
99
|
+
// pin the version, if any, against main.
|
|
100
|
+
const branch = options?.branch != null && options.branch !== "main"
|
|
101
|
+
? options.branch
|
|
102
|
+
: undefined;
|
|
103
|
+
if (branch != null) {
|
|
104
|
+
table = await (await table.branches()).checkout(branch, options?.version);
|
|
105
|
+
}
|
|
106
|
+
else if (options?.version != null) {
|
|
107
|
+
await table.checkout(options.version);
|
|
108
|
+
}
|
|
109
|
+
return table;
|
|
110
|
+
}
|
|
111
|
+
async cloneTable(targetTableName, sourceUri, options) {
|
|
112
|
+
const innerTable = await this.inner.cloneTable(targetTableName, sourceUri, options?.targetNamespacePath ?? [], options?.sourceVersion ?? null, options?.sourceTag ?? null, options?.isShallow ?? true);
|
|
113
|
+
return new table_1.LocalTable(innerTable);
|
|
114
|
+
}
|
|
115
|
+
getStorageOptions(options) {
|
|
116
|
+
if (options?.dataStorageVersion !== undefined) {
|
|
117
|
+
if (options.storageOptions === undefined) {
|
|
118
|
+
options.storageOptions = {};
|
|
119
|
+
}
|
|
120
|
+
options.storageOptions["newTableDataStorageVersion"] =
|
|
121
|
+
options.dataStorageVersion;
|
|
122
|
+
}
|
|
123
|
+
if (options?.enableV2ManifestPaths !== undefined) {
|
|
124
|
+
if (options.storageOptions === undefined) {
|
|
125
|
+
options.storageOptions = {};
|
|
126
|
+
}
|
|
127
|
+
options.storageOptions["newTableEnableV2ManifestPaths"] =
|
|
128
|
+
options.enableV2ManifestPaths ? "true" : "false";
|
|
129
|
+
}
|
|
130
|
+
return cleanseStorageOptions(options?.storageOptions);
|
|
131
|
+
}
|
|
132
|
+
async createTable(nameOrOptions, dataOrNamespacePath, namespacePathOrOptions, options) {
|
|
133
|
+
if (typeof nameOrOptions !== "string" && "name" in nameOrOptions) {
|
|
134
|
+
// First overload: createTable(options, namespacePath?)
|
|
135
|
+
const { name, data, ...createOptions } = nameOrOptions;
|
|
136
|
+
const namespacePath = dataOrNamespacePath;
|
|
137
|
+
return this._createTableImpl(name, data, namespacePath, createOptions);
|
|
138
|
+
}
|
|
139
|
+
// Second overload: createTable(name, data, namespacePath?, options?)
|
|
140
|
+
const name = nameOrOptions;
|
|
141
|
+
const data = dataOrNamespacePath;
|
|
142
|
+
// Detect if third argument is namespacePath array or options object
|
|
143
|
+
let namespacePath;
|
|
144
|
+
let createOptions;
|
|
145
|
+
if (Array.isArray(namespacePathOrOptions)) {
|
|
146
|
+
// Third argument is namespacePath array
|
|
147
|
+
namespacePath = namespacePathOrOptions;
|
|
148
|
+
createOptions = options;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// Third argument is options object (backwards compatibility)
|
|
152
|
+
namespacePath = undefined;
|
|
153
|
+
createOptions = namespacePathOrOptions;
|
|
154
|
+
}
|
|
155
|
+
return this._createTableImpl(name, data, namespacePath, createOptions);
|
|
156
|
+
}
|
|
157
|
+
async _createTableImpl(name, data, namespacePath, options) {
|
|
158
|
+
if (data === undefined) {
|
|
159
|
+
throw new Error("data is required");
|
|
160
|
+
}
|
|
161
|
+
const { buf, mode } = await parseTableData(data, options);
|
|
162
|
+
const storageOptions = this.getStorageOptions(options);
|
|
163
|
+
const innerTable = await this.inner.createTable(name, buf, mode, namespacePath ?? [], storageOptions);
|
|
164
|
+
return new table_1.LocalTable(innerTable);
|
|
165
|
+
}
|
|
166
|
+
async createEmptyTable(name, schema, namespacePathOrOptions, options) {
|
|
167
|
+
// Detect if third argument is namespacePath array or options object
|
|
168
|
+
let namespacePath;
|
|
169
|
+
let createOptions;
|
|
170
|
+
if (Array.isArray(namespacePathOrOptions)) {
|
|
171
|
+
// Third argument is namespacePath array
|
|
172
|
+
namespacePath = namespacePathOrOptions;
|
|
173
|
+
createOptions = options;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Third argument is options object (backwards compatibility)
|
|
177
|
+
namespacePath = undefined;
|
|
178
|
+
createOptions = namespacePathOrOptions;
|
|
179
|
+
}
|
|
180
|
+
let mode = createOptions?.mode ?? "create";
|
|
181
|
+
const existOk = createOptions?.existOk ?? false;
|
|
182
|
+
if (mode === "create" && existOk) {
|
|
183
|
+
mode = "exist_ok";
|
|
184
|
+
}
|
|
185
|
+
let metadata = undefined;
|
|
186
|
+
if (createOptions?.embeddingFunction !== undefined) {
|
|
187
|
+
const embeddingFunction = createOptions.embeddingFunction;
|
|
188
|
+
const registry = (0, registry_1.getRegistry)();
|
|
189
|
+
metadata = registry.getTableMetadata([embeddingFunction]);
|
|
190
|
+
}
|
|
191
|
+
const storageOptions = this.getStorageOptions(createOptions);
|
|
192
|
+
const table = (0, arrow_2.makeEmptyTable)(schema, metadata);
|
|
193
|
+
const buf = await (0, arrow_2.fromTableToBuffer)(table);
|
|
194
|
+
const innerTable = await this.inner.createEmptyTable(name, buf, mode, namespacePath ?? [], storageOptions);
|
|
195
|
+
return new table_1.LocalTable(innerTable);
|
|
196
|
+
}
|
|
197
|
+
async dropTable(name, namespacePath) {
|
|
198
|
+
return this.inner.dropTable(name, namespacePath ?? []);
|
|
199
|
+
}
|
|
200
|
+
async dropTableAsync(name, namespacePath) {
|
|
201
|
+
return this.inner.dropTableAsync(name, namespacePath ?? []);
|
|
202
|
+
}
|
|
203
|
+
async dropAllTables(namespacePath) {
|
|
204
|
+
return this.inner.dropAllTables(namespacePath ?? []);
|
|
205
|
+
}
|
|
206
|
+
describeNamespace(namespacePath) {
|
|
207
|
+
return this.inner.describeNamespace(namespacePath);
|
|
208
|
+
}
|
|
209
|
+
listNamespaces(namespacePath, options) {
|
|
210
|
+
return this.inner.listNamespaces(namespacePath ?? [], options?.pageToken, options?.limit);
|
|
211
|
+
}
|
|
212
|
+
createNamespace(namespacePath, options) {
|
|
213
|
+
return this.inner.createNamespace(namespacePath, options?.mode, options?.properties);
|
|
214
|
+
}
|
|
215
|
+
dropNamespace(namespacePath, options) {
|
|
216
|
+
return this.inner.dropNamespace(namespacePath, options?.mode, options?.behavior);
|
|
217
|
+
}
|
|
218
|
+
async renameTable(currentName, newName, options) {
|
|
219
|
+
return this.inner.renameTable(currentName, newName, options?.namespacePath ?? [], options?.newNamespacePath);
|
|
220
|
+
}
|
|
221
|
+
job(jobId) {
|
|
222
|
+
return this.inner.job(jobId);
|
|
223
|
+
}
|
|
224
|
+
async listJobs() {
|
|
225
|
+
return this.inner.listJobs();
|
|
226
|
+
}
|
|
227
|
+
async getJob(jobId) {
|
|
228
|
+
return this.inner.getJob(jobId);
|
|
229
|
+
}
|
|
230
|
+
async cancelJob(jobId) {
|
|
231
|
+
return this.inner.cancelJob(jobId);
|
|
232
|
+
}
|
|
233
|
+
async jobHistory(jobId) {
|
|
234
|
+
const buf = await this.inner.jobHistory(jobId);
|
|
235
|
+
if (buf.length === 0) {
|
|
236
|
+
return new arrow_2.Table();
|
|
237
|
+
}
|
|
238
|
+
return (0, apache_arrow_1.tableFromIPC)(buf);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.LocalConnection = LocalConnection;
|
|
242
|
+
/**
|
|
243
|
+
* Takes storage options and makes all the keys snake case.
|
|
244
|
+
*/
|
|
245
|
+
function cleanseStorageOptions(options) {
|
|
246
|
+
if (options === undefined) {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
const result = {};
|
|
250
|
+
for (const [key, value] of Object.entries(options)) {
|
|
251
|
+
if (value !== undefined) {
|
|
252
|
+
const newKey = camelToSnakeCase(key);
|
|
253
|
+
result[newKey] = value;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Convert a string to snake case. It might already be snake case, in which case it is
|
|
260
|
+
* returned unchanged.
|
|
261
|
+
*/
|
|
262
|
+
function camelToSnakeCase(camel) {
|
|
263
|
+
if (camel.includes("_")) {
|
|
264
|
+
// Assume if there is at least one underscore, it is already snake case
|
|
265
|
+
return camel;
|
|
266
|
+
}
|
|
267
|
+
if (camel.toLocaleUpperCase() === camel) {
|
|
268
|
+
// Assume if the string is all uppercase, it is already snake case
|
|
269
|
+
return camel;
|
|
270
|
+
}
|
|
271
|
+
let result = camel.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
272
|
+
if (result.startsWith("_")) {
|
|
273
|
+
result = result.slice(1);
|
|
274
|
+
}
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
async function parseTableData(data, options, streaming = false) {
|
|
278
|
+
let mode = options?.mode ?? "create";
|
|
279
|
+
const existOk = options?.existOk ?? false;
|
|
280
|
+
if (mode === "create" && existOk) {
|
|
281
|
+
mode = "exist_ok";
|
|
282
|
+
}
|
|
283
|
+
let table;
|
|
284
|
+
if ((0, arrow_1.isArrowTable)(data)) {
|
|
285
|
+
table = (0, sanitize_1.sanitizeTable)(data);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
table = (0, arrow_1.makeArrowTable)(data, options);
|
|
289
|
+
}
|
|
290
|
+
if (streaming) {
|
|
291
|
+
const buf = await (0, arrow_1.fromTableToStreamBuffer)(table, options?.embeddingFunction, options?.schema);
|
|
292
|
+
return { buf, mode };
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
const buf = await (0, arrow_2.fromTableToBuffer)(table, options?.embeddingFunction, options?.schema);
|
|
296
|
+
return { buf, mode };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { DataType, Float, type IntoVector } from "../arrow";
|
|
3
|
+
/**
|
|
4
|
+
* Options for a given embedding function
|
|
5
|
+
*/
|
|
6
|
+
export interface FunctionOptions {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface EmbeddingFunctionConstructor<T extends EmbeddingFunction = EmbeddingFunction> {
|
|
10
|
+
new (modelOptions?: T["TOptions"]): T;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An embedding function that automatically creates vector representation for a given column.
|
|
14
|
+
*
|
|
15
|
+
* It's important subclasses pass the **original** options to the super constructor
|
|
16
|
+
* and then pass those options to `resolveVariables` to resolve any variables before
|
|
17
|
+
* using them.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* class MyEmbeddingFunction extends EmbeddingFunction {
|
|
22
|
+
* constructor(options: {model: string, timeout: number}) {
|
|
23
|
+
* super(optionsRaw);
|
|
24
|
+
* const options = this.resolveVariables(optionsRaw);
|
|
25
|
+
* this.model = options.model;
|
|
26
|
+
* this.timeout = options.timeout;
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare abstract class EmbeddingFunction<T = any, M extends FunctionOptions = FunctionOptions> {
|
|
32
|
+
#private;
|
|
33
|
+
/**
|
|
34
|
+
* @ignore
|
|
35
|
+
* This is only used for associating the options type with the class for type checking
|
|
36
|
+
*/
|
|
37
|
+
readonly TOptions: M;
|
|
38
|
+
/**
|
|
39
|
+
* Get the original arguments to the constructor, to serialize them so they
|
|
40
|
+
* can be used to recreate the embedding function later.
|
|
41
|
+
*/
|
|
42
|
+
toJSON(): Record<string, any>;
|
|
43
|
+
constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Provide a list of keys in the function options that should be treated as
|
|
46
|
+
* sensitive. If users pass raw values for these keys, they will be rejected.
|
|
47
|
+
*/
|
|
48
|
+
protected getSensitiveKeys(): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Apply variables to the config.
|
|
51
|
+
*/
|
|
52
|
+
protected resolveVariables(config: Partial<M>): Partial<M>;
|
|
53
|
+
/**
|
|
54
|
+
* Optionally load any resources needed for the embedding function.
|
|
55
|
+
*
|
|
56
|
+
* This method is called after the embedding function has been initialized
|
|
57
|
+
* but before any embeddings are computed. It is useful for loading local models
|
|
58
|
+
* or other resources that are needed for the embedding function to work.
|
|
59
|
+
*/
|
|
60
|
+
init?(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* sourceField is used in combination with `LanceSchema` to provide a declarative data model
|
|
63
|
+
*
|
|
64
|
+
* @param optionsOrDatatype - The options for the field or the datatype
|
|
65
|
+
*
|
|
66
|
+
* @see {@link LanceSchema}
|
|
67
|
+
*/
|
|
68
|
+
sourceField(optionsOrDatatype: Partial<FieldOptions> | DataType): [DataType, Map<string, EmbeddingFunction>];
|
|
69
|
+
/**
|
|
70
|
+
* vectorField is used in combination with `LanceSchema` to provide a declarative data model
|
|
71
|
+
*
|
|
72
|
+
* @param optionsOrDatatype - The options for the field
|
|
73
|
+
*
|
|
74
|
+
* @see {@link LanceSchema}
|
|
75
|
+
*/
|
|
76
|
+
vectorField(optionsOrDatatype?: Partial<FieldOptions> | DataType): [DataType, Map<string, EmbeddingFunction>];
|
|
77
|
+
/** The number of dimensions of the embeddings */
|
|
78
|
+
ndims(): number | undefined;
|
|
79
|
+
/** The datatype of the embeddings */
|
|
80
|
+
abstract embeddingDataType(): Float;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a vector representation for the given values.
|
|
83
|
+
*/
|
|
84
|
+
abstract computeSourceEmbeddings(data: T[]): Promise<number[][] | Float32Array[] | Float64Array[]>;
|
|
85
|
+
/**
|
|
86
|
+
Compute the embeddings for a single query
|
|
87
|
+
*/
|
|
88
|
+
computeQueryEmbeddings(data: T): Promise<Awaited<IntoVector>>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* an abstract class for implementing embedding functions that take text as input
|
|
92
|
+
*/
|
|
93
|
+
export declare abstract class TextEmbeddingFunction<M extends FunctionOptions = FunctionOptions> extends EmbeddingFunction<string, M> {
|
|
94
|
+
abstract generateEmbeddings(texts: string[], ...args: any[]): Promise<number[][] | Float32Array[] | Float64Array[]>;
|
|
95
|
+
computeQueryEmbeddings(data: string): Promise<Awaited<IntoVector>>;
|
|
96
|
+
embeddingDataType(): Float;
|
|
97
|
+
sourceField(): [DataType, Map<string, EmbeddingFunction>];
|
|
98
|
+
computeSourceEmbeddings(data: string[]): Promise<number[][] | Float32Array[] | Float64Array[]>;
|
|
99
|
+
}
|
|
100
|
+
export interface FieldOptions<T extends DataType = DataType> {
|
|
101
|
+
datatype: T;
|
|
102
|
+
dims?: number;
|
|
103
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.TextEmbeddingFunction = exports.EmbeddingFunction = void 0;
|
|
6
|
+
require("reflect-metadata");
|
|
7
|
+
const arrow_1 = require("../arrow");
|
|
8
|
+
const sanitize_1 = require("../sanitize");
|
|
9
|
+
const registry_1 = require("./registry");
|
|
10
|
+
/**
|
|
11
|
+
* An embedding function that automatically creates vector representation for a given column.
|
|
12
|
+
*
|
|
13
|
+
* It's important subclasses pass the **original** options to the super constructor
|
|
14
|
+
* and then pass those options to `resolveVariables` to resolve any variables before
|
|
15
|
+
* using them.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* class MyEmbeddingFunction extends EmbeddingFunction {
|
|
20
|
+
* constructor(options: {model: string, timeout: number}) {
|
|
21
|
+
* super(optionsRaw);
|
|
22
|
+
* const options = this.resolveVariables(optionsRaw);
|
|
23
|
+
* this.model = options.model;
|
|
24
|
+
* this.timeout = options.timeout;
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class EmbeddingFunction {
|
|
30
|
+
/**
|
|
31
|
+
* @ignore
|
|
32
|
+
* This is only used for associating the options type with the class for type checking
|
|
33
|
+
*/
|
|
34
|
+
// biome-ignore lint/style/useNamingConvention: we want to keep the name as it is
|
|
35
|
+
TOptions;
|
|
36
|
+
#config;
|
|
37
|
+
/**
|
|
38
|
+
* Get the original arguments to the constructor, to serialize them so they
|
|
39
|
+
* can be used to recreate the embedding function later.
|
|
40
|
+
*/
|
|
41
|
+
// biome-ignore lint/suspicious/noExplicitAny :
|
|
42
|
+
toJSON() {
|
|
43
|
+
return JSON.parse(JSON.stringify(this.#config));
|
|
44
|
+
}
|
|
45
|
+
constructor() {
|
|
46
|
+
this.#config = {};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Provide a list of keys in the function options that should be treated as
|
|
50
|
+
* sensitive. If users pass raw values for these keys, they will be rejected.
|
|
51
|
+
*/
|
|
52
|
+
getSensitiveKeys() {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Apply variables to the config.
|
|
57
|
+
*/
|
|
58
|
+
resolveVariables(config) {
|
|
59
|
+
this.#config = config;
|
|
60
|
+
const registry = (0, registry_1.getRegistry)();
|
|
61
|
+
const newConfig = { ...config };
|
|
62
|
+
for (const [key_, value] of Object.entries(newConfig)) {
|
|
63
|
+
if (this.getSensitiveKeys().includes(key_) &&
|
|
64
|
+
!value.startsWith("$var:")) {
|
|
65
|
+
throw new Error(`The key "${key_}" is sensitive and cannot be set directly. Please use the $var: syntax to set it.`);
|
|
66
|
+
}
|
|
67
|
+
// Makes TS happy (https://stackoverflow.com/a/78391854)
|
|
68
|
+
const key = key_;
|
|
69
|
+
if (typeof value === "string" && value.startsWith("$var:")) {
|
|
70
|
+
const [name, defaultValue] = value.slice(5).split(":", 2);
|
|
71
|
+
const variableValue = registry.getVar(name);
|
|
72
|
+
if (!variableValue) {
|
|
73
|
+
if (defaultValue) {
|
|
74
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
75
|
+
newConfig[key] = defaultValue;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new Error(`Variable "${name}" not found`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
83
|
+
newConfig[key] = variableValue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return newConfig;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* sourceField is used in combination with `LanceSchema` to provide a declarative data model
|
|
91
|
+
*
|
|
92
|
+
* @param optionsOrDatatype - The options for the field or the datatype
|
|
93
|
+
*
|
|
94
|
+
* @see {@link LanceSchema}
|
|
95
|
+
*/
|
|
96
|
+
sourceField(optionsOrDatatype) {
|
|
97
|
+
let datatype = "datatype" in optionsOrDatatype
|
|
98
|
+
? optionsOrDatatype.datatype
|
|
99
|
+
: optionsOrDatatype;
|
|
100
|
+
if (!datatype) {
|
|
101
|
+
throw new Error("Datatype is required");
|
|
102
|
+
}
|
|
103
|
+
datatype = (0, sanitize_1.sanitizeType)(datatype);
|
|
104
|
+
const metadata = new Map();
|
|
105
|
+
metadata.set("source_column_for", this);
|
|
106
|
+
return [datatype, metadata];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* vectorField is used in combination with `LanceSchema` to provide a declarative data model
|
|
110
|
+
*
|
|
111
|
+
* @param optionsOrDatatype - The options for the field
|
|
112
|
+
*
|
|
113
|
+
* @see {@link LanceSchema}
|
|
114
|
+
*/
|
|
115
|
+
vectorField(optionsOrDatatype) {
|
|
116
|
+
let dtype;
|
|
117
|
+
let vectorType;
|
|
118
|
+
let dims = this.ndims();
|
|
119
|
+
// `func.vectorField(new Float32())`
|
|
120
|
+
if (optionsOrDatatype === undefined) {
|
|
121
|
+
dtype = new arrow_1.Float32();
|
|
122
|
+
}
|
|
123
|
+
else if (!("datatype" in optionsOrDatatype)) {
|
|
124
|
+
dtype = (0, sanitize_1.sanitizeType)(optionsOrDatatype);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// `func.vectorField({
|
|
128
|
+
// datatype: new Float32(),
|
|
129
|
+
// dims: 10
|
|
130
|
+
// })`
|
|
131
|
+
dims = dims ?? optionsOrDatatype?.dims;
|
|
132
|
+
dtype = (0, sanitize_1.sanitizeType)(optionsOrDatatype?.datatype);
|
|
133
|
+
}
|
|
134
|
+
if (dtype !== undefined) {
|
|
135
|
+
// `func.vectorField(new FixedSizeList(dims, new Field("item", new Float32(), true)))`
|
|
136
|
+
// or `func.vectorField({datatype: new FixedSizeList(dims, new Field("item", new Float32(), true))})`
|
|
137
|
+
if ((0, arrow_1.isFixedSizeList)(dtype)) {
|
|
138
|
+
vectorType = dtype;
|
|
139
|
+
// `func.vectorField(new Float32())`
|
|
140
|
+
// or `func.vectorField({datatype: new Float32()})`
|
|
141
|
+
}
|
|
142
|
+
else if ((0, arrow_1.isFloat)(dtype)) {
|
|
143
|
+
// No `ndims` impl and no `{dims: n}` provided;
|
|
144
|
+
if (dims === undefined) {
|
|
145
|
+
throw new Error("ndims is required for vector field");
|
|
146
|
+
}
|
|
147
|
+
vectorType = (0, arrow_1.newVectorType)(dims, dtype);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw new Error("Expected FixedSizeList or Float as datatype for vector field");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (dims === undefined) {
|
|
155
|
+
throw new Error("ndims is required for vector field");
|
|
156
|
+
}
|
|
157
|
+
vectorType = new arrow_1.FixedSizeList(dims, new arrow_1.Field("item", new arrow_1.Float32(), true));
|
|
158
|
+
}
|
|
159
|
+
const metadata = new Map();
|
|
160
|
+
metadata.set("vector_column_for", this);
|
|
161
|
+
return [vectorType, metadata];
|
|
162
|
+
}
|
|
163
|
+
/** The number of dimensions of the embeddings */
|
|
164
|
+
ndims() {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
Compute the embeddings for a single query
|
|
169
|
+
*/
|
|
170
|
+
async computeQueryEmbeddings(data) {
|
|
171
|
+
return this.computeSourceEmbeddings([data]).then((embeddings) => embeddings[0]);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.EmbeddingFunction = EmbeddingFunction;
|
|
175
|
+
/**
|
|
176
|
+
* an abstract class for implementing embedding functions that take text as input
|
|
177
|
+
*/
|
|
178
|
+
class TextEmbeddingFunction extends EmbeddingFunction {
|
|
179
|
+
async computeQueryEmbeddings(data) {
|
|
180
|
+
return this.generateEmbeddings([data]).then((data) => data[0]);
|
|
181
|
+
}
|
|
182
|
+
embeddingDataType() {
|
|
183
|
+
return new arrow_1.Float32();
|
|
184
|
+
}
|
|
185
|
+
sourceField() {
|
|
186
|
+
return super.sourceField(new arrow_1.Utf8());
|
|
187
|
+
}
|
|
188
|
+
computeSourceEmbeddings(data) {
|
|
189
|
+
return this.generateEmbeddings(data);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.TextEmbeddingFunction = TextEmbeddingFunction;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Schema } from "../arrow";
|
|
2
|
+
import { EmbeddingFunction } from "./embedding_function";
|
|
3
|
+
import { EmbeddingFunctionRegistry } from "./registry";
|
|
4
|
+
export { FieldOptions, EmbeddingFunction, TextEmbeddingFunction, FunctionOptions, EmbeddingFunctionConstructor, } from "./embedding_function";
|
|
5
|
+
export { EmbeddingFunctionRegistry, parseEmbeddingMetadata, register, } from "./registry";
|
|
6
|
+
export type { CreateReturnType, EmbeddingFunctionConfig, EmbeddingFunctionCreate, EmbeddingMetadataEntry, ResolvedEmbeddingFunctionConfig, } from "./registry";
|
|
7
|
+
/**
|
|
8
|
+
* Get the global embedding function registry.
|
|
9
|
+
*
|
|
10
|
+
* LanceDB built-in providers are initialized when this public API is first
|
|
11
|
+
* used, so importing the root package does not change automatic search
|
|
12
|
+
* selection for tables without embedding metadata.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getRegistry(): EmbeddingFunctionRegistry;
|
|
15
|
+
/**
|
|
16
|
+
* Create a schema with embedding functions.
|
|
17
|
+
*
|
|
18
|
+
* @param fields
|
|
19
|
+
* @returns Schema
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* class MyEmbeddingFunction extends EmbeddingFunction {
|
|
23
|
+
* // ...
|
|
24
|
+
* }
|
|
25
|
+
* const func = new MyEmbeddingFunction();
|
|
26
|
+
* const schema = LanceSchema({
|
|
27
|
+
* id: new Int32(),
|
|
28
|
+
* text: func.sourceField(new Utf8()),
|
|
29
|
+
* vector: func.vectorField(),
|
|
30
|
+
* // optional: specify the datatype and/or dimensions
|
|
31
|
+
* vector2: func.vectorField({ datatype: new Float32(), dims: 3}),
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const table = await db.createTable("my_table", data, { schema });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function LanceSchema(fields: Record<string, [object, Map<string, EmbeddingFunction>] | object>): Schema;
|