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
@@ -0,0 +1,58 @@
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
import { MomentoCache as LangchainMomentoCache } from 'langchain/cache/momento'
import { CacheClient, Configurations, CredentialProvider } from '@gomomento/sdk'
class MomentoCache 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 = 'Momento Cache'
this.name = 'momentoCache'
this.version = 1.0
this.type = 'Cache'
this.icon = 'momento.png'
this.category = 'Cache'
this.baseClasses = [this.type, ...getBaseClasses(MomentoCache)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
optional: true,
credentialNames: ['momentoCacheApi']
}
this.inputs = []
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const apiKey = getCredentialParam('momentoApiKey', credentialData, nodeData)
const cacheName = getCredentialParam('momentoCache', credentialData, nodeData)
const endPoint = getCredentialParam('momentoEndpoint', credentialData, nodeData)
// See https://github.com/momentohq/client-sdk-javascript for connection options
const client = new CacheClient({
configuration: Configurations.Laptop.v1(),
credentialProvider: CredentialProvider.fromString({
apiKey: apiKey
}),
defaultTtlSeconds: 60 * 60 * 24
})
let momentoCache = await LangchainMomentoCache.fromProps({
client,
cacheName: cacheName
})
return momentoCache
}
}
module.exports = { nodeClass: MomentoCache }
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB