Skip to content

Commit 14f987f

Browse files
committed
Merge remote-tracking branch 'origin/1.3.x'
2 parents cd9c1ee + 21d700f commit 14f987f

File tree

18 files changed

+1352
-10
lines changed

18 files changed

+1352
-10
lines changed

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,20 @@ bash docker/dev-app-builder.sh
7676
本章节给出快速启动之后,本地快速开发测试前端的方法。
7777

7878
### 1. 编译代码
79-
1. 全量编译前端(1 minutes 10 seconds)
79+
80+
1. 构建 `agent-flow`,在项目根目录下,执行以下命令编译:
81+
82+
```shell
83+
cd agent-flow
84+
npm install --legacy-peer-deps --force --registry=https://registry.npmmirror.com
85+
npm run build
86+
npm link
87+
cd -
88+
```
89+
90+
> 首次的话,需要执行一次,后续有修改再增量构建执行即可。
91+
92+
2. 全量编译前端(1 minutes 10 seconds)
8093
编写代码,在项目根目录下,执行以下命令编译:
8194
```shell
8295
cd frontend
@@ -238,7 +251,7 @@ fit debug
238251
239252
**修改代理文件**
240253
241-
修改 `app-platform/frontend` 目录下的 `proxy.config.json` 文件,可以修改需要访问的后端地址。如本地后端地址是 `http://127.0.0.1:8080` 。可以按照如下示例配置:
254+
修改 `frontend` 目录下的 `proxy.config.json` 文件,可以修改需要访问的后端地址。如本地后端地址是 `http://127.0.0.1:8080` 。可以按照如下示例配置:
242255
243256
```json
244257
{
@@ -253,10 +266,24 @@ fit debug
253266
}
254267
```
255268

269+
**前置准备**
270+
271+
构建 `agent-flow`:
272+
273+
```bash
274+
cd agent-flow
275+
276+
npm install
277+
npm run build
278+
npm link
279+
280+
cd -
281+
```
282+
256283
**依赖安装**
257284

258285
```
259-
cd app-platform/frontend/
286+
cd frontend/
260287
npm install
261288
```
262289

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>modelengine.fit.jade</groupId>
7+
<artifactId>app-builder-plugin-parent</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
11+
<groupId>modelengine.jade.plugin</groupId>
12+
<artifactId>data-mate-knowledge</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>17</maven.compiler.source>
16+
<maven.compiler.target>17</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
<dependencies>
21+
<!-- FIT -->
22+
<dependency>
23+
<groupId>org.fitframework</groupId>
24+
<artifactId>fit-api</artifactId>
25+
</dependency>
26+
27+
<!-- Service -->
28+
<dependency>
29+
<groupId>modelengine.fit.jade.service</groupId>
30+
<artifactId>knowledge-service</artifactId>
31+
</dependency>
32+
33+
<!-- lombok -->
34+
<dependency>
35+
<groupId>org.projectlombok</groupId>
36+
<artifactId>lombok</artifactId>
37+
</dependency>
38+
39+
<!-- Mapstruct -->
40+
<dependency>
41+
<groupId>org.mapstruct</groupId>
42+
<artifactId>mapstruct</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.mapstruct</groupId>
46+
<artifactId>mapstruct-processor</artifactId>
47+
</dependency>
48+
49+
<!-- Jackson -->
50+
<dependency>
51+
<groupId>com.fasterxml.jackson.core</groupId>
52+
<artifactId>jackson-databind</artifactId>
53+
</dependency>
54+
55+
<!-- Test -->
56+
<dependency>
57+
<groupId>org.fitframework</groupId>
58+
<artifactId>fit-test-framework</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.junit.jupiter</groupId>
62+
<artifactId>junit-jupiter</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.mockito</groupId>
66+
<artifactId>mockito-core</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.assertj</groupId>
70+
<artifactId>assertj-core</artifactId>
71+
</dependency>
72+
</dependencies>
73+
74+
<build>
75+
<plugins>
76+
<plugin>
77+
<groupId>org.fitframework</groupId>
78+
<artifactId>fit-build-maven-plugin</artifactId>
79+
<version>${fit.version}</version>
80+
<executions>
81+
<execution>
82+
<id>build-plugin</id>
83+
<goals>
84+
<goal>build-plugin</goal>
85+
</goals>
86+
</execution>
87+
<execution>
88+
<id>package-plugin</id>
89+
<goals>
90+
<goal>package-plugin</goal>
91+
</goals>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.fitframework</groupId>
97+
<artifactId>fit-dependency-maven-plugin</artifactId>
98+
<version>${fit.version}</version>
99+
<executions>
100+
<execution>
101+
<id>dependency</id>
102+
<phase>compile</phase>
103+
<goals>
104+
<goal>dependency</goal>
105+
</goals>
106+
</execution>
107+
</executions>
108+
</plugin>
109+
<plugin>
110+
<groupId>org.apache.maven.plugins</groupId>
111+
<artifactId>maven-jar-plugin</artifactId>
112+
<version>${maven.jar.version}</version>
113+
<configuration>
114+
<archive>
115+
<manifestEntries>
116+
<Created-By>FIT Lab</Created-By>
117+
</manifestEntries>
118+
</archive>
119+
</configuration>
120+
</plugin>
121+
<plugin>
122+
<groupId>org.apache.maven.plugins</groupId>
123+
<artifactId>maven-antrun-plugin</artifactId>
124+
<version>${maven.antrun.version}</version>
125+
<executions>
126+
<execution>
127+
<phase>install</phase>
128+
<configuration>
129+
<target>
130+
<copy file="${project.build.directory}/${project.build.finalName}.jar"
131+
todir="../../../build/plugins"/>
132+
</target>
133+
</configuration>
134+
<goals>
135+
<goal>run</goal>
136+
</goals>
137+
</execution>
138+
</executions>
139+
</plugin>
140+
</plugins>
141+
</build>
142+
</project>
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.jade.datamate.knowledge.convertor;
8+
9+
import com.fasterxml.jackson.core.JsonProcessingException;
10+
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import modelengine.fitframework.util.StringUtils;
12+
import modelengine.jade.knowledge.KnowledgeRepo;
13+
import modelengine.jade.knowledge.ReferenceLimit;
14+
import modelengine.jade.knowledge.document.KnowledgeDocument;
15+
import modelengine.fit.jade.datamate.knowledge.dto.DataMateRetrievalParam;
16+
import modelengine.fit.jade.datamate.knowledge.entity.DataMateKnowledgeEntity;
17+
import modelengine.fit.jade.datamate.knowledge.entity.DataMateRetrievalChunksEntity;
18+
import modelengine.jade.knowledge.support.FlatKnowledgeOption;
19+
20+
import org.mapstruct.Mapper;
21+
import org.mapstruct.Mapping;
22+
import org.mapstruct.Named;
23+
import org.mapstruct.factory.Mappers;
24+
25+
import java.time.LocalDateTime;
26+
import java.time.format.DateTimeFormatter;
27+
import java.util.HashMap;
28+
import java.util.Map;
29+
30+
/**
31+
* DataMate 内部数据的转换器接口。
32+
*
33+
* @author 陈镕希
34+
* @since 2025-12-15
35+
*/
36+
@Mapper
37+
public interface ParamConvertor {
38+
ParamConvertor INSTANCE = Mappers.getMapper(ParamConvertor.class);
39+
int TOP = 400;
40+
41+
/**
42+
* 将 {@link DataMateKnowledgeEntity} 转换为 {@link KnowledgeRepo}。
43+
*
44+
* @param entity 表示待转换的 {@link DataMateKnowledgeEntity}。
45+
* @return 转换完成的 {@link KnowledgeRepo}。
46+
*/
47+
@Mapping(target = "type", source = "entity", qualifiedByName = "mapIndexTypeToType")
48+
@Mapping(target = "createdAt", source = "entity", qualifiedByName = "stringToLocalDateTime")
49+
KnowledgeRepo convertToKnowledgeRepo(DataMateKnowledgeEntity entity);
50+
51+
/**
52+
* 将 DataMate 知识库的检索 type 映射为 平台知识库元数据 type。
53+
*
54+
* @param entity 表示待转换的 {@link DataMateKnowledgeEntity}。
55+
* @return 表示转换完成的 {@link String}。
56+
*/
57+
@Named("mapIndexTypeToType")
58+
default String mapIndexTypeToType(DataMateKnowledgeEntity entity) {
59+
return entity == null ? null : entity.getEmbeddingModel();
60+
}
61+
62+
/**
63+
* 将 DataMate 知识库的 createdAt 映射为 平台知识库元数据 createdAt。
64+
*
65+
* @param entity 表示待转换的 {@link DataMateKnowledgeEntity}。
66+
* @return 表示转换完成的 {@link LocalDateTime}。
67+
*/
68+
@Named("stringToLocalDateTime")
69+
default LocalDateTime stringToLocalDateTime(DataMateKnowledgeEntity entity) {
70+
String dateStr = entity.getCreatedAt();
71+
if (dateStr == null || StringUtils.isEmpty(dateStr)) {
72+
return null;
73+
}
74+
return LocalDateTime.parse(dateStr, DateTimeFormatter.ISO_DATE_TIME);
75+
}
76+
77+
/**
78+
* 将 {@link FlatKnowledgeOption} 转换为 {@link DataMateRetrievalParam}。
79+
*
80+
* @param option 表示待转换的 {@link FlatKnowledgeOption}。
81+
* @return 转换完成的 {@link DataMateRetrievalParam}。
82+
*/
83+
@Mapping(target = "knowledgeBaseIds", source = "repoIds")
84+
@Mapping(target = "query", source = "query")
85+
@Mapping(target = "topK", source = "referenceLimit", qualifiedByName = "mapReferenceLimitToTop")
86+
@Mapping(target = "threshold", source = "similarityThreshold")
87+
DataMateRetrievalParam convertToRetrievalParam(FlatKnowledgeOption option);
88+
89+
/**
90+
* 将平台检索请求 ReferenceLimit 映射为 DataMate 检索请求 top。
91+
*
92+
* @param limit 表示待转换的 {@link ReferenceLimit}。
93+
* @return 转换完成的 {@link int}。
94+
*/
95+
@Named("mapReferenceLimitToTop")
96+
default int mapReferenceLimitToTop(ReferenceLimit limit) {
97+
if (limit == null) {
98+
return TOP;
99+
}
100+
return limit.getValue();
101+
}
102+
103+
/**
104+
* 将 {@link DataMateRetrievalChunksEntity} 转换为 {@link KnowledgeDocument}。
105+
*
106+
* @param entity 表示待转换的 {@link DataMateRetrievalChunksEntity}。
107+
* @return 转换完成的 {@link KnowledgeDocument}。
108+
*/
109+
@Mapping(target = "id", expression = "java(entity.chunkId())")
110+
@Mapping(target = "text", expression = "java(entity.content())")
111+
@Mapping(target = "score", expression = "java(entity.retrievalScore())")
112+
@Mapping(target = "metadata", source = ".", qualifiedByName = "mapChunksEntityToMetadata")
113+
KnowledgeDocument convertToKnowledgeDocument(DataMateRetrievalChunksEntity entity);
114+
115+
/**
116+
* 将 DataMate 检索结果 entity 映射为 平台检索结果 metadata。
117+
*
118+
* @param entity 表示待转换的 {@link DataMateRetrievalChunksEntity}。
119+
* @return 转换完成的 {@link Map}{@code <}{@link String}{@code , }{@link Object}{@code >}。
120+
*/
121+
@Named("mapChunksEntityToMetadata")
122+
default Map<String, Object> mapChunksEntityToMetadata(DataMateRetrievalChunksEntity entity) {
123+
Map<String, Object> metadata = new HashMap<>();
124+
if (entity == null || entity.getEntity() == null) {
125+
return metadata;
126+
}
127+
metadata.put("primaryKey", entity.getPrimaryKey());
128+
String rawMetadata = entity.getEntity().getMetadata();
129+
if (!StringUtils.isEmpty(rawMetadata)) {
130+
try {
131+
Map<String, Object> parsed = new ObjectMapper().readValue(rawMetadata, Map.class);
132+
metadata.put("fileId", parsed.get("original_file_id"));
133+
metadata.put("fileName", parsed.get("file_name"));
134+
metadata.putAll(parsed);
135+
} catch (JsonProcessingException ex) {
136+
metadata.put("metadata", rawMetadata);
137+
}
138+
}
139+
return metadata;
140+
}
141+
}
142+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.jade.datamate.knowledge.dto;
8+
9+
import lombok.Builder;
10+
import lombok.Data;
11+
import modelengine.fitframework.serialization.annotation.SerializeStrategy;
12+
13+
/**
14+
* DataMate 知识库列表查询参数。
15+
*
16+
* @author 陈镕希
17+
* @since 2025-12-15
18+
*/
19+
@Data
20+
@Builder
21+
@SerializeStrategy(include = SerializeStrategy.Include.NON_NULL)
22+
public class DataMateKnowledgeListQueryParam {
23+
/**
24+
* 页码,从0开始。
25+
*/
26+
private Integer page;
27+
28+
/**
29+
* 每页大小。
30+
*/
31+
private Integer size;
32+
33+
/**
34+
* 知识库名称过滤。
35+
*/
36+
private String name;
37+
38+
/**
39+
* 知识库描述过滤。
40+
*/
41+
private String description;
42+
}
43+

0 commit comments

Comments
 (0)