From 98239a69f130484200b3b58d71e2731e3242d5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BA=91=E6=B6=9B?= <854262144@qq.com> Date: Thu, 26 Dec 2024 11:28:48 +0800 Subject: [PATCH 1/8] add Express Delivery function calling --- .../pom.xml | 44 +++++++++++ .../kuaidi100/Kuaidi100AutoConfiguration.java | 29 ++++++++ .../kuaidi100/Kuaidi100Properties.java | 44 +++++++++++ .../kuaidi100/Kuaidi100Service.java | 73 +++++++++++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + pom.xml | 1 + spring-ai-alibaba-core/pom.xml | 6 ++ .../java/com/alibaba/cloud/ai/agent/Mcp.java | 1 - .../ai/fucitoncalling/kuaidi100Test.java | 37 ++++++++++ 9 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml create mode 100644 community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java create mode 100644 community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java create mode 100644 community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java create mode 100644 community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml new file mode 100644 index 000000000..3edc8128d --- /dev/null +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + com.alibaba.cloud.ai + spring-ai-alibaba + ${revision} + ../../../pom.xml + + + spring-ai-alibaba-starter-function-calling-kuaidi100 + spring-ai-alibaba-starter-function-calling-kuaidi100 + Sina News tool for Spring AI Alibaba + https://github.com/alibaba/spring-ai-alibaba + + + + org.springframework.ai + spring-ai-spring-boot-autoconfigure + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + com.fasterxml.jackson.core + jackson-annotations + + + + com.github.kuaidi100-api + sdk + 1.0.15 + + + + + spring-ai-alibaba-starter-function-calling-kuaidi100 + + diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java new file mode 100644 index 000000000..3c7bf10d3 --- /dev/null +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java @@ -0,0 +1,29 @@ +package com.alibaba.cloud.ai.functioncalling.kuaidi100; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Description; + +/** + * @Author: XiaoYunTao + * @Date: 2024/12/18 + */ +@Configuration +@ConditionalOnClass(Kuaidi100AutoConfiguration.class) +@ConditionalOnProperty(prefix = "spring.ai.alibaba.functioncalling.kuaidi100", name = "enabled", havingValue = "true") +@EnableConfigurationProperties(Kuaidi100Properties.class) +public class Kuaidi100AutoConfiguration { + + + @Bean + @ConditionalOnMissingBean + @Description("Query courier tracking information") + public Kuaidi100Service queryTrackFunction(Kuaidi100Properties kuaidi100Properties) { + return new Kuaidi100Service(kuaidi100Properties); + } + +} diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java new file mode 100644 index 000000000..5eda7f135 --- /dev/null +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java @@ -0,0 +1,44 @@ +package com.alibaba.cloud.ai.functioncalling.kuaidi100; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @Author: XiaoYunTao + * @Date: 2024/12/25 + */ +@ConfigurationProperties(prefix = "spring.ai.alibaba.functioncalling.kuaidi100") +public class Kuaidi100Properties { + + /** + * 授权key 获取授权key + */ + private String key; + + /** + * customer + * 获取customer + */ + private String customer; + + public Kuaidi100Properties(String key, String customer){ + this.key = key; + this.customer = customer; + } + + public void setKey(String key) { + this.key = key; + } + + public void setCustomer(String customer) { + this.customer = customer; + } + + public String getKey() { + return key; + } + + public String getCustomer() { + return customer; + } + +} \ No newline at end of file diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java new file mode 100644 index 000000000..3558365a9 --- /dev/null +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java @@ -0,0 +1,73 @@ +package com.alibaba.cloud.ai.functioncalling.kuaidi100; + +import com.fasterxml.jackson.annotation.JsonClassDescription; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.google.gson.Gson; +import com.kuaidi100.sdk.api.AutoNum; +import com.kuaidi100.sdk.api.QueryTrack; +import com.kuaidi100.sdk.request.AutoNumReq; +import com.kuaidi100.sdk.request.QueryTrackParam; +import com.kuaidi100.sdk.request.QueryTrackReq; +import com.kuaidi100.sdk.response.QueryTrackResp; +import com.kuaidi100.sdk.utils.SignUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.function.Function; + +/** + * @Author: XiaoYunTao + * @Date: 2024/12/25 + */ +public class Kuaidi100Service implements Function { + + private static final Logger logger = LoggerFactory.getLogger(Kuaidi100Service.class); + + Kuaidi100Properties kuaidi100Properties; + + public Kuaidi100Service(Kuaidi100Properties kuaidi100Properties) { + this.kuaidi100Properties = kuaidi100Properties; + } + + @Override + public QueryTrackResp apply(Kuaidi100Service.Request request) { + QueryTrackResp queryTrackResp; + try { + queryTrackResp = queryTrack(request.num()); + } + catch (Exception e) { + throw new RuntimeException(e); + } + logger.info("queryTrackResp: {}", queryTrackResp); + return queryTrackResp; + } + + public QueryTrackResp queryTrack(String num) throws Exception { + String key = kuaidi100Properties.getKey(); + String customer = kuaidi100Properties.getCustomer(); + + QueryTrackReq queryTrackReq = new QueryTrackReq(); + QueryTrackParam queryTrackParam = new QueryTrackParam(); + AutoNumReq autoNumReq = new AutoNumReq(); + autoNumReq.setNum(num); + autoNumReq.setKey(key); + AutoNum autoNum = new AutoNum(); + queryTrackParam.setCom(autoNum.getFirstComByNum(autoNumReq)); + queryTrackParam.setNum(num); + String param = new Gson().toJson(queryTrackParam); + + queryTrackReq.setParam(param); + queryTrackReq.setCustomer(customer); + queryTrackReq.setSign(SignUtils.querySign(param, key, customer)); + return new QueryTrack().queryTrack(queryTrackReq); + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonClassDescription("Methods for real-time courier tracking") + public record Request( + @JsonProperty(required = true, value = "num") @JsonPropertyDescription("tracking number") String num) { + } + +} \ No newline at end of file diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 000000000..29dd9a1c5 --- /dev/null +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.alibaba.cloud.ai.functioncalling.kuaidi100.Kuaidi100AutoConfiguration \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8d6603bc9..8b2a2e486 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,7 @@ community/function-calling/spring-ai-alibaba-starter-function-calling-sinanews community/function-calling/spring-ai-alibaba-starter-function-calling-toutiaonews community/function-calling/spring-ai-alibaba-starter-function-calling-yuque + community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100 community/document-readers/github-reader community/document-readers/poi-document-reader diff --git a/spring-ai-alibaba-core/pom.xml b/spring-ai-alibaba-core/pom.xml index 836edbc9c..0c140315d 100644 --- a/spring-ai-alibaba-core/pom.xml +++ b/spring-ai-alibaba-core/pom.xml @@ -130,6 +130,12 @@ micrometer-observation-test test + + com.alibaba.cloud.ai + spring-ai-alibaba-starter-function-calling-kuaidi100 + 1.0.0-M3.2 + test + \ No newline at end of file diff --git a/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/agent/Mcp.java b/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/agent/Mcp.java index cbbb977f6..128b2a555 100644 --- a/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/agent/Mcp.java +++ b/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/agent/Mcp.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - */ package com.alibaba.cloud.ai.agent; /** diff --git a/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java b/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java new file mode 100644 index 000000000..c2b82cb88 --- /dev/null +++ b/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java @@ -0,0 +1,37 @@ +package com.alibaba.cloud.ai.fucitoncalling; + +import com.alibaba.cloud.ai.dashscope.DashscopeAiTestConfiguration; +import com.alibaba.cloud.ai.functioncalling.kuaidi100.Kuaidi100AutoConfiguration; +import com.alibaba.cloud.ai.functioncalling.kuaidi100.Kuaidi100Properties; +import com.alibaba.cloud.ai.functioncalling.kuaidi100.Kuaidi100Service; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.springframework.ai.chat.client.ChatClient; +import org.springframework.ai.chat.model.ChatModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +/** + * @Author: XiaoYunTao + * @Date: 2024/12/26 + */ +@SpringBootTest(classes = {Kuaidi100AutoConfiguration.class, DashscopeAiTestConfiguration.class}) +@EnabledIfEnvironmentVariable(named = "DASHSCOPE_API_KEY", matches = ".+") +public class kuaidi100Test { + + @Autowired + ChatModel dashscopeChatModel; + + @Autowired + Kuaidi100Properties kuaidi100Properties; + + @Test + public void test() { + ChatClient chatClient = ChatClient.builder(dashscopeChatModel).build(); + String content = chatClient.prompt() + .function("queryTrackFunction", "查询快递", new Kuaidi100Service(kuaidi100Properties)) + .user("查询一下单号为:,的快递") + .call().content(); + System.out.println(content); + } +} From 0eaef00b52fa73b29121bfbc4101b62588a10db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BA=91=E6=B6=9B?= <854262144@qq.com> Date: Thu, 26 Dec 2024 13:48:08 +0800 Subject: [PATCH 2/8] add Express Delivery function calling --- spring-ai-alibaba-core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-ai-alibaba-core/pom.xml b/spring-ai-alibaba-core/pom.xml index b06fb2971..f8cd2a568 100644 --- a/spring-ai-alibaba-core/pom.xml +++ b/spring-ai-alibaba-core/pom.xml @@ -139,7 +139,7 @@ com.alibaba.cloud.ai spring-ai-alibaba-starter-function-calling-kuaidi100 - 1.0.0-M3.2 + ${revision} test From b4579007aa7d79c72922f23736800913112bcafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BA=91=E6=B6=9B?= <854262144@qq.com> Date: Thu, 26 Dec 2024 13:49:02 +0800 Subject: [PATCH 3/8] code format --- .../kuaidi100/Kuaidi100AutoConfiguration.java | 13 ++++---- .../kuaidi100/Kuaidi100Properties.java | 2 +- .../ai/fucitoncalling/kuaidi100Test.java | 30 ++++++++++--------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java index 3c7bf10d3..615d9b950 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java @@ -18,12 +18,11 @@ @EnableConfigurationProperties(Kuaidi100Properties.class) public class Kuaidi100AutoConfiguration { - - @Bean - @ConditionalOnMissingBean - @Description("Query courier tracking information") - public Kuaidi100Service queryTrackFunction(Kuaidi100Properties kuaidi100Properties) { - return new Kuaidi100Service(kuaidi100Properties); - } + @Bean + @ConditionalOnMissingBean + @Description("Query courier tracking information") + public Kuaidi100Service queryTrackFunction(Kuaidi100Properties kuaidi100Properties) { + return new Kuaidi100Service(kuaidi100Properties); + } } diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java index 5eda7f135..f1c8e7a69 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java @@ -20,7 +20,7 @@ public class Kuaidi100Properties { */ private String customer; - public Kuaidi100Properties(String key, String customer){ + public Kuaidi100Properties(String key, String customer) { this.key = key; this.customer = customer; } diff --git a/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java b/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java index c2b82cb88..f7bc5b5dd 100644 --- a/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java +++ b/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java @@ -15,23 +15,25 @@ * @Author: XiaoYunTao * @Date: 2024/12/26 */ -@SpringBootTest(classes = {Kuaidi100AutoConfiguration.class, DashscopeAiTestConfiguration.class}) +@SpringBootTest(classes = { Kuaidi100AutoConfiguration.class, DashscopeAiTestConfiguration.class }) @EnabledIfEnvironmentVariable(named = "DASHSCOPE_API_KEY", matches = ".+") public class kuaidi100Test { - @Autowired - ChatModel dashscopeChatModel; + @Autowired + ChatModel dashscopeChatModel; - @Autowired - Kuaidi100Properties kuaidi100Properties; + @Autowired + Kuaidi100Properties kuaidi100Properties; + + @Test + public void test() { + ChatClient chatClient = ChatClient.builder(dashscopeChatModel).build(); + String content = chatClient.prompt() + .function("queryTrackFunction", "查询快递", new Kuaidi100Service(kuaidi100Properties)) + .user("查询一下单号为:,的快递") + .call() + .content(); + System.out.println(content); + } - @Test - public void test() { - ChatClient chatClient = ChatClient.builder(dashscopeChatModel).build(); - String content = chatClient.prompt() - .function("queryTrackFunction", "查询快递", new Kuaidi100Service(kuaidi100Properties)) - .user("查询一下单号为:,的快递") - .call().content(); - System.out.println(content); - } } From 0c08a3a9eb0acc9578894281fb4471835bc5b64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BA=91=E6=B6=9B?= <854262144@qq.com> Date: Thu, 26 Dec 2024 14:13:27 +0800 Subject: [PATCH 4/8] code format --- .../kuaidi100/Kuaidi100Exception.java | 13 +++++++ .../kuaidi100/Kuaidi100Service.java | 36 +++++++++++++------ 2 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java new file mode 100644 index 000000000..654c19be6 --- /dev/null +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java @@ -0,0 +1,13 @@ +package com.alibaba.cloud.ai.functioncalling.kuaidi100; + +/** + * @Author: XiaoYunTao + * @Date: 2024/12/26 + */ +public class Kuaidi100Exception extends RuntimeException { + + public Kuaidi100Exception(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java index 3558365a9..9dcd43342 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java @@ -25,7 +25,11 @@ public class Kuaidi100Service implements Function Date: Fri, 27 Dec 2024 10:11:41 +0800 Subject: [PATCH 5/8] code format --- .../pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml index 3edc8128d..f5251a48c 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml @@ -15,6 +15,7 @@ https://github.com/alibaba/spring-ai-alibaba + org.springframework.ai spring-ai-spring-boot-autoconfigure @@ -36,6 +37,7 @@ sdk 1.0.15 + From cabd6e00779a7145ae076e7d58320fdb82b30182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BA=91=E6=B6=9B?= <854262144@qq.com> Date: Fri, 27 Dec 2024 10:23:41 +0800 Subject: [PATCH 6/8] Remove test code --- spring-ai-alibaba-core/pom.xml | 6 --- .../ai/fucitoncalling/kuaidi100Test.java | 39 ------------------- 2 files changed, 45 deletions(-) delete mode 100644 spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java diff --git a/spring-ai-alibaba-core/pom.xml b/spring-ai-alibaba-core/pom.xml index f8cd2a568..d39852faf 100644 --- a/spring-ai-alibaba-core/pom.xml +++ b/spring-ai-alibaba-core/pom.xml @@ -136,12 +136,6 @@ micrometer-observation-test test - - com.alibaba.cloud.ai - spring-ai-alibaba-starter-function-calling-kuaidi100 - ${revision} - test - \ No newline at end of file diff --git a/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java b/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java deleted file mode 100644 index f7bc5b5dd..000000000 --- a/spring-ai-alibaba-core/src/test/java/com/alibaba/cloud/ai/fucitoncalling/kuaidi100Test.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.alibaba.cloud.ai.fucitoncalling; - -import com.alibaba.cloud.ai.dashscope.DashscopeAiTestConfiguration; -import com.alibaba.cloud.ai.functioncalling.kuaidi100.Kuaidi100AutoConfiguration; -import com.alibaba.cloud.ai.functioncalling.kuaidi100.Kuaidi100Properties; -import com.alibaba.cloud.ai.functioncalling.kuaidi100.Kuaidi100Service; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.chat.client.ChatClient; -import org.springframework.ai.chat.model.ChatModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -/** - * @Author: XiaoYunTao - * @Date: 2024/12/26 - */ -@SpringBootTest(classes = { Kuaidi100AutoConfiguration.class, DashscopeAiTestConfiguration.class }) -@EnabledIfEnvironmentVariable(named = "DASHSCOPE_API_KEY", matches = ".+") -public class kuaidi100Test { - - @Autowired - ChatModel dashscopeChatModel; - - @Autowired - Kuaidi100Properties kuaidi100Properties; - - @Test - public void test() { - ChatClient chatClient = ChatClient.builder(dashscopeChatModel).build(); - String content = chatClient.prompt() - .function("queryTrackFunction", "查询快递", new Kuaidi100Service(kuaidi100Properties)) - .user("查询一下单号为:,的快递") - .call() - .content(); - System.out.println(content); - } - -} From b465f509092bb3cc51157178c07d6545701d0e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BA=91=E6=B6=9B?= <854262144@qq.com> Date: Fri, 10 Jan 2025 16:38:29 +0800 Subject: [PATCH 7/8] update:license headers --- .../kuaidi100/Kuaidi100AutoConfiguration.java | 15 +++++++++++++++ .../kuaidi100/Kuaidi100Exception.java | 15 +++++++++++++++ .../kuaidi100/Kuaidi100Properties.java | 15 +++++++++++++++ .../kuaidi100/Kuaidi100Service.java | 15 +++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java index 615d9b950..07368e023 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100AutoConfiguration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.cloud.ai.functioncalling.kuaidi100; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java index 654c19be6..897f2bc69 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Exception.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.cloud.ai.functioncalling.kuaidi100; /** diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java index f1c8e7a69..2b44f4cb8 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Properties.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.cloud.ai.functioncalling.kuaidi100; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java index 9dcd43342..c954fbf8e 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/src/main/java/com/alibaba/cloud/ai/functioncalling/kuaidi100/Kuaidi100Service.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.cloud.ai.functioncalling.kuaidi100; import com.fasterxml.jackson.annotation.JsonClassDescription; From 5b96769eb4c456acce8562f673db77d57a0bcf07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BA=91=E6=B6=9B?= <854262144@qq.com> Date: Fri, 10 Jan 2025 16:41:33 +0800 Subject: [PATCH 8/8] update:license headers --- .../pom.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml index f5251a48c..30c6bdaf6 100644 --- a/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml +++ b/community/function-calling/spring-ai-alibaba-starter-function-calling-kuaidi100/pom.xml @@ -1,4 +1,19 @@ + 4.0.0