mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 01:01:11 +03:00
Extending support for Caching to all LLM's.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { HFInput, HuggingFaceInference } from './core'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class HuggingFaceInference_LLMs implements INode {
|
||||
label: string
|
||||
@@ -17,7 +18,7 @@ class HuggingFaceInference_LLMs implements INode {
|
||||
constructor() {
|
||||
this.label = 'HuggingFace Inference'
|
||||
this.name = 'huggingFaceInference_LLMs'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'HuggingFaceInference'
|
||||
this.icon = 'huggingface.png'
|
||||
this.category = 'LLMs'
|
||||
@@ -30,6 +31,12 @@ class HuggingFaceInference_LLMs implements INode {
|
||||
credentialNames: ['huggingFaceApi']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Cache',
|
||||
name: 'llmCache',
|
||||
type: 'LLMCache',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Model',
|
||||
name: 'model',
|
||||
@@ -106,6 +113,8 @@ class HuggingFaceInference_LLMs implements INode {
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const huggingFaceApiKey = getCredentialParam('huggingFaceApiKey', credentialData, nodeData)
|
||||
|
||||
const llmCache = nodeData.inputs?.llmCache as BaseCache
|
||||
|
||||
const obj: Partial<HFInput> = {
|
||||
model,
|
||||
apiKey: huggingFaceApiKey
|
||||
@@ -119,6 +128,8 @@ class HuggingFaceInference_LLMs implements INode {
|
||||
if (endpoint) obj.endpoint = endpoint
|
||||
|
||||
const huggingFace = new HuggingFaceInference(obj)
|
||||
if (llmCache) huggingFace.cache = llmCache
|
||||
|
||||
return huggingFace
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user