@lancedb/lancedb
Advanced tools
Comparing version 0.13.0-beta.1 to 0.13.0
import { Schema } from "../arrow"; | ||
import { EmbeddingFunction } from "./embedding_function"; | ||
export { EmbeddingFunction, TextEmbeddingFunction } from "./embedding_function"; | ||
export * from "./openai"; | ||
export * from "./transformers"; | ||
export * from "./registry"; | ||
@@ -7,0 +5,0 @@ /** |
@@ -38,5 +38,2 @@ "use strict"; | ||
Object.defineProperty(exports, "TextEmbeddingFunction", { enumerable: true, get: function () { return embedding_function_1.TextEmbeddingFunction; } }); | ||
// We need to explicitly export '*' so that the `register` decorator actually registers the class. | ||
__exportStar(require("./openai"), exports); | ||
__exportStar(require("./transformers"), exports); | ||
__exportStar(require("./registry"), exports); | ||
@@ -43,0 +40,0 @@ /** |
import { type EmbeddingFunction, type EmbeddingFunctionConstructor } from "./embedding_function"; | ||
import "reflect-metadata"; | ||
import { OpenAIEmbeddingFunction } from "./openai"; | ||
import { TransformersEmbeddingFunction } from "./transformers"; | ||
type CreateReturnType<T> = T extends { | ||
@@ -30,4 +28,2 @@ init: () => Promise<void>; | ||
register<T extends EmbeddingFunctionConstructor = EmbeddingFunctionConstructor>(this: EmbeddingFunctionRegistry, alias?: string): (ctor: T) => any; | ||
get(name: "openai"): EmbeddingFunctionCreate<OpenAIEmbeddingFunction>; | ||
get(name: "huggingface"): EmbeddingFunctionCreate<TransformersEmbeddingFunction>; | ||
get<T extends EmbeddingFunction<unknown>>(name: string): EmbeddingFunctionCreate<T> | undefined; | ||
@@ -34,0 +30,0 @@ /** |
@@ -69,13 +69,13 @@ "use strict"; | ||
// since typescript transpiles `import` to `require`, we need to do this in an unsafe way | ||
// We can't use `require` because `@xenova/transformers` is an ESM module | ||
// We can't use `require` because `@huggingface/transformers` is an ESM module | ||
// and we can't use `import` directly because typescript will transpile it to `require`. | ||
// and we want to remain compatible with both ESM and CJS modules | ||
// so we use `eval` to bypass typescript for this specific import. | ||
transformers = await eval('import("@xenova/transformers")'); | ||
transformers = await eval('import("@huggingface/transformers")'); | ||
} | ||
catch (e) { | ||
throw new Error(`error loading @xenova/transformers\nReason: ${e}`); | ||
throw new Error(`error loading @huggingface/transformers\nReason: ${e}`); | ||
} | ||
try { | ||
this.#model = await transformers.AutoModel.from_pretrained(this.#modelName); | ||
this.#model = await transformers.AutoModel.from_pretrained(this.#modelName, { dtype: "fp32" }); | ||
} | ||
@@ -99,3 +99,4 @@ catch (e) { | ||
const config = this.#model.config; | ||
const ndims = config["hidden_size"]; | ||
// biome-ignore lint/style/useNamingConvention: we don't control this name. | ||
const ndims = config.hidden_size; | ||
if (!ndims) { | ||
@@ -102,0 +103,0 @@ throw new Error("hidden_size not found in model config, you may need to manually specify the embedding dimensions. "); |
@@ -277,2 +277,3 @@ /* tslint:disable */ | ||
column(column: string): void | ||
addQueryVector(vector: Float32Array): void | ||
distanceType(distanceType: string): void | ||
@@ -279,0 +280,0 @@ postfilter(): void |
@@ -270,2 +270,3 @@ import { Table as ArrowTable, type IntoVector, RecordBatch } from "./arrow"; | ||
bypassVectorIndex(): VectorQuery; | ||
addQueryVector(vector: IntoVector): VectorQuery; | ||
} | ||
@@ -313,2 +314,3 @@ /** A builder for LanceDB queries. */ | ||
nearestTo(vector: IntoVector): VectorQuery; | ||
nearestToText(query: string, columns?: string[]): Query; | ||
} |
@@ -412,2 +412,37 @@ "use strict"; | ||
} | ||
/* | ||
* Add a query vector to the search | ||
* | ||
* This method can be called multiple times to add multiple query vectors | ||
* to the search. If multiple query vectors are added, then they will be searched | ||
* in parallel, and the results will be concatenated. A column called `query_index` | ||
* will be added to indicate the index of the query vector that produced the result. | ||
* | ||
* Performance wise, this is equivalent to running multiple queries concurrently. | ||
*/ | ||
addQueryVector(vector) { | ||
if (vector instanceof Promise) { | ||
const res = (async () => { | ||
try { | ||
const v = await vector; | ||
const arr = Float32Array.from(v); | ||
// | ||
// biome-ignore lint/suspicious/noExplicitAny: we need to get the `inner`, but js has no package scoping | ||
const value = this.addQueryVector(arr); | ||
const inner = value.inner; | ||
return inner; | ||
} | ||
catch (e) { | ||
return Promise.reject(e); | ||
} | ||
})(); | ||
return new VectorQuery(res); | ||
} | ||
else { | ||
super.doCall((inner) => { | ||
inner.addQueryVector(Float32Array.from(vector)); | ||
}); | ||
return this; | ||
} | ||
} | ||
} | ||
@@ -492,3 +527,7 @@ exports.VectorQuery = VectorQuery; | ||
} | ||
nearestToText(query, columns) { | ||
this.doCall((inner) => inner.fullTextSearch(query, columns)); | ||
return this; | ||
} | ||
} | ||
exports.Query = Query; |
@@ -13,7 +13,9 @@ { | ||
], | ||
"version": "0.13.0-beta.1", | ||
"version": "0.13.0", | ||
"main": "dist/index.js", | ||
"exports": { | ||
".": "./dist/index.js", | ||
"./embedding": "./dist/embedding/index.js" | ||
"./embedding": "./dist/embedding/index.js", | ||
"./embedding/openai": "./dist/embedding/openai.js", | ||
"./embedding/transformers": "./dist/embedding/transformers.js" | ||
}, | ||
@@ -96,7 +98,7 @@ "types": "dist/index.d.ts", | ||
"optionalDependencies": { | ||
"@lancedb/lancedb-darwin-arm64": "0.13.0-beta.1", | ||
"@lancedb/lancedb-linux-arm64-gnu": "0.13.0-beta.1", | ||
"@lancedb/lancedb-darwin-x64": "0.13.0-beta.1", | ||
"@lancedb/lancedb-linux-x64-gnu": "0.13.0-beta.1", | ||
"@lancedb/lancedb-win32-x64-msvc": "0.13.0-beta.1" | ||
"@lancedb/lancedb-darwin-arm64": "0.13.0", | ||
"@lancedb/lancedb-linux-arm64-gnu": "0.13.0", | ||
"@lancedb/lancedb-darwin-x64": "0.13.0", | ||
"@lancedb/lancedb-linux-x64-gnu": "0.13.0", | ||
"@lancedb/lancedb-win32-x64-msvc": "0.13.0" | ||
}, | ||
@@ -103,0 +105,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
240916
5717