weaviate-client
Version:
JS/TS client for Weaviate
64 lines (63 loc) • 2.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Check = void 0;
const errors_js_1 = require("../../errors.js");
const index_js_1 = require("../serialize/index.js");
class Check {
connection;
name;
dbVersionSupport;
consistencyLevel;
tenant;
constructor(connection, name, dbVersionSupport, consistencyLevel, tenant) {
this.connection = connection;
this.name = name;
this.dbVersionSupport = dbVersionSupport;
this.consistencyLevel = consistencyLevel;
this.tenant = tenant;
}
getSearcher = (callOpts) => this.connection.search(this.name, this.consistencyLevel, this.tenant, callOpts?.abortSignal);
checkSupportForVectors = async (vec) => {
if (vec === undefined || index_js_1.Serialize.isHybridNearTextSearch(vec))
return false;
const check = await this.dbVersionSupport.supportsVectorsFieldInGRPC();
return check.supports;
};
supportForSingleGroupedGenerative = async () => {
const check = await this.dbVersionSupport.supportsSingleGrouped();
if (!check.supports)
throw new errors_js_1.WeaviateUnsupportedFeatureError(check.message);
return check.supports;
};
supportForGenerativeConfigRuntime = async (generativeConfig) => {
if (generativeConfig === undefined)
return true;
const check = await this.dbVersionSupport.supportsGenerativeConfigRuntime();
if (!check.supports)
throw new errors_js_1.WeaviateUnsupportedFeatureError(check.message);
return check.supports;
};
nearSearch = (callOpts) => this.getSearcher(callOpts).then((search) => ({ search }));
nearVector = (vec, opts, callOpts) => {
return Promise.all([this.getSearcher(callOpts), this.checkSupportForVectors(vec)]).then(([search, supportsVectors]) => {
const is129 = supportsVectors;
return {
search,
supportsVectors: is129,
};
});
};
hybridSearch = (opts, callOpts) => {
return Promise.all([this.getSearcher(callOpts), this.checkSupportForVectors(opts?.vector)]).then(([search, supportsVectors]) => {
const is129 = supportsVectors;
return {
search,
supportsVectors: is129,
};
});
};
fetchObjects = (callOpts) => this.getSearcher(callOpts).then((search) => ({ search }));
fetchObjectById = (callOpts) => this.getSearcher(callOpts).then((search) => ({ search }));
bm25 = (callOpts) => this.getSearcher(callOpts).then((search) => ({ search }));
}
exports.Check = Check;