This commit is contained in:
Henry
2023-04-17 22:12:32 +01:00
3 changed files with 41 additions and 0 deletions
@@ -0,0 +1,40 @@
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses } from '../../../src/utils'
import { CohereEmbeddings } from 'langchain/embeddings/cohere'
class CohereEmbedding_Embeddings implements INode {
label: string
name: string
type: string
icon: string
category: string
description: string
baseClasses: string[]
inputs: INodeParams[]
constructor() {
this.label = 'Cohere Embeddings'
this.name = 'cohereEmbeddings'
this.type = 'CohereEmbeddings'
this.icon = 'cohere.png'
this.category = 'Embeddings'
this.description = 'Cohere API to generate embeddings for a given text'
this.baseClasses = [this.type, ...getBaseClasses(CohereEmbeddings)]
this.inputs = [
{
label: 'Cohere API Key',
name: 'cohereApiKey',
type: 'password'
}
]
}
async init(nodeData: INodeData): Promise<any> {
const apiKey = nodeData.inputs?.cohereApiKey as string
const model = new CohereEmbeddings({ apiKey })
return model
}
}
module.exports = { nodeClass: CohereEmbedding_Embeddings }
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

+1
View File
@@ -22,6 +22,7 @@
"axios": "^0.27.2",
"cheerio": "^1.0.0-rc.12",
"chromadb": "^1.3.1",
"cohere-ai": "^6.2.0",
"d3-dsv": "2",
"dotenv": "^16.0.0",
"express": "^4.17.3",