Skip to content

Conversation

@rainv123
Copy link
Collaborator

@rainv123 rainv123 commented Nov 5, 2025

No description provided.

@rainv123 rainv123 requested a review from openrz November 5, 2025 03:12
/**
* 默认RAG模型配置ID
*/
String DEFAULT_RAG_MODEL_ID = "RAG_DEFAULT_MODEL";
Copy link
Collaborator

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,
Copy link
Collaborator

@openrz openrz Nov 5, 2025

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),
Copy link
Collaborator

@openrz openrz Nov 5, 2025

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);
Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

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")
Copy link
Collaborator

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")
Copy link
Collaborator

@openrz openrz Nov 5, 2025

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}")
Copy link
Collaborator

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);
Copy link
Collaborator

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,
Copy link
Collaborator

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);
Copy link
Collaborator

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");
Copy link
Collaborator

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,
Copy link
Collaborator

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));
Copy link
Collaborator

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) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

报错信息没有显示接口返回的报错信息

Image

<result column="updated_at" property="updatedAt"/>
<result column="creator" property="creator"/>
<result column="created_at" property="createdAt"/>
</resultMap>
Copy link
Collaborator

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");
Copy link
Collaborator

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配置说明:
Copy link
Collaborator

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密钥”

@openrz
Copy link
Collaborator

openrz commented Nov 6, 2025

文档列表增加一栏:状态,参考

0 / UNSTART: Document not yet processed
1 / RUNNING: Document is currently being processed
2 / CANCEL: Document processing was cancelled
3 / DONE: Document processing completed successfully
4 / FAIL: Document processing failed
curl --location --request GET 'http://192.168.0.8/api/v1/datasets/84010beabad711f082a89abdd43ea1a9/documents?page=1&page_size=10' \
--header 'Authorization: Bearer ragflow-xxxxx' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'Accept: */*' \
--header 'Host: 192.168.0.8' \
--header 'Connection: keep-alive'

run属性

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants