mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
[Feature] added Jina AI Embedding support (#3355)
* added Jina AI Embedding support * Update JinaAIEmbedding.ts Change model name to string type * removed jina embeddings * lint fix --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||||
|
|
||||||
|
class JinaAICredential implements INodeCredential {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
version: number
|
||||||
|
description: string
|
||||||
|
inputs: INodeParams[]
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.label = 'JinaAI API'
|
||||||
|
this.name = 'jinaAIApi'
|
||||||
|
this.version = 1.0
|
||||||
|
this.description = 'You can get your API key from official <a target="_blank" href="https://jina.ai/">console</a> here.'
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'JinaAI API Key',
|
||||||
|
name: 'jinaAIAPIKey',
|
||||||
|
type: 'password'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { credClass: JinaAICredential }
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 94 40">
|
||||||
|
<path fill="#EB6161" d="M6.12 39.92c3.38 0 6.12-2.74 6.12-6.12s-2.74-6.12-6.12-6.12S0 30.42 0 33.8s2.74 6.12 6.12 6.12z"/>
|
||||||
|
<path fill="#009191" fill-rule="evenodd" d="M25.4 14.52c.8 0 1.44.64 1.44 1.44l-.08 11.72c0 6.68-5.36 12.12-12.04 12.24h-.2v-12.2h.04L14.6 16c0-.8.64-1.44 1.44-1.44h9.36v-.04zm18.8 0c.8 0 1.44.64 1.44 1.44v16.4c0 .8-.64 1.44-1.44 1.44h-9.36c-.8 0-1.44-.64-1.44-1.44v-16.4c0-.8.64-1.44 1.44-1.44h9.36zm14.72-.04h.2c6 .08 10.88 4.92 11.04 10.92v6.92c0 .8-.64 1.44-1.44 1.44H53.6c-.8 0-1.44-.64-1.44-1.44v-16.4c0-.8.64-1.44 1.44-1.44h5.32zM83.68 33.6c-5.04-.32-9.08-4.52-9.08-9.64 0-5.32 4.32-9.64 9.64-9.64 5.12 0 9.32 4 9.64 9.08v8.76c0 .8-.64 1.44-1.44 1.44h-8.76z" clip-rule="evenodd"/>
|
||||||
|
<path fill="#FBCB67" d="M39.499 12.24c3.38 0 6.12-2.74 6.12-6.12S42.879 0 39.499 0s-6.12 2.74-6.12 6.12 2.74 6.12 6.12 6.12z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 913 B |
@@ -0,0 +1,58 @@
|
|||||||
|
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
|
import { JinaEmbeddings, JinaEmbeddingsParams } from '@langchain/community/embeddings/jina'
|
||||||
|
|
||||||
|
class JinaAIEmbedding_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 = 'Jina Embeddings'
|
||||||
|
this.name = 'jinaEmbeddings'
|
||||||
|
this.version = 1.0
|
||||||
|
this.type = 'JinaEmbeddings'
|
||||||
|
this.icon = 'JinaAIEmbedding.svg'
|
||||||
|
this.category = 'Embeddings'
|
||||||
|
this.description = 'JinaAI API to generate embeddings for a given text'
|
||||||
|
this.baseClasses = [this.type, ...getBaseClasses(JinaEmbeddings)]
|
||||||
|
this.credential = {
|
||||||
|
label: 'Connect Credential',
|
||||||
|
name: 'credential',
|
||||||
|
type: 'credential',
|
||||||
|
credentialNames: ['jinaAIApi']
|
||||||
|
}
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Model Name',
|
||||||
|
name: 'modelName',
|
||||||
|
type: 'string',
|
||||||
|
default: 'jina-embeddings-v2-base-en',
|
||||||
|
description: 'Refer to <a href="https://jina.ai/embeddings/" target="_blank">JinaAI documentation</a> for available models'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
|
const apiKey = getCredentialParam('jinaAIAPIKey', credentialData, nodeData)
|
||||||
|
|
||||||
|
const obj: JinaEmbeddingsParams = {
|
||||||
|
apiKey: apiKey,
|
||||||
|
model: modelName
|
||||||
|
}
|
||||||
|
|
||||||
|
const model = new JinaEmbeddings(obj)
|
||||||
|
return model
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { nodeClass: JinaAIEmbedding_Embeddings }
|
||||||
Reference in New Issue
Block a user