redis缓存替换+pgvector向量替换

This commit is contained in:
1iaan
2026-04-04 22:39:16 +08:00
parent e993eb6c5c
commit 9d7c416737
124 changed files with 5460 additions and 141 deletions

16
init/create_db.sql Normal file
View File

@@ -0,0 +1,16 @@
create database ai_chat default charset utf8mb4;
use ai_chat;
CREATE TABLE `chat_records` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_msg` text,
`user_msg_tokens` int NOT NULL DEFAULT '0',
`user_msg_keywords` varchar(1024) NOT NULL DEFAULT '',
`ai_msg` text,
`ai_msg_tokens` int NOT NULL DEFAULT '0',
`req_tokens` int NOT NULL DEFAULT '0',
`create_at` bigint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `index_create_at` (`create_at` DESC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

12
init/pgvector-init.sql Normal file
View File

@@ -0,0 +1,12 @@
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS chat_record_vectors (
id BIGSERIAL PRIMARY KEY,
record_id BIGINT NOT NULL,
keywords_text TEXT NOT NULL,
embedding vector(1024) NOT NULL,
created_at BIGINT NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS uq_chat_record_vectors_record_id
ON chat_record_vectors(record_id);