Feature/externalize model list (#2113)

* fixes

* test json

* test json

* externalize model list

* externalize model list

* correcting awsChatBedRock Name

* lint fixes

* externalize models

* externalize chat models

* externalize chat models

* externalize llm models

* externalize llm models

* lint fixes

* addition of models for ChatMistral

* updating version numbers for all imapacted nodes.

* marketplace template updates

* update embeddings, marketplaces, add chatCohere

* config changes for new env variable

* removal of local models.json

* update models json file

---------

Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
Vinod Kiran
2024-04-12 17:16:10 +05:30
committed by GitHub
parent 4daf29db80
commit 788d40f26b
76 changed files with 789 additions and 4044 deletions
@@ -1,7 +1,8 @@
import { BedrockRuntimeClient, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime'
import { BedrockEmbeddings, BedrockEmbeddingsParams } from '@langchain/community/embeddings/bedrock'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels, getRegions } from '../../../src/modelLoader'
class AWSBedrockEmbedding_Embeddings implements INode {
label: string
@@ -18,7 +19,7 @@ class AWSBedrockEmbedding_Embeddings implements INode {
constructor() {
this.label = 'AWS Bedrock Embeddings'
this.name = 'AWSBedrockEmbeddings'
this.version = 3.0
this.version = 4.0
this.type = 'AWSBedrockEmbeddings'
this.icon = 'aws.svg'
this.category = 'Embeddings'
@@ -35,56 +36,15 @@ class AWSBedrockEmbedding_Embeddings implements INode {
{
label: 'Region',
name: 'region',
type: 'options',
options: [
{ label: 'af-south-1', name: 'af-south-1' },
{ label: 'ap-east-1', name: 'ap-east-1' },
{ label: 'ap-northeast-1', name: 'ap-northeast-1' },
{ label: 'ap-northeast-2', name: 'ap-northeast-2' },
{ label: 'ap-northeast-3', name: 'ap-northeast-3' },
{ label: 'ap-south-1', name: 'ap-south-1' },
{ label: 'ap-south-2', name: 'ap-south-2' },
{ label: 'ap-southeast-1', name: 'ap-southeast-1' },
{ label: 'ap-southeast-2', name: 'ap-southeast-2' },
{ label: 'ap-southeast-3', name: 'ap-southeast-3' },
{ label: 'ap-southeast-4', name: 'ap-southeast-4' },
{ label: 'ap-southeast-5', name: 'ap-southeast-5' },
{ label: 'ap-southeast-6', name: 'ap-southeast-6' },
{ label: 'ca-central-1', name: 'ca-central-1' },
{ label: 'ca-west-1', name: 'ca-west-1' },
{ label: 'cn-north-1', name: 'cn-north-1' },
{ label: 'cn-northwest-1', name: 'cn-northwest-1' },
{ label: 'eu-central-1', name: 'eu-central-1' },
{ label: 'eu-central-2', name: 'eu-central-2' },
{ label: 'eu-north-1', name: 'eu-north-1' },
{ label: 'eu-south-1', name: 'eu-south-1' },
{ label: 'eu-south-2', name: 'eu-south-2' },
{ label: 'eu-west-1', name: 'eu-west-1' },
{ label: 'eu-west-2', name: 'eu-west-2' },
{ label: 'eu-west-3', name: 'eu-west-3' },
{ label: 'il-central-1', name: 'il-central-1' },
{ label: 'me-central-1', name: 'me-central-1' },
{ label: 'me-south-1', name: 'me-south-1' },
{ label: 'sa-east-1', name: 'sa-east-1' },
{ label: 'us-east-1', name: 'us-east-1' },
{ label: 'us-east-2', name: 'us-east-2' },
{ label: 'us-gov-east-1', name: 'us-gov-east-1' },
{ label: 'us-gov-west-1', name: 'us-gov-west-1' },
{ label: 'us-west-1', name: 'us-west-1' },
{ label: 'us-west-2', name: 'us-west-2' }
],
type: 'asyncOptions',
loadMethod: 'listRegions',
default: 'us-east-1'
},
{
label: 'Model Name',
name: 'model',
type: 'options',
options: [
{ label: 'amazon.titan-embed-text-v1', name: 'amazon.titan-embed-text-v1' },
{ label: 'amazon.titan-embed-g1-text-02', name: 'amazon.titan-embed-g1-text-02' },
{ label: 'cohere.embed-english-v3', name: 'cohere.embed-english-v3' },
{ label: 'cohere.embed-multilingual-v3', name: 'cohere.embed-multilingual-v3' }
],
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'amazon.titan-embed-text-v1'
},
{
@@ -97,6 +57,16 @@ class AWSBedrockEmbedding_Embeddings implements INode {
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'AWSBedrockEmbeddings')
},
async listRegions(): Promise<INodeOptionsValue[]> {
return await getRegions(MODEL_TYPE.EMBEDDING, 'AWSBedrockEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const iRegion = nodeData.inputs?.region as string
const iModel = nodeData.inputs?.model as string
@@ -1,6 +1,7 @@
import { CohereEmbeddings, CohereEmbeddingsParams } from '@langchain/cohere'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
class CohereEmbedding_Embeddings implements INode {
label: string
@@ -17,7 +18,7 @@ class CohereEmbedding_Embeddings implements INode {
constructor() {
this.label = 'Cohere Embeddings'
this.name = 'cohereEmbeddings'
this.version = 2.0
this.version = 3.0
this.type = 'CohereEmbeddings'
this.icon = 'Cohere.svg'
this.category = 'Embeddings'
@@ -33,46 +34,9 @@ class CohereEmbedding_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'embed-english-v3.0',
name: 'embed-english-v3.0',
description: 'Embedding Dimensions: 1024'
},
{
label: 'embed-english-light-v3.0',
name: 'embed-english-light-v3.0',
description: 'Embedding Dimensions: 384'
},
{
label: 'embed-multilingual-v3.0',
name: 'embed-multilingual-v3.0',
description: 'Embedding Dimensions: 1024'
},
{
label: 'embed-multilingual-light-v3.0',
name: 'embed-multilingual-light-v3.0',
description: 'Embedding Dimensions: 384'
},
{
label: 'embed-english-v2.0',
name: 'embed-english-v2.0',
description: 'Embedding Dimensions: 4096'
},
{
label: 'embed-english-light-v2.0',
name: 'embed-english-light-v2.0',
description: 'Embedding Dimensions: 1024'
},
{
label: 'embed-multilingual-v2.0',
name: 'embed-multilingual-v2.0',
description: 'Embedding Dimensions: 768'
}
],
default: 'embed-english-v2.0',
optional: true
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'embed-english-v2.0'
},
{
label: 'Type',
@@ -108,6 +72,13 @@ class CohereEmbedding_Embeddings implements INode {
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'cohereEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
const inputType = nodeData.inputs?.inputType as string
@@ -1,7 +1,8 @@
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { GoogleGenerativeAIEmbeddings, GoogleGenerativeAIEmbeddingsParams } from '@langchain/google-genai'
import { TaskType } from '@google/generative-ai'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
class GoogleGenerativeAIEmbedding_Embeddings implements INode {
label: string
@@ -18,7 +19,7 @@ class GoogleGenerativeAIEmbedding_Embeddings implements INode {
constructor() {
this.label = 'GoogleGenerativeAI Embeddings'
this.name = 'googleGenerativeAiEmbeddings'
this.version = 1.0
this.version = 2.0
this.type = 'GoogleGenerativeAiEmbeddings'
this.icon = 'GoogleGemini.svg'
this.category = 'Embeddings'
@@ -36,13 +37,8 @@ class GoogleGenerativeAIEmbedding_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'embedding-001',
name: 'embedding-001'
}
],
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'embedding-001'
},
{
@@ -63,6 +59,13 @@ class GoogleGenerativeAIEmbedding_Embeddings implements INode {
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'googleGenerativeAiEmbeddings')
}
}
// eslint-disable-next-line unused-imports/no-unused-vars
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
@@ -1,6 +1,7 @@
import { GooglePaLMEmbeddings, GooglePaLMEmbeddingsParams } from '@langchain/community/embeddings/googlepalm'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
class GooglePaLMEmbedding_Embeddings implements INode {
label: string
@@ -17,7 +18,7 @@ class GooglePaLMEmbedding_Embeddings implements INode {
constructor() {
this.label = 'Google PaLM Embeddings'
this.name = 'googlePaLMEmbeddings'
this.version = 1.0
this.version = 2.0
this.type = 'GooglePaLMEmbeddings'
this.icon = 'GooglePaLM.svg'
this.category = 'Embeddings'
@@ -33,19 +34,20 @@ class GooglePaLMEmbedding_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'models/embedding-gecko-001',
name: 'models/embedding-gecko-001'
}
],
default: 'models/embedding-gecko-001',
optional: true
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'models/embedding-gecko-001'
}
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'googlePaLMEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
@@ -1,7 +1,8 @@
import { GoogleAuthOptions } from 'google-auth-library'
import { GoogleVertexAIEmbeddings, GoogleVertexAIEmbeddingsParams } from '@langchain/community/embeddings/googlevertexai'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
class GoogleVertexAIEmbedding_Embeddings implements INode {
label: string
@@ -18,7 +19,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
constructor() {
this.label = 'GoogleVertexAI Embeddings'
this.name = 'googlevertexaiEmbeddings'
this.version = 1.0
this.version = 2.0
this.type = 'GoogleVertexAIEmbeddings'
this.icon = 'GoogleVertex.svg'
this.category = 'Embeddings'
@@ -37,27 +38,20 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'textembedding-gecko@001',
name: 'textembedding-gecko@001'
},
{
label: 'textembedding-gecko@latest',
name: 'textembedding-gecko@latest'
},
{
label: 'textembedding-gecko-multilingual@latest',
name: 'textembedding-gecko-multilingual@latest'
}
],
default: 'textembedding-gecko@001',
optional: true
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'textembedding-gecko@001'
}
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'googlevertexaiEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const modelName = nodeData.inputs?.modelName as string
@@ -1,6 +1,7 @@
import { MistralAIEmbeddings, MistralAIEmbeddingsParams } from '@langchain/mistralai'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
class MistralEmbedding_Embeddings implements INode {
label: string
@@ -16,8 +17,8 @@ class MistralEmbedding_Embeddings implements INode {
constructor() {
this.label = 'MistralAI Embeddings'
this.name = 'mistralAI Embeddings'
this.version = 1.0
this.name = 'mistralAIEmbeddings'
this.version = 2.0
this.type = 'MistralAIEmbeddings'
this.icon = 'MistralAI.svg'
this.category = 'Embeddings'
@@ -33,13 +34,8 @@ class MistralEmbedding_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'mistral-embed',
name: 'mistral-embed'
}
],
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'mistral-embed'
},
{
@@ -69,6 +65,13 @@ class MistralEmbedding_Embeddings implements INode {
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'mistralAIEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
const batchSize = nodeData.inputs?.batchSize as string
@@ -1,6 +1,7 @@
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from '@langchain/openai'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
class OpenAIEmbedding_Embeddings implements INode {
label: string
@@ -17,7 +18,7 @@ class OpenAIEmbedding_Embeddings implements INode {
constructor() {
this.label = 'OpenAI Embeddings'
this.name = 'openAIEmbeddings'
this.version = 2.0
this.version = 3.0
this.type = 'OpenAIEmbeddings'
this.icon = 'openai.svg'
this.category = 'Embeddings'
@@ -33,23 +34,9 @@ class OpenAIEmbedding_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'text-embedding-3-large',
name: 'text-embedding-3-large'
},
{
label: 'text-embedding-3-small',
name: 'text-embedding-3-small'
},
{
label: 'text-embedding-ada-002',
name: 'text-embedding-ada-002'
}
],
default: 'text-embedding-ada-002',
optional: true
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'text-embedding-ada-002'
},
{
label: 'Strip New Lines',
@@ -82,6 +69,13 @@ class OpenAIEmbedding_Embeddings implements INode {
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'openAIEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const stripNewLines = nodeData.inputs?.stripNewLines as boolean
const batchSize = nodeData.inputs?.batchSize as string
@@ -1,4 +1,5 @@
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { OpenAIEmbedding } from 'llamaindex'
@@ -18,7 +19,7 @@ class OpenAIEmbedding_LlamaIndex_Embeddings implements INode {
constructor() {
this.label = 'OpenAI Embedding'
this.name = 'openAIEmbedding_LlamaIndex'
this.version = 1.0
this.version = 2.0
this.type = 'OpenAIEmbedding'
this.icon = 'openai.svg'
this.category = 'Embeddings'
@@ -35,23 +36,9 @@ class OpenAIEmbedding_LlamaIndex_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'text-embedding-3-large',
name: 'text-embedding-3-large'
},
{
label: 'text-embedding-3-small',
name: 'text-embedding-3-small'
},
{
label: 'text-embedding-ada-002',
name: 'text-embedding-ada-002'
}
],
default: 'text-embedding-ada-002',
optional: true
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'text-embedding-ada-002'
},
{
label: 'Timeout',
@@ -70,6 +57,13 @@ class OpenAIEmbedding_LlamaIndex_Embeddings implements INode {
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'openAIEmbedding_LlamaIndex')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const timeout = nodeData.inputs?.timeout as string
const modelName = nodeData.inputs?.modelName as string
@@ -1,4 +1,5 @@
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { VoyageEmbeddings, VoyageEmbeddingsParams } from 'langchain/embeddings/voyage'
@@ -17,7 +18,7 @@ class VoyageAIEmbedding_Embeddings implements INode {
constructor() {
this.label = 'VoyageAI Embeddings'
this.name = 'voyageAIEmbeddings'
this.version = 1.0
this.version = 2.0
this.type = 'VoyageAIEmbeddings'
this.icon = 'voyageai.png'
this.category = 'Embeddings'
@@ -33,35 +34,20 @@ class VoyageAIEmbedding_Embeddings implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'voyage-2',
name: 'voyage-2',
description: 'Base generalist embedding model optimized for both latency and quality'
},
{
label: 'voyage-code-2',
name: 'voyage-code-2',
description: 'Optimized for code retrieval'
},
{
label: 'voyage-large-2',
name: 'voyage-large-2',
description: 'Powerful generalist embedding model'
},
{
label: 'voyage-lite-02-instruct',
name: 'voyage-lite-02-instruct',
description: 'Instruction-tuned for classification, clustering, and sentence textual similarity tasks'
}
],
default: 'voyage-2',
optional: true
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'voyage-2'
}
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'voyageAIEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string