Expose dimensions parameter on Jina Embeddings (#3969)
* Expose dimensions parameter on Jina Embeddings * fix linting issue * update description text to refer to dimensions * Update JinaAIEmbedding.ts --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
parent
7d125d50d4
commit
8d327e465c
|
|
@ -17,7 +17,7 @@ class JinaAIEmbedding_Embeddings implements INode {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Jina Embeddings'
|
this.label = 'Jina Embeddings'
|
||||||
this.name = 'jinaEmbeddings'
|
this.name = 'jinaEmbeddings'
|
||||||
this.version = 1.0
|
this.version = 2.0
|
||||||
this.type = 'JinaEmbeddings'
|
this.type = 'JinaEmbeddings'
|
||||||
this.icon = 'JinaAIEmbedding.svg'
|
this.icon = 'JinaAIEmbedding.svg'
|
||||||
this.category = 'Embeddings'
|
this.category = 'Embeddings'
|
||||||
|
|
@ -36,18 +36,28 @@ class JinaAIEmbedding_Embeddings implements INode {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'jina-embeddings-v2-base-en',
|
default: 'jina-embeddings-v2-base-en',
|
||||||
description: 'Refer to <a href="https://jina.ai/embeddings/" target="_blank">JinaAI documentation</a> for available models'
|
description: 'Refer to <a href="https://jina.ai/embeddings/" target="_blank">JinaAI documentation</a> for available models'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Dimensions',
|
||||||
|
name: 'modelDimensions',
|
||||||
|
type: 'number',
|
||||||
|
default: 1024,
|
||||||
|
description:
|
||||||
|
'Refer to <a href="https://jina.ai/embeddings/" target="_blank">JinaAI documentation</a> for available dimensions'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const modelName = nodeData.inputs?.modelName as string
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
|
const modelDimensions = nodeData.inputs?.modelDimensions as number
|
||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const apiKey = getCredentialParam('jinaAIAPIKey', credentialData, nodeData)
|
const apiKey = getCredentialParam('jinaAIAPIKey', credentialData, nodeData)
|
||||||
|
|
||||||
const model = new JinaEmbeddings({
|
const model = new JinaEmbeddings({
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
model: modelName
|
model: modelName,
|
||||||
|
dimensions: modelDimensions
|
||||||
})
|
})
|
||||||
|
|
||||||
return model
|
return model
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue