mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Extending support for Caching to all LLM's.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { Replicate, ReplicateInput } from 'langchain/llms/replicate'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class Replicate_LLMs implements INode {
|
||||
label: string
|
||||
@@ -17,7 +19,7 @@ class Replicate_LLMs implements INode {
|
||||
constructor() {
|
||||
this.label = 'Replicate'
|
||||
this.name = 'replicate'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Replicate'
|
||||
this.icon = 'replicate.svg'
|
||||
this.category = 'LLMs'
|
||||
@@ -30,6 +32,12 @@ class Replicate_LLMs implements INode {
|
||||
credentialNames: ['replicateApi']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Cache',
|
||||
name: 'llmCache',
|
||||
type: 'LLMCache',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Model',
|
||||
name: 'model',
|
||||
@@ -103,7 +111,9 @@ class Replicate_LLMs implements INode {
|
||||
const name = modelName.split(':')[0].split('/').pop()
|
||||
const org = modelName.split(':')[0].split('/')[0]
|
||||
|
||||
const obj: ReplicateInput = {
|
||||
const llmCache = nodeData.inputs?.llmCache as BaseCache
|
||||
|
||||
const obj: ReplicateInput & BaseLLMParams = {
|
||||
model: `${org}/${name}:${version}`,
|
||||
apiKey
|
||||
}
|
||||
@@ -120,6 +130,8 @@ class Replicate_LLMs implements INode {
|
||||
}
|
||||
if (Object.keys(inputs).length) obj.input = inputs
|
||||
|
||||
if (llmCache) obj.cache = llmCache
|
||||
|
||||
const model = new Replicate(obj)
|
||||
return model
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user