-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add:Knowledge base #2470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add:Knowledge base #2470
Conversation
| /** | ||
| * 默认RAG模型配置ID | ||
| */ | ||
| String DEFAULT_RAG_MODEL_ID = "RAG_DEFAULT_MODEL"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
清删除掉此处无用代码
| @RequiresPermissions("sys:role:normal") | ||
| public Result<PageData<KnowledgeBaseDTO>> getPageList( | ||
| @RequestParam(required = false) String name, | ||
| @RequestParam(required = false) String id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id这个参数是不是用不到?用不到就暂时删掉。
| KnowledgeBaseDTO knowledgeBaseDTO = new KnowledgeBaseDTO(); | ||
| knowledgeBaseDTO.setName(name); | ||
| knowledgeBaseDTO.setDatasetId(id); | ||
| PageData<KnowledgeBaseDTO> pageData = knowledgeBaseService.getPageList(knowledgeBaseDTO, String.valueOf(page), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getPageList这里应该是获取【登录者】个人的知识库列表,需要传递登录人的id
| @Operation(summary = "根据知识库ID获取知识库详情") | ||
| @RequiresPermissions("sys:role:normal") | ||
| public Result<KnowledgeBaseDTO> getByDatasetId(@PathVariable("dataset_id") String datasetId) { | ||
| KnowledgeBaseDTO knowledgeBaseDTO = knowledgeBaseService.getByDatasetId(datasetId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码前,应该做一下权限判断,是不是【登录者的】的知识库,防止越权
| @RequiresPermissions("sys:role:normal") | ||
| public Result<KnowledgeBaseDTO> update(@PathVariable("dataset_id") String datasetId, | ||
| @RequestBody @Validated KnowledgeBaseDTO knowledgeBaseDTO) { | ||
| knowledgeBaseDTO.setDatasetId(datasetId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码前,应该做一下权限判断,是不是【登录者的】的知识库,防止越权
| @Parameter(name = "dataset_id", description = "知识库ID", required = true) | ||
| @RequiresPermissions("sys:role:normal") | ||
| public Result<Void> delete(@PathVariable("dataset_id") String datasetId) { | ||
| knowledgeBaseService.deleteByDatasetId(datasetId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请在 knowledgeBaseService.deleteByDatasetId里做一下权限判断,是不是【登录者的】的知识库,防止越权
| return new Result<>(); | ||
| } | ||
|
|
||
| @GetMapping("/rag-config/default") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除此处无用代码
|
|
||
| @AllArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/api/v1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、这里的接口不应该是"/api/v1",而是"/datasets"
2、本Controller的其他URL,不需要加"/datasets"
3、改了本Controller后,前端需要做修改调整
|
|
||
| @AllArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/api/v1/datasets/{dataset_id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、这里的接口不应该是"/api/v1/datasets/{dataset_id}",而是"/datasets/{dataset_id}"
2、改了本Controller后,前端需要做修改调整
| @RequestParam(required = false, defaultValue = "1") Integer page, | ||
| @RequestParam(required = false, defaultValue = "10") Integer page_size) { | ||
| KnowledgeFilesDTO knowledgeFilesDTO = new KnowledgeFilesDTO(); | ||
| knowledgeFilesDTO.setDatasetId(datasetId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码前,应该做一下权限判断,是不是【登录者的】的知识库,防止越权
| @RequestParam(required = false) String metaFields, | ||
| @RequestParam(required = false) String parserConfig) { | ||
|
|
||
| KnowledgeFilesDTO resp = knowledgeFilesService.uploadDocument(datasetId, file, name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码前,应该做一下权限判断,是不是【登录者的】的知识库,防止越权
| @RequiresPermissions("sys:role:normal") | ||
| public Result<Void> delete(@PathVariable("dataset_id") String datasetId, | ||
| @PathVariable("document_id") String documentId) { | ||
| knowledgeFilesService.deleteByDocumentId(documentId, datasetId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码前,应该做一下权限判断,是不是【登录者的】的知识库,防止越权
| @RequiresPermissions("sys:role:normal") | ||
| public Result<Void> parseDocuments(@PathVariable("dataset_id") String datasetId, | ||
| @RequestBody Map<String, List<String>> requestBody) { | ||
| List<String> documentIds = requestBody.get("document_ids"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码前,应该做一下权限判断,是不是【登录者的】的知识库,防止越权
| @RequestParam(required = false, defaultValue = "1") Integer page, | ||
| @RequestParam(required = false, defaultValue = "1024") Integer page_size, | ||
| @RequestParam(required = false) String id) { | ||
| Map<String, Object> result = knowledgeFilesService.listChunks(datasetId, documentId, keywords, page, page_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码前,应该做一下权限判断,是不是【登录者的】的知识库,防止越权
| knowledgeBaseDTO.setName(name); | ||
| knowledgeBaseDTO.setDatasetId(id); | ||
| PageData<KnowledgeBaseDTO> pageData = knowledgeBaseService.getPageList(knowledgeBaseDTO, String.valueOf(page), | ||
| String.valueOf(page_size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的页码和每页数量,不要转成String,而是直接传递Integer
| ragModelId: form.ragModelId | ||
| }; | ||
| console.log('Creating knowledge base with data:', createData); | ||
| Api.knowledgeBase.createKnowledgeBase(createData, (res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <result column="updated_at" property="updatedAt"/> | ||
| <result column="creator" property="creator"/> | ||
| <result column="created_at" property="createdAt"/> | ||
| </resultMap> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除无用代码KnowledgeBaseResultMap
| String datasetId = null; | ||
| try { | ||
| String baseUrl = (String) ragConfig.get("base_url"); | ||
| String apiKey = (String) ragConfig.get("api_key"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果baseUrl和apiKey为空,或者apiKey包含“你”,就是他没有完善rag的配置,需要抛出异常让他完善
|
|
||
| -- 添加RAG模型配置 | ||
| delete from `ai_model_config` where id = 'RAG_RAGFlow'; | ||
| INSERT INTO `ai_model_config` VALUES ('RAG_RAGFlow', 'RAG', 'ragflow', 'RAGFlow', 1, 1, '{"type": "ragflow", "base_url": "http://localhost", "api_key": "your_api_key_here"}', 'https://github.com/infiniflow/ragflow/blob/main/README_zh.md', 'RAGFlow配置说明: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里“your_api_key_here”改成“你的rag密钥”
…hi-esp32-server into Knowledge-Base
…hi-esp32-server into Knowledge-Base
|
文档列表增加一栏:状态,参考 run属性 |

No description provided.