Skip to content

Commit

Permalink
Update text2vec-azure-openai to utilize isAzure: true flag and ma…
Browse files Browse the repository at this point in the history
…rk `resourceName` + `deploymentId` as optional

This relates to the changes in weaviate/weaviate#5776
  • Loading branch information
flipace committed Sep 18, 2024
1 parent e333dab commit 9184e62
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/collections/config/types/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ export type Text2VecAWSConfig = {
export type Text2VecAzureOpenAIConfig = {
/** The base URL to use where API requests should go. */
baseURL?: string;
/** The deployment ID to use */
deploymentId: string;
/** The resource name to use. */
resourceName: string;
/** The deployment ID to use. If left empty, must be provided via X-Azure-Deployment-Id header */
deploymentId?: string;
/** The resource name to use. If left empty, must be provided via X-Azure-Resource-Name header */
resourceName?: string;
/** Will automatically be set to true. You don't need to set this manually. */
isAzure?: true;
/** Whether to vectorize the collection name. */
vectorizeCollectionName?: boolean;
};
Expand Down
19 changes: 19 additions & 0 deletions src/collections/configure/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,24 @@ describe('Unit testing of the vectorizer factory class', () => {
config: {
deploymentId: 'deployment-id',
resourceName: 'resource-name',
isAzure: true,
},
},
});
});

it('should create the correct Text2VecAzureOpenAIConfig type with just isAzure: true', () => {
const config = configure.vectorizer.text2VecAzureOpenAI({});
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-azure-openai'>>({
name: undefined,
vectorIndex: {
name: 'hnsw',
config: undefined,
},
vectorizer: {
name: 'text2vec-azure-openai',
config: {
isAzure: true,
},
},
});
Expand All @@ -623,6 +641,7 @@ describe('Unit testing of the vectorizer factory class', () => {
deploymentId: 'deployment-id',
resourceName: 'resource-name',
vectorizeCollectionName: true,
isAzure: true,
},
},
});
Expand Down
5 changes: 4 additions & 1 deletion src/collections/configure/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ export const vectorizer = {
vectorIndexConfig,
vectorizerConfig: {
name: 'text2vec-azure-openai',
config,
config: {
...config,
isAzure: true,
},
},
});
},
Expand Down

0 comments on commit 9184e62

Please sign in to comment.