Files
Henry Heng bca4de0c63 Feature/seq agents (#2798)
* update build functions

* sequential agents

* update langchain to 0.2, added sequential agent nodes

* add marketplace templates

* update howto wordings

* Merge branch 'main' into feature/Seq-Agents

# Conflicts:
#	pnpm-lock.yaml

* update deprecated functions and add new sequential nodes

* add marketplace templates

* update marketplace templates, add structured output to llm node

* add multi agents template

* update llm node with bindmodels

* update cypress version

* update templates sticky note wordings

* update tool node to include human in loop action

* update structured outputs error from models

* update cohere package to resolve google genai pipeThrough bug

* update mistral package version, added message reconstruction before invoke seq agent

* add HITL to agent

* update state messages restructuring

* update load and split methods for s3 directory
2024-07-22 17:46:14 +01:00

71 lines
2.4 KiB
TypeScript

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/community/embeddings/voyage'
class VoyageAIEmbedding_Embeddings implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'VoyageAI Embeddings'
this.name = 'voyageAIEmbeddings'
this.version = 2.0
this.type = 'VoyageAIEmbeddings'
this.icon = 'voyageai.png'
this.category = 'Embeddings'
this.description = 'Voyage AI API to generate embeddings for a given text'
this.baseClasses = [this.type, ...getBaseClasses(VoyageEmbeddings)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['voyageAIApi']
}
this.inputs = [
{
label: 'Model Name',
name: 'modelName',
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
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const voyageAiApiKey = getCredentialParam('apiKey', credentialData, nodeData)
const voyageAiEndpoint = getCredentialParam('endpoint', credentialData, nodeData)
const obj: Partial<VoyageEmbeddingsParams> & { apiKey?: string } = {
apiKey: voyageAiApiKey
}
if (modelName) obj.modelName = modelName
const model = new VoyageEmbeddings(obj)
if (voyageAiEndpoint) model.apiUrl = voyageAiEndpoint
return model
}
}
module.exports = { nodeClass: VoyageAIEmbedding_Embeddings }