mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 09:00:52 +03:00
Renaming of Category, Class Names and File names from LLMCache to Cache as this functionality is applicable to both LLM and Chat Models.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { UpstashRedisCache as LangchainUpstashRedisCache } from 'langchain/cache/upstash_redis'
|
||||
|
||||
class UpstashRedisCache implements INode {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
credential: INodeParams
|
||||
|
||||
constructor() {
|
||||
this.label = 'Upstash Redis LLM Cache'
|
||||
this.name = 'upstashRedisCache'
|
||||
this.version = 1.0
|
||||
this.type = 'Cache'
|
||||
this.icon = 'upstash.png'
|
||||
this.category = 'Cache'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(UpstashRedisCache)]
|
||||
this.credential = {
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
optional: true,
|
||||
credentialNames: ['upstashRedisApi']
|
||||
}
|
||||
this.inputs = []
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const upstashConnectionUrl = getCredentialParam('upstashConnectionUrl', credentialData, nodeData)
|
||||
const upstashToken = getCredentialParam('upstashConnectionToken', credentialData, nodeData)
|
||||
|
||||
const cache = new LangchainUpstashRedisCache({
|
||||
config: {
|
||||
url: upstashConnectionUrl,
|
||||
token: upstashToken
|
||||
}
|
||||
})
|
||||
return cache
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: UpstashRedisCache }
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user