Skip to content

Commit 99a78b5

Browse files
committed
Merge branch 'main' of https://github.com/weaviate/typescript-client into dev/1.26
2 parents 5a44b2d + 285b63d commit 99a78b5

File tree

12 files changed

+145
-31
lines changed

12 files changed

+145
-31
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "weaviate-client",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"description": "JS/TS client for Weaviate",
55
"main": "dist/node/cjs/index.js",
66
"type": "module",
@@ -51,7 +51,7 @@
5151
},
5252
"homepage": "https://github.com/weaviate/typescript-client#readme",
5353
"dependencies": {
54-
"graphql": "^16.8.1",
54+
"graphql": "^16.8.2",
5555
"graphql-request": "^6.1.0",
5656
"long": "^5.2.3",
5757
"nice-grpc": "^2.1.9",

src/collections/config/types/generative.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export type GenerativePaLMConfig = {
5959
apiEndpoint?: string;
6060
maxOutputTokens?: number;
6161
modelId?: string;
62-
projectId: string;
62+
projectId?: string;
6363
temperature?: number;
6464
topK?: number;
6565
topP?: number;

src/collections/config/types/vectorizer.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type Vectorizer =
2424
| 'text2vec-gpt4all'
2525
| 'text2vec-huggingface'
2626
| 'text2vec-jina'
27+
| 'text2vec-octoai'
2728
| 'text2vec-ollama'
2829
| 'text2vec-openai'
2930
| 'text2vec-palm'
@@ -254,6 +255,20 @@ export type Text2VecJinaConfig = {
254255
vectorizeCollectionName?: boolean;
255256
};
256257

258+
/**
259+
* The configuration for text vectorization using OctoAI.
260+
*
261+
* See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-octoai) for detailed usage.
262+
*/
263+
export type Text2VecOctoAIConfig = {
264+
/** The base URL to use where API requests should go. */
265+
baseURL?: string;
266+
/** The model to use. */
267+
model?: string;
268+
/** Whether to vectorize the collection name. */
269+
vectorizeCollectionName?: boolean;
270+
};
271+
257272
/**
258273
* The configuration for text vectorization using Ollama.
259274
*
@@ -378,6 +393,8 @@ export type VectorizerConfigType<V> = V extends 'img2vec-neural'
378393
? Text2VecHuggingFaceConfig | undefined
379394
: V extends 'text2vec-jina'
380395
? Text2VecJinaConfig | undefined
396+
: V extends 'text2vec-octoai'
397+
? Text2VecOctoAIConfig | undefined
381398
: V extends 'text2vec-ollama'
382399
? Text2VecOllamaConfig | undefined
383400
: V extends 'text2vec-openai'

src/collections/configure/generative.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ export default {
182182
*
183183
* See the [documentation](https://weaviate.io/developers/weaviate/modules/reader-generator-modules/generative-palm) for detailed usage.
184184
*
185-
* @param {GenerativePaLMConfigCreate} config The configuration for the `generative-palm` module.
185+
* @param {GenerativePaLMConfigCreate} [config] The configuration for the `generative-palm` module.
186186
* @returns {ModuleConfig<'generative-palm', GenerativePaLMConfig>} The configuration object.
187187
*/
188-
palm: (config: GenerativePaLMConfigCreate): ModuleConfig<'generative-palm', GenerativePaLMConfig> => {
188+
palm: (
189+
config?: GenerativePaLMConfigCreate
190+
): ModuleConfig<'generative-palm', GenerativePaLMConfig | undefined> => {
189191
return {
190192
name: 'generative-palm',
191193
config,

src/collections/configure/types/vectorizer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Text2VecGPT4AllConfig,
1111
Text2VecHuggingFaceConfig,
1212
Text2VecJinaConfig,
13+
Text2VecOctoAIConfig,
1314
Text2VecOllamaConfig,
1415
Text2VecOpenAIConfig,
1516
Text2VecPalmConfig,
@@ -144,6 +145,8 @@ export type Text2VecHuggingFaceConfigCreate = Text2VecHuggingFaceConfig;
144145

145146
export type Text2VecJinaConfigCreate = Text2VecJinaConfig;
146147

148+
export type Text2VecOctoAIConfigCreate = Text2VecOctoAIConfig;
149+
147150
export type Text2VecOllamaConfigCreate = Text2VecOllamaConfig;
148151

149152
export type Text2VecOpenAIConfigCreate = Text2VecOpenAIConfig;
@@ -176,6 +179,8 @@ export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
176179
? Text2VecHuggingFaceConfigCreate | undefined
177180
: V extends 'text2vec-jina'
178181
? Text2VecJinaConfigCreate | undefined
182+
: V extends 'text2vec-octoai'
183+
? Text2VecOctoAIConfigCreate | undefined
179184
: V extends 'text2vec-ollama'
180185
? Text2VecOllamaConfigCreate | undefined
181186
: V extends 'text2vec-openai'

src/collections/configure/unit.test.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,45 @@ describe('Unit testing of the vectorizer factory class', () => {
822822
});
823823
});
824824

825+
it('should create the correct Text2VecOctoAIConfig type with defaults', () => {
826+
const config = configure.vectorizer.text2VecOctoAI();
827+
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-octoai'>>({
828+
name: undefined,
829+
vectorIndex: {
830+
name: 'hnsw',
831+
config: undefined,
832+
},
833+
vectorizer: {
834+
name: 'text2vec-octoai',
835+
config: undefined,
836+
},
837+
});
838+
});
839+
840+
it('should create the correct Text2VecOctoAIConfig type with all values', () => {
841+
const config = configure.vectorizer.text2VecOctoAI({
842+
name: 'test',
843+
baseURL: 'base-url',
844+
model: 'model',
845+
vectorizeCollectionName: true,
846+
});
847+
expect(config).toEqual<VectorConfigCreate<never, 'test', 'hnsw', 'text2vec-octoai'>>({
848+
name: 'test',
849+
vectorIndex: {
850+
name: 'hnsw',
851+
config: undefined,
852+
},
853+
vectorizer: {
854+
name: 'text2vec-octoai',
855+
config: {
856+
baseURL: 'base-url',
857+
model: 'model',
858+
vectorizeCollectionName: true,
859+
},
860+
},
861+
});
862+
});
863+
825864
it('should create the correct Text2VecOllamaConfig type with defaults', () => {
826865
const config = configure.vectorizer.text2VecOllama();
827866
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-ollama'>>({
@@ -1256,14 +1295,10 @@ describe('Unit testing of the generative factory class', () => {
12561295
});
12571296

12581297
it('should create the correct GenerativePaLMConfig type with required & default values', () => {
1259-
const config = configure.generative.palm({
1260-
projectId: 'project-id',
1261-
});
1262-
expect(config).toEqual<ModuleConfig<'generative-palm', GenerativePaLMConfig>>({
1298+
const config = configure.generative.palm();
1299+
expect(config).toEqual<ModuleConfig<'generative-palm', undefined>>({
12631300
name: 'generative-palm',
1264-
config: {
1265-
projectId: 'project-id',
1266-
},
1301+
config: undefined,
12671302
});
12681303
});
12691304

src/collections/configure/vectorizer.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,22 @@ export const vectorizer = {
362362
},
363363
});
364364
},
365+
/**
366+
*
367+
*/
368+
text2VecOctoAI: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
369+
opts?: ConfigureTextVectorizerOptions<T, N, I, 'text2vec-octoai'>
370+
): VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-octoai'> => {
371+
const { name, sourceProperties, vectorIndexConfig, ...config } = opts || {};
372+
return makeVectorizer(name, {
373+
sourceProperties,
374+
vectorIndexConfig,
375+
vectorizerConfig: {
376+
name: 'text2vec-octoai',
377+
config: Object.keys(config).length === 0 ? undefined : config,
378+
},
379+
});
380+
},
365381
/**
366382
* Create a `VectorConfigCreate` object with the vectorizer set to `'text2vec-openai'`.
367383
*

src/collections/data/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ const data = <T>(
193193
if (Array.isArray(object.vectors)) {
194194
const supportsNamedVectors = await dbVersionSupport.supportsNamedVectors();
195195
if (supportsNamedVectors.supports) {
196+
obj.vector = object.vectors;
196197
obj.vectors = { default: object.vectors };
197198
} else {
198199
obj.vector = object.vectors;

src/collections/data/integration.test.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
33
import { v4 } from 'uuid';
44
import { WeaviateUnsupportedFeatureError } from '../../errors.js';
5-
import weaviate, { WeaviateClient } from '../../index.js';
5+
import weaviate, { WeaviateClient, weaviateV2 } from '../../index.js';
66
import { GeoCoordinate, PhoneNumber } from '../../proto/v1/properties.js';
77
import { Collection } from '../collection/index.js';
88
import { CrossReference, CrossReferences, Reference } from '../references/index.js';
@@ -1000,3 +1000,40 @@ describe('Testing of the collection.data methods with a vector index', () => {
10001000
expect(obj2?.vectors.default).toEqual([5, 6, 7, 8]);
10011001
});
10021002
});
1003+
1004+
describe('Testing of BYOV insertion with legacy vectorizer', () => {
1005+
const collectionName = 'TestBYOVEdgeCase';
1006+
const oldClient = weaviateV2.client({ scheme: 'http', host: 'localhost:8080' });
1007+
1008+
beforeAll(() =>
1009+
oldClient.schema
1010+
.classCreator()
1011+
.withClass({
1012+
class: collectionName,
1013+
vectorizer: 'none',
1014+
})
1015+
.do()
1016+
);
1017+
1018+
afterAll(() => oldClient.schema.classDeleter().withClassName(collectionName).do());
1019+
1020+
it('should insert and retrieve many vectors using the new client', async () => {
1021+
const client = await weaviate.connectToLocal();
1022+
const collection = client.collections.get(collectionName);
1023+
const { uuids } = await collection.data.insertMany([{ vectors: [1, 2, 3] }, { vectors: [4, 5, 6] }]);
1024+
await collection.query
1025+
.fetchObjectById(uuids[0], { includeVector: true })
1026+
.then((res) => expect(res?.vectors.default).toEqual([1, 2, 3]));
1027+
await collection.query
1028+
.fetchObjectById(uuids[1], { includeVector: true })
1029+
.then((res) => expect(res?.vectors.default).toEqual([4, 5, 6]));
1030+
});
1031+
1032+
it('should insert and retrieve single vectors using the new client', async () => {
1033+
const client = await weaviate.connectToLocal();
1034+
const collection = client.collections.get(collectionName);
1035+
const id = await collection.data.insert({ vectors: [7, 8, 9] });
1036+
const object = await collection.query.fetchObjectById(id, { includeVector: true });
1037+
expect(object?.vectors.default).toEqual([7, 8, 9]);
1038+
});
1039+
});

0 commit comments

Comments
 (0)