Skip to content

Commit 9c5adec

Browse files
升级插件结构,提供插件组定义逻辑 (#87)
* [fel] 升级插件的结构 * [fel] 去除升级插件结构引入的额外三方插件 * [fel] 修正 pom 导入依赖
1 parent d6c4aeb commit 9c5adec

File tree

55 files changed

+2875
-828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2875
-828
lines changed

examples/fel-example/06-agent/src/main/java/modelengine/example/ai/chat/agent/tool/WeatherService.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66

77
package modelengine.example.ai.chat.agent.tool;
88

9+
import modelengine.fel.tool.annotation.Group;
10+
import modelengine.fel.tool.annotation.ToolMethod;
911
import modelengine.fitframework.annotation.Genericable;
12+
import modelengine.fitframework.annotation.Property;
1013

1114
/**
1215
* 表示天气服务的接口定义。
1316
*
1417
* @author 易文渊
18+
* @author 杭潇
1519
* @since 2024-09-02
1620
*/
21+
@Group(name = "weather_service")
1722
public interface WeatherService {
1823
/**
1924
* 获取指定地点的当前温度。
@@ -22,15 +27,18 @@ public interface WeatherService {
2227
* @param unit 表示温度单位的 {@link String}。
2328
* @return 表示当前温度的 {@link String}。
2429
*/
30+
@ToolMethod(namespace = "example", name = "current_temperature", description = "获取指定地点的当前温度")
2531
@Genericable("modelengine.example.weather.temperature")
26-
String getCurrentTemperature(String location, String unit);
32+
String getCurrentTemperature(@Property(description = "城市名称", required = true) String location,
33+
@Property(description = "使用的温度单位,可选:Celsius,Fahrenheit", defaultValue = "Celsius") String unit);
2734

2835
/**
2936
* 获取指定地点的降雨概率。
3037
*
3138
* @param location 表示地点名称的 {@link String}。
3239
* @return 表示降雨概率的 {@link String}。
3340
*/
41+
@ToolMethod(namespace = "example", name = "rain_probability", description = "获取指定地点的降雨概率")
3442
@Genericable("modelengine.example.weather.rain")
35-
String getRainProbability(String location);
43+
String getRainProbability(@Property(description = "城市名称", required = true) String location);
3644
}

examples/fel-example/06-agent/src/main/java/modelengine/example/ai/chat/agent/tool/WeatherServiceImpl.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package modelengine.example.ai.chat.agent.tool;
88

99
import modelengine.fel.tool.annotation.Attribute;
10+
import modelengine.fel.tool.annotation.Group;
1011
import modelengine.fel.tool.annotation.ToolMethod;
1112
import modelengine.fitframework.annotation.Component;
1213
import modelengine.fitframework.annotation.Fitable;
@@ -16,27 +17,30 @@
1617
* 表示 {@link WeatherService} 的默认实现。
1718
*
1819
* @author 易文渊
20+
* @author 杭潇
1921
* @since 2024-09-02
2022
*/
2123
@Component
24+
@Group(name = "default_weather_service")
2225
public class WeatherServiceImpl implements WeatherService {
2326
@Override
2427
@Fitable("default")
25-
@ToolMethod(namespace = "example", name = "get_current_temperature", description = "获取指定城市的当前温度",
28+
@ToolMethod(name = "get_current_temperature", description = "获取指定城市的当前温度",
2629
extensions = {
2730
@Attribute(key = "tags", value = "FIT"), @Attribute(key = "tags", value = "TEST"),
2831
@Attribute(key = "attribute", value = "nothing"),
2932
@Attribute(key = "attribute", value = "nothing two")
3033
})
31-
public String getCurrentTemperature(@Property(description = "城市名称", required = true) String location,
32-
@Property(description = "使用的温度单位,可选:Celsius,Fahrenheit", defaultValue = "Celsius") String unit) {
34+
@Property(description = "当前温度的结果")
35+
public String getCurrentTemperature(String location, String unit) {
3336
return "26";
3437
}
3538

3639
@Override
3740
@Fitable("default")
38-
@ToolMethod(namespace = "example", name = "get_rain_probability", description = "获取指定城市下雨的概率")
39-
public String getRainProbability(@Property(description = "城市名称", required = true) String location) {
41+
@ToolMethod(name = "get_rain_probability", description = "获取指定城市下雨的概率")
42+
@Property(description = "下雨的概率")
43+
public String getRainProbability(String location) {
4044
return "0.06";
4145
}
4246
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
6+
<parent>
7+
<groupId>org.fitframework.fel</groupId>
8+
<artifactId>fel-parent</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>fel-component-parent</artifactId>
13+
<packaging>pom</packaging>
14+
15+
<modules>
16+
<module>tool-info</module>
17+
</modules>
18+
</project>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
6+
<parent>
7+
<groupId>org.fitframework.fel</groupId>
8+
<artifactId>fel-component-parent</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>tool-info</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.fitframework</groupId>
17+
<artifactId>fit-util</artifactId>
18+
</dependency>
19+
</dependencies>
20+
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.fitframework</groupId>
25+
<artifactId>fit-dependency-maven-plugin</artifactId>
26+
<version>${fit.version}</version>
27+
<executions>
28+
<execution>
29+
<id>dependency</id>
30+
<phase>compile</phase>
31+
<goals>
32+
<goal>dependency</goal>
33+
</goals>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-jar-plugin</artifactId>
40+
<version>${maven.jar.version}</version>
41+
<configuration>
42+
<archive>
43+
<manifestEntries>
44+
<Created-By>FIT Lab</Created-By>
45+
</manifestEntries>
46+
</archive>
47+
</configuration>
48+
</plugin>
49+
</plugins>
50+
</build>
51+
</project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.fel.tool.info.entity;
8+
9+
/**
10+
* 表示定义的实体类,用于存储定义信息。
11+
*
12+
* @author 曹嘉美
13+
* @author 李金绪
14+
* @since 2024-10-26
15+
*/
16+
public class DefinitionEntity {
17+
private SchemaEntity schema;
18+
19+
/**
20+
* 获取 schema 对象。
21+
*
22+
* @return 表示 schema 对象的 {@link SchemaEntity}。
23+
*/
24+
public SchemaEntity getSchema() {
25+
return this.schema;
26+
}
27+
28+
/**
29+
* 设置 schema 对象。
30+
*
31+
* @param schema 表示 schema 对象的 {@link SchemaEntity}。
32+
*/
33+
public void setSchema(SchemaEntity schema) {
34+
this.schema = schema;
35+
}
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.fel.tool.info.entity;
8+
9+
import java.util.List;
10+
11+
/**
12+
* 表示定义组的实体类。
13+
*
14+
* @author 曹嘉美
15+
* @author 李金绪
16+
* @since 2024-10-26
17+
*/
18+
public class DefinitionGroupEntity extends GroupEntity {
19+
private List<DefinitionEntity> definitions;
20+
21+
/**
22+
* 获取定义组中的所有定义。
23+
*
24+
* @return 表示定义组的 {@link List}{@code <}{@link DefinitionEntity}{@code >}。
25+
*/
26+
public List<DefinitionEntity> getDefinitions() {
27+
return this.definitions;
28+
}
29+
30+
/**
31+
* 设置定义组中的所有定义。
32+
*
33+
* @param definitions 表示定义组的 {@link List}{@code <}{@link DefinitionEntity}{@code >}。
34+
*/
35+
public void setDefinitions(List<DefinitionEntity> definitions) {
36+
this.definitions = definitions;
37+
}
38+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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.fel.tool.info.entity;
8+
9+
import java.util.Map;
10+
11+
/**
12+
* 表示组的基本实体类。
13+
*
14+
* @author 李金绪
15+
* @since 2024-12-12
16+
*/
17+
public class GroupEntity {
18+
private String name;
19+
private String summary;
20+
private String description;
21+
private Map<String, Object> extensions;
22+
23+
/**
24+
* 获取组名。
25+
*
26+
* @return 表示组名的 {@link String}。
27+
*/
28+
public String getName() {
29+
return this.name;
30+
}
31+
32+
/**
33+
* 设置组名。
34+
*
35+
* @param name 表示组名的 {@link String}。
36+
*/
37+
public void setName(String name) {
38+
this.name = name;
39+
}
40+
41+
/**
42+
* 获取摘要。
43+
*
44+
* @return 表示摘要的 {@link String}。
45+
*/
46+
public String getSummary() {
47+
return this.summary;
48+
}
49+
50+
/**
51+
* 设置摘要
52+
*
53+
* @param summary 表示要设置的摘要的 {@link String}。
54+
*/
55+
public void setSummary(String summary) {
56+
this.summary = summary;
57+
}
58+
59+
/**
60+
* 获取描述。
61+
*
62+
* @return 表示描述的 {@link String}。
63+
*/
64+
public String getDescription() {
65+
return this.description;
66+
}
67+
68+
/**
69+
* 设置描述。
70+
*
71+
* @param description 表示要设置的描述的 {@link String}。
72+
*/
73+
public void setDescription(String description) {
74+
this.description = description;
75+
}
76+
77+
/**
78+
* 获取扩展属性。
79+
*
80+
* @return 表示扩展属性的 {@link Map}{@code <}{@link String}{@code , }{@link Object}{@code >}。
81+
*/
82+
public Map<String, Object> getExtensions() {
83+
return this.extensions;
84+
}
85+
86+
/**
87+
* 设置扩展属性。
88+
*
89+
* @param extensions 扩展属性的 {@link Map}{@code <}{@link String}{@code , }{@link Object}{@code >}。
90+
*/
91+
public void setExtensions(Map<String, Object> extensions) {
92+
this.extensions = extensions;
93+
}
94+
}

0 commit comments

Comments
 (0)