Skip to content

Commit ec23daa

Browse files
committed
chore: adjust types for text2VecAzureOpenAI to allow no object to be passed at all
Since the only indicator for the azureOpenAI config is now the isAzure: true flag, which is set in the vectorizer setup directly, no config object is necessary for it.
1 parent 9f072ca commit ec23daa

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/collections/configure/types/vectorizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
196196
: V extends 'text2vec-openai'
197197
? Text2VecOpenAIConfigCreate | undefined
198198
: V extends 'text2vec-azure-openai'
199-
? Text2VecAzureOpenAIConfigCreate
199+
? Text2VecAzureOpenAIConfigCreate | undefined
200200
: V extends 'text2vec-palm'
201201
? Text2VecPalmConfigCreate | undefined
202202
: V extends 'text2vec-transformers'

src/collections/configure/unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ describe('Unit testing of the vectorizer factory class', () => {
604604
});
605605

606606
it('should create the correct Text2VecAzureOpenAIConfig type with just isAzure: true', () => {
607-
const config = configure.vectorizer.text2VecAzureOpenAI({});
607+
const config = configure.vectorizer.text2VecAzureOpenAI();
608608
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-azure-openai'>>({
609609
name: undefined,
610610
vectorIndex: {

src/collections/configure/vectorizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ export const vectorizer = {
245245
* @returns {VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-azure-openai'>} The configuration object.
246246
*/
247247
text2VecAzureOpenAI: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
248-
opts: ConfigureTextVectorizerOptions<T, N, I, 'text2vec-azure-openai'>
248+
opts?: ConfigureTextVectorizerOptions<T, N, I, 'text2vec-azure-openai'>
249249
): VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-azure-openai'> => {
250-
const { name, sourceProperties, vectorIndexConfig, ...config } = opts;
250+
const { name, sourceProperties, vectorIndexConfig, ...config } = opts || {};
251251
return makeVectorizer(name, {
252252
sourceProperties,
253253
vectorIndexConfig,

0 commit comments

Comments
 (0)