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:
vinodkiran 2023-10-08 15:53:06 +05:30
parent 679eac1d0b
commit e01acbc3e8
8 changed files with 24 additions and 24 deletions

View File

@ -1,8 +1,8 @@
import { INode, INodeParams } from '../../../src/Interface' import { INode, INodeParams } from '../../../src/Interface'
import { InMemoryCache } from 'langchain/cache' import { InMemoryCache as LangchainInMemoryCache } from 'langchain/cache'
import { getBaseClasses } from '../../../src' import { getBaseClasses } from '../../../src'
class LLMInMemoryCache implements INode { class InMemoryCache implements INode {
label: string label: string
name: string name: string
version: number version: number
@ -18,19 +18,19 @@ class LLMInMemoryCache implements INode {
this.label = 'Local (Builtin) Cache' this.label = 'Local (Builtin) Cache'
this.name = 'localCache' this.name = 'localCache'
this.version = 1.0 this.version = 1.0
this.type = 'LLMCache' this.type = 'Cache'
this.icon = 'memorycache.png' this.icon = 'memorycache.png'
this.category = 'LLM Cache' this.category = 'Cache'
this.baseClasses = [this.type, ...getBaseClasses(InMemoryCache)] this.baseClasses = [this.type, ...getBaseClasses(InMemoryCache)]
this.inputs = [] this.inputs = []
} }
async init(): Promise<any> { async init(): Promise<any> {
if (!this.inMemoryCache) { if (!this.inMemoryCache) {
this.inMemoryCache = InMemoryCache.global() this.inMemoryCache = LangchainInMemoryCache.global()
} }
return this.inMemoryCache return this.inMemoryCache
} }
} }
module.exports = { nodeClass: LLMInMemoryCache } module.exports = { nodeClass: InMemoryCache }

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,8 +1,8 @@
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src' import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
import { MomentoCache } from 'langchain/cache/momento' import { MomentoCache as LangchainMomentoCache } from 'langchain/cache/momento'
import { CacheClient, Configurations, CredentialProvider } from '@gomomento/sdk' import { CacheClient, Configurations, CredentialProvider } from '@gomomento/sdk'
class LLMMomentoCache implements INode { class MomentoCache implements INode {
label: string label: string
name: string name: string
version: number version: number
@ -18,9 +18,9 @@ class LLMMomentoCache implements INode {
this.label = 'Momento Cache' this.label = 'Momento Cache'
this.name = 'momentoCache' this.name = 'momentoCache'
this.version = 1.0 this.version = 1.0
this.type = 'LLMCache' this.type = 'Cache'
this.icon = 'momento.png' this.icon = 'momento.png'
this.category = 'LLM Cache' this.category = 'Cache'
this.baseClasses = [this.type, ...getBaseClasses(MomentoCache)] this.baseClasses = [this.type, ...getBaseClasses(MomentoCache)]
this.credential = { this.credential = {
label: 'Connect Credential', label: 'Connect Credential',
@ -47,7 +47,7 @@ class LLMMomentoCache implements INode {
defaultTtlSeconds: 60 * 60 * 24 defaultTtlSeconds: 60 * 60 * 24
}) })
let momentoCache = await MomentoCache.fromProps({ let momentoCache = await LangchainMomentoCache.fromProps({
client, client,
cacheName: cacheName cacheName: cacheName
}) })
@ -55,4 +55,4 @@ class LLMMomentoCache implements INode {
} }
} }
module.exports = { nodeClass: LLMMomentoCache } module.exports = { nodeClass: MomentoCache }

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -1,8 +1,8 @@
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src' import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
import { RedisCache } from 'langchain/cache/ioredis' import { RedisCache as LangchainRedisCache } from 'langchain/cache/ioredis'
import { Redis } from 'ioredis' import { Redis } from 'ioredis'
class LLMRedisCache implements INode { class RedisCache implements INode {
label: string label: string
name: string name: string
version: number version: number
@ -18,9 +18,9 @@ class LLMRedisCache implements INode {
this.label = 'Redis LLM Cache' this.label = 'Redis LLM Cache'
this.name = 'redisCache' this.name = 'redisCache'
this.version = 1.0 this.version = 1.0
this.type = 'LLMCache' this.type = 'Cache'
this.icon = 'redis.svg' this.icon = 'redis.svg'
this.category = 'LLM Cache' this.category = 'Cache'
this.baseClasses = [this.type, ...getBaseClasses(RedisCache)] this.baseClasses = [this.type, ...getBaseClasses(RedisCache)]
this.credential = { this.credential = {
label: 'Connect Credential', label: 'Connect Credential',
@ -45,8 +45,8 @@ class LLMRedisCache implements INode {
username, username,
password password
}) })
return new RedisCache(client) return new LangchainRedisCache(client)
} }
} }
module.exports = { nodeClass: LLMRedisCache } module.exports = { nodeClass: RedisCache }

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,7 +1,7 @@
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src' import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
import { UpstashRedisCache } from 'langchain/cache/upstash_redis' import { UpstashRedisCache as LangchainUpstashRedisCache } from 'langchain/cache/upstash_redis'
class LLMUpstashRedisCache implements INode { class UpstashRedisCache implements INode {
label: string label: string
name: string name: string
version: number version: number
@ -17,9 +17,9 @@ class LLMUpstashRedisCache implements INode {
this.label = 'Upstash Redis LLM Cache' this.label = 'Upstash Redis LLM Cache'
this.name = 'upstashRedisCache' this.name = 'upstashRedisCache'
this.version = 1.0 this.version = 1.0
this.type = 'LLMCache' this.type = 'Cache'
this.icon = 'upstash.png' this.icon = 'upstash.png'
this.category = 'LLM Cache' this.category = 'Cache'
this.baseClasses = [this.type, ...getBaseClasses(UpstashRedisCache)] this.baseClasses = [this.type, ...getBaseClasses(UpstashRedisCache)]
this.credential = { this.credential = {
label: 'Connect Credential', label: 'Connect Credential',
@ -36,7 +36,7 @@ class LLMUpstashRedisCache implements INode {
const upstashConnectionUrl = getCredentialParam('upstashConnectionUrl', credentialData, nodeData) const upstashConnectionUrl = getCredentialParam('upstashConnectionUrl', credentialData, nodeData)
const upstashToken = getCredentialParam('upstashConnectionToken', credentialData, nodeData) const upstashToken = getCredentialParam('upstashConnectionToken', credentialData, nodeData)
const cache = new UpstashRedisCache({ const cache = new LangchainUpstashRedisCache({
config: { config: {
url: upstashConnectionUrl, url: upstashConnectionUrl,
token: upstashToken token: upstashToken
@ -46,4 +46,4 @@ class LLMUpstashRedisCache implements INode {
} }
} }
module.exports = { nodeClass: LLMUpstashRedisCache } module.exports = { nodeClass: UpstashRedisCache }

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB