Skip to content

Commit f1621e8

Browse files
committed
Merge branch 'main' of https://github.com/weaviate/typescript-client into 1.29/colbert-multivector-support
2 parents 263c8a8 + d13502f commit f1621e8

File tree

14 files changed

+274
-99
lines changed

14 files changed

+274
-99
lines changed

.github/workflows/main.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env:
1515
WEAVIATE_129: 1.29.8
1616
WEAVIATE_130: 1.30.7
1717
WEAVIATE_131: 1.31.0
18+
WEAVIATE_132: 1.32.0-rc.1
1819

1920
concurrency:
2021
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -48,9 +49,11 @@ jobs:
4849
{ node: "22.x", weaviate: $WEAVIATE_127},
4950
{ node: "22.x", weaviate: $WEAVIATE_128},
5051
{ node: "22.x", weaviate: $WEAVIATE_129},
51-
{ node: "18.x", weaviate: $WEAVIATE_130},
52-
{ node: "20.x", weaviate: $WEAVIATE_130},
53-
{ node: "22.x", weaviate: $WEAVIATE_130}
52+
{ node: "22.x", weaviate: $WEAVIATE_130},
53+
{ node: "22.x", weaviate: $WEAVIATE_131},
54+
{ node: "18.x", weaviate: $WEAVIATE_132},
55+
{ node: "20.x", weaviate: $WEAVIATE_132},
56+
{ node: "22.x", weaviate: $WEAVIATE_132}
5457
]
5558
steps:
5659
- uses: actions/checkout@v3

package-lock.json

Lines changed: 43 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252
"homepage": "https://github.com/weaviate/typescript-client#readme",
5353
"dependencies": {
5454
"abort-controller-x": "^0.4.3",
55-
"graphql": "^16.10.0",
55+
"graphql": "^16.11.0",
5656
"graphql-request": "^6.1.0",
57-
"long": "^5.2.4",
58-
"nice-grpc": "^2.1.11",
59-
"nice-grpc-client-middleware-retry": "^3.1.10",
57+
"long": "^5.3.1",
58+
"nice-grpc": "^2.1.12",
59+
"nice-grpc-client-middleware-retry": "^3.1.11",
6060
"nice-grpc-common": "^2.0.2",
6161
"uuid": "^9.0.1"
6262
},

src/collections/config/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
CollectionConfigUpdate,
2020
PQConfig,
2121
QuantizerConfig,
22+
RQConfig,
2223
SQConfig,
2324
VectorIndexConfig,
2425
VectorIndexConfigDynamic,
@@ -192,6 +193,9 @@ export class Quantizer {
192193
static isSQ(config?: QuantizerConfig): config is SQConfig {
193194
return config?.type === 'sq';
194195
}
196+
static isRQ(config?: QuantizerConfig): config is RQConfig {
197+
return config?.type === 'rq';
198+
}
195199
}
196200

197201
export const configGuards = {

src/collections/config/integration.test.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import {
1212
VectorIndexConfigHNSW,
1313
} from './types/index.js';
1414

15-
const fail = (msg: string) => {
16-
throw new Error(msg);
17-
};
18-
1915
describe('Testing of the collection.config namespace', () => {
2016
let client: WeaviateClient;
2117

@@ -212,6 +208,30 @@ describe('Testing of the collection.config namespace', () => {
212208
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
213209
});
214210

211+
requireAtLeast(1, 32, 0).it('should be able to get the config of a collection with hnsw-rq', async () => {
212+
const collectionName = 'TestCollectionConfigGetHNSWPlusRQ';
213+
const collection = await client.collections.create({
214+
name: collectionName,
215+
vectorizers: weaviate.configure.vectorizer.none({
216+
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({
217+
quantizer: weaviate.configure.vectorIndex.quantizer.rq(),
218+
}),
219+
}),
220+
});
221+
const config = await collection.config.get();
222+
223+
const vectorIndexConfig = config.vectorizers.default.indexConfig as VectorIndexConfigHNSW;
224+
expect(config.name).toEqual(collectionName);
225+
expect(config.generative).toBeUndefined();
226+
expect(config.reranker).toBeUndefined();
227+
expect(vectorIndexConfig).toBeDefined();
228+
expect(vectorIndexConfig.quantizer).toBeDefined();
229+
expect(vectorIndexConfig.quantizer?.type).toEqual('rq');
230+
expect(config.vectorizers.default.indexType).toEqual('hnsw');
231+
expect(config.vectorizers.default.properties).toBeUndefined();
232+
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
233+
});
234+
215235
it('should be able to get the config of a collection with hnsw-bq', async () => {
216236
const collectionName = 'TestCollectionConfigGetHNSWPlusBQ';
217237
const query = () =>

src/collections/config/types/vectorIndex.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ export type PQConfig = {
6262
type: 'pq';
6363
};
6464

65+
export type RQConfig = {
66+
bits?: number;
67+
rescoreLimit?: number;
68+
type: 'rq';
69+
};
70+
6571
export type MultiVectorConfig = {
6672
aggregation: 'maxSim' | string;
6773
encoding?: MultiVectorEncodingConfig;
@@ -92,4 +98,4 @@ export type VectorIndexFilterStrategy = 'sweeping' | 'acorn';
9298

9399
export type VectorIndexConfig = VectorIndexConfigHNSW | VectorIndexConfigFlat | VectorIndexConfigDynamic;
94100

95-
export type QuantizerConfig = PQConfig | BQConfig | SQConfig;
101+
export type QuantizerConfig = PQConfig | BQConfig | SQConfig | RQConfig;

src/collections/config/utils.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ import {
4646
PQEncoderType,
4747
PropertyConfig,
4848
PropertyVectorizerConfig,
49+
QuantizerConfig,
50+
RQConfig,
4951
ReferenceConfig,
5052
ReplicationConfig,
5153
Reranker,
@@ -207,6 +209,16 @@ export const parseVectorIndex = (module: ModuleConfig<VectorIndexType, VectorInd
207209
},
208210
};
209211
}
212+
if (QuantizerGuards.isRQCreate(quantizer)) {
213+
const { type, ...quant } = quantizer;
214+
return {
215+
...conf,
216+
rq: {
217+
...quant,
218+
enabled: true,
219+
},
220+
};
221+
}
210222
};
211223

212224
export const parseVectorizerConfig = (config?: VectorizerConfig): any => {
@@ -493,11 +505,13 @@ class ConfigMapping {
493505
throw new WeaviateDeserializationError(
494506
'Vector index vector cache max objects was not returned by Weaviate'
495507
);
496-
let quantizer: PQConfig | BQConfig | SQConfig | undefined;
508+
let quantizer: QuantizerConfig | undefined;
497509
if (exists<Record<string, any>>(v.pq) && v.pq.enabled === true) {
498510
quantizer = ConfigMapping.pq(v.pq);
499511
} else if (exists<Record<string, any>>(v.bq) && v.bq.enabled === true) {
500512
quantizer = ConfigMapping.bq(v.bq);
513+
} else if (exists<Record<string, any>>(v.rq) && v.rq.enabled === true) {
514+
quantizer = ConfigMapping.rq(v.rq);
501515
} else if (exists<Record<string, any>>(v.sq) && v.sq.enabled === true) {
502516
quantizer = ConfigMapping.sq(v.sq);
503517
} else {
@@ -564,6 +578,19 @@ class ConfigMapping {
564578
type: 'bq',
565579
};
566580
}
581+
static rq(v?: Record<string, unknown>): RQConfig | undefined {
582+
if (v === undefined) throw new WeaviateDeserializationError('RQ was not returned by Weaviate');
583+
if (!exists<boolean>(v.enabled))
584+
throw new WeaviateDeserializationError('RQ enabled was not returned by Weaviate');
585+
if (v.enabled === false) return undefined;
586+
const bits = v.bits === undefined ? 6 : (v.bits as number);
587+
const rescoreLimit = v.rescoreLimit === undefined ? 20 : (v.rescoreLimit as number);
588+
return {
589+
bits,
590+
rescoreLimit,
591+
type: 'rq',
592+
};
593+
}
567594
static sq(v?: Record<string, unknown>): SQConfig | undefined {
568595
if (v === undefined) throw new WeaviateDeserializationError('SQ was not returned by Weaviate');
569596
if (!exists<boolean>(v.enabled))

src/collections/configure/parsing.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
BQConfigUpdate,
55
PQConfigCreate,
66
PQConfigUpdate,
7+
RQConfigCreate,
8+
RQConfigUpdate,
79
SQConfigCreate,
810
SQConfigUpdate,
911
VectorIndexConfigDynamicCreate,
@@ -17,7 +19,10 @@ type QuantizerConfig =
1719
| BQConfigCreate
1820
| BQConfigUpdate
1921
| SQConfigCreate
20-
| SQConfigUpdate;
22+
| SQConfigUpdate
23+
| RQConfigCreate
24+
| RQConfigUpdate
25+
| Record<string, any>;
2126

2227
export class QuantizerGuards {
2328
static isPQCreate(config?: QuantizerConfig): config is PQConfigCreate {
@@ -38,6 +43,12 @@ export class QuantizerGuards {
3843
static isSQUpdate(config?: QuantizerConfig): config is SQConfigUpdate {
3944
return (config as SQConfigUpdate)?.type === 'sq';
4045
}
46+
static isRQCreate(config?: QuantizerConfig): config is RQConfigCreate {
47+
return (config as RQConfigCreate)?.type === 'rq';
48+
}
49+
static isRQUpdate(config?: QuantizerConfig): config is RQConfigUpdate {
50+
return (config as RQConfigUpdate)?.type === 'rq';
51+
}
4152
}
4253

4354
type VectorIndexConfigCreate =

0 commit comments

Comments
 (0)