-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminragEntity.go
651 lines (476 loc) · 19.8 KB
/
minragEntity.go
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
// Copyright (c) 2025 minRAG Authors.
//
// This file is part of minRAG.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses>.
package main
import "gitee.com/chunanyong/zorm"
// Config 配置表
type Config struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID 主键
Id string `column:"id" json:"id,omitempty"`
// BasePath 根路径,默认/
BasePath string `column:"basePath" json:"basePath,omitempty"`
// JwtSecret jwt加密密钥
JwtSecret string `column:"jwtSecret" json:"jwtSecret,omitempty"`
// JwttokenKey jwt加密密钥
JwttokenKey string `column:"jwttokenKey" json:"jwttokenKey,omitempty"`
// ServerPort 服务器端口
ServerPort string `column:"serverPort" json:"serverPort,omitempty"`
// Timeout 超时时间,单位秒
Timeout int `column:"timeout" json:"timeout,omitempty"`
// MaxRequestBodySize 最大请求
MaxRequestBodySize int `column:"maxRequestBodySize" json:"maxRequestBodySize,omitempty"`
// Locale 语言包
Locale string `column:"locale" json:"locale,omitempty"`
// Proxy 代理,用于翻墙 格式: http://127.0.0.1:8090
Proxy string `column:"proxy" json:"proxy,omitempty"`
// AIBaseURL AI平台base_url
AIBaseURL string `column:"aiBaseURL" json:"aiBaseURL,omitempty"`
// AIAPIkey AI平台api_key
AIAPIkey string `column:"aiAPIKey" json:"aiAPIKey,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1)
Status int `column:"status" json:"status,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Config) GetTableName() string {
return tableConfigName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Config) GetPKColumnName() string {
return "id"
}
// KnowledgeBase 知识库
type KnowledgeBase struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// Name 名称
Name string `column:"name" json:"name,omitempty"`
// Pid 父级ID
Pid string `column:"pid" json:"pid,omitempty"`
// KnowledgeBaseType 知识库类型
KnowledgeBaseType int `column:"knowledgeBaseType" json:"knowledgeBaseType,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1)
Status int `column:"status" json:"status,omitempty"`
Leaf []*KnowledgeBase `json:"leaf,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *KnowledgeBase) GetTableName() string {
return tableKnowledgeBaseName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *KnowledgeBase) GetPKColumnName() string {
return "id"
}
// Document 文档
type Document struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// Name 文章标题
Name string `column:"name" json:"name,omitempty"`
// KnowledgeBaseID 知识库ID
KnowledgeBaseID string `column:"knowledgeBaseID" json:"knowledgeBaseID,omitempty"`
// KnowledgeBaseName 知识库
KnowledgeBaseName string `column:"knowledgeBaseName" json:"knowledgeBaseName,omitempty"`
// Toc 目录
Toc string `column:"toc" json:"toc,omitempty"`
// Summary 摘要
Summary string `column:"summary" json:"summary,omitempty"`
// Markdown Markdown内容
Markdown string `column:"markdown" json:"markdown,omitempty"`
// FilePath 上传的文件路径
FilePath string `column:"filePath" json:"filePath,omitempty"`
// FileSize 上传的文件大小,单位k
FileSize int `column:"fileSize" json:"fileSize,omitempty"`
// FileExt 文档后缀
FileExt string `column:"fileExt" json:"fileExt,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1),处理中(2),处理失败(3)
Status int `column:"status" json:"status,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Document) GetTableName() string {
return tableDocumentName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Document) GetPKColumnName() string {
return "id"
}
// DocumentChunk 文档分块
type DocumentChunk struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// DocumentID 文档ID
DocumentID string `column:"documentID" json:"documentID,omitempty"`
// KnowledgeBaseID 知识库ID
KnowledgeBaseID string `column:"knowledgeBaseID" json:"knowledgeBaseID,omitempty"`
// Markdown Markdown内容
Markdown string `column:"markdown" json:"markdown,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1),处理中(2),处理失败(3)
Status int `column:"status" json:"status,omitempty"`
//----------数据库字段结束-----------//
// Embedding markdown向量化二进制
Embedding []byte `json:"embedding,omitempty"`
// RowID 默认的rowid字段
RowID int `json:"rowID,omitempty"`
// Score 向量表的score匹配分数
Score float32 `json:"score,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *DocumentChunk) GetTableName() string {
return tableDocumentChunkName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *DocumentChunk) GetPKColumnName() string {
return "id"
}
// VecDocumentChunk 向量化的数据表
type VecDocumentChunk struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// DocumentID 文档ID
DocumentID string `column:"documentID" json:"documentID,omitempty"`
// KnowledgeBaseID 知识库ID
KnowledgeBaseID string `column:"knowledgeBaseID" json:"knowledgeBaseID,omitempty"`
// Markdown Markdown内容
Markdown string `json:"markdown,omitempty"`
// Embedding markdown向量化二进制
Embedding []byte `column:"embedding" json:"embedding,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1),处理中(2),处理失败(3)
Status int `column:"status" json:"status,omitempty"`
// RowID 默认的rowid字段
RowID int `json:"rowID,omitempty"`
// Score 向量表的score匹配分数
Score float32 `json:"score,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *VecDocumentChunk) GetTableName() string {
return tableVecDocumentChunkName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *VecDocumentChunk) GetPKColumnName() string {
return "id"
}
// Component 组件表
type Component struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// ComponentType 组件类型,和componentTypeMap关联
ComponentType string `column:"componentType" json:"componentType,omitempty"`
// Parameter 参数,json格式字符串
Parameter string `column:"parameter" json:"parameter,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1)
Status int `column:"status" json:"status,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Component) GetTableName() string {
return tableComponentName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Component) GetPKColumnName() string {
return "id"
}
// Agent 智能体
type Agent struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// Name 智能体名称
Name string `column:"name" json:"name,omitempty"`
// KnowledgeBaseID 知识库ID
KnowledgeBaseID string `column:"knowledgeBaseID" json:"knowledgeBaseID,omitempty"`
// PipelineID 流水线ID
PipelineID string `column:"pipelineID" json:"pipelineID,omitempty"`
// DefaultReply 默认回复
DefaultReply string `column:"defaultReply" json:"defaultReply,omitempty"`
// AgentType 智能体类型
AgentType int `column:"agentType" json:"agentType,omitempty"`
// AgentPrompt 智能体的提示词
AgentPrompt string `column:"agentPrompt" json:"agentPrompt,omitempty"`
// Avatar 头像
Avatar string `column:"avatar" json:"avatar,omitempty"`
// Welcome 欢迎语
Welcome string `column:"welcome" json:"welcome,omitempty"`
// Tools tools调用的函数名称
Tools string `column:"tools" json:"tools,omitempty"`
// MemoryLength 上下文记忆的长度
MemoryLength int `column:"memoryLength" json:"memoryLength,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1)
Status int `column:"status" json:"status,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Agent) GetTableName() string {
return tableAgentName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Agent) GetPKColumnName() string {
return "id"
}
// ChatRoom 聊天室
type ChatRoom struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// RoomID 聊天室名称
Name string `column:"name" json:"name,omitempty"`
// AgentID 智能体ID
AgentID string `column:"agentID" json:"agentID,omitempty"`
// KnowledgeBaseID 知识库ID
KnowledgeBaseID string `column:"knowledgeBaseID" json:"knowledgeBaseID,omitempty"`
// PipelineID 流水线ID
PipelineID string `column:"pipelineID" json:"pipelineID,omitempty"`
// UserID 用户ID
UserID string `column:"userID" json:"userID,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *ChatRoom) GetTableName() string {
return tableChatRoomName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *ChatRoom) GetPKColumnName() string {
return "id"
}
// MessageLog 消息日志
type MessageLog struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID
Id string `column:"id" json:"id,omitempty"`
// AgentID 智能体ID
AgentID string `column:"agentID" json:"agentID,omitempty"`
// RoomID 聊天室ID
RoomID string `column:"roomID" json:"roomID,omitempty"`
// KnowledgeBaseID 知识库ID
KnowledgeBaseID string `column:"knowledgeBaseID" json:"knowledgeBaseID,omitempty"`
// PipelineID 流水线ID
PipelineID string `column:"pipelineID" json:"pipelineID,omitempty"`
// UserMessage 用户发送的消息
UserMessage string `column:"userMessage" json:"userMessage,omitempty"`
// AIMessage AI发送的信息
AIMessage string `column:"aiMessage" json:"aiMessage,omitempty"`
// UserID 用户ID
UserID string `column:"userID" json:"userID,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *MessageLog) GetTableName() string {
return tableMessageLogName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *MessageLog) GetPKColumnName() string {
return "id"
}
// Site 站点信息
type Site struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// ID 主键
Id string `column:"id" json:"id"`
// Title 标题
Title string `column:"title" json:"title,omitempty"`
// Name 名称
Name string `column:"name" json:"name,omitempty"`
// Domain 域名
Domain string `column:"domain" json:"domain,omitempty"`
// Keyword 关键字
Keyword string `column:"keyword" json:"keyword,omitempty"`
// Description 描述
Description string `column:"description" json:"description,omitempty"`
// Theme 主题
Theme string `column:"theme" json:"theme,omitempty"`
// ThemePC PC主题
ThemePC string `column:"themePC" json:"themePC,omitempty"`
// ThemeWAP WAP主题WAP
ThemeWAP string `column:"themeWAP" json:"themeWAP,omitempty"`
// ThemeWX 微信主题
ThemeWX string `column:"themeWX" json:"themeWX,omitempty"`
// Logo 站点logo
Logo string `column:"logo" json:"logo,omitempty"`
// Favicon 站点favicon
Favicon string `column:"favicon" json:"favicon,omitempty"`
// Footer 页脚
Footer string `column:"footer" json:"footer,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1)
Status int `column:"status" json:"status,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Site) GetTableName() string {
return tableSiteName
}
// GetPKColumnName 获取数据库表的主键字段名称.因为要兼容Map,只能是数据库的字段名称
// 不支持联合主键,变通认为无主键,业务控制实现(艰难取舍)
// 如果没有主键,也需要实现这个方法, return "" 即可
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *Site) GetPKColumnName() string {
return "id"
}
// User 用户信息
type User struct {
// 引入默认的struct,隔离IEntityStruct的方法改动
zorm.EntityStruct
// Id 主键
Id string `column:"id" json:"id,omitempty"`
// Account 账号
Account string `column:"account" json:"account,omitempty"`
// Password 密码
Password string `column:"password" json:"password,omitempty"`
// UserName 用户名
UserName string `column:"userName" json:"userName,omitempty"`
// CreateTime 创建时间
CreateTime string `column:"createTime" json:"createTime,omitempty"`
// UpdateTime 更新时间
UpdateTime string `column:"updateTime" json:"updateTime,omitempty"`
// CreateUser 创建人,初始化 system
CreateUser string `column:"createUser" json:"createUser,omitempty"`
// SortNo 排序
SortNo int `column:"sortNo" json:"sortNo,omitempty"`
// Status 状态 禁用(0),可用(1)
Status int `column:"status" json:"status,omitempty"`
}
// GetTableName 获取表名称
// IEntityStruct 接口的方法,实体类需要实现!!!
func (entity *User) GetTableName() string {
return tableUserName
}
func (entity *User) GetPKColumnName() string {
return "id"
}
// ThemeTemplate 主题模板
type ThemeTemplate struct {
// Id 主键,完整路径
Id string `json:"id,omitempty"`
// Pid 上级目录
Pid string `json:"pid,omitempty"`
// Name 名称,
Name string `json:"name,omitempty"`
// FileType 文件类型:dir(目录),file(文件)
FileType string `json:"fileType,omitempty"`
// FileSuffix 文件后缀
FileSuffix string `json:"fileSuffix,omitempty"`
// FilePath 模板路径
FilePath string `json:"filePath,omitempty"`
// FileDocument 文件内容
FileDocument string `json:"fileDocument,omitempty"`
}