modify input parameters

This commit is contained in:
chungyau97
2023-05-12 20:26:09 +07:00
parent 5c49a58985
commit c596feb09a
3 changed files with 128 additions and 30 deletions
@@ -70,22 +70,51 @@ class AzureChatOpenAI_ChatModels implements INode {
{ {
label: 'Azure OpenAI Api Version', label: 'Azure OpenAI Api Version',
name: 'azureOpenAIApiVersion', name: 'azureOpenAIApiVersion',
type: 'string', type: 'options',
placeholder: 'YOUR-API-VERSION' options: [
{
label: '2023-03-15-preview',
name: '2023-03-15-preview'
},
{
label: '2022-12-01',
name: '2022-12-01'
}
],
default: '2023-03-15-preview'
}, },
{ {
label: 'Azure OpenAI Api Embeddings Deployment Name', label: 'Max Tokens',
name: 'azureOpenAIApiEmbeddingsDeploymentName', name: 'maxTokens',
type: 'string', type: 'number',
placeholder: 'YOUR-EMBEDDINGS-NAME',
optional: true, optional: true,
additionalParams: true additionalParams: true
}, },
{ {
label: 'Azure OpenAI Api Completions Deployment Name', label: 'Top Probability',
name: 'azureOpenAIApiCompletionsDeploymentName', name: 'topP',
type: 'string', type: 'number',
placeholder: 'YOUR-COMPLETIONS-NAME', optional: true,
additionalParams: true
},
{
label: 'Frequency Penalty',
name: 'frequencyPenalty',
type: 'number',
optional: true,
additionalParams: true
},
{
label: 'Presence Penalty',
name: 'presencePenalty',
type: 'number',
optional: true,
additionalParams: true
},
{
label: 'Timeout',
name: 'timeout',
type: 'number',
optional: true, optional: true,
additionalParams: true additionalParams: true
} }
@@ -99,8 +128,11 @@ class AzureChatOpenAI_ChatModels implements INode {
const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string
const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string
const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string
const azureOpenAIApiEmbeddingsDeploymentName = nodeData.inputs?.azureOpenAIApiEmbeddingsDeploymentName as string const maxTokens = nodeData.inputs?.maxTokens as string
const azureOpenAIApiCompletionsDeploymentName = nodeData.inputs?.azureOpenAIApiCompletionsDeploymentName as string const topP = nodeData.inputs?.topP as string
const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string
const presencePenalty = nodeData.inputs?.presencePenalty as string
const timeout = nodeData.inputs?.timeout as string
const obj: Partial<AzureOpenAIInput> & Partial<OpenAIBaseInput> = { const obj: Partial<AzureOpenAIInput> & Partial<OpenAIBaseInput> = {
temperature: parseInt(temperature, 10), temperature: parseInt(temperature, 10),
@@ -111,8 +143,11 @@ class AzureChatOpenAI_ChatModels implements INode {
azureOpenAIApiVersion azureOpenAIApiVersion
} }
if (azureOpenAIApiEmbeddingsDeploymentName) obj.azureOpenAIApiEmbeddingsDeploymentName = azureOpenAIApiEmbeddingsDeploymentName if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
if (azureOpenAIApiCompletionsDeploymentName) obj.azureOpenAIApiCompletionsDeploymentName = azureOpenAIApiCompletionsDeploymentName if (topP) obj.topP = parseInt(topP, 10)
if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10)
if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10)
if (timeout) obj.timeout = parseInt(timeout, 10)
const model = new ChatOpenAI(obj) const model = new ChatOpenAI(obj)
return model return model
@@ -42,8 +42,18 @@ class AzureOpenAIEmbedding_Embeddings implements INode {
{ {
label: 'Azure OpenAI Api Version', label: 'Azure OpenAI Api Version',
name: 'azureOpenAIApiVersion', name: 'azureOpenAIApiVersion',
type: 'string', type: 'options',
placeholder: 'YOUR-API-VERSION' options: [
{
label: '2023-03-15-preview',
name: '2023-03-15-preview'
},
{
label: '2022-12-01',
name: '2022-12-01'
}
],
default: '2023-03-15-preview'
}, },
{ {
label: 'Strip New Lines', label: 'Strip New Lines',
@@ -105,22 +105,65 @@ class AzureOpenAI_LLMs implements INode {
{ {
label: 'Azure OpenAI Api Version', label: 'Azure OpenAI Api Version',
name: 'azureOpenAIApiVersion', name: 'azureOpenAIApiVersion',
type: 'string', type: 'options',
placeholder: 'YOUR-API-VERSION' options: [
{
label: '2023-03-15-preview',
name: '2023-03-15-preview'
},
{
label: '2022-12-01',
name: '2022-12-01'
}
],
default: '2023-03-15-preview'
}, },
{ {
label: 'Azure OpenAI Api Embeddings Deployment Name', label: 'Max Tokens',
name: 'azureOpenAIApiEmbeddingsDeploymentName', name: 'maxTokens',
type: 'string', type: 'number',
placeholder: 'YOUR-EMBEDDINGS-NAME',
optional: true, optional: true,
additionalParams: true additionalParams: true
}, },
{ {
label: 'Azure OpenAI Api Completions Deployment Name', label: 'Top Probability',
name: 'azureOpenAIApiCompletionsDeploymentName', name: 'topP',
type: 'string', type: 'number',
placeholder: 'YOUR-COMPLETIONS-NAME', optional: true,
additionalParams: true
},
{
label: 'Best Of',
name: 'bestOf',
type: 'number',
optional: true,
additionalParams: true
},
{
label: 'Frequency Penalty',
name: 'frequencyPenalty',
type: 'number',
optional: true,
additionalParams: true
},
{
label: 'Presence Penalty',
name: 'presencePenalty',
type: 'number',
optional: true,
additionalParams: true
},
{
label: 'Batch Size',
name: 'batchSize',
type: 'number',
optional: true,
additionalParams: true
},
{
label: 'Timeout',
name: 'timeout',
type: 'number',
optional: true, optional: true,
additionalParams: true additionalParams: true
} }
@@ -134,8 +177,13 @@ class AzureOpenAI_LLMs implements INode {
const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string
const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string
const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string
const azureOpenAIApiEmbeddingsDeploymentName = nodeData.inputs?.azureOpenAIApiEmbeddingsDeploymentName as string const maxTokens = nodeData.inputs?.maxTokens as string
const azureOpenAIApiCompletionsDeploymentName = nodeData.inputs?.azureOpenAIApiCompletionsDeploymentName as string const topP = nodeData.inputs?.topP as string
const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string
const presencePenalty = nodeData.inputs?.presencePenalty as string
const timeout = nodeData.inputs?.timeout as string
const batchSize = nodeData.inputs?.batchSize as string
const bestOf = nodeData.inputs?.bestOf as string
const obj: Partial<AzureOpenAIInput> & Partial<OpenAIInput> = { const obj: Partial<AzureOpenAIInput> & Partial<OpenAIInput> = {
temperature: parseInt(temperature, 10), temperature: parseInt(temperature, 10),
@@ -146,8 +194,13 @@ class AzureOpenAI_LLMs implements INode {
azureOpenAIApiVersion azureOpenAIApiVersion
} }
if (azureOpenAIApiEmbeddingsDeploymentName) obj.azureOpenAIApiEmbeddingsDeploymentName = azureOpenAIApiEmbeddingsDeploymentName if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
if (azureOpenAIApiCompletionsDeploymentName) obj.azureOpenAIApiCompletionsDeploymentName = azureOpenAIApiCompletionsDeploymentName if (topP) obj.topP = parseInt(topP, 10)
if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10)
if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10)
if (timeout) obj.timeout = parseInt(timeout, 10)
if (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (bestOf) obj.bestOf = parseInt(bestOf, 10)
const model = new OpenAI(obj) const model = new OpenAI(obj)
return model return model