feat(components): cohere.ai embeddings node

This commit is contained in:
Miles Zimmerman
2023-04-16 13:48:41 +00:00
parent 0681a34408
commit da56cd5f68
3 changed files with 42 additions and 1 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

+2 -1
View File
@@ -21,10 +21,11 @@
"@pinecone-database/pinecone": "^0.0.12",
"axios": "^0.27.2",
"chromadb": "^1.3.1",
"cohere-ai": "^6.2.0",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"form-data": "^4.0.0",
"langchain": "^0.0.53",
"langchain": "^0.0.56",
"moment": "^2.29.3",
"node-fetch": "2",
"pdf-parse": "^1.1.1",