mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-28 05:59:42 -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,
|
||||
default: '2023-07-01-preview',
|
||||
},
|
||||
{
|
||||
displayName: 'Endpoint',
|
||||
name: 'endpoint',
|
||||
type: 'string',
|
||||
default: undefined,
|
||||
placeholder: 'https://westeurope.api.cognitive.microsoft.com',
|
||||
},
|
||||
];
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue