Quellcode durchsuchen

批量导入、批量删除文件

lamphua vor 1 Woche
Ursprung
Commit
c88899ba57

+ 0
- 97
llm-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/controller/CmcAgentToolController.java Datei anzeigen

@@ -1,97 +0,0 @@
1
-package com.ruoyi.web.llm.controller;
2
-
3
-import java.util.List;
4
-import javax.servlet.http.HttpServletResponse;
5
-import org.springframework.beans.factory.annotation.Autowired;
6
-import org.springframework.web.bind.annotation.GetMapping;
7
-import org.springframework.web.bind.annotation.PostMapping;
8
-import org.springframework.web.bind.annotation.PutMapping;
9
-import org.springframework.web.bind.annotation.DeleteMapping;
10
-import org.springframework.web.bind.annotation.PathVariable;
11
-import org.springframework.web.bind.annotation.RequestBody;
12
-import org.springframework.web.bind.annotation.RequestMapping;
13
-import org.springframework.web.bind.annotation.RestController;
14
-import com.ruoyi.common.annotation.Log;
15
-import com.ruoyi.common.core.controller.BaseController;
16
-import com.ruoyi.common.core.domain.AjaxResult;
17
-import com.ruoyi.common.enums.BusinessType;
18
-import com.ruoyi.llm.domain.CmcAgentTool;
19
-import com.ruoyi.llm.service.ICmcAgentToolService;
20
-import com.ruoyi.common.utils.poi.ExcelUtil;
21
-import com.ruoyi.common.core.page.TableDataInfo;
22
-
23
-/**
24
- * 智能体工具Controller
25
- * 
26
- * @author ruoyi
27
- * @date 2025-07-17
28
- */
29
-@RestController
30
-@RequestMapping("/llm/tool")
31
-public class CmcAgentToolController extends BaseController
32
-{
33
-    @Autowired
34
-    private ICmcAgentToolService cmcAgentToolService;
35
-
36
-    /**
37
-     * 查询智能体工具列表
38
-     */
39
-    @GetMapping("/list")
40
-    public TableDataInfo list(CmcAgentTool cmcAgentTool)
41
-    {
42
-        startPage();
43
-        List<CmcAgentTool> list = cmcAgentToolService.selectCmcAgentToolList(cmcAgentTool);
44
-        return getDataTable(list);
45
-    }
46
-
47
-    /**
48
-     * 导出智能体工具列表
49
-     */
50
-    @Log(title = "智能体工具", businessType = BusinessType.EXPORT)
51
-    @PostMapping("/export")
52
-    public void export(HttpServletResponse response, CmcAgentTool cmcAgentTool)
53
-    {
54
-        List<CmcAgentTool> list = cmcAgentToolService.selectCmcAgentToolList(cmcAgentTool);
55
-        ExcelUtil<CmcAgentTool> util = new ExcelUtil<CmcAgentTool>(CmcAgentTool.class);
56
-        util.exportExcel(response, list, "智能体工具数据");
57
-    }
58
-
59
-    /**
60
-     * 获取智能体工具详细信息
61
-     */
62
-    @GetMapping(value = "/{agentToolId}")
63
-    public AjaxResult getInfo(@PathVariable("agentToolId") Integer agentToolId)
64
-    {
65
-        return success(cmcAgentToolService.selectCmcAgentToolByAgentToolId(agentToolId));
66
-    }
67
-
68
-    /**
69
-     * 新增智能体工具
70
-     */
71
-    @Log(title = "智能体工具", businessType = BusinessType.INSERT)
72
-    @PostMapping
73
-    public AjaxResult add(@RequestBody CmcAgentTool cmcAgentTool)
74
-    {
75
-        return toAjax(cmcAgentToolService.insertCmcAgentTool(cmcAgentTool));
76
-    }
77
-
78
-    /**
79
-     * 修改智能体工具
80
-     */
81
-    @Log(title = "智能体工具", businessType = BusinessType.UPDATE)
82
-    @PutMapping
83
-    public AjaxResult edit(@RequestBody CmcAgentTool cmcAgentTool)
84
-    {
85
-        return toAjax(cmcAgentToolService.updateCmcAgentTool(cmcAgentTool));
86
-    }
87
-
88
-    /**
89
-     * 删除智能体工具
90
-     */
91
-    @Log(title = "智能体工具", businessType = BusinessType.DELETE)
92
-	@DeleteMapping("/{agentToolIds}")
93
-    public AjaxResult remove(@PathVariable Integer[] agentToolIds)
94
-    {
95
-        return success(cmcAgentToolService.deleteCmcAgentToolByAgentToolIds(agentToolIds));
96
-    }
97
-}

+ 6
- 3
llm-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/controller/KnowLedgeController.java Datei anzeigen

@@ -79,6 +79,7 @@ public class KnowLedgeController extends BaseController
79 79
     @DeleteMapping("/remove")
80 80
     public AjaxResult removeKnowLedgeCollection(String collectionName)
81 81
     {
82
+        milvusService.removeAllDocument(milvusClient, collectionName);
82 83
         milvusService.deleteCollectionName(milvusClient, collectionName);
83 84
         return success();
84 85
     }
@@ -97,10 +98,12 @@ public class KnowLedgeController extends BaseController
97 98
      * 导入知识库文件
98 99
      */
99 100
     @PostMapping("/insertDocument")
100
-    public AjaxResult insertKnowledgeDocument(MultipartFile file, String collectionName) throws IOException {
101
-        R<MutationResult> insertResult = langChainMilvusService.insertLangchainEmbeddingDocument(milvusClient, file, collectionName, embeddingModel);
101
+    public AjaxResult insertKnowledgeDocument(MultipartFile[] fileList, String collectionName) throws IOException {
102
+        R<MutationResult> insertResult = null;
103
+        for (MultipartFile file : fileList)
104
+            insertResult = langChainMilvusService.insertLangchainEmbeddingDocument(milvusClient, file, collectionName, embeddingModel);
102 105
         String message = "文件导入成功";
103
-        if (insertResult.getStatus() != R.Status.Success.getCode()) {
106
+        if (insertResult != null && insertResult.getStatus() != R.Status.Success.getCode()) {
104 107
             message = "文件导入失败:" + insertResult.getMessage();
105 108
             return error(message);
106 109
         }

+ 5
- 0
llm-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/service/IMilvusService.java Datei anzeigen

@@ -38,4 +38,9 @@ public interface IMilvusService {
38 38
      * 删除知识库文件
39 39
      */
40 40
     public void removeDocument(MilvusClient milvusClient, String collectionName, String fileName);
41
+
42
+    /**
43
+     * 删除知识库所有文件
44
+     */
45
+    public void removeAllDocument(MilvusClient milvusClient, String collectionName);
41 46
 }

+ 3
- 3
llm-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/service/impl/LangChainMilvusServiceImpl.java Datei anzeigen

@@ -52,7 +52,7 @@ public class LangChainMilvusServiceImpl implements ILangChainMilvusService
52 52
     @Override
53 53
     public R<MutationResult> insertLangchainEmbeddingDocument(MilvusClient milvusClient, MultipartFile file, String collectionName, EmbeddingModel embeddingModel) throws IOException
54 54
     {
55
-        File profilePath = new File( RuoYiConfig.getProfile() + "/upload/knowledge");
55
+        File profilePath = new File( RuoYiConfig.getProfile() + "/upload/knowledge/" + collectionName);
56 56
         if (!profilePath.exists())
57 57
             profilePath.mkdirs();
58 58
         File transferFile = new File( profilePath + File.separator + file.getOriginalFilename());
@@ -75,7 +75,7 @@ public class LangChainMilvusServiceImpl implements ILangChainMilvusService
75 75
         else {
76 76
             throw new UnsupportedOperationException("不支持文件类型: " + filename);
77 77
         }
78
-        DocumentByParagraphSplitter splitter = new DocumentByParagraphSplitter(1024,100);;
78
+        DocumentByParagraphSplitter splitter = new DocumentByParagraphSplitter(1000,200);;
79 79
         List<TextSegment> segments = splitter.split(document);
80 80
 
81 81
         // 提取文本和生成嵌入
@@ -208,7 +208,7 @@ public class LangChainMilvusServiceImpl implements ILangChainMilvusService
208 208
                 .withOutFields(Arrays.asList("file_name", "file_type", "content"))
209 209
                 .withVectorFieldName("embedding")
210 210
                 .withMetricType(MetricType.COSINE)
211
-                .withParams("{\"nprobe\": 1}")
211
+                .withParams("{\"nprobe\": 8}")
212 212
                 .build();
213 213
 
214 214
         R<SearchResults> response = milvusClient.search(searchParam);

+ 12
- 0
llm-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/service/impl/MilvusServiceImpl.java Datei anzeigen

@@ -180,6 +180,18 @@ public class MilvusServiceImpl implements IMilvusService {
180 180
         milvusClient.delete(deleteParam);
181 181
     }
182 182
 
183
+    /**
184
+     * 删除知识库所有文件
185
+     */
186
+    public void removeAllDocument(MilvusClient milvusClient, String collectionName) {
187
+        loadCollectionName(milvusClient, collectionName);
188
+        DeleteParam deleteParam = DeleteParam.newBuilder()
189
+                .withCollectionName(collectionName)
190
+                .withExpr("id > 0")
191
+                .build();
192
+        milvusClient.delete(deleteParam);
193
+    }
194
+
183 195
     /**
184 196
      * 加载知识库Collection
185 197
      */

+ 0
- 79
llm-back/ruoyi-system/src/main/java/com/ruoyi/llm/domain/CmcAgentTool.java Datei anzeigen

@@ -1,79 +0,0 @@
1
-package com.ruoyi.llm.domain;
2
-
3
-import org.apache.commons.lang3.builder.ToStringBuilder;
4
-import org.apache.commons.lang3.builder.ToStringStyle;
5
-import com.ruoyi.common.annotation.Excel;
6
-import com.ruoyi.common.core.domain.BaseEntity;
7
-
8
-/**
9
- * 智能体工具对象 cmc_agent_tool
10
- * 
11
- * @author ruoyi
12
- * @date 2025-07-17
13
- */
14
-public class CmcAgentTool extends BaseEntity
15
-{
16
-    private static final long serialVersionUID = 1L;
17
-
18
-    /** 智能体工具id */
19
-    private Integer agentToolId;
20
-
21
-    /** 工具描述 */
22
-    @Excel(name = "工具描述")
23
-    private String toolName;
24
-
25
-    /** 智能体id */
26
-    @Excel(name = "智能体id")
27
-    private Integer agentId;
28
-
29
-    /** 顺序 */
30
-    @Excel(name = "顺序")
31
-    private String toolSort;
32
-
33
-    public void setAgentToolId(Integer agentToolId) 
34
-    {
35
-        this.agentToolId = agentToolId;
36
-    }
37
-
38
-    public Integer getAgentToolId() 
39
-    {
40
-        return agentToolId;
41
-    }
42
-    public void setToolName(String toolName) 
43
-    {
44
-        this.toolName = toolName;
45
-    }
46
-
47
-    public String getToolName() 
48
-    {
49
-        return toolName;
50
-    }
51
-    public void setAgentId(Integer agentId) 
52
-    {
53
-        this.agentId = agentId;
54
-    }
55
-
56
-    public Integer getAgentId() 
57
-    {
58
-        return agentId;
59
-    }
60
-    public void setToolSort(String toolSort) 
61
-    {
62
-        this.toolSort = toolSort;
63
-    }
64
-
65
-    public String getToolSort() 
66
-    {
67
-        return toolSort;
68
-    }
69
-
70
-    @Override
71
-    public String toString() {
72
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
73
-            .append("agentToolId", getAgentToolId())
74
-            .append("toolName", getToolName())
75
-            .append("agentId", getAgentId())
76
-            .append("toolSort", getToolSort())
77
-            .toString();
78
-    }
79
-}

+ 0
- 61
llm-back/ruoyi-system/src/main/java/com/ruoyi/llm/mapper/CmcAgentToolMapper.java Datei anzeigen

@@ -1,61 +0,0 @@
1
-package com.ruoyi.llm.mapper;
2
-
3
-import java.util.List;
4
-import com.ruoyi.llm.domain.CmcAgentTool;
5
-
6
-/**
7
- * 智能体工具Mapper接口
8
- * 
9
- * @author ruoyi
10
- * @date 2025-07-17
11
- */
12
-public interface CmcAgentToolMapper 
13
-{
14
-    /**
15
-     * 查询智能体工具
16
-     * 
17
-     * @param agentToolId 智能体工具主键
18
-     * @return 智能体工具
19
-     */
20
-    public CmcAgentTool selectCmcAgentToolByAgentToolId(Integer agentToolId);
21
-
22
-    /**
23
-     * 查询智能体工具列表
24
-     * 
25
-     * @param cmcAgentTool 智能体工具
26
-     * @return 智能体工具集合
27
-     */
28
-    public List<CmcAgentTool> selectCmcAgentToolList(CmcAgentTool cmcAgentTool);
29
-
30
-    /**
31
-     * 新增智能体工具
32
-     * 
33
-     * @param cmcAgentTool 智能体工具
34
-     * @return 结果
35
-     */
36
-    public int insertCmcAgentTool(CmcAgentTool cmcAgentTool);
37
-
38
-    /**
39
-     * 修改智能体工具
40
-     * 
41
-     * @param cmcAgentTool 智能体工具
42
-     * @return 结果
43
-     */
44
-    public int updateCmcAgentTool(CmcAgentTool cmcAgentTool);
45
-
46
-    /**
47
-     * 删除智能体工具
48
-     * 
49
-     * @param agentToolId 智能体工具主键
50
-     * @return 结果
51
-     */
52
-    public int deleteCmcAgentToolByAgentToolId(Integer agentToolId);
53
-
54
-    /**
55
-     * 批量删除智能体工具
56
-     * 
57
-     * @param agentToolIds 需要删除的数据主键集合
58
-     * @return 结果
59
-     */
60
-    public int deleteCmcAgentToolByAgentToolIds(Integer[] agentToolIds);
61
-}

+ 0
- 61
llm-back/ruoyi-system/src/main/java/com/ruoyi/llm/service/ICmcAgentToolService.java Datei anzeigen

@@ -1,61 +0,0 @@
1
-package com.ruoyi.llm.service;
2
-
3
-import java.util.List;
4
-import com.ruoyi.llm.domain.CmcAgentTool;
5
-
6
-/**
7
- * 智能体工具Service接口
8
- * 
9
- * @author ruoyi
10
- * @date 2025-07-17
11
- */
12
-public interface ICmcAgentToolService 
13
-{
14
-    /**
15
-     * 查询智能体工具
16
-     * 
17
-     * @param agentToolId 智能体工具主键
18
-     * @return 智能体工具
19
-     */
20
-    public CmcAgentTool selectCmcAgentToolByAgentToolId(Integer agentToolId);
21
-
22
-    /**
23
-     * 查询智能体工具列表
24
-     * 
25
-     * @param cmcAgentTool 智能体工具
26
-     * @return 智能体工具集合
27
-     */
28
-    public List<CmcAgentTool> selectCmcAgentToolList(CmcAgentTool cmcAgentTool);
29
-
30
-    /**
31
-     * 新增智能体工具
32
-     * 
33
-     * @param cmcAgentTool 智能体工具
34
-     * @return 结果
35
-     */
36
-    public int insertCmcAgentTool(CmcAgentTool cmcAgentTool);
37
-
38
-    /**
39
-     * 修改智能体工具
40
-     * 
41
-     * @param cmcAgentTool 智能体工具
42
-     * @return 结果
43
-     */
44
-    public int updateCmcAgentTool(CmcAgentTool cmcAgentTool);
45
-
46
-    /**
47
-     * 批量删除智能体工具
48
-     * 
49
-     * @param agentToolIds 需要删除的智能体工具主键集合
50
-     * @return 结果
51
-     */
52
-    public int deleteCmcAgentToolByAgentToolIds(Integer[] agentToolIds);
53
-
54
-    /**
55
-     * 删除智能体工具信息
56
-     * 
57
-     * @param agentToolId 智能体工具主键
58
-     * @return 结果
59
-     */
60
-    public int deleteCmcAgentToolByAgentToolId(Integer agentToolId);
61
-}

+ 0
- 93
llm-back/ruoyi-system/src/main/java/com/ruoyi/llm/service/impl/CmcAgentToolServiceImpl.java Datei anzeigen

@@ -1,93 +0,0 @@
1
-package com.ruoyi.llm.service.impl;
2
-
3
-import java.util.List;
4
-import org.springframework.beans.factory.annotation.Autowired;
5
-import org.springframework.stereotype.Service;
6
-import com.ruoyi.llm.mapper.CmcAgentToolMapper;
7
-import com.ruoyi.llm.domain.CmcAgentTool;
8
-import com.ruoyi.llm.service.ICmcAgentToolService;
9
-
10
-/**
11
- * 智能体工具Service业务层处理
12
- * 
13
- * @author ruoyi
14
- * @date 2025-07-17
15
- */
16
-@Service
17
-public class CmcAgentToolServiceImpl implements ICmcAgentToolService 
18
-{
19
-    @Autowired
20
-    private CmcAgentToolMapper cmcAgentToolMapper;
21
-
22
-    /**
23
-     * 查询智能体工具
24
-     * 
25
-     * @param agentToolId 智能体工具主键
26
-     * @return 智能体工具
27
-     */
28
-    @Override
29
-    public CmcAgentTool selectCmcAgentToolByAgentToolId(Integer agentToolId)
30
-    {
31
-        return cmcAgentToolMapper.selectCmcAgentToolByAgentToolId(agentToolId);
32
-    }
33
-
34
-    /**
35
-     * 查询智能体工具列表
36
-     * 
37
-     * @param cmcAgentTool 智能体工具
38
-     * @return 智能体工具
39
-     */
40
-    @Override
41
-    public List<CmcAgentTool> selectCmcAgentToolList(CmcAgentTool cmcAgentTool)
42
-    {
43
-        return cmcAgentToolMapper.selectCmcAgentToolList(cmcAgentTool);
44
-    }
45
-
46
-    /**
47
-     * 新增智能体工具
48
-     * 
49
-     * @param cmcAgentTool 智能体工具
50
-     * @return 结果
51
-     */
52
-    @Override
53
-    public int insertCmcAgentTool(CmcAgentTool cmcAgentTool)
54
-    {
55
-        return cmcAgentToolMapper.insertCmcAgentTool(cmcAgentTool);
56
-    }
57
-
58
-    /**
59
-     * 修改智能体工具
60
-     * 
61
-     * @param cmcAgentTool 智能体工具
62
-     * @return 结果
63
-     */
64
-    @Override
65
-    public int updateCmcAgentTool(CmcAgentTool cmcAgentTool)
66
-    {
67
-        return cmcAgentToolMapper.updateCmcAgentTool(cmcAgentTool);
68
-    }
69
-
70
-    /**
71
-     * 批量删除智能体工具
72
-     * 
73
-     * @param agentToolIds 需要删除的智能体工具主键
74
-     * @return 结果
75
-     */
76
-    @Override
77
-    public int deleteCmcAgentToolByAgentToolIds(Integer[] agentToolIds)
78
-    {
79
-        return cmcAgentToolMapper.deleteCmcAgentToolByAgentToolIds(agentToolIds);
80
-    }
81
-
82
-    /**
83
-     * 删除智能体工具信息
84
-     * 
85
-     * @param agentToolId 智能体工具主键
86
-     * @return 结果
87
-     */
88
-    @Override
89
-    public int deleteCmcAgentToolByAgentToolId(Integer agentToolId)
90
-    {
91
-        return cmcAgentToolMapper.deleteCmcAgentToolByAgentToolId(agentToolId);
92
-    }
93
-}

+ 0
- 68
llm-back/ruoyi-system/src/main/resources/mapper/llm/CmcAgentToolMapper.xml Datei anzeigen

@@ -1,68 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8" ?>
2
-<!DOCTYPE mapper
3
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
-<mapper namespace="com.ruoyi.llm.mapper.CmcAgentToolMapper">
6
-    
7
-    <resultMap type="CmcAgentTool" id="CmcAgentToolResult">
8
-        <result property="agentToolId"    column="agent_tool_id"    />
9
-        <result property="toolName"    column="tool_name"    />
10
-        <result property="agentId"    column="agent_id"    />
11
-        <result property="toolSort"    column="tool_sort"    />
12
-    </resultMap>
13
-
14
-    <sql id="selectCmcAgentToolVo">
15
-        select agent_tool_id, tool_name, agent_id, tool_sort from cmc_agent_tool
16
-    </sql>
17
-
18
-    <select id="selectCmcAgentToolList" parameterType="CmcAgentTool" resultMap="CmcAgentToolResult">
19
-        <include refid="selectCmcAgentToolVo"/>
20
-        <where>  
21
-            <if test="toolName != null  and toolName != ''"> and tool_name like concat('%', #{toolName}, '%')</if>
22
-            <if test="agentId != null "> and agent_id = #{agentId}</if>
23
-            <if test="toolSort != null  and toolSort != ''"> and tool_sort = #{toolSort}</if>
24
-        </where>
25
-    </select>
26
-    
27
-    <select id="selectCmcAgentToolByAgentToolId" parameterType="Integer" resultMap="CmcAgentToolResult">
28
-        <include refid="selectCmcAgentToolVo"/>
29
-        where agent_tool_id = #{agentToolId}
30
-    </select>
31
-
32
-    <insert id="insertCmcAgentTool" parameterType="CmcAgentTool">
33
-        insert into cmc_agent_tool
34
-        <trim prefix="(" suffix=")" suffixOverrides=",">
35
-            <if test="agentToolId != null">agent_tool_id,</if>
36
-            <if test="toolName != null">tool_name,</if>
37
-            <if test="agentId != null">agent_id,</if>
38
-            <if test="toolSort != null">tool_sort,</if>
39
-         </trim>
40
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
41
-            <if test="agentToolId != null">#{agentToolId},</if>
42
-            <if test="toolName != null">#{toolName},</if>
43
-            <if test="agentId != null">#{agentId},</if>
44
-            <if test="toolSort != null">#{toolSort},</if>
45
-         </trim>
46
-    </insert>
47
-
48
-    <update id="updateCmcAgentTool" parameterType="CmcAgentTool">
49
-        update cmc_agent_tool
50
-        <trim prefix="SET" suffixOverrides=",">
51
-            <if test="toolName != null">tool_name = #{toolName},</if>
52
-            <if test="agentId != null">agent_id = #{agentId},</if>
53
-            <if test="toolSort != null">tool_sort = #{toolSort},</if>
54
-        </trim>
55
-        where agent_tool_id = #{agentToolId}
56
-    </update>
57
-
58
-    <delete id="deleteCmcAgentToolByAgentToolId" parameterType="Integer">
59
-        delete from cmc_agent_tool where agent_tool_id = #{agentToolId}
60
-    </delete>
61
-
62
-    <delete id="deleteCmcAgentToolByAgentToolIds" parameterType="String">
63
-        delete from cmc_agent_tool where agent_tool_id in 
64
-        <foreach item="agentToolId" collection="array" open="(" separator="," close=")">
65
-            #{agentToolId}
66
-        </foreach>
67
-    </delete>
68
-</mapper>

+ 6
- 4
llm-ui/src/api/llm/knowLedge.js Datei anzeigen

@@ -1,8 +1,8 @@
1 1
 /*
2 2
  * @Author: ysh
3 3
  * @Date: 2025-06-30 09:56:10
4
- * @LastEditors: Please set LastEditors
5
- * @LastEditTime: 2025-07-03 10:47:54
4
+ * @LastEditors: wrh
5
+ * @LastEditTime: 2025-07-18 15:40:00
6 6
  */
7 7
 import request from '@/utils/request'
8 8
 
@@ -43,9 +43,11 @@ export function delKnowledge(collectionName) {
43 43
 }
44 44
 
45 45
 // 插入知识库文件
46
-export function insertKnowledgeFile(file, collectionName) {
46
+export function insertKnowledgeFile(fileList, collectionName) {
47 47
   const formData = new FormData()
48
-  formData.append('file', file)
48
+  for(let f of fileList){
49
+    formData.append('fileList', f)
50
+  }
49 51
   formData.append('collectionName', collectionName)
50 52
   return request({
51 53
     url: '/llm/knowledge/insertDocument',

+ 5
- 6
llm-ui/src/views/llm/knowledge/index.vue Datei anzeigen

@@ -266,7 +266,7 @@
266 266
           <el-input v-model="uploadForm.collectionName" disabled />
267 267
         </el-form-item>
268 268
         <el-form-item label="选择文件" prop="file">
269
-          <el-upload ref="knowledgeUpload" :limit="1" accept=".doc,.docx,.pdf" :headers="upload.headers" :action="''"
269
+          <el-upload ref="knowledgeUpload" multiple accept=".docx,.pdf" :headers="upload.headers" :action="''"
270 270
             :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess"
271 271
             :auto-upload="false" drag :on-change="handleFileChange">
272 272
             <el-icon class="el-icon--upload"><upload-filled /></el-icon>
@@ -277,7 +277,7 @@
277 277
                   <el-checkbox v-model="upload.updateSupport" />
278 278
                   是否更新已经存在的文件数据
279 279
                 </div>
280
-                <span>支持 .doc、.docx、.pdf 格式文件</span>
280
+                <span>支持 .docx、.pdf 格式文件</span>
281 281
               </div>
282 282
             </template>
283 283
           </el-upload>
@@ -638,8 +638,6 @@ function getFileType(fileName) {
638 638
   switch (extension) {
639 639
     case 'pdf':
640 640
       return 'PDF文档';
641
-    case 'doc':
642
-      return 'Word文档';
643 641
     case 'docx':
644 642
       return 'Word文档';
645 643
     default:
@@ -772,7 +770,8 @@ function handleFileUploadProgress(event, file, fileList) {
772 770
 }
773 771
 
774 772
 function handleFileChange(file, fileList) {
775
-  upload.file = file.raw;
773
+  upload.fileList = fileList.map(f => f.raw)
774
+  console.log(upload.fileList)
776 775
 }
777 776
 
778 777
 // 文件上传成功处理
@@ -797,7 +796,7 @@ function handleFileSuccess(response, file, fileList) {
797 796
 
798 797
 // 提交上传
799 798
 function submitUpload() {
800
-  insertKnowledgeFile(upload.file, uploadForm.collectionName).then(response => {
799
+  insertKnowledgeFile(upload.fileList, uploadForm.collectionName).then(response => {
801 800
     proxy.$modal.msgSuccess("上传成功");
802 801
     uploadOpen.value = false;
803 802
     proxy.$refs.knowledgeUpload.clearFiles();

Laden…
Abbrechen
Speichern