From ec94703d012dcca6390aff055d6a5ecddb661e7b Mon Sep 17 00:00:00 2001 From: limin Date: Tue, 11 Feb 2025 17:13:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9F=A5=E8=AF=86=E5=BA=93?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../llm/service/async/AsyncKnowledgeBase.java | 14 +++++++++++++- .../src/main/resources/application-local.yaml | 18 +++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/async/AsyncKnowledgeBase.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/async/AsyncKnowledgeBase.java index 5b8a5249f..c49f9bc98 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/async/AsyncKnowledgeBase.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/async/AsyncKnowledgeBase.java @@ -50,7 +50,19 @@ public class AsyncKnowledgeBase { .setFileId(String.valueOf(knowledge.getId())) .setFileName(knowledge.getDocumentName()) .setFileUrl(knowledge.getFileUrl()); - ragHttpService.embedUploadFile(regUploadReqVO); + int lastIndex = knowledge.getDocumentName().lastIndexOf("."); + if (lastIndex != -1){ + String extension = knowledge.getDocumentName().substring(lastIndex + 1).toLowerCase(); + if ("txt".equals(extension)) { + ragHttpService.embedUploadFile(regUploadReqVO); + }else { + KnowledgeRagEmbedReqVO knowledgeRagEmbedReqVO = new KnowledgeRagEmbedReqVO() + .setFileId(String.valueOf(knowledge.getId())) + .setFileName(knowledge.getDocumentName()) + .setFileInputStream(new ByteArrayInputStream(Objects.requireNonNull(getFileByte(knowledge.getFileUrl())))); + ragHttpService.knowledgeEmbed(knowledgeRagEmbedReqVO,knowledge.getKnowledgeBaseId()); + } + } } catch (Exception e) { log.error("the creation of the knowledge base error {}", e.getMessage()); } diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 5c4fbfb58..04ac1ae1b 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -248,19 +248,19 @@ llm: backend: #### RAG服务 #RAG健康检查 GET - rag_health: http://36.103.199.104:8123/health + rag_health: http://rag.xhllm.xinnuojinzhi.com/health #上传并向量化 POST - rag_embed: http://36.103.199.104:8123/embed + rag_embed: http://rag.xhllm.xinnuojinzhi.com/embed #获取所有向量id GET - rag_ids: http://36.103.199.104:8123/ids + rag_ids: http://rag.xhllm.xinnuojinzhi.com/ids #根据id获取文档 GET - rag_documents: http://36.103.199.104:8123/documents + rag_documents: http://rag.xhllm.xinnuojinzhi.com/documents #根据id删除文档 DEL - rag_documents_del: http://36.103.199.104:8123/documents + rag_documents_del: http://rag.xhllm.xinnuojinzhi.com/documents #根据file_id检索向量 POST - rag_query: http://36.103.199.104:8123/query + rag_query: http://rag.xhllm.xinnuojinzhi.com/query #支持多个文件id查询向量 GET - rag_query_multiple: http://36.103.199.104:8123/query_multiple + rag_query_multiple: http://rag.xhllm.xinnuojinzhi.com/query_multiple #### LLM train and service api # 训练集列表 GET @@ -324,9 +324,9 @@ llm: # 文生图 text_to_image: http://36.103.199.104:5123/generate-image # 知识库向量嵌入 - embed: http://36.103.199.104:8123/embed + embed: http://rag.xhllm.xinnuojinzhi.com/embed # 知识库查询 - embed_query: http://36.103.199.104:8123/query + embed_query: http://rag.xhllm.xinnuojinzhi.com/query check_file_list: http://36.103.199.104:5123/llm/finetuning/checkpoints?model_name=