return tableName, partiionKey, dynamoKey from initalizeDynamoDB

This commit is contained in:
Jared Tracy
2024-02-07 22:07:12 -06:00
parent 3f0f0e4d28
commit d7f9c07381
@@ -117,7 +117,10 @@ const initalizeDynamoDB = async (nodeData: INodeData, options: ICommonObject): P
memoryKey: memoryKey ?? 'chat_history', memoryKey: memoryKey ?? 'chat_history',
chatHistory: dynamoDb, chatHistory: dynamoDb,
sessionId, sessionId,
dynamodbClient: client dynamodbClient: client,
tableName,
partitionKey,
dynamoKey: { [partitionKey]: { S: sessionId } }
}) })
return memory return memory
} }
@@ -125,6 +128,9 @@ const initalizeDynamoDB = async (nodeData: INodeData, options: ICommonObject): P
interface BufferMemoryExtendedInput { interface BufferMemoryExtendedInput {
dynamodbClient: DynamoDBClient dynamodbClient: DynamoDBClient
sessionId: string sessionId: string
tableName: string
partitionKey: string
dynamoKey: Record<string, AttributeValue>
} }
interface DynamoDBSerializedChatMessage { interface DynamoDBSerializedChatMessage {
@@ -143,10 +149,10 @@ interface DynamoDBSerializedChatMessage {
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods { class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
tableName = '' tableName = ''
partitionKey = ''
dynamoKey: Record<string, AttributeValue>
sessionId = '' sessionId = ''
dynamodbClient: DynamoDBClient dynamodbClient: DynamoDBClient
dynamoKey = ''
partitionKey = ''
constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) { constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
super(fields) super(fields)
@@ -154,9 +160,9 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
this.dynamodbClient = fields.dynamodbClient this.dynamodbClient = fields.dynamodbClient
// These fields are coming in on chatHistory, but should they be on the dynamodbClient instead? // 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.tableName = fields.tableName
this.dynamoKey = (fields?.chatHistory as unknown as { dynamoKey: string }).dynamoKey this.partitionKey = fields.partitionKey
this.tableName = (fields?.chatHistory as unknown as { tableName: string }).tableName this.dynamoKey = fields.dynamoKey
} }
overrideDynamoKey(overrideSessionId = '') { overrideDynamoKey(overrideSessionId = '') {