Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
pull_request:

env:
WEAVIATE_125: 1.25.34
WEAVIATE_126: 1.26.17
WEAVIATE_127: 1.27.27
WEAVIATE_128: 1.28.16
WEAVIATE_129: 1.29.9
Expand Down Expand Up @@ -42,8 +40,6 @@ jobs:
fail-fast: false
matrix:
versions: [
{ node: "22.x", weaviate: $WEAVIATE_125},
{ node: "22.x", weaviate: $WEAVIATE_126},
{ node: "22.x", weaviate: $WEAVIATE_127},
{ node: "22.x", weaviate: $WEAVIATE_128},
{ node: "22.x", weaviate: $WEAVIATE_129},
Expand Down
8 changes: 2 additions & 6 deletions src/collections/config/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ import {
} from './types/index.js';

export class MergeWithExisting {
static schema(
current: WeaviateClass,
supportsNamedVectors: boolean,
update?: CollectionConfigUpdate<any>
): WeaviateClass {
static schema(current: WeaviateClass, update?: CollectionConfigUpdate<any>): WeaviateClass {
if (update === undefined) return current;
if (update.description !== undefined) current.description = update.description;
if (update.propertyDescriptions !== undefined)
Expand All @@ -61,7 +57,7 @@ export class MergeWithExisting {
if (update.vectorizers !== undefined) {
if (Array.isArray(update.vectorizers)) {
current.vectorConfig = MergeWithExisting.vectors(current.vectorConfig, update.vectorizers);
} else if (supportsNamedVectors && current.vectorConfig !== undefined) {
} else if (current.vectorConfig !== undefined) {
const updateVectorizers = {
...update.vectorizers,
name: 'default',
Expand Down
13 changes: 3 additions & 10 deletions src/collections/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ const config = <T>(
.withProperty(resolveReference<any>(reference))
.do()
.then(() => {}),
addVector: async (vectors: VectorizersConfigAdd<T>) => {
const supportsDynamicVectorIndex = await dbVersionSupport.supportsDynamicVectorIndex();
const { vectorsConfig } = makeVectorsConfig(vectors, supportsDynamicVectorIndex);
addVector: (vectors: VectorizersConfigAdd<T>) => {
const { vectorsConfig } = makeVectorsConfig(vectors);
return new VectorAdder(connection).withClassName(name).withVectors(vectorsConfig).do();
},
get: () => getRaw().then(classToCollection<T>),
Expand Down Expand Up @@ -90,13 +89,7 @@ const config = <T>(
},
update: (config?: CollectionConfigUpdate<T>) => {
return getRaw()
.then(async (current) =>
MergeWithExisting.schema(
current,
await dbVersionSupport.supportsNamedVectors().then((s) => s.supports),
config
)
)
.then((current) => MergeWithExisting.schema(current, config))
.then((merged) => new ClassUpdater(connection).withClass(merged).do())
.then(() => {});
},
Expand Down
13 changes: 2 additions & 11 deletions src/collections/config/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
WeaviateDeserializationError,
WeaviateInvalidInputError,
WeaviateUnsupportedFeatureError,
} from '../../errors.js';
import { WeaviateDeserializationError, WeaviateInvalidInputError } from '../../errors.js';
import {
WeaviateBM25Config,
WeaviateClass,
Expand All @@ -17,7 +13,6 @@ import {
WeaviateVectorIndexConfig,
WeaviateVectorsConfig,
} from '../../openapi/types.js';
import { DbVersionSupport } from '../../utils/dbVersion.js';
import { MultiVectorEncodingGuards, QuantizerGuards, VectorIndexGuards } from '../configure/parsing.js';
import {
PropertyConfigCreate,
Expand Down Expand Up @@ -237,8 +232,7 @@ export const parseVectorizerConfig = (config?: VectorizerConfig): any => {
};

export const makeVectorsConfig = (
configVectorizers: VectorizersConfigCreate<any, any> | VectorizersConfigAdd<any>,
supportsDynamicVectorIndex: Awaited<ReturnType<DbVersionSupport['supportsDynamicVectorIndex']>>
configVectorizers: VectorizersConfigCreate<any, any> | VectorizersConfigAdd<any>
) => {
let vectorizers: string[] = [];
const vectorsConfig: Record<string, any> = {};
Expand All @@ -251,9 +245,6 @@ export const makeVectorsConfig = (
},
];
vectorizersConfig.forEach((v) => {
if (v.vectorIndex.name === 'dynamic' && !supportsDynamicVectorIndex.supports) {
throw new WeaviateUnsupportedFeatureError(supportsDynamicVectorIndex.message);
}
const vectorConfig: any = {
vectorIndexConfig: parseVectorIndex(v.vectorIndex),
vectorIndexType: v.vectorIndex.name,
Expand Down
17 changes: 3 additions & 14 deletions src/collections/deserialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,8 @@ const UINT16LEN = 2;
const UINT32LEN = 4;

export class Deserialize {
private supports125ListValue: boolean;

private constructor(supports125ListValue: boolean) {
this.supports125ListValue = supports125ListValue;
}

public static async use(support: DbVersionSupport): Promise<Deserialize> {
const supports125ListValue = await support.supports125ListValue().then((res) => res.supports);
return new Deserialize(supports125ListValue);
public static use(support: DbVersionSupport): Promise<Deserialize> {
return Promise.resolve(new Deserialize());
}

private static aggregateBoolean(
Expand Down Expand Up @@ -374,13 +367,9 @@ export class Deserialize {
if (value.boolValue !== undefined) return value.boolValue;
if (value.dateValue !== undefined) return new Date(value.dateValue);
if (value.intValue !== undefined) return value.intValue;
if (value.listValue !== undefined)
return this.supports125ListValue
? this.parseListValue(value.listValue)
: value.listValue.values.map((v) => this.parsePropertyValue(v));
if (value.listValue !== undefined) return this.parseListValue(value.listValue);
if (value.numberValue !== undefined) return value.numberValue;
if (value.objectValue !== undefined) return this.objectProperties(value.objectValue);
if (value.stringValue !== undefined) return value.stringValue;
if (value.textValue !== undefined) return value.textValue;
if (value.uuidValue !== undefined) return value.uuidValue;
if (value.blobValue !== undefined) return value.blobValue;
Expand Down
110 changes: 42 additions & 68 deletions src/collections/generate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GenerateManager<T, V> implements Generate<T, V> {
opts?: FetchObjectsOptions<T, V>
): Promise<GenerativeReturn<T, V, C>> {
return Promise.all([
this.check.fetchObjects(opts),
this.check.fetchObjects(),
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
Expand Down Expand Up @@ -116,7 +116,7 @@ class GenerateManager<T, V> implements Generate<T, V> {
C extends GenerativeConfigRuntime | undefined = undefined
>(query: string, generate: GenerateOptions<T, C>, opts?: Bm25Options<T, I>): GenerateReturn<T, RV, C> {
return Promise.all([
this.check.bm25(opts),
this.check.bm25(),
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
Expand Down Expand Up @@ -159,27 +159,19 @@ class GenerateManager<T, V> implements Generate<T, V> {
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
.then(
async ([
{ search, supportsTargets, supportsVectorsForTargets, supportsWeightsForTargets, supportsVectors },
supportsSingleGrouped,
]) => ({
search,
args: {
...(await Serialize.search.hybrid(
{
query,
supportsTargets,
supportsVectorsForTargets,
supportsWeightsForTargets,
supportsVectors,
},
opts
)),
generative: await Serialize.generative({ supportsSingleGrouped }, generate),
},
})
)
.then(async ([{ search, supportsVectors }, supportsSingleGrouped]) => ({
search,
args: {
...(await Serialize.search.hybrid(
{
query,
supportsVectors,
},
opts
)),
generative: await Serialize.generative({ supportsSingleGrouped }, generate),
},
}))
.then(({ search, args }) => search.withHybrid(args))
.then((reply) => this.parseGroupByReply(opts, reply));
}
Expand Down Expand Up @@ -212,18 +204,16 @@ class GenerateManager<T, V> implements Generate<T, V> {
opts?: NearOptions<T, V, I>
): GenerateReturn<T, RV, C> {
return Promise.all([
this.check.nearSearch(opts),
this.check.nearSearch(),
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
.then(async ([{ search, supportsTargets, supportsWeightsForTargets }, supportsSingleGrouped]) => ({
.then(async ([{ search }, supportsSingleGrouped]) => ({
search,
args: {
...Serialize.search.nearImage(
{
image: await toBase64FromMedia(image),
supportsTargets,
supportsWeightsForTargets,
},
opts
),
Expand Down Expand Up @@ -258,18 +248,16 @@ class GenerateManager<T, V> implements Generate<T, V> {
C extends GenerativeConfigRuntime | undefined = undefined
>(id: string, generate: GenerateOptions<T, C>, opts?: NearOptions<T, V, I>): GenerateReturn<T, RV, C> {
return Promise.all([
this.check.nearSearch(opts),
this.check.nearSearch(),
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
.then(async ([{ search, supportsTargets, supportsWeightsForTargets }, supportsSingleGrouped]) => ({
.then(async ([{ search }, supportsSingleGrouped]) => ({
search,
args: {
...Serialize.search.nearObject(
{
id,
supportsTargets,
supportsWeightsForTargets,
},
opts
),
Expand Down Expand Up @@ -308,18 +296,16 @@ class GenerateManager<T, V> implements Generate<T, V> {
opts?: NearOptions<T, V, I>
): GenerateReturn<T, RV, C> {
return Promise.all([
this.check.nearSearch(opts),
this.check.nearSearch(),
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
.then(async ([{ search, supportsTargets, supportsWeightsForTargets }, supportsSingleGrouped]) => ({
.then(async ([{ search }, supportsSingleGrouped]) => ({
search,
args: {
...Serialize.search.nearText(
{
query,
supportsTargets,
supportsWeightsForTargets,
},
opts
),
Expand Down Expand Up @@ -362,27 +348,19 @@ class GenerateManager<T, V> implements Generate<T, V> {
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
.then(
async ([
{ search, supportsTargets, supportsVectorsForTargets, supportsWeightsForTargets, supportsVectors },
supportsSingleGrouped,
]) => ({
search,
args: {
...(await Serialize.search.nearVector(
{
vector,
supportsTargets,
supportsVectorsForTargets,
supportsWeightsForTargets,
supportsVectors,
},
opts
)),
generative: await Serialize.generative({ supportsSingleGrouped }, generate),
},
})
)
.then(async ([{ search, supportsVectors }, supportsSingleGrouped]) => ({
search,
args: {
...(await Serialize.search.nearVector(
{
vector,
supportsVectors,
},
opts
)),
generative: await Serialize.generative({ supportsSingleGrouped }, generate),
},
}))
.then(({ search, args }) => search.withNearVector(args))
.then((reply) => this.parseGroupByReply(opts, reply));
}
Expand Down Expand Up @@ -418,56 +396,52 @@ class GenerateManager<T, V> implements Generate<T, V> {
opts?: NearOptions<T, V, I>
): GenerateReturn<T, RV, C> {
return Promise.all([
this.check.nearSearch(opts),
this.check.nearSearch(),
this.check.supportForSingleGroupedGenerative(),
this.check.supportForGenerativeConfigRuntime(generate.config),
])
.then(([{ search, supportsTargets, supportsWeightsForTargets }, supportsSingleGrouped]) => {
const args = {
supportsTargets,
supportsWeightsForTargets,
};
.then(([{ search }, supportsSingleGrouped]) => {
let send: (media: string, generative: GenerativeSearch) => Promise<SearchReply>;
switch (type) {
case 'audio':
send = (media, generative) =>
search.withNearAudio({
...Serialize.search.nearAudio({ audio: media, ...args }, opts),
...Serialize.search.nearAudio({ audio: media }, opts),
generative,
});
break;
case 'depth':
send = (media, generative) =>
search.withNearDepth({
...Serialize.search.nearDepth({ depth: media, ...args }, opts),
...Serialize.search.nearDepth({ depth: media }, opts),
generative,
});
break;
case 'image':
send = (media, generative) =>
search.withNearImage({
...Serialize.search.nearImage({ image: media, ...args }, opts),
...Serialize.search.nearImage({ image: media }, opts),
generative,
});
break;
case 'imu':
send = (media, generative) =>
search.withNearIMU({
...Serialize.search.nearIMU({ imu: media, ...args }, opts),
...Serialize.search.nearIMU({ imu: media }, opts),
generative,
});
break;
case 'thermal':
send = (media, generative) =>
search.withNearThermal({
...Serialize.search.nearThermal({ thermal: media, ...args }, opts),
...Serialize.search.nearThermal({ thermal: media }, opts),
generative,
});
break;
case 'video':
send = (media, generative) =>
search.withNearVideo({
...Serialize.search.nearVideo({ video: media, ...args }),
...Serialize.search.nearVideo({ video: media }),
generative,
});
break;
Expand Down
Loading