Skip to content

Commit 489d16d

Browse files
[fel] 去除升级插件结构引入的额外三方插件
1 parent 23a5a9b commit 489d16d

15 files changed

Lines changed: 86 additions & 76 deletions

File tree

examples/fel-example/06-agent/src/main/resources/application.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,4 @@ fel:
33
api-base: '${api-base}'
44
api-key: '${your-api-key}'
55
example:
6-
model: '${model-name}'
7-
8-
okhttp:
9-
config-client:
10-
cache:
11-
max-size: 20
6+
model: '${model-name}'

framework/fel/java/components/tool-info/pom.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,11 @@
1111

1212
<artifactId>tool-info</artifactId>
1313

14-
<properties>
15-
<jackson.version>2.16.2</jackson.version>
16-
</properties>
17-
1814
<dependencies>
1915
<dependency>
2016
<groupId>org.fitframework</groupId>
2117
<artifactId>fit-util</artifactId>
2218
</dependency>
23-
<dependency>
24-
<groupId>com.fasterxml.jackson.core</groupId>
25-
<artifactId>jackson-annotations</artifactId>
26-
<version>${jackson.version}</version>
27-
</dependency>
28-
<dependency>
29-
<groupId>com.fasterxml.jackson.core</groupId>
30-
<artifactId>jackson-core</artifactId>
31-
<version>${jackson.version}</version>
32-
</dependency>
3319
</dependencies>
3420

3521
<build>

framework/fel/java/components/tool-info/src/main/java/modelengine/fel/tool/info/entity/PropertyEntity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
public class PropertyEntity {
1717
private String defaultValue;
1818
private String description;
19-
private boolean isRequired;
2019
private String name;
2120
private String type;
2221
private Object items;
2322
private Object properties;
2423
private String examples;
24+
private boolean required;
2525

2626
/**
2727
* 获取参数的默认值。
@@ -65,7 +65,7 @@ public void setDescription(String description) {
6565
* @return 如果参数是必需的,则返回 {@code true},否则返回 {@code false}。
6666
*/
6767
public boolean isRequired() {
68-
return this.isRequired;
68+
return this.required;
6969
}
7070

7171
/**
@@ -74,7 +74,7 @@ public boolean isRequired() {
7474
* @param required 表示参数是否是必需的 {@link boolean}。
7575
*/
7676
public void setRequired(boolean required) {
77-
this.isRequired = required;
77+
this.required = required;
7878
}
7979

8080
/**

framework/fel/java/components/tool-info/src/main/java/modelengine/fel/tool/info/entity/SchemaEntity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
package modelengine.fel.tool.info.entity;
88

9-
import com.fasterxml.jackson.annotation.JsonProperty;
10-
119
import modelengine.fitframework.annotation.Property;
1210

1311
import java.util.List;
@@ -18,14 +16,14 @@
1816
*
1917
* @author 曹嘉美
2018
* @author 李金绪
19+
* @author 杭潇
2120
* @since 2024-10-26
2221
*/
2322
public class SchemaEntity {
2423
private String name;
2524
private String description;
2625
private ParameterEntity parameters;
2726
private List<String> order;
28-
@JsonProperty("return")
2927
@Property(name = "return")
3028
private Map<String, Object> ret;
3129
private Map<String, Object> parameterExtensions;

framework/fel/java/components/tool-info/src/main/java/modelengine/fel/tool/info/entity/ToolEntity.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ public class ToolEntity {
3636
private List<String> tags;
3737
private String definitionName;
3838

39+
/**
40+
* 获取工具的命名空间。
41+
*
42+
* @return 表示工具命名空间的 {@link String}。
43+
*/
44+
public String getNamespace() {
45+
return this.namespace;
46+
}
47+
48+
/**
49+
* 配置工具的命名空间。
50+
*
51+
* @param namespace 表示工具命名空间的 {@link String}。
52+
*/
53+
public void setNamespace(String namespace) {
54+
this.namespace = namespace;
55+
}
56+
3957
/**
4058
* 获取 schema 对象。
4159
*
@@ -127,24 +145,6 @@ public void setDefinitionName(String definitionName) {
127145
this.definitionName = definitionName;
128146
}
129147

130-
/**
131-
* 获取工具的命名空间。
132-
*
133-
* @return 表示工具命名空间的 {@link String}。
134-
*/
135-
public String getNamespace() {
136-
return this.namespace;
137-
}
138-
139-
/**
140-
* 配置工具的命名空间。
141-
*
142-
* @param namespace 表示工具命名空间的 {@link String}。
143-
*/
144-
public void setNamespace(String namespace) {
145-
this.namespace = namespace;
146-
}
147-
148148
/**
149149
* 将 Schema 中的 Parameters 转换为 {@link Map}{@code <}{@link String}{@code , }{@link Object}{@code >} 结构。
150150
*

framework/fel/java/maven-plugins/tool-maven-plugin/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@
2222
<groupId>org.fitframework</groupId>
2323
<artifactId>fit-maven-plugin-util</artifactId>
2424
</dependency>
25+
<dependency>
26+
<groupId>org.fitframework.plugin</groupId>
27+
<artifactId>fit-message-serializer-json-jackson</artifactId>
28+
</dependency>
2529

2630
<!-- FEL -->
2731
<dependency>
2832
<groupId>org.fitframework.fel</groupId>
2933
<artifactId>tool-service</artifactId>
3034
</dependency>
35+
36+
<!-- Component -->
3137
<dependency>
3238
<groupId>org.fitframework.fel</groupId>
3339
<artifactId>tool-info</artifactId>

framework/fel/java/maven-plugins/tool-maven-plugin/src/main/java/modelengine/fel/maven/complie/plugin/UrlClassLoaderInitializer.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
package modelengine.fel.maven.complie.plugin;
88

9-
import com.fasterxml.jackson.annotation.JsonInclude;
9+
import static modelengine.fit.serialization.json.jackson.JacksonObjectSerializer.DEFAULT_DATE_FORMAT;
10+
import static modelengine.fit.serialization.json.jackson.JacksonObjectSerializer.DEFAULT_DATE_TIME_FORMAT;
11+
1012
import com.fasterxml.jackson.databind.ObjectMapper;
1113

14+
import modelengine.fel.maven.complie.util.JsonUtils;
1215
import modelengine.fel.tool.ToolSchema;
1316
import modelengine.fel.tool.info.entity.ToolJsonEntity;
17+
import modelengine.fit.serialization.json.jackson.JacksonObjectSerializer;
1418
import modelengine.fitframework.log.Logger;
1519
import modelengine.fitframework.protocol.jar.Jar;
1620
import modelengine.fitframework.util.FileUtils;
@@ -24,6 +28,7 @@
2428
import java.nio.file.Paths;
2529
import java.util.LinkedList;
2630
import java.util.List;
31+
import java.util.Map;
2732
import java.util.stream.Stream;
2833

2934
/**
@@ -70,9 +75,14 @@ public void outputToolManifest(String outputDirectory, ToolJsonEntity toolJsonEn
7075
return;
7176
}
7277
File jsonFile = Paths.get(outputDirectory, ToolSchema.TOOL_MANIFEST).toFile();
78+
JacksonObjectSerializer serializer = new JacksonObjectSerializer(
79+
DEFAULT_DATE_TIME_FORMAT,
80+
DEFAULT_DATE_FORMAT,
81+
"Asia/Shanghai"
82+
);
83+
Map<String, Object> stringObjectMap = JsonUtils.convertToMap(serializer.serialize(toolJsonEntity));
7384
ObjectMapper objectMapper = new ObjectMapper();
74-
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
75-
objectMapper.writerWithDefaultPrettyPrinter().writeValue(jsonFile, toolJsonEntity);
85+
objectMapper.writerWithDefaultPrettyPrinter().writeValue(jsonFile, stringObjectMap);
7686
log.info("Write tool json successfully. [file={}]", jsonFile.getName());
7787
}
7888
}

framework/fel/java/maven-plugins/tool-maven-plugin/src/test/java/modelengine/fel/maven/compile/parser/weather/Rain.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import modelengine.fitframework.annotation.Genericable;
1212
import modelengine.fitframework.annotation.Property;
1313

14-
1514
import java.util.Date;
1615

1716
/**

framework/fel/java/maven-plugins/tool-maven-plugin/src/test/java/modelengine/fel/maven/compile/parser/weather/impl/MobileRainImpl.java renamed to framework/fel/java/maven-plugins/tool-maven-plugin/src/test/java/modelengine/fel/maven/compile/parser/weather/impl/CityARainImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
* @author 曹嘉美
2323
* @since 2024-10-26
2424
*/
25-
@Group(name = "implGroup_weather_Rain_Mobile", extensions = {
25+
@Group(name = "implGroup_weather_rain_city_a", extensions = {
2626
@Attribute(key = "owner", value = "测试"), @Attribute(key = "language", value = "english")
2727
})
28-
public class MobileRainImpl implements Rain {
29-
private static final String FITABLE_ID = "weather_rain_mobile";
28+
public class CityARainImpl implements Rain {
29+
private static final String FITABLE_ID = "weather_rain_city_a";
3030

3131
@Fitable(FITABLE_ID)
32-
@ToolMethod(name = "mobile_rain_today", description = "使用A提供的今日下雨信息", extensions = {
32+
@ToolMethod(name = "city_a_rain_today", description = "城市A提供的今日下雨信息", extensions = {
3333
@Attribute(key = "tags", value = "FIT"), @Attribute(key = "tags", value = "TEST")
3434
})
3535
@Property(description = "获取今日下雨信息的结果")
@@ -39,7 +39,7 @@ public String today(String location, Date date) {
3939
}
4040

4141
@Fitable(FITABLE_ID)
42-
@ToolMethod(name = "mobile_rain_tomorrow", description = "使用A提供的明日下雨信息", extensions = {
42+
@ToolMethod(name = "city_a_rain_tomorrow", description = "城市A提供的明日下雨信息", extensions = {
4343
@Attribute(key = "tags", value = "FIT"), @Attribute(key = "tags", value = "TEST")
4444
})
4545
@Property(description = "获取明日下雨信息的结果")

framework/fel/java/maven-plugins/tool-maven-plugin/src/test/java/modelengine/fel/maven/compile/parser/weather/impl/UnicomRainImpl.java renamed to framework/fel/java/maven-plugins/tool-maven-plugin/src/test/java/modelengine/fel/maven/compile/parser/weather/impl/CityBRainImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
* @author 曹嘉美
2222
* @since 2024-10-26
2323
*/
24-
@Group(name = "implGroup_weather_Rain_Unicom")
25-
public class UnicomRainImpl implements Rain {
26-
private static final String FITABLE_ID = "weather_rain_unicom";
24+
@Group(name = "implGroup_weather_rain_city_b")
25+
public class CityBRainImpl implements Rain {
26+
private static final String FITABLE_ID = "weather_rain_city_b";
2727

2828
@Fitable(FITABLE_ID)
29-
@ToolMethod(name = "unicom_rain_today", description = "使用B提供的今日下雨信息", extensions = {
29+
@ToolMethod(name = "city_b_rain_today", description = "城市B提供的今日下雨信息", extensions = {
3030
@Attribute(key = "tags", value = "FIT"), @Attribute(key = "tags", value = "TEST")
3131
})
3232
@Override
@@ -35,7 +35,7 @@ public String today(String location, Date date) {
3535
}
3636

3737
@Fitable(FITABLE_ID)
38-
@ToolMethod(name = "unicom_rain_tomorrow", description = "使用B提供的明日下雨信息", extensions = {
38+
@ToolMethod(name = "city_b_rain_tomorrow", description = "城市B提供的明日下雨信息", extensions = {
3939
@Attribute(key = "tags", value = "FIT"), @Attribute(key = "tags", value = "TEST")
4040
})
4141
@Override

0 commit comments

Comments
 (0)