-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpgsql.sql
276 lines (262 loc) · 13 KB
/
pgsql.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
-- ----------------------------
-- Table structure for tb_embedding_file
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_embedding_file";
CREATE TABLE "public"."tb_embedding_file" (
"id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1
),
"project_id" int8 NOT NULL,
"status" int2 NOT NULL,
"file_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"file_size" int4 NOT NULL,
"content" text COLLATE "pg_catalog"."default" NOT NULL,
"create_time" int8 NOT NULL,
"update_time" int8 NOT NULL,
"begin_training_time" int8 NOT NULL DEFAULT 0,
"complete_training_time" int8 NOT NULL DEFAULT 0,
"tokens" int8 NOT NULL DEFAULT 0,
"pay_tokens" int8 NOT NULL DEFAULT 0,
"ip" inet NOT NULL
)
;
COMMENT ON COLUMN "public"."tb_embedding_file"."project_id" IS '项目ID';
COMMENT ON COLUMN "public"."tb_embedding_file"."status" IS '状态';
COMMENT ON COLUMN "public"."tb_embedding_file"."file_name" IS '文件名';
COMMENT ON COLUMN "public"."tb_embedding_file"."file_size" IS '文件大小,单位:字节';
COMMENT ON COLUMN "public"."tb_embedding_file"."content" IS '文件内容';
COMMENT ON COLUMN "public"."tb_embedding_file"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."tb_embedding_file"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."tb_embedding_file"."begin_training_time" IS '开始训练时间';
COMMENT ON COLUMN "public"."tb_embedding_file"."complete_training_time" IS '完成训练时间';
COMMENT ON COLUMN "public"."tb_embedding_file"."tokens" IS 'Token数量';
COMMENT ON COLUMN "public"."tb_embedding_file"."pay_tokens" IS '支付 Token 数量';
COMMENT ON COLUMN "public"."tb_embedding_file"."ip" IS 'IP地址';
COMMENT ON TABLE "public"."tb_embedding_file" IS '训练的文件';
-- ----------------------------
-- Table structure for tb_embedding_project
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_embedding_project";
CREATE TABLE "public"."tb_embedding_project" (
"id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1
),
"member_id" int4 NOT NULL,
"name" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
"total_file_size" int4 NOT NULL,
"create_time" int8 NOT NULL,
"update_time" int8 NOT NULL,
"status" int2 NOT NULL,
"tokens" int8 NOT NULL DEFAULT 0,
"pay_tokens" int8 NOT NULL DEFAULT 0,
"ip" inet NOT NULL,
"public" bool NOT NULL DEFAULT false,
"section_separator" varchar(16) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying,
"section_split_length" int4 NOT NULL DEFAULT 512,
"section_split_by_title" bool NOT NULL DEFAULT true,
"chat_config" json NOT NULL DEFAULT '{}'::json,
"similarity" float4 NOT NULL DEFAULT 0,
"top_sections" int2 NOT NULL DEFAULT 0,
"prompt" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::text
)
;
COMMENT ON COLUMN "public"."tb_embedding_project"."member_id" IS '用户ID';
COMMENT ON COLUMN "public"."tb_embedding_project"."name" IS '项目名称';
COMMENT ON COLUMN "public"."tb_embedding_project"."total_file_size" IS '文件总大小,单位:字节';
COMMENT ON COLUMN "public"."tb_embedding_project"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."tb_embedding_project"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."tb_embedding_project"."status" IS '状态';
COMMENT ON COLUMN "public"."tb_embedding_project"."tokens" IS 'Token数量';
COMMENT ON COLUMN "public"."tb_embedding_project"."pay_tokens" IS '支付 Token 数量';
COMMENT ON COLUMN "public"."tb_embedding_project"."ip" IS 'IP地址';
COMMENT ON COLUMN "public"."tb_embedding_project"."public" IS '是否公开使用';
COMMENT ON COLUMN "public"."tb_embedding_project"."section_separator" IS '段落分隔符';
COMMENT ON COLUMN "public"."tb_embedding_project"."section_split_length" IS '段落分割长度';
COMMENT ON COLUMN "public"."tb_embedding_project"."section_split_by_title" IS '使用标题分割段落';
COMMENT ON COLUMN "public"."tb_embedding_project"."chat_config" IS '聊天对话推荐配置';
COMMENT ON COLUMN "public"."tb_embedding_project"."similarity" IS '相似度';
COMMENT ON COLUMN "public"."tb_embedding_project"."top_sections" IS '使用最匹配的段落数量';
COMMENT ON COLUMN "public"."tb_embedding_project"."prompt" IS '提示语';
COMMENT ON TABLE "public"."tb_embedding_project" IS '文件训练项目';
-- ----------------------------
-- Table structure for tb_embedding_public_project
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_embedding_public_project";
CREATE TABLE "public"."tb_embedding_public_project" (
"project_id" int8 NOT NULL,
"status" int2 NOT NULL DEFAULT 0,
"time" int8 NOT NULL DEFAULT 0,
"index" int2 NOT NULL
)
;
COMMENT ON COLUMN "public"."tb_embedding_public_project"."project_id" IS '项目ID';
COMMENT ON COLUMN "public"."tb_embedding_public_project"."status" IS '状态';
COMMENT ON COLUMN "public"."tb_embedding_public_project"."time" IS '时间';
COMMENT ON COLUMN "public"."tb_embedding_public_project"."index" IS '排序,越小越靠前';
COMMENT ON TABLE "public"."tb_embedding_public_project" IS '公共项目';
-- ----------------------------
-- Table structure for tb_embedding_qa
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_embedding_qa";
CREATE TABLE "public"."tb_embedding_qa" (
"id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1
),
"member_id" int4 NOT NULL,
"project_id" int8 NOT NULL,
"question" text COLLATE "pg_catalog"."default" NOT NULL,
"answer" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::text,
"begin_time" int8 NOT NULL DEFAULT 0,
"complete_time" int8 NOT NULL DEFAULT 0,
"tokens" int4 NOT NULL DEFAULT 0,
"config" json NOT NULL,
"status" int2 NOT NULL,
"title" varchar(16) COLLATE "pg_catalog"."default" NOT NULL,
"create_time" int8 NOT NULL,
"pay_tokens" int4 NOT NULL DEFAULT 0,
"ip" inet NOT NULL,
"similarity" float4 NOT NULL DEFAULT 0,
"top_sections" int2 NOT NULL DEFAULT 0,
"prompt" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::text
)
;
COMMENT ON COLUMN "public"."tb_embedding_qa"."member_id" IS '用户ID';
COMMENT ON COLUMN "public"."tb_embedding_qa"."project_id" IS '项目ID';
COMMENT ON COLUMN "public"."tb_embedding_qa"."question" IS '问题';
COMMENT ON COLUMN "public"."tb_embedding_qa"."answer" IS '回答';
COMMENT ON COLUMN "public"."tb_embedding_qa"."begin_time" IS '开始时间';
COMMENT ON COLUMN "public"."tb_embedding_qa"."complete_time" IS '结束时间';
COMMENT ON COLUMN "public"."tb_embedding_qa"."tokens" IS '总tokens';
COMMENT ON COLUMN "public"."tb_embedding_qa"."config" IS '配置';
COMMENT ON COLUMN "public"."tb_embedding_qa"."status" IS '状态';
COMMENT ON COLUMN "public"."tb_embedding_qa"."title" IS '标题';
COMMENT ON COLUMN "public"."tb_embedding_qa"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."tb_embedding_qa"."pay_tokens" IS '支付 Token 数量';
COMMENT ON COLUMN "public"."tb_embedding_qa"."ip" IS 'IP地址';
COMMENT ON COLUMN "public"."tb_embedding_qa"."similarity" IS '相似度';
COMMENT ON COLUMN "public"."tb_embedding_qa"."top_sections" IS '使用最匹配的段落数量';
COMMENT ON COLUMN "public"."tb_embedding_qa"."prompt" IS '提示语';
COMMENT ON TABLE "public"."tb_embedding_qa" IS '训练文件问答';
-- ----------------------------
-- Table structure for tb_embedding_section
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_embedding_section";
CREATE TABLE "public"."tb_embedding_section" (
"id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1
),
"project_id" int8 NOT NULL,
"file_id" int8 NOT NULL,
"status" int2 NOT NULL,
"content" text COLLATE "pg_catalog"."default" NOT NULL,
"vector" "public"."vector" NOT NULL,
"create_time" int8 NOT NULL,
"update_time" int8 NOT NULL,
"begin_training_time" int8 NOT NULL DEFAULT 0,
"complete_training_time" int8 NOT NULL DEFAULT 0,
"reason" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::text,
"tokens" int4 NOT NULL,
"pay_tokens" int4 NOT NULL DEFAULT 0,
"title" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::text
)
;
COMMENT ON COLUMN "public"."tb_embedding_section"."project_id" IS '项目ID';
COMMENT ON COLUMN "public"."tb_embedding_section"."file_id" IS '文件ID';
COMMENT ON COLUMN "public"."tb_embedding_section"."status" IS '状态';
COMMENT ON COLUMN "public"."tb_embedding_section"."content" IS '文件内容';
COMMENT ON COLUMN "public"."tb_embedding_section"."vector" IS '向量';
COMMENT ON COLUMN "public"."tb_embedding_section"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."tb_embedding_section"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."tb_embedding_section"."begin_training_time" IS '开始训练时间';
COMMENT ON COLUMN "public"."tb_embedding_section"."complete_training_time" IS '完成训练时间';
COMMENT ON COLUMN "public"."tb_embedding_section"."reason" IS '失败原因';
COMMENT ON COLUMN "public"."tb_embedding_section"."tokens" IS 'Token数量';
COMMENT ON COLUMN "public"."tb_embedding_section"."pay_tokens" IS '支付 Token 数量';
COMMENT ON COLUMN "public"."tb_embedding_section"."title" IS '标题';
COMMENT ON TABLE "public"."tb_embedding_section" IS '训练内容段落';
-- ----------------------------
-- Indexes structure for table tb_embedding_file
-- ----------------------------
CREATE INDEX "tb_embedding_file_project_id_update_time_idx" ON "public"."tb_embedding_file" USING btree (
"project_id" "pg_catalog"."int8_ops" ASC NULLS LAST,
"update_time" "pg_catalog"."int8_ops" DESC NULLS LAST
);
CREATE INDEX "tb_embedding_file_status_idx" ON "public"."tb_embedding_file" USING btree (
"status" "pg_catalog"."int2_ops" ASC NULLS LAST,
"update_time" "pg_catalog"."int8_ops" ASC NULLS LAST
);
-- ----------------------------
-- Primary Key structure for table tb_embedding_file
-- ----------------------------
ALTER TABLE "public"."tb_embedding_file" ADD CONSTRAINT "tb_embedding_file_pkey" PRIMARY KEY ("id");
-- ----------------------------
-- Indexes structure for table tb_embedding_project
-- ----------------------------
CREATE INDEX "tb_embedding_project_member_id_idx" ON "public"."tb_embedding_project" USING btree (
"member_id" "pg_catalog"."int4_ops" ASC NULLS LAST,
"update_time" "pg_catalog"."int8_ops" DESC NULLS FIRST
);
CREATE INDEX "tb_embedding_project_status_idx" ON "public"."tb_embedding_project" USING btree (
"status" "pg_catalog"."int2_ops" ASC NULLS LAST,
"update_time" "pg_catalog"."int8_ops" ASC NULLS LAST
);
-- ----------------------------
-- Primary Key structure for table tb_embedding_project
-- ----------------------------
ALTER TABLE "public"."tb_embedding_project" ADD CONSTRAINT "tb_embedding_project_pkey" PRIMARY KEY ("id");
-- ----------------------------
-- Indexes structure for table tb_embedding_public_project
-- ----------------------------
CREATE INDEX "tb_embedding_public_project_status_index_time_idx" ON "public"."tb_embedding_public_project" USING btree (
"status" "pg_catalog"."int2_ops" ASC NULLS LAST,
"index" "pg_catalog"."int2_ops" ASC NULLS LAST,
"time" "pg_catalog"."int8_ops" DESC NULLS LAST
);
-- ----------------------------
-- Primary Key structure for table tb_embedding_public_project
-- ----------------------------
ALTER TABLE "public"."tb_embedding_public_project" ADD CONSTRAINT "tb_embedding_public_project_pkey" PRIMARY KEY ("project_id");
-- ----------------------------
-- Indexes structure for table tb_embedding_qa
-- ----------------------------
CREATE INDEX "tb_embedding_qa_member_id_idx" ON "public"."tb_embedding_qa" USING btree (
"member_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "tb_embedding_qa_project_id_idx" ON "public"."tb_embedding_qa" USING btree (
"project_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
-- ----------------------------
-- Primary Key structure for table tb_embedding_qa
-- ----------------------------
ALTER TABLE "public"."tb_embedding_qa" ADD CONSTRAINT "tb_embedding_qa_pkey" PRIMARY KEY ("id");
-- ----------------------------
-- Indexes structure for table tb_embedding_section
-- ----------------------------
CREATE INDEX "tb_embedding_section_project_id_file_id_idx" ON "public"."tb_embedding_section" USING btree (
"project_id" "pg_catalog"."int8_ops" ASC NULLS LAST,
"file_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "tb_embedding_section_status_idx" ON "public"."tb_embedding_section" USING btree (
"status" "pg_catalog"."int2_ops" ASC NULLS LAST,
"update_time" "pg_catalog"."int8_ops" ASC NULLS LAST
);
-- ----------------------------
-- Primary Key structure for table tb_embedding_section
-- ----------------------------
ALTER TABLE "public"."tb_embedding_section" ADD CONSTRAINT "tb_embedding_section_pkey" PRIMARY KEY ("id");