Skip to content

Commit 9184e62

Browse files
committed
Update text2vec-azure-openai to utilize isAzure: true flag and mark resourceName + deploymentId as optional
This relates to the changes in weaviate/weaviate#5776
1 parent e333dab commit 9184e62

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/collections/config/types/vectorizer.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,12 @@ export type Text2VecAWSConfig = {
180180
export type Text2VecAzureOpenAIConfig = {
181181
/** The base URL to use where API requests should go. */
182182
baseURL?: string;
183-
/** The deployment ID to use */
184-
deploymentId: string;
185-
/** The resource name to use. */
186-
resourceName: string;
183+
/** The deployment ID to use. If left empty, must be provided via X-Azure-Deployment-Id header */
184+
deploymentId?: string;
185+
/** The resource name to use. If left empty, must be provided via X-Azure-Resource-Name header */
186+
resourceName?: string;
187+
/** Will automatically be set to true. You don't need to set this manually. */
188+
isAzure?: true;
187189
/** Whether to vectorize the collection name. */
188190
vectorizeCollectionName?: boolean;
189191
};

src/collections/configure/unit.test.ts

+19
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,24 @@ describe('Unit testing of the vectorizer factory class', () => {
597597
config: {
598598
deploymentId: 'deployment-id',
599599
resourceName: 'resource-name',
600+
isAzure: true,
601+
},
602+
},
603+
});
604+
});
605+
606+
it('should create the correct Text2VecAzureOpenAIConfig type with just isAzure: true', () => {
607+
const config = configure.vectorizer.text2VecAzureOpenAI({});
608+
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-azure-openai'>>({
609+
name: undefined,
610+
vectorIndex: {
611+
name: 'hnsw',
612+
config: undefined,
613+
},
614+
vectorizer: {
615+
name: 'text2vec-azure-openai',
616+
config: {
617+
isAzure: true,
600618
},
601619
},
602620
});
@@ -623,6 +641,7 @@ describe('Unit testing of the vectorizer factory class', () => {
623641
deploymentId: 'deployment-id',
624642
resourceName: 'resource-name',
625643
vectorizeCollectionName: true,
644+
isAzure: true,
626645
},
627646
},
628647
});

src/collections/configure/vectorizer.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ export const vectorizer = {
253253
vectorIndexConfig,
254254
vectorizerConfig: {
255255
name: 'text2vec-azure-openai',
256-
config,
256+
config: {
257+
...config,
258+
isAzure: true,
259+
},
257260
},
258261
});
259262
},

0 commit comments

Comments
 (0)