mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Update LLMRedisCache.ts
code cleanup
This commit is contained in:
@@ -1,13 +1,4 @@
|
|||||||
import {
|
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||||
getBaseClasses,
|
|
||||||
getCredentialData,
|
|
||||||
getCredentialParam,
|
|
||||||
ICommonObject,
|
|
||||||
INode,
|
|
||||||
INodeData,
|
|
||||||
INodeOutputsValue,
|
|
||||||
INodeParams
|
|
||||||
} from '../../../src'
|
|
||||||
import { RedisCache } from 'langchain/cache/ioredis'
|
import { RedisCache } from 'langchain/cache/ioredis'
|
||||||
import { Redis } from 'ioredis'
|
import { Redis } from 'ioredis'
|
||||||
|
|
||||||
@@ -21,7 +12,6 @@ class LLMRedisCache implements INode {
|
|||||||
category: string
|
category: string
|
||||||
baseClasses: string[]
|
baseClasses: string[]
|
||||||
inputs: INodeParams[]
|
inputs: INodeParams[]
|
||||||
outputs: INodeOutputsValue[]
|
|
||||||
credential: INodeParams
|
credential: INodeParams
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -31,7 +21,7 @@ class LLMRedisCache implements INode {
|
|||||||
this.type = 'LLMCache'
|
this.type = 'LLMCache'
|
||||||
this.icon = 'redis.svg'
|
this.icon = 'redis.svg'
|
||||||
this.category = 'LLM Cache'
|
this.category = 'LLM Cache'
|
||||||
this.baseClasses = [this.type, 'LLMCacheBase']
|
this.baseClasses = [this.type, ...getBaseClasses(RedisCache)]
|
||||||
this.credential = {
|
this.credential = {
|
||||||
label: 'Connect Credential',
|
label: 'Connect Credential',
|
||||||
name: 'credential',
|
name: 'credential',
|
||||||
@@ -40,13 +30,6 @@ class LLMRedisCache implements INode {
|
|||||||
credentialNames: ['redisCacheApi']
|
credentialNames: ['redisCacheApi']
|
||||||
}
|
}
|
||||||
this.inputs = []
|
this.inputs = []
|
||||||
this.outputs = [
|
|
||||||
{
|
|
||||||
label: 'LLM Cache',
|
|
||||||
name: 'cache',
|
|
||||||
baseClasses: [this.type, ...getBaseClasses(RedisCache)]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
@@ -55,18 +38,12 @@ class LLMRedisCache implements INode {
|
|||||||
const password = getCredentialParam('redisCachePwd', credentialData, nodeData)
|
const password = getCredentialParam('redisCachePwd', credentialData, nodeData)
|
||||||
const portStr = getCredentialParam('redisCachePort', credentialData, nodeData)
|
const portStr = getCredentialParam('redisCachePort', credentialData, nodeData)
|
||||||
const host = getCredentialParam('redisCacheHost', credentialData, nodeData)
|
const host = getCredentialParam('redisCacheHost', credentialData, nodeData)
|
||||||
let port = 6379
|
|
||||||
try {
|
|
||||||
port = portStr ? parseInt(portStr) : 6379
|
|
||||||
} catch (e) {
|
|
||||||
port = 6379
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = new Redis({
|
const client = new Redis({
|
||||||
port: port, // Redis port
|
port: portStr ? parseInt(portStr) : 6379,
|
||||||
host: host,
|
host,
|
||||||
username: username,
|
username,
|
||||||
password: password
|
password
|
||||||
})
|
})
|
||||||
return new RedisCache(client)
|
return new RedisCache(client)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user