Skip to content

Commit

Permalink
chore: adjust types for text2VecAzureOpenAI to allow no object to be …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
flipace committed Sep 23, 2024
1 parent 9f072ca commit ec23daa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/collections/configure/types/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
: V extends 'text2vec-openai'
? Text2VecOpenAIConfigCreate | undefined
: V extends 'text2vec-azure-openai'
? Text2VecAzureOpenAIConfigCreate
? Text2VecAzureOpenAIConfigCreate | undefined
: V extends 'text2vec-palm'
? Text2VecPalmConfigCreate | undefined
: V extends 'text2vec-transformers'
Expand Down
2 changes: 1 addition & 1 deletion src/collections/configure/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ describe('Unit testing of the vectorizer factory class', () => {
});

it('should create the correct Text2VecAzureOpenAIConfig type with just isAzure: true', () => {
const config = configure.vectorizer.text2VecAzureOpenAI({});
const config = configure.vectorizer.text2VecAzureOpenAI();
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-azure-openai'>>({
name: undefined,
vectorIndex: {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/configure/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ export const vectorizer = {
* @returns {VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-azure-openai'>} The configuration object.
*/
text2VecAzureOpenAI: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
opts: ConfigureTextVectorizerOptions<T, N, I, 'text2vec-azure-openai'>
opts?: ConfigureTextVectorizerOptions<T, N, I, 'text2vec-azure-openai'>
): VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-azure-openai'> => {
const { name, sourceProperties, vectorIndexConfig, ...config } = opts;
const { name, sourceProperties, vectorIndexConfig, ...config } = opts || {};
return makeVectorizer(name, {
sourceProperties,
vectorIndexConfig,
Expand Down

0 comments on commit ec23daa

Please sign in to comment.