feat(Embeddings Azure OpenAI Node, Azure OpenAI Chat Model Node): Add support for basePath url in Azure Open AI nodes (#11784)

This commit is contained in:
Mutasem Aldmour 2024-11-19 12:06:33 +01:00 committed by GitHub
parent 6cf0abab5b
commit e298ebe90d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View file

@ -30,6 +30,13 @@ export class AzureOpenAiApi implements ICredentialType {
required: true,
default: '2023-07-01-preview',
},
{
displayName: 'Endpoint',
name: 'endpoint',
type: 'string',
default: undefined,
placeholder: 'https://westeurope.api.cognitive.microsoft.com',
},
];
authenticate: IAuthenticateGeneric = {

View file

@ -128,6 +128,7 @@ export class EmbeddingsAzureOpenAi implements INodeType {
apiKey: string;
resourceName: string;
apiVersion: string;
endpoint?: string;
}>('azureOpenAiApi');
const modelName = this.getNodeParameter('model', itemIndex) as string;
@ -144,9 +145,15 @@ export class EmbeddingsAzureOpenAi implements INodeType {
const embeddings = new OpenAIEmbeddings({
azureOpenAIApiDeploymentName: modelName,
azureOpenAIApiInstanceName: credentials.resourceName,
// instance name only needed to set base url
azureOpenAIApiInstanceName: !credentials.endpoint ? credentials.resourceName : undefined,
azureOpenAIApiKey: credentials.apiKey,
azureOpenAIApiVersion: credentials.apiVersion,
// azureOpenAIEndpoint and configuration.baseURL are both ignored here
// only setting azureOpenAIBasePath worked
azureOpenAIBasePath: credentials.endpoint
? `${credentials.endpoint}/openai/deployments`
: undefined,
...options,
});

View file

@ -168,6 +168,7 @@ export class LmChatAzureOpenAi implements INodeType {
apiKey: string;
resourceName: string;
apiVersion: string;
endpoint?: string;
}>('azureOpenAiApi');
const modelName = this.getNodeParameter('model', itemIndex) as string;
@ -184,9 +185,11 @@ export class LmChatAzureOpenAi implements INodeType {
const model = new ChatOpenAI({
azureOpenAIApiDeploymentName: modelName,
azureOpenAIApiInstanceName: credentials.resourceName,
// instance name only needed to set base url
azureOpenAIApiInstanceName: !credentials.endpoint ? credentials.resourceName : undefined,
azureOpenAIApiKey: credentials.apiKey,
azureOpenAIApiVersion: credentials.apiVersion,
azureOpenAIEndpoint: credentials.endpoint,
...options,
timeout: options.timeout ?? 60000,
maxRetries: options.maxRetries ?? 2,