From f42a2d338765a350c87a41a1fbc21c637de63259 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 11 Oct 2023 19:54:10 +0100 Subject: [PATCH 1/2] add in-mem llm cache --- .../cache/InMemoryCache/InMemoryCache.ts | 64 ++++++++++++++++++ .../cache/InMemoryCache/inmemorycache.png | Bin 0 -> 12175 bytes packages/components/package.json | 2 + packages/server/src/CachePool.ts | 53 +++++++++++++++ packages/server/src/Interface.ts | 4 ++ packages/server/src/index.ts | 9 ++- packages/server/src/utils/index.ts | 11 ++- 7 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts create mode 100644 packages/components/nodes/cache/InMemoryCache/inmemorycache.png create mode 100644 packages/server/src/CachePool.ts diff --git a/packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts b/packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts new file mode 100644 index 00000000000..fe7a3f120a2 --- /dev/null +++ b/packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts @@ -0,0 +1,64 @@ +import { getBaseClasses, ICommonObject, INode, INodeData, INodeParams } from '../../../src' +import { BaseCache } from 'langchain/schema' +import hash from 'object-hash' + +class InMemoryCache 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 = 'InMemory Cache' + this.name = 'inMemoryCache' + this.version = 1.0 + this.type = 'InMemoryCache' + this.icon = 'inmemorycache.png' + this.category = 'Cache' + this.baseClasses = [this.type, ...getBaseClasses(InMemoryCacheExtended)] + this.inputs = [] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const memoryMap = options.cachePool.getLLMCache(options.chatflowid) ?? new Map() + const inMemCache = new InMemoryCacheExtended(memoryMap) + + inMemCache.lookup = async (prompt: string, llmKey: string): Promise => { + const memory = options.cachePool.getLLMCache(options.chatflowid) ?? inMemCache.cache + return Promise.resolve(memory.get(getCacheKey(prompt, llmKey)) ?? null) + } + + inMemCache.update = async (prompt: string, llmKey: string, value: any): Promise => { + inMemCache.cache.set(getCacheKey(prompt, llmKey), value) + options.cachePool.addLLMCache(options.chatflowid, inMemCache.cache) + } + return inMemCache + } +} + +const getCacheKey = (...strings: string[]): string => hash(strings.join('_')) + +class InMemoryCacheExtended extends BaseCache { + cache: Map + + constructor(map: Map) { + super() + this.cache = map + } + + lookup(prompt: string, llmKey: string): Promise { + return Promise.resolve(this.cache.get(getCacheKey(prompt, llmKey)) ?? null) + } + + async update(prompt: string, llmKey: string, value: any): Promise { + this.cache.set(getCacheKey(prompt, llmKey), value) + } +} + +module.exports = { nodeClass: InMemoryCache } diff --git a/packages/components/nodes/cache/InMemoryCache/inmemorycache.png b/packages/components/nodes/cache/InMemoryCache/inmemorycache.png new file mode 100644 index 0000000000000000000000000000000000000000..1e5fe6d14a4eac6876acd05668e165aa9daf9eca GIT binary patch literal 12175 zcmdsdXH*nR*KSW>Kypw)az;c63W6d@5f~6qat1*}K(gdCBOYOnd58iMbP$IuIS4d| zQ4|Ce2FcKl2NWa>AUVu!_5I%Up8M;rd)E!?{$Nc}yY{Z#yL(qX_3R>CG&AI26=Vef zfCFo!Zvg;ExQPTudIbLf&d^6VDBANa2}9AAWl{ z3AdjGar~UPMDOmGy586xKH{0LkvYxlBfjOm+p7-cAz`;eK51{4)U5FSB?s#%+5;d0lJd?Nu0(p;z*fiKRUPYZ@*GLkeu6xB?%uRn07h9LQ6j+hT!o=7& z#yN%=bI|g?V5NfK=pnN zjE1PjK@Cm~Rt=Yq*^BIv zRD7MRnwg7C2V5nPZMUlj9xZzT*FGJAoFHNMx;;_vVyV@?q`+`I8$kO6WtkZoZUP( zu>2{1a1?n)qxx0NmO5%Q@<;4qIHRGywMN<7XjW)YU6G`Le zsq=EFZl4?#?YHNM;odN$-8QgT9R92?7cZ+qZv`^4YEL)Uq}9v6A1NAZ$eL;*=ryRa z5!?dBD=MQ}il-8STnMt)nOh9d_+I2_pN*l9**kkBURdmK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0_JlrF#q|9@=gLb;AUXJX!riAH=0xSgKA`C4a}i z24~0$k}$0UObq^_b^II9Lwp)iq35M*rk{Yh2oJv&GVDN_3giwQf%d!Q!u%>VFAF{% z#~Z?z#v^$1sGcjhuc%&>8HQ7qlgFsDUl!t|RZgxDPVCh^FM7{Fso*|G^qE|z!} value + */ + addLLMCache(chatflowid: string, value: Map) { + this.activeLLMCache[chatflowid] = value + } + + /** + * Add to the embedding cache pool + * @param {string} chatflowid + * @param {Map} value + */ + addEmbeddingCache(chatflowid: string, value: Map) { + this.activeEmbeddingCache[chatflowid] = value + } + + /** + * Get item from llm cache pool + * @param {string} chatflowid + */ + getLLMCache(chatflowid: string): Map | undefined { + return this.activeLLMCache[chatflowid] + } + + /** + * Get item from embedding cache pool + * @param {string} chatflowid + */ + getEmbeddingCache(chatflowid: string): Map | undefined { + return this.activeEmbeddingCache[chatflowid] + } +} + +let cachePoolInstance: CachePool | undefined + +export function getInstance(): CachePool { + if (cachePoolInstance === undefined) { + cachePoolInstance = new CachePool() + } + + return cachePoolInstance +} diff --git a/packages/server/src/Interface.ts b/packages/server/src/Interface.ts index 58740b864d4..b3c3a3925ce 100644 --- a/packages/server/src/Interface.ts +++ b/packages/server/src/Interface.ts @@ -157,6 +157,10 @@ export interface IActiveChatflows { } } +export interface IActiveCache { + [key: string]: Map +} + export interface IOverrideConfig { node: string nodeId: string diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index db5ecf38412..9d3f7052400 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -53,6 +53,7 @@ import { ChatMessage } from './database/entities/ChatMessage' import { Credential } from './database/entities/Credential' import { Tool } from './database/entities/Tool' import { ChatflowPool } from './ChatflowPool' +import { CachePool } from './CachePool' import { ICommonObject, INodeOptionsValue } from 'flowise-components' import { createRateLimiter, getRateLimiter, initializeRateLimiter } from './utils/rateLimit' @@ -60,6 +61,7 @@ export class App { app: express.Application nodesPool: NodesPool chatflowPool: ChatflowPool + cachePool: CachePool AppDataSource = getDataSource() constructor() { @@ -91,6 +93,9 @@ export class App { // Initialize Rate Limit const AllChatFlow: IChatFlow[] = await getAllChatFlow() await initializeRateLimiter(AllChatFlow) + + // Initialize cache pool + this.cachePool = new CachePool() }) .catch((err) => { logger.error('❌ [server]: Error during Data Source initialization:', err) @@ -944,8 +949,10 @@ export class App { incomingInput.question, incomingInput.history, chatId, + chatflowid, this.AppDataSource, - incomingInput?.overrideConfig + incomingInput?.overrideConfig, + this.cachePool ) const nodeToExecute = reactFlowNodes.find((node: IReactFlowNode) => node.id === endingNodeId) diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index 7686e476080..317bcc0c26d 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -35,6 +35,7 @@ import { ChatMessage } from '../database/entities/ChatMessage' import { Credential } from '../database/entities/Credential' import { Tool } from '../database/entities/Tool' import { DataSource } from 'typeorm' +import { CachePool } from '../CachePool' const QUESTION_VAR_PREFIX = 'question' const CHAT_HISTORY_VAR_PREFIX = 'chat_history' @@ -197,8 +198,10 @@ export const getEndingNode = (nodeDependencies: INodeDependencies, graph: INodeD * @param {IComponentNodes} componentNodes * @param {string} question * @param {string} chatId + * @param {string} chatflowid * @param {DataSource} appDataSource * @param {ICommonObject} overrideConfig + * @param {CachePool} cachePool */ export const buildLangchain = async ( startingNodeIds: string[], @@ -209,8 +212,10 @@ export const buildLangchain = async ( question: string, chatHistory: IMessage[], chatId: string, + chatflowid: string, appDataSource: DataSource, - overrideConfig?: ICommonObject + overrideConfig?: ICommonObject, + cachePool?: CachePool ) => { const flowNodes = cloneDeep(reactFlowNodes) @@ -245,9 +250,11 @@ export const buildLangchain = async ( logger.debug(`[server]: Initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) flowNodes[nodeIndex].data.instance = await newNodeInstance.init(reactFlowNodeData, question, { chatId, + chatflowid, appDataSource, databaseEntities, - logger + logger, + cachePool }) logger.debug(`[server]: Finished initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) } catch (e: any) { From 41e612408c0ae738dcadfe5ed25cb9574bb02085 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 11 Oct 2023 20:09:13 +0100 Subject: [PATCH 2/2] add description --- packages/components/credentials/UpstashRedisApi.credential.ts | 3 +++ packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts | 1 + packages/components/nodes/cache/MomentoCache/MomentoCache.ts | 1 + packages/components/nodes/cache/RedisCache/RedisCache.ts | 1 + .../nodes/cache/UpstashRedisCache/UpstashRedisCache.ts | 1 + 5 files changed, 7 insertions(+) diff --git a/packages/components/credentials/UpstashRedisApi.credential.ts b/packages/components/credentials/UpstashRedisApi.credential.ts index b6e62ff35ca..7e2b367f996 100644 --- a/packages/components/credentials/UpstashRedisApi.credential.ts +++ b/packages/components/credentials/UpstashRedisApi.credential.ts @@ -4,12 +4,15 @@ class UpstashRedisApi implements INodeCredential { label: string name: string version: number + description: string inputs: INodeParams[] constructor() { this.label = 'Upstash Redis API' this.name = 'upstashRedisApi' this.version = 1.0 + this.description = + 'Refer to official guide on how to create redis instance and get redis REST URL and Token' this.inputs = [ { label: 'Upstash Redis REST URL', diff --git a/packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts b/packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts index fe7a3f120a2..1ea035668b8 100644 --- a/packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts +++ b/packages/components/nodes/cache/InMemoryCache/InMemoryCache.ts @@ -19,6 +19,7 @@ class InMemoryCache implements INode { this.name = 'inMemoryCache' this.version = 1.0 this.type = 'InMemoryCache' + this.description = 'Cache LLM response in memory, will be cleared once app restarted' this.icon = 'inmemorycache.png' this.category = 'Cache' this.baseClasses = [this.type, ...getBaseClasses(InMemoryCacheExtended)] diff --git a/packages/components/nodes/cache/MomentoCache/MomentoCache.ts b/packages/components/nodes/cache/MomentoCache/MomentoCache.ts index 9aa82e822ca..2bd2625b86a 100644 --- a/packages/components/nodes/cache/MomentoCache/MomentoCache.ts +++ b/packages/components/nodes/cache/MomentoCache/MomentoCache.ts @@ -19,6 +19,7 @@ class MomentoCache implements INode { this.name = 'momentoCache' this.version = 1.0 this.type = 'MomentoCache' + this.description = 'Cache LLM response using Momento, a distributed, serverless cache' this.icon = 'momento.png' this.category = 'Cache' this.baseClasses = [this.type, ...getBaseClasses(LangchainMomentoCache)] diff --git a/packages/components/nodes/cache/RedisCache/RedisCache.ts b/packages/components/nodes/cache/RedisCache/RedisCache.ts index c1b08be69ea..da2dfc49ec5 100644 --- a/packages/components/nodes/cache/RedisCache/RedisCache.ts +++ b/packages/components/nodes/cache/RedisCache/RedisCache.ts @@ -19,6 +19,7 @@ class RedisCache implements INode { this.name = 'redisCache' this.version = 1.0 this.type = 'RedisCache' + this.description = 'Cache LLM response in Redis, useful for sharing cache across multiple processes or servers' this.icon = 'redis.svg' this.category = 'Cache' this.baseClasses = [this.type, ...getBaseClasses(LangchainRedisCache)] diff --git a/packages/components/nodes/cache/UpstashRedisCache/UpstashRedisCache.ts b/packages/components/nodes/cache/UpstashRedisCache/UpstashRedisCache.ts index eb5a9e2f6a5..f4ed947baa3 100644 --- a/packages/components/nodes/cache/UpstashRedisCache/UpstashRedisCache.ts +++ b/packages/components/nodes/cache/UpstashRedisCache/UpstashRedisCache.ts @@ -18,6 +18,7 @@ class UpstashRedisCache implements INode { this.name = 'upstashRedisCache' this.version = 1.0 this.type = 'UpstashRedisCache' + this.description = 'Cache LLM response in Upstash Redis, serverless data for Redis and Kafka' this.icon = 'upstash.png' this.category = 'Cache' this.baseClasses = [this.type, ...getBaseClasses(LangchainUpstashRedisCache)]