mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 01:01:11 +03:00
DynamoDB Chat Memory fix
Fixes #1624 Please note comment in class BufferMemoryExtended for further discussion, if necessary
This commit is contained in:
@@ -142,18 +142,26 @@ interface DynamoDBSerializedChatMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
||||||
|
tableName = ''
|
||||||
sessionId = ''
|
sessionId = ''
|
||||||
dynamodbClient: DynamoDBClient
|
dynamodbClient: DynamoDBClient
|
||||||
|
dynamoKey = ''
|
||||||
|
partitionKey = ''
|
||||||
|
|
||||||
constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
|
constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
|
||||||
super(fields)
|
super(fields)
|
||||||
this.sessionId = fields.sessionId
|
this.sessionId = fields.sessionId
|
||||||
this.dynamodbClient = fields.dynamodbClient
|
this.dynamodbClient = fields.dynamodbClient
|
||||||
|
|
||||||
|
// These fields are coming in on chatHistory, but should they be on the dynamodbClient instead?
|
||||||
|
this.partitionKey = (fields?.chatHistory as unknown as { partitionKey: string }).partitionKey
|
||||||
|
this.dynamoKey = (fields?.chatHistory as unknown as { dynamoKey: string }).dynamoKey
|
||||||
|
this.tableName = (fields?.chatHistory as unknown as { tableName: string }).tableName
|
||||||
}
|
}
|
||||||
|
|
||||||
overrideDynamoKey(overrideSessionId = '') {
|
overrideDynamoKey(overrideSessionId = '') {
|
||||||
const existingDynamoKey = (this as any).dynamoKey
|
const existingDynamoKey = this.dynamoKey
|
||||||
const partitionKey = (this as any).partitionKey
|
const partitionKey = this.partitionKey
|
||||||
|
|
||||||
let newDynamoKey: Record<string, AttributeValue> = {}
|
let newDynamoKey: Record<string, AttributeValue> = {}
|
||||||
|
|
||||||
@@ -210,7 +218,7 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
|||||||
if (!this.dynamodbClient) return []
|
if (!this.dynamodbClient) return []
|
||||||
|
|
||||||
const dynamoKey = overrideSessionId ? this.overrideDynamoKey(overrideSessionId) : (this as any).dynamoKey
|
const dynamoKey = overrideSessionId ? this.overrideDynamoKey(overrideSessionId) : (this as any).dynamoKey
|
||||||
const tableName = (this as any).tableName
|
const tableName = this.tableName
|
||||||
const messageAttributeName = (this as any).messageAttributeName
|
const messageAttributeName = (this as any).messageAttributeName
|
||||||
|
|
||||||
const params: GetItemCommandInput = {
|
const params: GetItemCommandInput = {
|
||||||
|
|||||||
Reference in New Issue
Block a user