Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@

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

import modelengine.fel.tool.annotation.Group;
import modelengine.fel.tool.annotation.ToolMethod;
import modelengine.fitframework.annotation.Genericable;
import modelengine.fitframework.annotation.Property;

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

/**
* 获取指定地点的降雨概率。
*
* @param location 表示地点名称的 {@link String}。
* @return 表示降雨概率的 {@link String}。
*/
@ToolMethod(namespace = "example", name = "rain_probability", description = "获取指定地点的降雨概率")
@Genericable("modelengine.example.weather.rain")
String getRainProbability(String location);
String getRainProbability(@Property(description = "城市名称", required = true) String location);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package modelengine.example.ai.chat.agent.tool;

import modelengine.fel.tool.annotation.Attribute;
import modelengine.fel.tool.annotation.Group;
import modelengine.fel.tool.annotation.ToolMethod;
import modelengine.fitframework.annotation.Component;
import modelengine.fitframework.annotation.Fitable;
Expand All @@ -16,27 +17,30 @@
* 表示 {@link WeatherService} 的默认实现。
*
* @author 易文渊
* @author 杭潇
* @since 2024-09-02
*/
@Component
@Group(name = "default_weather_service")
public class WeatherServiceImpl implements WeatherService {
@Override
@Fitable("default")
@ToolMethod(namespace = "example", name = "get_current_temperature", description = "获取指定城市的当前温度",
@ToolMethod(name = "get_current_temperature", description = "获取指定城市的当前温度",
extensions = {
@Attribute(key = "tags", value = "FIT"), @Attribute(key = "tags", value = "TEST"),
@Attribute(key = "attribute", value = "nothing"),
@Attribute(key = "attribute", value = "nothing two")
})
public String getCurrentTemperature(@Property(description = "城市名称", required = true) String location,
@Property(description = "使用的温度单位,可选:Celsius,Fahrenheit", defaultValue = "Celsius") String unit) {
@Property(description = "当前温度的结果")
public String getCurrentTemperature(String location, String unit) {
return "26";
}

@Override
@Fitable("default")
@ToolMethod(namespace = "example", name = "get_rain_probability", description = "获取指定城市下雨的概率")
public String getRainProbability(@Property(description = "城市名称", required = true) String location) {
@ToolMethod(name = "get_rain_probability", description = "获取指定城市下雨的概率")
@Property(description = "下雨的概率")
public String getRainProbability(String location) {
return "0.06";
}
}
18 changes: 18 additions & 0 deletions framework/fel/java/components/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.fitframework.fel</groupId>
<artifactId>fel-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>fel-component-parent</artifactId>
<packaging>pom</packaging>

<modules>
<module>tool-info</module>
</modules>
</project>
51 changes: 51 additions & 0 deletions framework/fel/java/components/tool-info/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.fitframework.fel</groupId>
<artifactId>fel-component-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>tool-info</artifactId>

<dependencies>
<dependency>
<groupId>org.fitframework</groupId>
<artifactId>fit-util</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.fitframework</groupId>
<artifactId>fit-dependency-maven-plugin</artifactId>
<version>${fit.version}</version>
<executions>
<execution>
<id>dependency</id>
<phase>compile</phase>
<goals>
<goal>dependency</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.version}</version>
<configuration>
<archive>
<manifestEntries>
<Created-By>FIT Lab</Created-By>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fel.tool.info.entity;

/**
* 表示定义的实体类,用于存储定义信息。
*
* @author 曹嘉美
* @author 李金绪
* @since 2024-10-26
*/
public class DefinitionEntity {
private SchemaEntity schema;

/**
* 获取 schema 对象。
*
* @return 表示 schema 对象的 {@link SchemaEntity}。
*/
public SchemaEntity getSchema() {
return this.schema;
}

/**
* 设置 schema 对象。
*
* @param schema 表示 schema 对象的 {@link SchemaEntity}。
*/
public void setSchema(SchemaEntity schema) {
this.schema = schema;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fel.tool.info.entity;

import java.util.List;

/**
* 表示定义组的实体类。
*
* @author 曹嘉美
* @author 李金绪
* @since 2024-10-26
*/
public class DefinitionGroupEntity extends GroupEntity {
private List<DefinitionEntity> definitions;

/**
* 获取定义组中的所有定义。
*
* @return 表示定义组的 {@link List}{@code <}{@link DefinitionEntity}{@code >}。
*/
public List<DefinitionEntity> getDefinitions() {
return this.definitions;
}

/**
* 设置定义组中的所有定义。
*
* @param definitions 表示定义组的 {@link List}{@code <}{@link DefinitionEntity}{@code >}。
*/
public void setDefinitions(List<DefinitionEntity> definitions) {
this.definitions = definitions;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fel.tool.info.entity;

import java.util.Map;

/**
* 表示组的基本实体类。
*
* @author 李金绪
* @since 2024-12-12
*/
public class GroupEntity {
private String name;
private String summary;
private String description;
private Map<String, Object> extensions;

/**
* 获取组名。
*
* @return 表示组名的 {@link String}。
*/
public String getName() {
return this.name;
}

/**
* 设置组名。
*
* @param name 表示组名的 {@link String}。
*/
public void setName(String name) {
this.name = name;
}

/**
* 获取摘要。
*
* @return 表示摘要的 {@link String}。
*/
public String getSummary() {
return this.summary;
}

/**
* 设置摘要
*
* @param summary 表示要设置的摘要的 {@link String}。
*/
public void setSummary(String summary) {
this.summary = summary;
}

/**
* 获取描述。
*
* @return 表示描述的 {@link String}。
*/
public String getDescription() {
return this.description;
}

/**
* 设置描述。
*
* @param description 表示要设置的描述的 {@link String}。
*/
public void setDescription(String description) {
this.description = description;
}

/**
* 获取扩展属性。
*
* @return 表示扩展属性的 {@link Map}{@code <}{@link String}{@code , }{@link Object}{@code >}。
*/
public Map<String, Object> getExtensions() {
return this.extensions;
}

/**
* 设置扩展属性。
*
* @param extensions 扩展属性的 {@link Map}{@code <}{@link String}{@code , }{@link Object}{@code >}。
*/
public void setExtensions(Map<String, Object> extensions) {
this.extensions = extensions;
}
}
Loading