Compare commits

...

1 Commits

Author SHA1 Message Date
chungyau97 b0701481b3 add DynamoDB Memory init 2023-05-26 09:44:17 +07:00
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,50 @@
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses } from '../../../src/utils'
import { BufferMemory } from 'langchain/memory'
class DynamoDBMemory_Memory implements INode {
label: string
name: string
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs: INodeParams[]
constructor() {
this.label = 'DynamoDB Memory'
this.name = 'dynamoDBMemory'
this.type = 'DynamoDBMemory'
this.icon = 'memory.svg'
this.category = 'Memory'
this.description = 'Remembers previous conversational back and forths directly'
this.baseClasses = [this.type, ...getBaseClasses(BufferMemory)]
this.inputs = [
{
label: 'Memory Key',
name: 'memoryKey',
type: 'string',
default: 'chat_history'
},
{
label: 'Input Key',
name: 'inputKey',
type: 'string',
default: 'input'
}
]
}
async init(nodeData: INodeData): Promise<any> {
const memoryKey = nodeData.inputs?.memoryKey as string
const inputKey = nodeData.inputs?.inputKey as string
return new BufferMemory({
returnMessages: true,
memoryKey,
inputKey
})
}
}
module.exports = { nodeClass: DynamoDBMemory_Memory }

View File

@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-aws" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M17 18.5a15.198 15.198 0 0 1 -7.37 1.44a14.62 14.62 0 0 1 -6.63 -2.94"></path>
<path d="M19.5 21c.907 -1.411 1.451 -3.323 1.5 -5c-1.197 -.773 -2.577 -.935 -4 -1"></path>
<path d="M3 11v-4.5a1.5 1.5 0 0 1 3 0v4.5"></path>
<path d="M3 9h3"></path>
<path d="M9 5l1.2 6l1.8 -4l1.8 4l1.2 -6"></path>
<path d="M18 10.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"></path>
</svg>

After

Width:  |  Height:  |  Size: 773 B

View File

@ -16,6 +16,7 @@
},
"license": "SEE LICENSE IN LICENSE.md",
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.338.0",
"@dqbd/tiktoken": "^1.0.7",
"@huggingface/inference": "1",
"@pinecone-database/pinecone": "^0.0.12",