refactor: use mem0 as long-memory maneger

This commit is contained in:
Acbox
2026-01-10 17:59:56 +08:00
parent 58fbd550da
commit 4db09dcd35
28 changed files with 2970 additions and 228 deletions
+11
View File
@@ -0,0 +1,11 @@
import { pgTable, timestamp, uuid, jsonb, text } from 'drizzle-orm/pg-core'
export const history = pgTable(
'history',
{
id: uuid('id').primaryKey().defaultRandom(),
messages: jsonb('messages').notNull(),
timestamp: timestamp('timestamp').notNull(),
user: text('user').notNull(),
}
)
+12 -15
View File
@@ -1,16 +1,13 @@
import { pgTable, timestamp, uuid, jsonb, text, vector, index } from 'drizzle-orm/pg-core'
import { pgTable, text, timestamp, integer } from 'drizzle-orm/pg-core'
import { sql } from 'drizzle-orm'
export const memory = pgTable(
'memory',
{
id: uuid('id').primaryKey().defaultRandom(),
messages: jsonb('messages').notNull(),
timestamp: timestamp('timestamp').notNull(),
user: text('user').notNull(),
rawContent: text('raw_content').notNull(),
embedding: vector('embedding', { dimensions: 1536 }).notNull(),
},
(table) => [
index('embedding_index').using('hnsw', table.embedding.op('vector_cosine_ops')),
]
)
export const memory = pgTable('memory', {
id: text('id').primaryKey(),
memoryId: text('memory_id').notNull(),
previousValue: text('previous_value'),
newValue: text('new_value'),
action: text('action').notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).default(sql`timezone('utc', now())`),
updatedAt: timestamp('updated_at', { withTimezone: true }),
isDeleted: integer('is_deleted').default(0),
})
+1
View File
@@ -1 +1,2 @@
export * from './history'
export * from './memory'