Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDB Chat Memory fix #1697

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/components/nodes/memory/DynamoDb/DynamoDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,26 @@ interface DynamoDBSerializedChatMessage {
}

class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
tableName = ''
sessionId = ''
dynamodbClient: DynamoDBClient
dynamoKey = ''
partitionKey = ''

constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
super(fields)
this.sessionId = fields.sessionId
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 = '') {
const existingDynamoKey = (this as any).dynamoKey
const partitionKey = (this as any).partitionKey
const existingDynamoKey = this.dynamoKey
const partitionKey = this.partitionKey

let newDynamoKey: Record<string, AttributeValue> = {}

Expand Down Expand Up @@ -210,7 +218,7 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
if (!this.dynamodbClient) return []

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 params: GetItemCommandInput = {
Expand Down
Loading