Skip to content

Commit defeb66

Browse files
committed
Merge branch 'main' of https://github.com/weaviate/typescript-client into mt/allow-updating-config
2 parents b7e2802 + 0d444cd commit defeb66

File tree

9 files changed

+1454
-771
lines changed

9 files changed

+1454
-771
lines changed

src/collections/collection/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export interface Collection<T = undefined, N = string> {
6363
* are returned. Use `wvc.QueryReference` to specify which references to return.
6464
*/
6565
iterator: (opts?: IteratorOptions<T>) => Iterator<T>;
66+
/**
67+
* Use this method to return the total number of objects in the collection.
68+
*
69+
* This is a short-hand for calling `collection.aggregate.overAll().then(({ totalCount }) => totalCount)`.
70+
*/
71+
length: () => Promise<number>;
6672
/**
6773
* Use this method to return a collection object specific to a single consistency level.
6874
*
@@ -111,9 +117,16 @@ const collection = <T, N>(
111117
throw new WeaviateInvalidInputError(`The collection name must be a string, got: ${typeof name}`);
112118
}
113119
const capitalizedName = capitalizeCollectionName(name);
120+
const aggregateCollection = aggregate<T>(
121+
connection,
122+
capitalizedName,
123+
dbVersionSupport,
124+
consistencyLevel,
125+
tenant
126+
);
114127
const queryCollection = query<T>(connection, capitalizedName, dbVersionSupport, consistencyLevel, tenant);
115128
return {
116-
aggregate: aggregate<T>(connection, capitalizedName, dbVersionSupport, consistencyLevel, tenant),
129+
aggregate: aggregateCollection,
117130
backup: backupCollection(connection, capitalizedName),
118131
config: config<T>(connection, capitalizedName, dbVersionSupport, tenant),
119132
data: data<T>(connection, capitalizedName, dbVersionSupport, consistencyLevel, tenant),
@@ -139,6 +152,7 @@ const collection = <T, N>(
139152
})
140153
.then((res) => res.objects)
141154
),
155+
length: () => aggregateCollection.overAll().then(({ totalCount }) => totalCount),
142156
withConsistency: (consistencyLevel: ConsistencyLevel) =>
143157
collection<T, N>(connection, capitalizedName, dbVersionSupport, consistencyLevel, tenant),
144158
withTenant: <TT extends TenantBase>(tenant: string | TT) =>

src/collections/config/types/generative.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ export type GenerativeMistralConfig = {
5858
temperature?: number;
5959
};
6060

61-
export type GenerativeOctoAIConfig = {
62-
baseURL?: string;
63-
maxTokens?: number;
64-
model?: string;
65-
temperature?: number;
66-
};
67-
6861
export type GenerativeOllamaConfig = {
6962
apiEndpoint?: string;
7063
model?: string;
@@ -102,7 +95,6 @@ export type GenerativeConfig =
10295
| GenerativeGoogleConfig
10396
| GenerativeFriendliAIConfig
10497
| GenerativeMistralConfig
105-
| GenerativeOctoAIConfig
10698
| GenerativeOllamaConfig
10799
| GenerativeOpenAIConfig
108100
| GenerativePaLMConfig
@@ -127,8 +119,6 @@ export type GenerativeConfigType<G> = G extends 'generative-anthropic'
127119
? GenerativeFriendliAIConfig
128120
: G extends 'generative-mistral'
129121
? GenerativeMistralConfig
130-
: G extends 'generative-octoai'
131-
? GenerativeOctoAIConfig
132122
: G extends 'generative-ollama'
133123
? GenerativeOllamaConfig
134124
: G extends 'generative-openai'
@@ -152,7 +142,6 @@ export type GenerativeSearch =
152142
| 'generative-google'
153143
| 'generative-friendliai'
154144
| 'generative-mistral'
155-
| 'generative-octoai'
156145
| 'generative-ollama'
157146
| 'generative-openai'
158147
| GenerativePalm

src/collections/config/types/vectorizer.ts

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Text2VecPalmVectorizer = 'text2vec-palm';
2020
export type Vectorizer =
2121
| 'img2vec-neural'
2222
| 'multi2vec-clip'
23+
| 'multi2vec-cohere'
2324
| 'multi2vec-bind'
2425
| Multi2VecPalmVectorizer
2526
| 'multi2vec-google'
@@ -33,7 +34,6 @@ export type Vectorizer =
3334
| 'text2vec-huggingface'
3435
| 'text2vec-jina'
3536
| 'text2vec-mistral'
36-
| 'text2vec-octoai'
3737
| 'text2vec-ollama'
3838
| 'text2vec-openai'
3939
| Text2VecPalmVectorizer
@@ -81,6 +81,33 @@ export type Multi2VecClipConfig = {
8181
};
8282
};
8383

84+
/**
85+
* The configuration for multi-media vectorization using the Cohere module.
86+
*
87+
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/cohere/embeddings-multimodal) for detailed usage.
88+
*/
89+
export type Multi2VecCohereConfig = {
90+
/** The base URL to use where API requests should go. */
91+
baseURL?: string;
92+
/** The image fields used when vectorizing. */
93+
imageFields?: string[];
94+
/** The specific model to use. */
95+
model?: string;
96+
/** The text fields used when vectorizing. */
97+
textFields?: string[];
98+
/** The truncation strategy to use. */
99+
truncate?: string;
100+
/** Whether the collection name is vectorized. */
101+
vectorizeCollectionName?: boolean;
102+
/** The weights of the fields used for vectorization. */
103+
weights?: {
104+
/** The weights of the image fields. */
105+
imageFields?: number[];
106+
/** The weights of the text fields. */
107+
textFields?: number[];
108+
};
109+
};
110+
84111
/** The configuration for multi-media vectorization using the Bind module.
85112
*
86113
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/imagebind/embeddings-multimodal) for detailed usage.
@@ -290,20 +317,6 @@ export type Text2VecMistralConfig = {
290317
vectorizeCollectionName?: boolean;
291318
};
292319

293-
/**
294-
* The configuration for text vectorization using the OctoAI module.
295-
*
296-
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/octoai/embeddings) for detailed usage.
297-
*/
298-
export type Text2VecOctoAIConfig = {
299-
/** The base URL to use where API requests should go. */
300-
baseURL?: string;
301-
/** The model to use. */
302-
model?: string;
303-
/** Whether to vectorize the collection name. */
304-
vectorizeCollectionName?: boolean;
305-
};
306-
307320
/**
308321
* The configuration for text vectorization using the Ollama module.
309322
*
@@ -421,6 +434,8 @@ export type VectorizerConfigType<V> = V extends 'img2vec-neural'
421434
? Img2VecNeuralConfig | undefined
422435
: V extends 'multi2vec-clip'
423436
? Multi2VecClipConfig | undefined
437+
: V extends 'multi2vec-cohere'
438+
? Multi2VecCohereConfig | undefined
424439
: V extends 'multi2vec-bind'
425440
? Multi2VecBindConfig | undefined
426441
: V extends 'multi2vec-google'
@@ -447,8 +462,6 @@ export type VectorizerConfigType<V> = V extends 'img2vec-neural'
447462
? Text2VecJinaConfig | undefined
448463
: V extends 'text2vec-mistral'
449464
? Text2VecMistralConfig | undefined
450-
: V extends 'text2vec-octoai'
451-
? Text2VecOctoAIConfig | undefined
452465
: V extends 'text2vec-ollama'
453466
? Text2VecOllamaConfig | undefined
454467
: V extends 'text2vec-openai'

src/collections/configure/generative.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
GenerativeFriendliAIConfig,
99
GenerativeGoogleConfig,
1010
GenerativeMistralConfig,
11-
GenerativeOctoAIConfig,
1211
GenerativeOllamaConfig,
1312
GenerativeOpenAIConfig,
1413
GenerativePaLMConfig,
@@ -23,7 +22,6 @@ import {
2322
GenerativeDatabricksConfigCreate,
2423
GenerativeFriendliAIConfigCreate,
2524
GenerativeMistralConfigCreate,
26-
GenerativeOctoAIConfigCreate,
2725
GenerativeOllamaConfigCreate,
2826
GenerativeOpenAIConfigCreate,
2927
GenerativePaLMConfigCreate,
@@ -171,22 +169,6 @@ export default {
171169
config,
172170
};
173171
},
174-
/**
175-
* Create a `ModuleConfig<'generative-octoai', GenerativeOpenAIConfig | undefined>` object for use when performing AI generation using the `generative-octoai` module.
176-
*
177-
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/octoai/generative) for detailed usage.
178-
*
179-
* @param {GenerativeOctoAIConfigCreate} [config] The configuration for the `generative-octoai` module.
180-
* @returns {ModuleConfig<'generative-octoai', GenerativeOctoAIConfig | undefined>} The configuration object.
181-
*/
182-
octoai(
183-
config?: GenerativeOctoAIConfigCreate
184-
): ModuleConfig<'generative-octoai', GenerativeOctoAIConfig | undefined> {
185-
return {
186-
name: 'generative-octoai',
187-
config,
188-
};
189-
},
190172
/**
191173
* Create a `ModuleConfig<'generative-ollama', GenerativeOllamaConfig | undefined>` object for use when performing AI generation using the `generative-ollama` module.
192174
*

src/collections/configure/types/generative.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
GenerativeDatabricksConfig,
66
GenerativeFriendliAIConfig,
77
GenerativeMistralConfig,
8-
GenerativeOctoAIConfig,
98
GenerativeOllamaConfig,
109
GenerativePaLMConfig,
1110
} from '../../index.js';
@@ -45,8 +44,6 @@ export type GenerativeFriendliAIConfigCreate = GenerativeFriendliAIConfig;
4544

4645
export type GenerativeMistralConfigCreate = GenerativeMistralConfig;
4746

48-
export type GenerativeOctoAIConfigCreate = GenerativeOctoAIConfig;
49-
5047
export type GenerativeOllamaConfigCreate = GenerativeOllamaConfig;
5148

5249
export type GenerativeOpenAIConfigCreate = GenerativeOpenAIConfigBaseCreate & {
@@ -64,7 +61,6 @@ export type GenerativeConfigCreate =
6461
| GenerativeDatabricksConfigCreate
6562
| GenerativeFriendliAIConfigCreate
6663
| GenerativeMistralConfigCreate
67-
| GenerativeOctoAIConfigCreate
6864
| GenerativeOllamaConfigCreate
6965
| GenerativeOpenAIConfigCreate
7066
| GenerativePaLMConfigCreate
@@ -85,8 +81,6 @@ export type GenerativeConfigCreateType<G> = G extends 'generative-anthropic'
8581
? GenerativeFriendliAIConfigCreate
8682
: G extends 'generative-mistral'
8783
? GenerativeMistralConfigCreate
88-
: G extends 'generative-octoai'
89-
? GenerativeOctoAIConfigCreate
9084
: G extends 'generative-ollama'
9185
? GenerativeOllamaConfigCreate
9286
: G extends 'generative-openai'

src/collections/configure/types/vectorizer.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
Text2VecHuggingFaceConfig,
1414
Text2VecJinaConfig,
1515
Text2VecMistralConfig,
16-
Text2VecOctoAIConfig,
1716
Text2VecOllamaConfig,
1817
Text2VecOpenAIConfig,
1918
Text2VecTransformersConfig,
@@ -111,6 +110,22 @@ export type Multi2VecBindConfigCreate = {
111110
vectorizeCollectionName?: boolean;
112111
};
113112

113+
/** The configuration for the `multi2vec-cohere` vectorizer. */
114+
export type Multi2VecCohereConfigCreate = {
115+
/** The base URL to use where API requests should go. */
116+
baseURL?: string;
117+
/** The image fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
118+
imageFields?: string[] | Multi2VecField[];
119+
/** The specific model to use. */
120+
model?: string;
121+
/** The text fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
122+
textFields?: string[] | Multi2VecField[];
123+
/** The truncation strategy to use. */
124+
truncate?: string;
125+
/** Whether to vectorize the collection name. */
126+
vectorizeCollectionName?: boolean;
127+
};
128+
114129
/** @deprecated Use `Multi2VecGoogleConfigCreate` instead.*/
115130
export type Multi2VecPalmConfigCreate = Multi2VecGoogleConfigCreate;
116131

@@ -154,8 +169,6 @@ export type Text2VecJinaConfigCreate = Text2VecJinaConfig;
154169

155170
export type Text2VecMistralConfigCreate = Text2VecMistralConfig;
156171

157-
export type Text2VecOctoAIConfigCreate = Text2VecOctoAIConfig;
158-
159172
export type Text2VecOllamaConfigCreate = Text2VecOllamaConfig;
160173

161174
export type Text2VecOpenAIConfigCreate = Text2VecOpenAIConfig;
@@ -173,6 +186,8 @@ export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
173186
? Img2VecNeuralConfigCreate | undefined
174187
: V extends 'multi2vec-clip'
175188
? Multi2VecClipConfigCreate | undefined
189+
: V extends 'multi2vec-cohere'
190+
? Multi2VecCohereConfigCreate | undefined
176191
: V extends 'multi2vec-bind'
177192
? Multi2VecBindConfigCreate | undefined
178193
: V extends 'multi2vec-palm'
@@ -197,8 +212,6 @@ export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
197212
? Text2VecJinaConfigCreate | undefined
198213
: V extends 'text2vec-mistral'
199214
? Text2VecMistralConfigCreate | undefined
200-
: V extends 'text2vec-octoai'
201-
? Text2VecOctoAIConfigCreate | undefined
202215
: V extends 'text2vec-ollama'
203216
? Text2VecOllamaConfigCreate | undefined
204217
: V extends 'text2vec-openai'

0 commit comments

Comments
 (0)