mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-28 22:19:41 -08:00
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:
parent
6cf0abab5b
commit
e298ebe90d
|
@ -30,6 +30,13 @@ export class AzureOpenAiApi implements ICredentialType {
|
||||||
required: true,
|
required: true,
|
||||||
default: '2023-07-01-preview',
|
default: '2023-07-01-preview',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Endpoint',
|
||||||
|
name: 'endpoint',
|
||||||
|
type: 'string',
|
||||||
|
default: undefined,
|
||||||
|
placeholder: 'https://westeurope.api.cognitive.microsoft.com',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
authenticate: IAuthenticateGeneric = {
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
|
|
@ -128,6 +128,7 @@ export class EmbeddingsAzureOpenAi implements INodeType {
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
resourceName: string;
|
resourceName: string;
|
||||||
apiVersion: string;
|
apiVersion: string;
|
||||||
|
endpoint?: string;
|
||||||
}>('azureOpenAiApi');
|
}>('azureOpenAiApi');
|
||||||
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
||||||
|
|
||||||
|
@ -144,9 +145,15 @@ export class EmbeddingsAzureOpenAi implements INodeType {
|
||||||
|
|
||||||
const embeddings = new OpenAIEmbeddings({
|
const embeddings = new OpenAIEmbeddings({
|
||||||
azureOpenAIApiDeploymentName: modelName,
|
azureOpenAIApiDeploymentName: modelName,
|
||||||
azureOpenAIApiInstanceName: credentials.resourceName,
|
// instance name only needed to set base url
|
||||||
|
azureOpenAIApiInstanceName: !credentials.endpoint ? credentials.resourceName : undefined,
|
||||||
azureOpenAIApiKey: credentials.apiKey,
|
azureOpenAIApiKey: credentials.apiKey,
|
||||||
azureOpenAIApiVersion: credentials.apiVersion,
|
azureOpenAIApiVersion: credentials.apiVersion,
|
||||||
|
// azureOpenAIEndpoint and configuration.baseURL are both ignored here
|
||||||
|
// only setting azureOpenAIBasePath worked
|
||||||
|
azureOpenAIBasePath: credentials.endpoint
|
||||||
|
? `${credentials.endpoint}/openai/deployments`
|
||||||
|
: undefined,
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,7 @@ export class LmChatAzureOpenAi implements INodeType {
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
resourceName: string;
|
resourceName: string;
|
||||||
apiVersion: string;
|
apiVersion: string;
|
||||||
|
endpoint?: string;
|
||||||
}>('azureOpenAiApi');
|
}>('azureOpenAiApi');
|
||||||
|
|
||||||
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
||||||
|
@ -184,9 +185,11 @@ export class LmChatAzureOpenAi implements INodeType {
|
||||||
|
|
||||||
const model = new ChatOpenAI({
|
const model = new ChatOpenAI({
|
||||||
azureOpenAIApiDeploymentName: modelName,
|
azureOpenAIApiDeploymentName: modelName,
|
||||||
azureOpenAIApiInstanceName: credentials.resourceName,
|
// instance name only needed to set base url
|
||||||
|
azureOpenAIApiInstanceName: !credentials.endpoint ? credentials.resourceName : undefined,
|
||||||
azureOpenAIApiKey: credentials.apiKey,
|
azureOpenAIApiKey: credentials.apiKey,
|
||||||
azureOpenAIApiVersion: credentials.apiVersion,
|
azureOpenAIApiVersion: credentials.apiVersion,
|
||||||
|
azureOpenAIEndpoint: credentials.endpoint,
|
||||||
...options,
|
...options,
|
||||||
timeout: options.timeout ?? 60000,
|
timeout: options.timeout ?? 60000,
|
||||||
maxRetries: options.maxRetries ?? 2,
|
maxRetries: options.maxRetries ?? 2,
|
||||||
|
|
Loading…
Reference in a new issue